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.46 by greg, Mon Aug 15 19:48:06 2011 UTC vs.
Revision 2.54 by greg, Sat Jun 7 05:09:45 2025 UTC

# Line 12 | Line 12 | static const char RCSid[] = "$Id$";
12   #include  <ctype.h>
13  
14   #include  "platform.h"
15 #include  "paths.h"
16 #include  "rtprocess.h" /* win_popen() */
15   #include  "rtio.h"
16   #include  "rtmath.h"
17   #include  "object.h"
# Line 98 | Line 96 | main(          /* get transform options and transform file */
96                                  if (idprefix == NULL)
97                                          idprefix = argv[a];
98                                  else {
99 <                                        register char   *newp;
99 >                                        char    *newp;
100                                          newp = (char *)malloc(strlen(idprefix)+
101                                                          strlen(argv[a])+2);
102                                          if (newp == NULL)
# Line 134 | Line 132 | main(          /* get transform options and transform file */
132  
133          a += xf(&tot, argc-a, argv+a);
134  
135 <        if ( (reverse = tot.sca < 0.0) )
135 >        if ( (reverse = (tot.sca < 0.0)) )
136                  tot.sca = -tot.sca;
137          if (invert)
138                  reverse = !reverse;
# Line 184 | Line 182 | doargf(                        /* take argument list from file */
182          char  argbuf[2048];
183          char  *newid, newidbuf[128];
184          char  *oldid;
185 <        register char   *cp;
185 >        char    *cp;
186          FILE    *argfp;
187          int  n, i, k, newac, err;
188          
# Line 210 | Line 208 | doargf(                        /* take argument list from file */
208                  }
209                  n = 0;                  /* count number of lines in file */
210                  while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL)
211 <                        n += argbuf[0] && argbuf[0] != '#';
211 >                        n += (argbuf[0] != '\0') & (argbuf[0] != '#');
212                  if (!n) {
213                          fprintf(stderr, "%s: empty argument file \"%s\"\n",
214                                          av[0], av[fi+1]);
215                          exit(1);
216                  }
219                nrept *= n;
217                  rewind(argfp);
218          }
219 +        nrept *= n;
220          err = 0; k = 0;                 /* read each arg list and call main */
221          while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL) {
222 <                if (!argbuf[0] || argbuf[0] == '#')
222 >                if (!argbuf[0] | (argbuf[0] == '#')) {
223 >                        printf("%s\n", argbuf);
224                          continue;
225 +                }
226                  avp = newav+2;
227                  avp[0] = av[0];
228                  for (i = 1; i < fi; i++)
# Line 343 | Line 343 | doarray(                       /* make array */
343   void
344   xform(                  /* transform stream by tot.xfm */
345          char  *name,
346 <        register FILE  *fin
346 >        FILE  *fin
347   )
348   {
349          int  nobjs = 0;
350 <        register int  c;
350 >        int  c;
351  
352          while ((c = getc(fin)) != EOF) {
353                  if (isspace(c))                         /* blank */
# Line 393 | Line 393 | xfcomm(                        /* transform a command */
393                          exit(1);
394                  }
395                  xform(buf, pin);
396 <                pclose(pin);
396 >                if (pclose(pin) != 0)
397 >                        fprintf(stderr, "%s: (%s): warning - bad status from \"%s\"\n",
398 >                                        progname, fname, buf);
399          } else {
400                  printf("\n%s", buf);
401                  if (xac > 1) {
# Line 456 | Line 458 | o_default(                     /* pass on arguments unchanged */
458          FILE  *fin
459   )
460   {
461 <        register int  i;
461 >        int  i;
462          FUNARGS  fa;
463  
464          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 494 | addxform(                      /* add xf arguments to strings */
494          FILE  *fin
495   )
496   {
497 <        register int  i;
497 >        int  i;
498          int  resetarr = 0;
499          FUNARGS  fa;
500  
# Line 553 | Line 555 | m_glow(                        /* transform arguments for proximity light *
555  
556          if (readfargs(&fa, fin) != 1)
557                  return(-1);
558 <        if (fa.nsargs != 0  || fa.nfargs != 4)
558 >        if ((fa.nsargs != 0) | (fa.nfargs != 4))
559                  return(-1);
560          printf("0\n0\n4");
561          printf(" %18.12g %18.12g %18.12g",
# Line 574 | Line 576 | m_spot(                        /* transform arguments for spotlight */
576  
577          if (readfargs(&fa, fin) != 1)
578                  return(-1);
579 <        if (fa.nsargs != 0  || fa.nfargs != 7)
579 >        if ((fa.nsargs != 0) | ( fa.nfargs != 7))
580                  return(-1);
581          printf("0\n0\n7");
582          printf(" %18.12g %18.12g %18.12g %18.12g\n",
# Line 605 | Line 607 | m_mist(                /* transform arguments for mist */
607          else
608                  for (i = 0; i < fa.nsargs; i++) {
609                          char    sname[256], *sp;
610 <                        register char   *cp1, *cp2 = sname;
610 >                        char    *cp1, *cp2 = sname;
611                                                          /* add idprefix */
612                          for (sp = fa.sarg[i]; *sp; sp = cp1) {
613                                  for (cp1 = idprefix; *cp1; )
# Line 775 | Line 777 | o_face(                        /* transform face arguments */
777   )
778   {
779          FVECT  p;
780 <        register int  i;
780 >        int  i;
781          FUNARGS  fa;
782  
783          if (readfargs(&fa, fin) != 1)
# Line 889 | Line 891 | o_ring(                        /* transform ring arguments */
891   void
892   initotypes(void)                        /* initialize ofun[] array */
893   {
894 <        register int  i;
894 >        int  i;
895  
896          if (ofun[OBJ_SOURCE].funp == o_source)
897                  return;                 /* done already */
# Line 967 | Line 969 | openmain(              /* open input, changing directory for file
969          static char  origdir[PATH_MAX];
970          static char  curfn[PATH_MAX];
971          static int  diffdir;
972 <        register char  *fpath;
972 >        char  *fpath;
973  
974          if (iname == NULL) {                    /* standard input */
975                  if (mainfp == NULL) {
976 <                        register int  c;
976 >                        int  c;
977                          strcpy(mainfn, "standard input");
978                          if (nrept <= 1) {
979                                  mainfp = stdin;
# Line 1015 | Line 1017 | openmain(              /* open input, changing directory for file
1017                                                  /* record path name */
1018          strcpy(mainfn, fpath);
1019          if (expand) {                           /* change to local directory */
1020 <                register char  *cp = fpath + strlen(fpath);     /* get dir. */
1020 >                char  *cp = fpath + strlen(fpath);      /* get dir. */
1021                  while (cp > fpath) {
1022                          cp--;
1023                          if (ISDIRSEP(*cp)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines