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.3 by greg, Thu Jul 25 14:36:49 1991 UTC vs.
Revision 2.4 by gwlarson, Fri Jan 29 11:18:23 1999 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 */
23 > atos(rs, nb, s)                 /* get word from string, returning rs */
24   char  *rs;
25   register int  nb;
26   register char  *s;
# Line 37 | Line 37 | register char  *s;
37  
38  
39   char *
40 < sskip(s)                        /* skip word in string */
40 > nextword(cp, nb, s)             /* get (quoted) word, returning new s */
41 > register char  *cp;
42 > register int  nb;
43   register char  *s;
44   {
45 +        int     quote = 0;
46 +
47 +        if (s == NULL) return(NULL);
48          while (isspace(*s))
49                  s++;
50 +        switch (*s) {
51 +        case '\0':
52 +                return(NULL);
53 +        case '"':
54 +        case '\'':
55 +                quote = *s++;
56 +        }
57 +        while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s)))
58 +                *cp++ = *s++;
59 +        *cp = '\0';
60 +        if (quote && *s==quote)
61 +                s++;
62 +        return(s);
63 + }
64 +
65 +
66 + char *
67 + sskip(s)                        /* skip word in string, leaving on space */
68 + register char  *s;
69 + {
70 +        while (isspace(*s))
71 +                s++;
72          while (*s && !isspace(*s))
73                  s++;
74          return(s);
# Line 49 | Line 76 | register char  *s;
76  
77  
78   char *
79 + sskip2(s, n)                    /* skip word(s) in string, leaving on word */
80 + register char  *s;
81 + register int    n;
82 + {
83 +        while (isspace(*s))
84 +                s++;
85 +        while (n-- > 0) {
86 +                while (*s && !isspace(*s))
87 +                        s++;
88 +                while (isspace(*s))
89 +                        s++;
90 +        }
91 +        return(s);
92 + }
93 +
94 +
95 + char *
96   iskip(s)                        /* skip integer in string */
97   register char  *s;
98   {
# Line 69 | Line 113 | char *
113   fskip(s)                        /* skip float in string */
114   register char  *s;
115   {
116 <        register char  *cp = s;
116 >        register char  *cp;
117  
118 <        while (isspace(*cp))
119 <                cp++;
120 <        if (*cp == '-' || *cp == '+')
121 <                cp++;
122 <        s = cp;
118 >        while (isspace(*s))
119 >                s++;
120 >        if (*s == '-' || *s == '+')
121 >                s++;
122 >        cp = s;
123          while (isdigit(*cp))
124                  cp++;
125          if (*cp == '.') {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines