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.7 by greg, Mon Mar 10 17:26:26 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  
13 #ifdef  BSD
14 #define  strchr         index
15 #endif
15  
17 #define  NULL           0
18
19 extern char  *strchr();
20
21
16   char *
17 < atos(rs, nb, s)                 /* get next word from string */
17 > atos(rs, nb, s)                 /* get word from string, returning rs */
18   char  *rs;
19   register int  nb;
20   register char  *s;
# Line 37 | Line 31 | register char  *s;
31  
32  
33   char *
34 < sskip(s)                        /* skip word in string */
34 > nextword(cp, nb, s)             /* get (quoted) word, returning new s */
35 > register char  *cp;
36 > register int  nb;
37   register char  *s;
38   {
39 +        int     quote = 0;
40 +
41 +        if (s == NULL) return(NULL);
42          while (isspace(*s))
43                  s++;
44 +        switch (*s) {
45 +        case '\0':
46 +                return(NULL);
47 +        case '"':
48 +        case '\'':
49 +                quote = *s++;
50 +        }
51 +        while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s)))
52 +                *cp++ = *s++;
53 +        *cp = '\0';
54 +        if (quote && *s==quote)
55 +                s++;
56 +        return(s);
57 + }
58 +
59 +
60 + char *
61 + sskip(s)                        /* skip word in string, leaving on space */
62 + register char  *s;
63 + {
64 +        while (isspace(*s))
65 +                s++;
66          while (*s && !isspace(*s))
67                  s++;
68          return(s);
# Line 49 | Line 70 | register char  *s;
70  
71  
72   char *
73 + sskip2(s, n)                    /* skip word(s) in string, leaving on word */
74 + register char  *s;
75 + register int    n;
76 + {
77 +        while (isspace(*s))
78 +                s++;
79 +        while (n-- > 0) {
80 +                while (*s && !isspace(*s))
81 +                        s++;
82 +                while (isspace(*s))
83 +                        s++;
84 +        }
85 +        return(s);
86 + }
87 +
88 +
89 + char *
90   iskip(s)                        /* skip integer in string */
91   register char  *s;
92   {
# Line 69 | Line 107 | char *
107   fskip(s)                        /* skip float in string */
108   register char  *s;
109   {
110 <        register char  *cp = s;
110 >        register char  *cp;
111  
112 <        while (isspace(*cp))
113 <                cp++;
114 <        if (*cp == '-' || *cp == '+')
115 <                cp++;
116 <        s = cp;
112 >        while (isspace(*s))
113 >                s++;
114 >        if (*s == '-' || *s == '+')
115 >                s++;
116 >        cp = s;
117          while (isdigit(*cp))
118                  cp++;
119          if (*cp == '.') {
# Line 91 | Line 129 | register char  *s;
129   }
130  
131  
132 + int
133   isint(s)                        /* check integer format */
134   char  *s;
135   {
# Line 101 | Line 140 | char  *s;
140   }
141  
142  
143 + int
144   isintd(s, ds)                   /* check integer format with delimiter set */
145   char  *s, *ds;
146   {
# Line 111 | Line 151 | char  *s, *ds;
151   }
152  
153  
154 + int
155   isflt(s)                        /* check float format */
156   char  *s;
157   {
# Line 121 | Line 162 | char  *s;
162   }
163  
164  
165 + int
166   isfltd(s, ds)                   /* check integer format with delimiter set */
167   char  *s, *ds;
168   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines