mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
Fix comment handling when the comment is the last item in at the end of a file without endline
This commit is contained in:
parent
8d745551a0
commit
13db966940
1 changed files with 10 additions and 1 deletions
|
|
@ -94,7 +94,16 @@ LpItem * lp_item_new(const char *key, const char *value){
|
|||
|
||||
LpItem * lp_comment_new(const char *comment){
|
||||
LpItem *item=lp_new0(LpItem,1);
|
||||
char* pos = NULL;
|
||||
item->value=ortp_strdup(comment);
|
||||
|
||||
pos=strchr(item->value,'\r');
|
||||
if (pos==NULL)
|
||||
pos=strchr(item->value,'\n');
|
||||
|
||||
if(pos) {
|
||||
*pos='\0'; /*replace the '\n' */
|
||||
}
|
||||
item->is_comment=TRUE;
|
||||
return item;
|
||||
}
|
||||
|
|
@ -567,7 +576,7 @@ void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key
|
|||
|
||||
void lp_item_write(LpItem *item, FILE *file){
|
||||
if (item->is_comment)
|
||||
fprintf(file,"%s",item->value);
|
||||
fprintf(file,"%s\n",item->value);
|
||||
else if (item->value && item->value[0] != '\0' )
|
||||
fprintf(file,"%s=%s\n",item->key,item->value);
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue