353 |
|
return(idf); /* success! */ |
354 |
|
} |
355 |
|
|
356 |
+ |
/* Check string for end-of-line */ |
357 |
+ |
static int |
358 |
+ |
idf_hasEOL(const char *s) |
359 |
+ |
{ |
360 |
+ |
while (*s) |
361 |
+ |
if (*s++ == '\n') |
362 |
+ |
return(1); |
363 |
+ |
return(0); |
364 |
+ |
} |
365 |
+ |
|
366 |
|
/* Write a object and fields to an open file */ |
367 |
|
int |
368 |
|
idf_writeparam(IDF_OBJECT *param, FILE *fp, int incl_comm) |
375 |
|
fputc(',', fp); |
376 |
|
if (incl_comm) |
377 |
|
fputs(param->rem, fp); |
378 |
+ |
else |
379 |
+ |
fputc('\n', fp); |
380 |
|
for (fptr = param->flist; fptr != NULL; fptr = fptr->next) { |
381 |
|
if (!incl_comm) |
382 |
< |
fputs("\n ", fp); |
382 |
> |
fputs(" ", fp); |
383 |
|
fputs(fptr->val, fp); |
384 |
< |
fputc((fptr->next==NULL ? ';' : ','), fp); |
384 |
> |
if (fptr->next == NULL) { |
385 |
> |
fputc(';', fp); |
386 |
> |
if (incl_comm && !idf_hasEOL(fptr->rem)) |
387 |
> |
fputc('\n', fp); |
388 |
> |
} else |
389 |
> |
fputc(',', fp); |
390 |
|
if (incl_comm) |
391 |
|
fputs(fptr->rem, fp); |
392 |
+ |
else |
393 |
+ |
fputc('\n', fp); |
394 |
|
} |
395 |
|
if (!incl_comm) |
396 |
< |
fputs("\n\n", fp); |
396 |
> |
fputc('\n', fp); |
397 |
|
return(!ferror(fp)); |
398 |
|
} |
399 |
|
|