Commit | Line | Data |
---|---|---|
addfa672 GM |
1 | #include <ctype.h> |
2 | ||
3 | #include "../general/general.h" | |
d382747c GM |
4 | |
5 | #include "../ctlr/function.h" | |
6 | ||
addfa672 GM |
7 | #include "astosc.h" |
8 | #include "state.h" | |
9 | ||
d382747c GM |
10 | struct astosc astosc[256] = { |
11 | #include "astosc.out" | |
12 | }; | |
13 | ||
addfa672 GM |
14 | /* compare two strings, ignoring case */ |
15 | ||
16 | static | |
17 | ustrcmp(string1, string2) | |
18 | register char *string1; | |
19 | register char *string2; | |
20 | { | |
21 | register int c1, c2; | |
22 | ||
23 | while ((c1 = (unsigned char) *string1++) != 0) { | |
24 | if (isupper(c1)) { | |
25 | c1 = tolower(c1); | |
26 | } | |
27 | if (isupper(c2 = (unsigned char) *string2++)) { | |
28 | c2 = tolower(c2); | |
29 | } | |
30 | if (c1 < c2) { | |
31 | return(-1); | |
32 | } else if (c1 > c2) { | |
33 | return(1); | |
34 | } | |
35 | } | |
36 | if (*string2) { | |
37 | return(-1); | |
38 | } else { | |
39 | return(0); | |
40 | } | |
41 | } | |
42 | ||
d382747c GM |
43 | |
44 | /* | |
45 | * This routine takes a string and returns an integer. It may return | |
46 | * STATE_NULL if there is no other integer which corresponds to the | |
47 | * string. STATE_NULL implies an error. | |
48 | */ | |
49 | ||
50 | int | |
51 | ascii_to_index(string) | |
52 | register char *string; | |
53 | { | |
54 | register struct astosc *this; | |
55 | ||
56 | for (this = astosc; this <= &astosc[highestof(astosc)]; this++) { | |
addfa672 | 57 | if (ustrcmp(this->name, string) == 0) { |
d382747c GM |
58 | return this-astosc; |
59 | } | |
60 | } | |
61 | return STATE_NULL; | |
62 | } |