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.23 by greg, Tue Sep 7 11:57:04 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  
# Line 1015 | Line 1026 | char   *vn;            /* returned view name */
1026   printview(vopts)                        /* print out selected view */
1027   register char   *vopts;
1028   {
1029 <        extern char     *atos();
1029 >        extern char     *atos(), *getenv();
1030          char    buf[256];
1031          FILE    *fp;
1032          register char   *cp;
# Line 1050 | Line 1061 | register char  *vopts;
1061                          while (isspace(*vopts))
1062                                  vopts++;
1063                          putchar(' ');
1064 <                        while (*vopts && !isspace(*vopts))
1065 <                                putchar(*vopts++);
1064 > #ifdef MSDOS
1065 >                        if (*vopts == '$') {            /* expand env. var. */
1066 >                                if (!*atos(buf, sizeof(buf), vopts+1))
1067 >                                        return(-1);
1068 >                                if ((cp = getenv(buf)) == NULL)
1069 >                                        return(-1);
1070 >                                fputs(cp, stdout);
1071 >                                vopts = sskip(vopts);
1072 >                        } else
1073 > #endif
1074 >                                while (*vopts && !isspace(*vopts))
1075 >                                        putchar(*vopts++);
1076                  }
1077          } while (*vopts++);
1078          putchar('\n');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines