1 |
/* Copyright (c) 1991 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 |
sskip(s) /* skip word in string */ |
24 |
register char *s; |
25 |
{ |
26 |
while (isspace(*s)) |
27 |
s++; |
28 |
while (*s && !isspace(*s)) |
29 |
s++; |
30 |
return(s); |
31 |
} |
32 |
|
33 |
|
34 |
char * |
35 |
iskip(s) /* skip integer in string */ |
36 |
char *s; |
37 |
{ |
38 |
register char *cp = s; |
39 |
|
40 |
while (isspace(*cp)) |
41 |
cp++; |
42 |
if (*cp == '-' || *cp == '+') |
43 |
cp++; |
44 |
while (isdigit(*cp)) |
45 |
cp++; |
46 |
return(cp); |
47 |
} |
48 |
|
49 |
|
50 |
char * |
51 |
fskip(s) /* skip float in string */ |
52 |
char *s; |
53 |
{ |
54 |
register char *cp = s; |
55 |
|
56 |
while (isspace(*cp)) |
57 |
cp++; |
58 |
if (*cp == '-' || *cp == '+') |
59 |
cp++; |
60 |
while (isdigit(*cp)) |
61 |
cp++; |
62 |
if (*cp == '.') { |
63 |
cp++; |
64 |
while (isdigit(*cp)) |
65 |
cp++; |
66 |
} |
67 |
if (*cp == 'e' || *cp == 'E') |
68 |
return(iskip(cp+1)); |
69 |
return(cp); |
70 |
} |
71 |
|
72 |
|
73 |
isint(s) /* check integer format */ |
74 |
char *s; |
75 |
{ |
76 |
register char *cp; |
77 |
|
78 |
cp = iskip(s); |
79 |
return(cp > s && *cp == '\0'); |
80 |
} |
81 |
|
82 |
|
83 |
isintd(s, ds) /* check integer format with delimiter set */ |
84 |
char *s, *ds; |
85 |
{ |
86 |
register char *cp; |
87 |
|
88 |
cp = iskip(s); |
89 |
return(cp > s && strchr(*cp, ds) != NULL); |
90 |
} |
91 |
|
92 |
|
93 |
isflt(s) /* check float format */ |
94 |
char *s; |
95 |
{ |
96 |
register char *cp; |
97 |
|
98 |
cp = fskip(s); |
99 |
return(cp > s && *cp == '\0'); |
100 |
} |
101 |
|
102 |
|
103 |
isfltd(s, ds) /* check integer format with delimiter set */ |
104 |
char *s, *ds; |
105 |
{ |
106 |
register char *cp; |
107 |
|
108 |
cp = fskip(s); |
109 |
return(cp > s && strchr(*cp, ds) != NULL); |
110 |
} |