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.47 by greg, Tue Aug 16 18:09:53 2011 UTC vs.
Revision 2.52 by greg, Tue Apr 22 04:45:25 2025 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"
# Line 98 | Line 97 | main(          /* get transform options and transform file */
97                                  if (idprefix == NULL)
98                                          idprefix = argv[a];
99                                  else {
100 <                                        register char   *newp;
100 >                                        char    *newp;
101                                          newp = (char *)malloc(strlen(idprefix)+
102                                                          strlen(argv[a])+2);
103                                          if (newp == NULL)
# Line 184 | Line 183 | doargf(                        /* take argument list from file */
183          char  argbuf[2048];
184          char  *newid, newidbuf[128];
185          char  *oldid;
186 <        register char   *cp;
186 >        char    *cp;
187          FILE    *argfp;
188          int  n, i, k, newac, err;
189          
# Line 210 | Line 209 | doargf(                        /* take argument list from file */
209                  }
210                  n = 0;                  /* count number of lines in file */
211                  while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL)
212 <                        n += argbuf[0] && argbuf[0] != '#';
212 >                        n += (argbuf[0] != '\0') & (argbuf[0] != '#');
213                  if (!n) {
214                          fprintf(stderr, "%s: empty argument file \"%s\"\n",
215                                          av[0], av[fi+1]);
216                          exit(1);
217                  }
219                nrept *= n;
218                  rewind(argfp);
219          }
220 +        nrept *= n;
221          err = 0; k = 0;                 /* read each arg list and call main */
222          while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL) {
223 <                if (!argbuf[0] || argbuf[0] == '#')
223 >                if (!argbuf[0] | (argbuf[0] == '#')) {
224 >                        printf("%s\n", argbuf);
225                          continue;
226 +                }
227                  avp = newav+2;
228                  avp[0] = av[0];
229                  for (i = 1; i < fi; i++)
# Line 343 | Line 344 | doarray(                       /* make array */
344   void
345   xform(                  /* transform stream by tot.xfm */
346          char  *name,
347 <        register FILE  *fin
347 >        FILE  *fin
348   )
349   {
350          int  nobjs = 0;
351 <        register int  c;
351 >        int  c;
352  
353          while ((c = getc(fin)) != EOF) {
354                  if (isspace(c))                         /* blank */
# Line 393 | Line 394 | xfcomm(                        /* transform a command */
394                          exit(1);
395                  }
396                  xform(buf, pin);
397 <                pclose(pin);
397 >                if (pclose(pin) != 0) {
398 >                        fprintf(stderr, "%s: (%s): bad status from \"%s\"\n",
399 >                                        progname, fname, buf);
400 >                        exit(1);
401 >                }
402          } else {
403                  printf("\n%s", buf);
404                  if (xac > 1) {
# Line 456 | Line 461 | o_default(                     /* pass on arguments unchanged */
461          FILE  *fin
462   )
463   {
464 <        register int  i;
464 >        int  i;
465          FUNARGS  fa;
466  
467          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 497 | addxform(                      /* add xf arguments to strings */
497          FILE  *fin
498   )
499   {
500 <        register int  i;
500 >        int  i;
501          int  resetarr = 0;
502          FUNARGS  fa;
503  
# Line 553 | Line 558 | m_glow(                        /* transform arguments for proximity light *
558  
559          if (readfargs(&fa, fin) != 1)
560                  return(-1);
561 <        if (fa.nsargs != 0  || fa.nfargs != 4)
561 >        if ((fa.nsargs != 0) | (fa.nfargs != 4))
562                  return(-1);
563          printf("0\n0\n4");
564          printf(" %18.12g %18.12g %18.12g",
# Line 574 | Line 579 | m_spot(                        /* transform arguments for spotlight */
579  
580          if (readfargs(&fa, fin) != 1)
581                  return(-1);
582 <        if (fa.nsargs != 0  || fa.nfargs != 7)
582 >        if ((fa.nsargs != 0) | ( fa.nfargs != 7))
583                  return(-1);
584          printf("0\n0\n7");
585          printf(" %18.12g %18.12g %18.12g %18.12g\n",
# Line 605 | Line 610 | m_mist(                /* transform arguments for mist */
610          else
611                  for (i = 0; i < fa.nsargs; i++) {
612                          char    sname[256], *sp;
613 <                        register char   *cp1, *cp2 = sname;
613 >                        char    *cp1, *cp2 = sname;
614                                                          /* add idprefix */
615                          for (sp = fa.sarg[i]; *sp; sp = cp1) {
616                                  for (cp1 = idprefix; *cp1; )
# Line 775 | Line 780 | o_face(                        /* transform face arguments */
780   )
781   {
782          FVECT  p;
783 <        register int  i;
783 >        int  i;
784          FUNARGS  fa;
785  
786          if (readfargs(&fa, fin) != 1)
# Line 889 | Line 894 | o_ring(                        /* transform ring arguments */
894   void
895   initotypes(void)                        /* initialize ofun[] array */
896   {
897 <        register int  i;
897 >        int  i;
898  
899          if (ofun[OBJ_SOURCE].funp == o_source)
900                  return;                 /* done already */
# Line 967 | Line 972 | openmain(              /* open input, changing directory for file
972          static char  origdir[PATH_MAX];
973          static char  curfn[PATH_MAX];
974          static int  diffdir;
975 <        register char  *fpath;
975 >        char  *fpath;
976  
977          if (iname == NULL) {                    /* standard input */
978                  if (mainfp == NULL) {
979 <                        register int  c;
979 >                        int  c;
980                          strcpy(mainfn, "standard input");
981                          if (nrept <= 1) {
982                                  mainfp = stdin;
# Line 1015 | Line 1020 | openmain(              /* open input, changing directory for file
1020                                                  /* record path name */
1021          strcpy(mainfn, fpath);
1022          if (expand) {                           /* change to local directory */
1023 <                register char  *cp = fpath + strlen(fpath);     /* get dir. */
1023 >                char  *cp = fpath + strlen(fpath);      /* get dir. */
1024                  while (cp > fpath) {
1025                          cp--;
1026                          if (ISDIRSEP(*cp)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines