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.15 by greg, Fri May 22 14:44:11 2015 UTC vs.
Revision 2.19 by greg, Fri Jun 9 22:52:47 2023 UTC

# Line 21 | Line 21 | extern char  *fgetline();
21  
22   void
23   loadvars(                       /* load variables into vv from file */
24 <        char    *rfname
24 >        const char      *rfname
25   )
26   {
27          FILE    *fp;
# Line 54 | Line 54 | loadvars(                      /* load variables into vv from file */
54                          quit(1);
55                  }
56          }
57 <        fclose(fp);
57 >        if (fp != stdin)
58 >                fclose(fp);
59   }
60  
61  
62   int
63   setvariable(                    /* assign variable according to string */
64 <        char    *ass,
65 <        VARIABLE        *(*mv)(char*)
64 >        const char      *ass,
65 >        VARIABLE        *(*mv)(const char*)
66   )
67   {
68 +        int     quote = '\0';
69          char    varname[32];
70          int     n;
71          char    *cp;
# Line 105 | Line 107 | setvariable(                   /* assign variable according to string
107                  perror(progname);
108                  quit(1);
109          }
110 <        cp = vp->value+i;               /* copy value, squeezing spaces */
110 >        cp = vp->value+i;               /* copy value */
111          *cp = *ass;
112          for (i = 1; i <= n; i++) {
113                  if (ass[i] == NOCHAR)
114                          continue;
115 <                if (isspace(*cp))
116 <                        while (isspace(ass[i]))
117 <                                i++;
115 >                if (quote) {            /* don't change quoted parts */
116 >                        quote *= (ass[i] != quote);
117 >                } else {                /* otherwise, squeeze spaces */
118 >                        if (isspace(*cp))
119 >                                while (isspace(ass[i]))
120 >                                        i++;
121 >                        if ((ass[i] == '"') | (ass[i] == '\''))
122 >                                quote = ass[i];
123 >                }
124                  *++cp = ass[i];
125          }
126          if (isspace(*cp))               /* remove trailing space */
# Line 123 | Line 131 | setvariable(                   /* assign variable according to string
131  
132   VARIABLE *
133   matchvar(                       /* match a variable by its name */
134 <        char    *nam
134 >        const char      *nam
135   )
136   {
137          int     n = strlen(nam);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines