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 2.39 by greg, Wed Dec 28 18:35:42 2005 UTC vs.
Revision 2.49 by greg, Tue Feb 2 18:02:32 2016 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13  
14   #include  "platform.h"
15   #include  "paths.h"
16 #include  "rtprocess.h" /* win_popen() */
16   #include  "rtio.h"
17   #include  "rtmath.h"
18   #include  "object.h"
19   #include  "otypes.h"
20  
21 + #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
22 + #undef getc
23 + #define getc    getc_unlocked
24 + #endif
25 +
26   int  xac;                               /* global xform argument count */
27   char  **xav;                            /* global xform argument pointer */
28   int  xfa;                               /* start of xf arguments */
# Line 98 | Line 102 | main(          /* get transform options and transform file */
102                                  if (idprefix == NULL)
103                                          idprefix = argv[a];
104                                  else {
105 <                                        register char   *newp;
105 >                                        char    *newp;
106                                          newp = (char *)malloc(strlen(idprefix)+
107                                                          strlen(argv[a])+2);
108                                          if (newp == NULL)
# Line 106 | Line 110 | main(          /* get transform options and transform file */
110                                          sprintf(newp, "%s.%s",
111                                                          idprefix, argv[a]);
112                                          if (mal_prefix++)
113 <                                                free((void *)idprefix);
113 >                                                free(idprefix);
114                                          idprefix = newp;
115                                  }
116                                  continue;
# Line 134 | Line 138 | main(          /* get transform options and transform file */
138  
139          a += xf(&tot, argc-a, argv+a);
140  
141 <        if ( (reverse = tot.sca < 0.0) )
141 >        if ( (reverse = (tot.sca < 0.0)) )
142                  tot.sca = -tot.sca;
143          if (invert)
144                  reverse = !reverse;
# Line 167 | Line 171 | main(          /* get transform options and transform file */
171                  }
172  
173          if (mal_prefix)
174 <                free((void *)idprefix);
174 >                free(idprefix);
175          return(0);
176   }
177  
# Line 182 | Line 186 | doargf(                        /* take argument list from file */
186          int  inquote;
187          char  *newav[256], **avp;
188          char  argbuf[2048];
189 <        char  newid[128];
189 >        char  *newid, newidbuf[128];
190          char  *oldid;
191 <        register char   *cp;
191 >        char    *cp;
192          FILE    *argfp;
193          int  n, i, k, newac, err;
194          
# Line 258 | Line 262 | doargf(                        /* take argument list from file */
262                  for (i = fi+2; i < ac; i++)
263                          avp[newac++] = av[i];
264                  avp[newac] = NULL;
265 +                newid = newidbuf;
266                  oldid = NULL;
267                  for (i = 2; i < newac; i++)
268                          if (!strcmp(avp[i-1], "-n")) {
269                                  oldid = avp[i];
270 +                                if (strlen(oldid)+32 > sizeof(newidbuf)) {
271 +                                        newid = (char *)malloc(strlen(oldid)+32);
272 +                                        if (newid == NULL)
273 +                                                exit(2);
274 +                                }
275                                  avp[i] = newid;
276                                  break;
277                          }
# Line 277 | Line 287 | doargf(                        /* take argument list from file */
287                  else
288                          sprintf(newid, "%s.%d", oldid, k);
289                  err |= main(newac, avp);
290 +                if (newid != newidbuf)
291 +                        free(newid);
292                  k++;
293          }
294          fclose(argfp);
# Line 335 | Line 347 | doarray(                       /* make array */
347   void
348   xform(                  /* transform stream by tot.xfm */
349          char  *name,
350 <        register FILE  *fin
350 >        FILE  *fin
351   )
352   {
353          int  nobjs = 0;
354 <        register int  c;
354 >        int  c;
355  
356          while ((c = getc(fin)) != EOF) {
357                  if (isspace(c))                         /* blank */
# Line 448 | Line 460 | o_default(                     /* pass on arguments unchanged */
460          FILE  *fin
461   )
462   {
463 <        register int  i;
463 >        int  i;
464          FUNARGS  fa;
465  
466          if (readfargs(&fa, fin) != 1)
# Line 484 | Line 496 | addxform(                      /* add xf arguments to strings */
496          FILE  *fin
497   )
498   {
499 <        register int  i;
499 >        int  i;
500          int  resetarr = 0;
501          FUNARGS  fa;
502  
# Line 597 | Line 609 | m_mist(                /* transform arguments for mist */
609          else
610                  for (i = 0; i < fa.nsargs; i++) {
611                          char    sname[256], *sp;
612 <                        register char   *cp1, *cp2 = sname;
612 >                        char    *cp1, *cp2 = sname;
613                                                          /* add idprefix */
614                          for (sp = fa.sarg[i]; *sp; sp = cp1) {
615                                  for (cp1 = idprefix; *cp1; )
# Line 767 | Line 779 | o_face(                        /* transform face arguments */
779   )
780   {
781          FVECT  p;
782 <        register int  i;
782 >        int  i;
783          FUNARGS  fa;
784  
785          if (readfargs(&fa, fin) != 1)
# Line 881 | Line 893 | o_ring(                        /* transform ring arguments */
893   void
894   initotypes(void)                        /* initialize ofun[] array */
895   {
896 <        register int  i;
896 >        int  i;
897  
898          if (ofun[OBJ_SOURCE].funp == o_source)
899                  return;                 /* done already */
# Line 921 | Line 933 | initotypes(void)                       /* initialize ofun[] array */
933          tinvers[OBJ_CYLINDER] = OBJ_TUBE;
934          tinvers[OBJ_TUBE] = OBJ_CYLINDER;
935          tinvers[OBJ_INSTANCE] = OBJ_INSTANCE;   /* oh, well */
936 +        tinvers[OBJ_MESH] = OBJ_MESH;           /* ditto */
937   }
938  
939  
# Line 958 | Line 971 | openmain(              /* open input, changing directory for file
971          static char  origdir[PATH_MAX];
972          static char  curfn[PATH_MAX];
973          static int  diffdir;
974 <        register char  *fpath;
974 >        char  *fpath;
975  
976          if (iname == NULL) {                    /* standard input */
977                  if (mainfp == NULL) {
978 <                        register int  c;
978 >                        int  c;
979                          strcpy(mainfn, "standard input");
980                          if (nrept <= 1) {
981                                  mainfp = stdin;
# Line 1006 | Line 1019 | openmain(              /* open input, changing directory for file
1019                                                  /* record path name */
1020          strcpy(mainfn, fpath);
1021          if (expand) {                           /* change to local directory */
1022 <                register char  *cp = fpath + strlen(fpath);     /* get dir. */
1022 >                char  *cp = fpath + strlen(fpath);      /* get dir. */
1023                  while (cp > fpath) {
1024                          cp--;
1025                          if (ISDIRSEP(*cp)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines