ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/words.c
Revision: 1.1
Committed: Tue Jun 21 14:45:47 1994 UTC (29 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1994 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Routines for recognizing and moving about words in strings.
9 */
10
11 #include <ctype.h>
12
13 #ifdef BSD
14 #define strchr index
15 #endif
16
17 #define NULL 0
18
19 extern char *strchr();
20
21
22 char *
23 iskip(s) /* skip integer in string */
24 register char *s;
25 {
26 while (isspace(*s))
27 s++;
28 if (*s == '-' || *s == '+')
29 s++;
30 if (!isdigit(*s))
31 return(NULL);
32 do
33 s++;
34 while (isdigit(*s));
35 return(s);
36 }
37
38
39 char *
40 fskip(s) /* skip float in string */
41 register char *s;
42 {
43 register char *cp;
44
45 while (isspace(*s))
46 s++;
47 if (*s == '-' || *s == '+')
48 s++;
49 cp = s;
50 while (isdigit(*cp))
51 cp++;
52 if (*cp == '.') {
53 cp++; s++;
54 while (isdigit(*cp))
55 cp++;
56 }
57 if (cp == s)
58 return(NULL);
59 if (*cp == 'e' || *cp == 'E')
60 return(iskip(cp+1));
61 return(cp);
62 }
63
64
65 int
66 isint(s) /* check integer format */
67 char *s;
68 {
69 register char *cp;
70
71 cp = iskip(s);
72 return(cp != NULL && *cp == '\0');
73 }
74
75
76 int
77 isintd(s, ds) /* check integer format with delimiter set */
78 char *s, *ds;
79 {
80 register char *cp;
81
82 cp = iskip(s);
83 return(cp != NULL && strchr(ds, *cp) != NULL);
84 }
85
86
87 int
88 isflt(s) /* check float format */
89 char *s;
90 {
91 register char *cp;
92
93 cp = fskip(s);
94 return(cp != NULL && *cp == '\0');
95 }
96
97
98 int
99 isfltd(s, ds) /* check integer format with delimiter set */
100 char *s, *ds;
101 {
102 register char *cp;
103
104 cp = fskip(s);
105 return(cp != NULL && strchr(ds, *cp) != NULL);
106 }