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

Comparing ray/src/cal/rcalc.c (file contents):
Revision 1.5 by schorsch, Sun Jun 8 12:03:09 2003 UTC vs.
Revision 1.9 by greg, Wed Nov 5 19:03:03 2003 UTC

# Line 15 | Line 15 | static const char RCSid[] = "$Id$";
15  
16   #include  "platform.h"
17   #include  "calcomp.h"
18 + #include  "rterror.h"
19  
19 #ifdef  CPM
20 #define  getc           agetc   /* text files only, right? */
21 #endif
22
20   #define  isnum(c)       (isdigit(c) || (c)=='-' || (c)=='.' \
21                                  || (c)=='+' || (c)=='e' || (c)=='E')
22  
# Line 150 | Line 147 | char  *argv[]
147                                          nbicols = atoi(argv[i]+3);
148                                  else
149                                          nbicols = 1;
150 +                                if (nbicols*sizeof(double) > INBSIZ) {
151 +                                        eputs(argv[0]);
152 +                                        eputs(": too many input columns\n");
153 +                                        quit(1);
154 +                                }
155                                  break;
156                          case 'f':
157                                  if (isdigit(argv[i][3]))
158                                          nbicols = -atoi(argv[i]+3);
159                                  else
160                                          nbicols = -1;
161 +                                if (-nbicols*sizeof(float) > INBSIZ) {
162 +                                        eputs(argv[0]);
163 +                                        eputs(": too many input columns\n");
164 +                                        quit(1);
165 +                                }
166                                  break;
167                          default:
168                                  goto userr;
# Line 616 | Line 623 | getfield(                             /* get next fiel
623   register struct field  *f
624   )
625   {
626 <        static char  buf[MAXWORD+1];            /* no recursion! */
626 >        static char  buf[RMAXWORD+1];            /* no recursion! */
627          int  delim, inword;
628          double  d;
629          char  *np;
# Line 649 | Line 656 | register struct field  *f
656                          delim = f->next->f.sl[0];
657                  cp = buf;
658                  do {
659 <                        if (ipb.chr == EOF)
659 >                        if (ipb.chr == EOF || ipb.chr == '\n')
660                                  inword = 0;
661                          else if (blnkeq && delim != EOF)
662                                  inword = isblnk(delim) ?
# Line 661 | Line 668 | register struct field  *f
668                                  *cp++ = ipb.chr;
669                                  scaninp();
670                          }
671 <                } while (inword && cp < &buf[MAXWORD]);
671 >                } while (inword && cp < &buf[RMAXWORD]);
672                  *cp = '\0';
673                  if (f->f.sv->val == NULL)
674                          f->f.sv->val = savqstr(buf);    /* first setting */
# Line 690 | Line 697 | register struct field  *f
697                                  *cp++ = ipb.chr;
698                                  scaninp();
699                          }
700 <                } while (inword && cp < &buf[MAXWORD]);
700 >                } while (inword && cp < &buf[RMAXWORD]);
701                  *cp = '\0';
702                  d = np==NULL ? 0. : atof(np);
703                  if (!vardefined(f->f.nv))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines