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.19 by greg, Wed Mar 23 18:17:46 2016 UTC vs.
Revision 2.24 by greg, Sat Dec 28 18:05:14 2019 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #include "copyright.h"
11  
12   #include <ctype.h>
13 #include <string.h>
13  
14   #include "platform.h"
15   #include "rtio.h"
# Line 40 | Line 39 | wordfile(                      /* get words from fname, put in words */
39                  return(-1);                     /* open error */
40          words[0] = NULL;
41          while (nargs > 1 && (n += read(fd, buf+n, MAXWLEN-n)) > 0) {
42 +                int     dlen = n;
43                  int     crem = 0;
44 <                if (n >= MAXWLEN)               /* still something left? */
44 >                if (n > MAXWLEN/2)              /* check for mid-word end */
45                          while (!isspace(buf[--n])) {
46                                  if (n <= 0)     /* one long word! */
47                                          goto done;
# Line 56 | Line 56 | wordfile(                      /* get words from fname, put in words */
56                  words += n; nargs -= n;
57                  wrdcnt += n;
58                  if ((n = crem) > 0)             /* move remainder */
59 <                        memmove(buf, buf+MAXWLEN-crem, crem);
59 >                        memmove(buf, buf+dlen-crem, crem);
60          }
61   done:
62          close(fd);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines