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

Comparing ray/src/util/rad.c (file contents):
Revision 2.24 by greg, Thu Sep 9 13:07:13 1993 UTC vs.
Revision 2.25 by greg, Wed Sep 15 15:11:47 1993 UTC

# Line 208 | Line 208 | register char  *rn, *fn;
208   }
209  
210  
211 + #define NOCHAR  127             /* constant for character to delete */
212 +
213 +
214   load(rfname)                    /* load Radiance simulation file */
215   char    *rfname;
216   {
# Line 223 | Line 226 | char   *rfname;
226                  for (cp = buf; *cp; cp++) {
227                          switch (*cp) {
228                          case '\\':
229 <                        case '\n':
227 <                                *cp = ' ';
229 >                                *cp++ = NOCHAR;
230                                  continue;
231                          case '#':
232                                  *cp = '\0';
# Line 244 | Line 246 | setvariable(ass)               /* assign variable according to stri
246   register char   *ass;
247   {
248          char    varname[32];
249 +        char    varval[512];
250 +        int     n;
251          register char   *cp;
252          register VARIABLE       *vp;
253          register int    i;
250        int     n;
254  
255          while (isspace(*ass))           /* skip leading space */
256                  ass++;
# Line 261 | Line 264 | register char  *ass;
264                                          /* trim value */
265          while (isspace(*ass) || *ass == '=')
266                  ass++;
267 <        cp = ass + strlen(ass);
268 <        do
269 <                *cp-- = '\0';
267 <        while (cp >= ass && isspace(*cp));
268 <        n = cp - ass + 1;
267 >        for (n = strlen(ass); n > 0; n--)
268 >                if (!isspace(ass[n-1]))
269 >                        break;
270          if (!n) {
271                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
272                                  progname, varname);
# Line 290 | Line 291 | register char  *ass;
291                  vp->value = malloc(n+1);
292          if (vp->value == NULL)
293                  syserr(progname);
294 <        strcpy(vp->value+i, ass);
294 >        cp = vp->value+i;               /* copy value, squeezing spaces */
295 >        *cp = *ass;
296 >        for (i = 1; i <= n; i++) {
297 >                if (ass[i] == NOCHAR)
298 >                        continue;
299 >                if (isspace(*cp))
300 >                        while (isspace(ass[i]))
301 >                                i++;
302 >                *++cp = ass[i];
303 >        }
304 >        *++cp = '\0';
305          vp->nass++;
306   }
307  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines