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.2 by greg, Sat Feb 1 02:13:24 2014 UTC vs.
Revision 2.3 by greg, Sun Feb 9 02:18:16 2014 UTC

# Line 97 | Line 97 | idf_addfield(IDF_PARAMETER *param, const char *fval, c
97          return(fnum);
98   }
99  
100 + /* Retrieve the indexed field from parameter (first field index is 1) */
101 + IDF_FIELD *
102 + idf_getfield(IDF_PARAMETER *param, int fn)
103 + {
104 +        IDF_FIELD       *fld;
105 +
106 +        if ((param == NULL) | (fn <= 0))
107 +                return(NULL);
108 +        fld = param->flist;
109 +        while ((--fn > 0) & (fld != NULL))
110 +                fld = fld->next;
111 +        return(fld);
112 + }
113 +
114   /* Delete the specified parameter from loaded IDF */
115   int
116   idf_delparam(IDF_LOADED *idf, IDF_PARAMETER *param)
# Line 186 | Line 200 | idf_read_comment(char *buf, int len, FILE *fp)
200                  buf = &dummyc;
201                  len = 1;
202          }
203 <        while ((c = getc(fp)) != EOF && isspace(c) | incomm) {
204 <                if (c == '!')
205 <                        ++incomm;
192 <                else if (c == '\n')
203 >        while ((c = getc(fp)) != EOF &&
204 >                        (isspace(c) || (incomm += (c == '!')))) {
205 >                if (c == '\n')
206                          incomm = 0;
207                  if (cp-buf < len-1)
208                          *cp++ = c;
# Line 217 | Line 230 | idf_readparam(IDF_LOADED *idf, FILE *fp)
230                          idf_addfield(pnew, abuf, cbuf);
231                  }
232          if (delim != ';')
233 <                fprintf(stderr, "Expected ';' at end of parameter list\n");
233 >                fputs("Expected ';' at end of parameter list!\n", stderr);
234          return(pnew);
235   }
236  
# Line 260 | Line 273 | idf_create(const char *hdrcomm)
273   IDF_LOADED *
274   idf_load(const char *fname)
275   {
276 <        char            *hdrcomm;
276 >        char            hdrcomm[300*IF_MAXLINE];
277          FILE            *fp;
278          IDF_LOADED      *idf;
279  
# Line 269 | Line 282 | idf_load(const char *fname)
282          else if ((fp = fopen(fname, "r")) == NULL)
283                  return(NULL);
284                                          /* read header comments */
285 <        hdrcomm = (char *)malloc(100*IDF_MAXLINE);
273 <        idf_read_comment(hdrcomm, 100*IDF_MAXLINE, fp);
285 >        idf_read_comment(hdrcomm, sizeof(hdrcomm), fp);
286          idf = idf_create(hdrcomm);      /* create IDF struct */
275        free(hdrcomm);
287          if (idf == NULL)
288                  return(NULL);
289                                          /* read each parameter */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines