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

Comparing ray/src/common/loadvars.c (file contents):
Revision 2.1 by greg, Tue Dec 12 14:00:48 1995 UTC vs.
Revision 2.5 by greg, Thu Mar 20 12:29:20 1997 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   extern char  *malloc(), *realloc();
19   #endif
20  
21 + extern char  *fgetline();
22  
23 +
24   loadvars(rfname)                /* load variables into vv from file */
25   char    *rfname;
26   {
# Line 30 | Line 32 | char   *rfname;
32                  fp = stdin;
33          else if ((fp = fopen(rfname, "r")) == NULL) {
34                  perror(rfname);
35 <                exit(1);
35 >                quit(1);
36          }
37          while (fgetline(buf, sizeof(buf), fp) != NULL) {
38                  for (cp = buf; *cp; cp++) {
# Line 76 | Line 78 | register char  *ass;
78          for (n = strlen(ass); n > 0; n--)
79                  if (!isspace(ass[n-1]))
80                          break;
81 <        if (!n && !nowarn) {
82 <                fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
83 <                                progname, varname);
81 >        if (!n) {
82 >                if (!nowarn)
83 >                        fprintf(stderr,
84 >                        "%s: warning - missing value for variable '%s'\n",
85 >                                        progname, varname);
86                  return;
87          }
88                                          /* match variable from list */
# Line 86 | Line 90 | register char  *ass;
90          if (vp == NULL) {
91                  fprintf(stderr, "%s: unknown variable '%s'\n",
92                                  progname, varname);
93 <                exit(1);
93 >                quit(1);
94          }
95                                          /* assign new value */
96          if (i = vp->nass) {
# Line 100 | Line 104 | register char  *ass;
104                  vp->value = malloc(n+1);
105          if (vp->value == NULL) {
106                  perror(progname);
107 <                exit(1);
107 >                quit(1);
108          }
109          cp = vp->value+i;               /* copy value, squeezing spaces */
110          *cp = *ass;
# Line 133 | Line 137 | char   *nam;
137  
138  
139   char *
140 < nvalue(vp, n)                   /* return nth variable value */
141 < VARIABLE        *vp;
140 > nvalue(vn, n)                   /* return nth variable value */
141 > register int    vn;
142   register int    n;
143   {
144          register char   *cp;
145  
146 <        if (vp == NULL | n < 0 | n >= vp->nass)
146 >        if (vval(vn) == NULL | n < 0 | n >= vdef(vn))
147                  return(NULL);
148 <        cp = vp->value;
148 >        cp = vval(vn);
149          while (n--)
150                  while (*cp++)
151                          ;
# Line 217 | Line 221 | register VARIABLE      *vp;
221          }
222          fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
223                          progname, vp->name);
224 <        exit(1);
224 >        quit(1);
225   }
226  
227  
# Line 239 | Line 243 | register VARIABLE      *vp;
243          }
244          fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
245                          progname, vp->name);
246 <        exit(1);
246 >        quit(1);
247   }
248  
249  
# Line 251 | Line 255 | register VARIABLE      *vp;
255          if (isint(vp->value)) return;
256          fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
257                          progname, vp->name);
258 <        exit(1);
258 >        quit(1);
259   }
260  
261  
# Line 263 | Line 267 | register VARIABLE      *vp;
267          if (isflt(vp->value)) return;
268          fprintf(stderr, "%s: illegal value for real variable '%s'\n",
269                          progname, vp->name);
270 <        exit(1);
270 >        quit(1);
271   }
272  
273  
# Line 279 | Line 283 | register FILE  *fp;
283                  fputs("= ", fp);
284                  k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
285                                  - strlen(vnam(i)) ;
286 <                cp = nvalue(vv+i, j);
286 >                cp = nvalue(i, j);
287                  while (*cp) {
288                      putc(*cp++, fp);
289                      if (--k <= 0) {             /* line too long */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines