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

Comparing ray/src/common/fgetword.c (file contents):
Revision 2.6 by greg, Wed Oct 12 03:37:54 2005 UTC vs.
Revision 2.7 by greg, Sun Apr 9 21:33:24 2017 UTC

# Line 18 | Line 18 | char *
18   fgetword(                       /* get (quoted) word up to n-1 characters */
19          char  *s,
20          int  n,
21 <        register FILE  *fp
21 >        FILE  *fp
22   )
23   {
24          int  quote = '\0';
25 <        register char  *cp;
26 <        register int  c;
25 >        char  *cp;
26 >        int  c;
27                                          /* sanity checks */
28 <        if ((s == NULL) | (n <= 0))
28 >        if ((s == NULL) | (n < 2))
29                  return(NULL);
30                                          /* skip initial white space */
31          do
# Line 36 | Line 36 | fgetword(                      /* get (quoted) word up to n-1 characters
36                  quote = c;
37                  c = getc(fp);
38          }
39                                        /* check for end of file */
40        if (c == EOF)
41                return(NULL);
39                                          /* get actual word */
40          cp = s;
41 <        do {
41 >        while (c != EOF && !(quote ? c==quote : isspace(c))) {
42                  if (--n <= 0)           /* check length limit */
43                          break;
44                  *cp++ = c;
45                  c = getc(fp);
46 <        } while (c != EOF && !(quote ? c==quote : isspace(c)));
46 >        }
47          *cp = '\0';
48 <        if ((c != EOF) & (!quote))      /* replace space */
48 >        if ((c != EOF) & !quote)        /* replace space */
49                  ungetc(c, fp);
50          return(s);
51   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines