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.3 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.6 by greg, Wed Oct 12 03:37:54 2005 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   * Read white space separated words from stream
6   *
7 < *  External symbols declared in standard.h
7 > *  External symbols declared in rtio.h
8   */
9  
10   #include "copyright.h"
11  
12 < #include  <stdio.h>
12 > #include  "rtio.h"
13  
14   #include  <ctype.h>
15  
16  
17   char *
18 < fgetword(s, n, fp)              /* get (quoted) word up to n-1 characters */
19 < char  *s;
20 < int  n;
21 < register FILE  *fp;
18 > fgetword(                       /* get (quoted) word up to n-1 characters */
19 >        char  *s,
20 >        int  n,
21 >        register FILE  *fp
22 > )
23   {
24          int  quote = '\0';
25          register char  *cp;
26          register int  c;
27 +                                        /* sanity checks */
28 +        if ((s == NULL) | (n <= 0))
29 +                return(NULL);
30                                          /* skip initial white space */
31          do
32                  c = getc(fp);
33          while (isspace(c));
34                                          /* check for quote */
35 <        if ((c == '"' | c == '\'')) {
35 >        if ((c == '"') | (c == '\'')) {
36                  quote = c;
37                  c = getc(fp);
38          }
# Line 44 | Line 48 | register FILE  *fp;
48                  c = getc(fp);
49          } while (c != EOF && !(quote ? c==quote : isspace(c)));
50          *cp = '\0';
51 <        if ((c != EOF & !quote))        /* replace space */
51 >        if ((c != EOF) & (!quote))      /* replace space */
52                  ungetc(c, fp);
53          return(s);
54   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines