ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/eplus_idf.c
(Generate patch)

Comparing ray/src/util/eplus_idf.c (file contents):
Revision 2.10 by greg, Thu Feb 13 17:39:39 2014 UTC vs.
Revision 2.12 by greg, Wed Mar 5 19:49:39 2014 UTC

# Line 353 | Line 353 | idf_load(const char *fname)
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)
# Line 365 | Line 375 | idf_writeparam(IDF_OBJECT *param, FILE *fp, int incl_c
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  
# Line 409 | Line 428 | idf_free(IDF_LOADED *idf)
428   {
429          if (idf == NULL)
430                  return;
431 +        while (idf->pfirst != NULL) {
432 +                IDF_OBJECT      *pdel = idf->pfirst;
433 +                idf->pfirst = pdel->dnext;
434 +                while (pdel->flist != NULL) {
435 +                        IDF_FIELD       *fdel = pdel->flist;
436 +                        pdel->flist = fdel->next;
437 +                        free(fdel);
438 +                }
439 +                free(pdel);
440 +        }
441 +        lu_done(&idf->ptab);
442          if (idf->hrem != NULL)
443                  free(idf->hrem);
444 <        while (idf->pfirst != NULL)
415 <                idf_delobject(idf, idf->pfirst);
416 <        lu_done(&idf->ptab);
444 >        free(idf);
445   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines