| 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 |
| 16 |
|
#define strchr index |
| 17 |
|
#endif |
| 18 |
|
|
| 17 |
– |
#define NULL 0 |
| 19 |
|
|
| 19 |
– |
extern char *strchr(); |
| 20 |
– |
|
| 21 |
– |
|
| 20 |
|
char * |
| 21 |
< |
atos(rs, nb, s) /* get next word from string */ |
| 21 |
> |
atos(rs, nb, s) /* get word from string, returning rs */ |
| 22 |
|
char *rs; |
| 23 |
|
register int nb; |
| 24 |
|
register char *s; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
char * |
| 38 |
< |
sskip(s) /* skip word in string */ |
| 38 |
> |
nextword(cp, nb, s) /* get (quoted) word, returning new s */ |
| 39 |
> |
register char *cp; |
| 40 |
> |
register int nb; |
| 41 |
|
register char *s; |
| 42 |
|
{ |
| 43 |
+ |
int quote = 0; |
| 44 |
+ |
|
| 45 |
+ |
if (s == NULL) return(NULL); |
| 46 |
|
while (isspace(*s)) |
| 47 |
|
s++; |
| 48 |
+ |
switch (*s) { |
| 49 |
+ |
case '\0': |
| 50 |
+ |
return(NULL); |
| 51 |
+ |
case '"': |
| 52 |
+ |
case '\'': |
| 53 |
+ |
quote = *s++; |
| 54 |
+ |
} |
| 55 |
+ |
while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s))) |
| 56 |
+ |
*cp++ = *s++; |
| 57 |
+ |
*cp = '\0'; |
| 58 |
+ |
if (quote && *s==quote) |
| 59 |
+ |
s++; |
| 60 |
+ |
return(s); |
| 61 |
+ |
} |
| 62 |
+ |
|
| 63 |
+ |
|
| 64 |
+ |
char * |
| 65 |
+ |
sskip(s) /* skip word in string, leaving on space */ |
| 66 |
+ |
register char *s; |
| 67 |
+ |
{ |
| 68 |
+ |
while (isspace(*s)) |
| 69 |
+ |
s++; |
| 70 |
|
while (*s && !isspace(*s)) |
| 71 |
|
s++; |
| 72 |
|
return(s); |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
char * |
| 77 |
+ |
sskip2(s, n) /* skip word(s) in string, leaving on word */ |
| 78 |
+ |
register char *s; |
| 79 |
+ |
register int n; |
| 80 |
+ |
{ |
| 81 |
+ |
while (isspace(*s)) |
| 82 |
+ |
s++; |
| 83 |
+ |
while (n-- > 0) { |
| 84 |
+ |
while (*s && !isspace(*s)) |
| 85 |
+ |
s++; |
| 86 |
+ |
while (isspace(*s)) |
| 87 |
+ |
s++; |
| 88 |
+ |
} |
| 89 |
+ |
return(s); |
| 90 |
+ |
} |
| 91 |
+ |
|
| 92 |
+ |
|
| 93 |
+ |
char * |
| 94 |
|
iskip(s) /* skip integer in string */ |
| 95 |
|
register char *s; |
| 96 |
|
{ |
| 111 |
|
fskip(s) /* skip float in string */ |
| 112 |
|
register char *s; |
| 113 |
|
{ |
| 114 |
< |
register char *cp = s; |
| 114 |
> |
register char *cp; |
| 115 |
|
|
| 116 |
< |
while (isspace(*cp)) |
| 117 |
< |
cp++; |
| 118 |
< |
if (*cp == '-' || *cp == '+') |
| 119 |
< |
cp++; |
| 120 |
< |
s = cp; |
| 116 |
> |
while (isspace(*s)) |
| 117 |
> |
s++; |
| 118 |
> |
if (*s == '-' || *s == '+') |
| 119 |
> |
s++; |
| 120 |
> |
cp = s; |
| 121 |
|
while (isdigit(*cp)) |
| 122 |
|
cp++; |
| 123 |
|
if (*cp == '.') { |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
+ |
int |
| 137 |
|
isint(s) /* check integer format */ |
| 138 |
|
char *s; |
| 139 |
|
{ |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
|
| 147 |
+ |
int |
| 148 |
|
isintd(s, ds) /* check integer format with delimiter set */ |
| 149 |
|
char *s, *ds; |
| 150 |
|
{ |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
+ |
int |
| 159 |
|
isflt(s) /* check float format */ |
| 160 |
|
char *s; |
| 161 |
|
{ |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
|
| 169 |
+ |
int |
| 170 |
|
isfltd(s, ds) /* check integer format with delimiter set */ |
| 171 |
|
char *s, *ds; |
| 172 |
|
{ |