Commit 13db9669 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI
Browse files

Fix comment handling when the comment is the last item in at the end of a file without endline

parent 8d745551
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment