source: trunk/athena/bin/discuss/edsc/parse.c @ 1548

Revision 1548, 969 bytes checked in by srz, 36 years ago (diff)
Initial revision
Line 
1/*
2 *
3 * parse () -- Routines to parse words.
4 *
5 */
6
7#include <stdio.h>
8#include <ctype.h>
9
10#define EAT_SPACE(x) \
11     while (isspace(*x)) x++;
12
13int
14get_word(spp,tpp,possible_delims,delimp)
15char **spp;
16char **tpp;
17char *possible_delims;
18char *delimp;
19{
20     register char *s,*u;
21
22     s = *spp;
23     EAT_SPACE(s);
24
25     *tpp = s;
26     for (; *s; s++) {
27          for (u = possible_delims; *u; u++) {
28               if (*u == *s)
29                    goto found_delim;
30          }
31     }
32
33     /* Found null before delim.  */
34     *delimp = '\0';
35
36     /* Get rid of trailing spaces */
37     trim(*tpp);
38
39     *spp = ++s;
40     return(0);
41
42found_delim:
43     *delimp = *s;
44     *s++ = '\0';
45     trim(*tpp);
46     *spp = s;
47     return(0);
48}
49
50static
51lowercase(s)
52char *s;
53{
54     while (*s) {
55          if (isupper(*s))
56               *s = tolower(*s);
57          s++;
58     }
59     return;
60}
61
62trim(s)
63char *s;
64{
65     int j;
66     char *t;
67
68     j = strlen(s);
69     t = s + j - 1;
70     while (t >= s && isspace(*t))
71          *t-- = '\0';
72}
Note: See TracBrowser for help on using the repository browser.