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

Comparing ray/src/common/wordfile.c (file contents):
Revision 2.1 by greg, Wed Mar 4 09:59:19 1992 UTC vs.
Revision 2.2 by greg, Fri Oct 16 13:02:46 1992 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   * Assume the passed pointer array is big enough to hold them all.
10   */
11  
12 + #include <ctype.h>
13 +
14   #define NULL            0
15  
16 < #define BUFSIZ          4096            /* file must be smaller than this */
16 > #define MAXFLEN         10240           /* file must be smaller than this */
17  
16 #include <ctype.h>
17
18   extern char     *bmalloc();
19  
20  
# Line 29 | Line 29 | char   *fname;
29          register int    n;
30          register char   *cp;
31                                          /* allocate memory */
32 <        if ((cp = buf = bmalloc(BUFSIZ)) == NULL)
32 >        if ((cp = buf = bmalloc(MAXFLEN)) == NULL)
33                  return(-1);
34          if ((fd = open(fname, 0)) < 0)
35                  goto err;
36 <        n = read(fd, buf, BUFSIZ);
36 >        n = read(fd, buf, MAXFLEN);
37          close(fd);
38          if (n < 0)
39                  goto err;
40 <        if (n == BUFSIZ)                /* file too big, take what we can */
40 >        if (n == MAXFLEN)               /* file too big, take what we can */
41                  while (!isspace(buf[--n]))
42                          if (n <= 0)
43                                  goto err;
44 <        bfree(buf+n+1, BUFSIZ-n-1);     /* return unneeded memory */
44 >        bfree(buf+n+1, MAXFLEN-n-1);    /* return unneeded memory */
45          while (n > 0) {                 /* break buffer into words */
46                  while (isspace(*cp)) {
47                          cp++;
# Line 56 | Line 56 | char   *fname;
56                  }
57                  *cp++ = '\0'; n--;
58          }
59 +        *wp = NULL;                     /* null terminator */
60          return(wp - words);
61   err:
62 <        bfree(buf, BUFSIZ);
62 >        bfree(buf, MAXFLEN);
63          return(-1);
64   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines