Revision 1929,
1.2 KB
checked in by srz, 36 years ago
(diff) |
Added standard copyright notice.
|
Line | |
---|
1 | /* |
---|
2 | * |
---|
3 | * Copyright (C) 1989 by the Massachusetts Institute of Technology |
---|
4 | * Developed by the MIT Student Information Processing Board (SIPB). |
---|
5 | * For copying information, see the file mit-copyright.h in this release. |
---|
6 | * |
---|
7 | */ |
---|
8 | /* |
---|
9 | * |
---|
10 | * parse () -- Routines to parse words. |
---|
11 | * |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <ctype.h> |
---|
16 | |
---|
17 | #define EAT_SPACE(x) \ |
---|
18 | while (isspace(*x)) x++; |
---|
19 | |
---|
20 | int |
---|
21 | get_word(spp,tpp,possible_delims,delimp) |
---|
22 | char **spp; |
---|
23 | char **tpp; |
---|
24 | char *possible_delims; |
---|
25 | char *delimp; |
---|
26 | { |
---|
27 | register char *s,*u; |
---|
28 | |
---|
29 | s = *spp; |
---|
30 | EAT_SPACE(s); |
---|
31 | |
---|
32 | *tpp = s; |
---|
33 | for (; *s; s++) { |
---|
34 | for (u = possible_delims; *u; u++) { |
---|
35 | if (*u == *s) |
---|
36 | goto found_delim; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | /* Found null before delim. */ |
---|
41 | *delimp = '\0'; |
---|
42 | |
---|
43 | /* Get rid of trailing spaces */ |
---|
44 | trim(*tpp); |
---|
45 | |
---|
46 | *spp = ++s; |
---|
47 | return(0); |
---|
48 | |
---|
49 | found_delim: |
---|
50 | *delimp = *s; |
---|
51 | *s++ = '\0'; |
---|
52 | trim(*tpp); |
---|
53 | *spp = s; |
---|
54 | return(0); |
---|
55 | } |
---|
56 | |
---|
57 | static |
---|
58 | lowercase(s) |
---|
59 | char *s; |
---|
60 | { |
---|
61 | while (*s) { |
---|
62 | if (isupper(*s)) |
---|
63 | *s = tolower(*s); |
---|
64 | s++; |
---|
65 | } |
---|
66 | return; |
---|
67 | } |
---|
68 | |
---|
69 | trim(s) |
---|
70 | char *s; |
---|
71 | { |
---|
72 | int j; |
---|
73 | char *t; |
---|
74 | |
---|
75 | j = strlen(s); |
---|
76 | t = s + j - 1; |
---|
77 | while (t >= s && isspace(*t)) |
---|
78 | *t-- = '\0'; |
---|
79 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.