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.2 by greg, Tue Jul 23 11:36:42 1991 UTC vs.
Revision 2.8 by schorsch, Thu Jul 17 09:21:29 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id";
3   #endif
6
4   /*
5   * Routines for recognizing and moving about words in strings.
6 + *
7 + * External symbols declared in standard.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include  <ctype.h>
13 + #include  <string.h>
14  
15 < #ifdef  BSD
14 < #define  strchr         index
15 < #endif
15 > #include  "rtio.h"
16  
17 #define  NULL           0
18
19 extern char  *strchr();
20
21
17   char *
18 < atos(rs, nb, s)                 /* get next word from string */
18 > atos(rs, nb, s)                 /* get word from string, returning rs */
19   char  *rs;
20   register int  nb;
21   register char  *s;
# Line 37 | Line 32 | register char  *s;
32  
33  
34   char *
35 < sskip(s)                        /* skip word in string */
35 > nextword(cp, nb, s)             /* get (quoted) word, returning new s */
36 > register char  *cp;
37 > register int  nb;
38   register char  *s;
39   {
40 +        int     quote = 0;
41 +
42 +        if (s == NULL) return(NULL);
43          while (isspace(*s))
44                  s++;
45 +        switch (*s) {
46 +        case '\0':
47 +                return(NULL);
48 +        case '"':
49 +        case '\'':
50 +                quote = *s++;
51 +        }
52 +        while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s)))
53 +                *cp++ = *s++;
54 +        *cp = '\0';
55 +        if (quote && *s==quote)
56 +                s++;
57 +        return(s);
58 + }
59 +
60 +
61 + char *
62 + sskip(s)                        /* skip word in string, leaving on space */
63 + register char  *s;
64 + {
65 +        while (isspace(*s))
66 +                s++;
67          while (*s && !isspace(*s))
68                  s++;
69          return(s);
# Line 49 | Line 71 | register char  *s;
71  
72  
73   char *
74 + sskip2(s, n)                    /* skip word(s) in string, leaving on word */
75 + register char  *s;
76 + register int    n;
77 + {
78 +        while (isspace(*s))
79 +                s++;
80 +        while (n-- > 0) {
81 +                while (*s && !isspace(*s))
82 +                        s++;
83 +                while (isspace(*s))
84 +                        s++;
85 +        }
86 +        return(s);
87 + }
88 +
89 +
90 + char *
91   iskip(s)                        /* skip integer in string */
92   register char  *s;
93   {
# Line 69 | Line 108 | char *
108   fskip(s)                        /* skip float in string */
109   register char  *s;
110   {
111 <        register char  *cp = s;
111 >        register char  *cp;
112  
113 <        while (isspace(*cp))
114 <                cp++;
115 <        if (*cp == '-' || *cp == '+')
116 <                cp++;
117 <        s = cp;
113 >        while (isspace(*s))
114 >                s++;
115 >        if (*s == '-' || *s == '+')
116 >                s++;
117 >        cp = s;
118          while (isdigit(*cp))
119                  cp++;
120          if (*cp == '.') {
# Line 91 | Line 130 | register char  *s;
130   }
131  
132  
133 + int
134   isint(s)                        /* check integer format */
135   char  *s;
136   {
# Line 101 | Line 141 | char  *s;
141   }
142  
143  
144 + int
145   isintd(s, ds)                   /* check integer format with delimiter set */
146   char  *s, *ds;
147   {
148          register char  *cp;
149  
150          cp = iskip(s);
151 <        return(cp != NULL && strchr(*cp, ds) != NULL);
151 >        return(cp != NULL && strchr(ds, *cp) != NULL);
152   }
153  
154  
155 + int
156   isflt(s)                        /* check float format */
157   char  *s;
158   {
# Line 121 | Line 163 | char  *s;
163   }
164  
165  
166 + int
167   isfltd(s, ds)                   /* check integer format with delimiter set */
168   char  *s, *ds;
169   {
170          register char  *cp;
171  
172          cp = fskip(s);
173 <        return(cp != NULL && strchr(*cp, ds) != NULL);
173 >        return(cp != NULL && strchr(ds, *cp) != NULL);
174   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines