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

Comparing ray/src/gen/xform.c (file contents):
Revision 1.1 by greg, Thu Feb 2 11:16:33 1989 UTC vs.
Revision 1.9 by greg, Fri Oct 13 19:34:17 1989 UTC

# Line 69 | Line 69 | FUN  ofun[] = {
69          { "colortext", text },
70          { "brighttext", text },
71          { "texfunc", addxform },
72 +        { "texdata", addxform },
73          { "colorfunc", addxform },
74          { "brightfunc", addxform },
75          { "colorpict", addxform },
# Line 112 | Line 113 | char  *argv[];
113          FILE  *fopen();
114          FILE  *fp;
115          int  a;
116 +                                        /* check for array */
117 +        for (a = 1; a < argc; a++)
118 +                if (!strcmp(argv[a], "-a"))
119 +                        return(doarray(argc, argv, a));
120  
116        xav = argv;
117
121          for (a = 1; a < argc; a++) {
122                  if (argv[a][0] == '-')
123                          switch (argv[a][1]) {
124                          case 'n':
125 +                                if (argv[a][2] || a+1 >= argc)
126 +                                        break;
127                                  idprefix = argv[++a];
128                                  continue;
129                          case 'e':
130 +                                if (argv[a][2])
131 +                                        break;
132                                  expand = 1;
133                                  continue;
134                          }
135                  break;
136          }
137  
138 +        xav = argv;
139          xfa = a;
140  
141          totscale = 1.0;
# Line 138 | Line 146 | char  *argv[];
146          if (reverse = totscale < 0.0)
147                  totscale = -totscale;
148  
149 +        if (a < argc && argv[a][0] == '-') {
150 +                fprintf(stderr, "%s: command line error at '%s'\n",
151 +                                argv[0], argv[a]);
152 +                exit(1);
153 +        }
154          xac = a;
155  
156          putchar('#');                           /* simple header */
# Line 158 | Line 171 | char  *argv[];
171                          fclose(fp);
172                  }
173  
174 <        exit(0);
174 >        return(0);
175   }
176  
177  
178 + doarray(ac, av, ai)                     /* make array */
179 + char  **av;
180 + int  ac, ai;
181 + {
182 +        char  *newav[256], **avp;
183 +        char  newid[128], repts[32];
184 +        char  *oldid = NULL;
185 +        int  i, err;
186 +        
187 +        avp = newav+2;
188 +        avp[0] = av[0];
189 +        for (i = 1; i < ac; i++)
190 +                if (!strcmp(av[i-1], "-n")) {
191 +                        oldid = av[i];
192 +                        avp[i] = newid;
193 +                } else
194 +                        avp[i] = av[i];
195 +        avp[ai] = "-i";
196 +        avp[ai+1] = repts;
197 +        avp[i] = NULL;
198 +        if (oldid == NULL) {
199 +                newav[0] = av[0];
200 +                newav[1] = "-n";
201 +                newav[2] = newid;
202 +                avp = newav;
203 +                ac += 2;
204 +        }
205 +        err = 0;
206 +        for (i = 0; i < atoi(av[ai+1]); i++) {
207 +                if (oldid == NULL)
208 +                        sprintf(newid, "a%d", i);
209 +                else
210 +                        sprintf(newid, "%s.%d", oldid, i);
211 +                sprintf(repts, "%d", i);
212 +                err |= main(ac, avp);
213 +        }
214 +        return(err);
215 + }
216 +
217 +
218   xform(name, fin)                        /* transform stream by totxform */
219   char  *name;
220   register FILE  *fin;
# Line 180 | Line 233 | register FILE  *fin;
233                          } while (c != '\n');
234                  } else if (c == '!') {                  /* command */
235                          ungetc(c, fin);
236 <                        if (expand)
184 <                                xfcomm(name, fin);
185 <                        else {
186 <                                putchar('\n');
187 <                                while ((c = getc(fin)) != EOF && c != '\n')
188 <                                        putchar(c);
189 <                                printf(" |");
190 <                                for (c = 0; c < xac; c++)
191 <                                        printf(" %s", xav[c]);
192 <                                putchar('\n');
193 <                        }
236 >                        xfcomm(name, fin);
237                  } else {                                /* object */
238                          ungetc(c, fin);
239                          xfobject(name, fin);
# Line 199 | Line 242 | register FILE  *fin;
242   }
243  
244  
245 < xfcomm(fname, fin)                              /* expand a command */
245 > xfcomm(fname, fin)                      /* transform a command */
246   FILE  *fin;
247   {
248          FILE  *popen();
249 <        char  *fgets();
249 >        char  *fgetline();
250          FILE  *pin;
251          char  buf[512];
252 +        int  i;
253  
254 <        buf[0] = '\0';
255 <        fgets(buf, sizeof(buf), fin);
256 <        if (buf[0] && buf[strlen(buf)-1] == '\n')
257 <                buf[strlen(buf)-1] = '\0';
258 <        if ((pin = popen(buf+1, "r")) == NULL) {
259 <                fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n",
260 <                                progname, fname, buf);
261 <                exit(1);
254 >        fgetline(buf, sizeof(buf), fin);
255 >        if (expand) {
256 >                if ((pin = popen(buf+1, "r")) == NULL) {
257 >                        fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n",
258 >                                        progname, fname, buf);
259 >                        exit(1);
260 >                }
261 >                xform(buf, pin);
262 >                pclose(pin);
263 >        } else {
264 >                printf("\n%s | %s -e", buf, xav[0]);
265 >                for (i = 1; i < xac; i++)
266 >                        printf(" %s", xav[i]);
267 >                putchar('\n');
268          }
219        xform(buf, pin);
220        pclose(pin);
269   }
270  
271  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines