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