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

Comparing ray/src/common/words.c (file contents):
Revision 1.1 by greg, Mon Jul 22 14:34:27 1991 UTC vs.
Revision 2.2 by greg, Wed Jan 10 21:04:21 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | extern char  *strchr();
20  
21  
22   char *
23 + atos(rs, nb, s)                 /* get next word from string */
24 + char  *rs;
25 + register int  nb;
26 + register char  *s;
27 + {
28 +        register char  *cp = rs;
29 +
30 +        while (isspace(*s))
31 +                s++;
32 +        while (--nb > 0 && *s && !isspace(*s))
33 +                *cp++ = *s++;
34 +        *cp = '\0';
35 +        return(rs);
36 + }
37 +
38 +
39 + char *
40   sskip(s)                        /* skip word in string */
41   register char  *s;
42   {
# Line 27 | Line 44 | register char  *s;
44                  s++;
45          while (*s && !isspace(*s))
46                  s++;
47 +        while (isspace(*s))
48 +                s++;
49          return(s);
50   }
51  
52  
53   char *
54   iskip(s)                        /* skip integer in string */
55 < char  *s;
55 > register char  *s;
56   {
57 <        register char  *cp = s;
58 <
59 <        while (isspace(*cp))
60 <                cp++;
61 <        if (*cp == '-' || *cp == '+')
62 <                cp++;
63 <        while (isdigit(*cp))
64 <                cp++;
65 <        return(cp);
57 >        while (isspace(*s))
58 >                s++;
59 >        if (*s == '-' || *s == '+')
60 >                s++;
61 >        if (!isdigit(*s))
62 >                return(NULL);
63 >        do
64 >                s++;
65 >        while (isdigit(*s));
66 >        return(s);
67   }
68  
69  
70   char *
71   fskip(s)                        /* skip float in string */
72 < char  *s;
72 > register char  *s;
73   {
74 <        register char  *cp = s;
74 >        register char  *cp;
75  
76 <        while (isspace(*cp))
77 <                cp++;
78 <        if (*cp == '-' || *cp == '+')
79 <                cp++;
76 >        while (isspace(*s))
77 >                s++;
78 >        if (*s == '-' || *s == '+')
79 >                s++;
80 >        cp = s;
81          while (isdigit(*cp))
82                  cp++;
83          if (*cp == '.') {
84 <                cp++;
84 >                cp++; s++;
85                  while (isdigit(*cp))
86                          cp++;
87          }
88 +        if (cp == s)
89 +                return(NULL);
90          if (*cp == 'e' || *cp == 'E')
91                  return(iskip(cp+1));
92          return(cp);
# Line 76 | Line 99 | char  *s;
99          register char  *cp;
100  
101          cp = iskip(s);
102 <        return(cp > s && *cp == '\0');
102 >        return(cp != NULL && *cp == '\0');
103   }
104  
105  
# Line 86 | Line 109 | char  *s, *ds;
109          register char  *cp;
110  
111          cp = iskip(s);
112 <        return(cp > s && strchr(*cp, ds) != NULL);
112 >        return(cp != NULL && strchr(ds, *cp) != NULL);
113   }
114  
115  
# Line 96 | Line 119 | char  *s;
119          register char  *cp;
120  
121          cp = fskip(s);
122 <        return(cp > s && *cp == '\0');
122 >        return(cp != NULL && *cp == '\0');
123   }
124  
125  
# Line 106 | Line 129 | char  *s, *ds;
129          register char  *cp;
130  
131          cp = fskip(s);
132 <        return(cp > s && strchr(*cp, ds) != NULL);
132 >        return(cp != NULL && strchr(ds, *cp) != NULL);
133   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines