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

Revision 1929, 1.2 KB checked in by srz, 35 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
20int
21get_word(spp,tpp,possible_delims,delimp)
22char **spp;
23char **tpp;
24char *possible_delims;
25char *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
49found_delim:
50     *delimp = *s;
51     *s++ = '\0';
52     trim(*tpp);
53     *spp = s;
54     return(0);
55}
56
57static
58lowercase(s)
59char *s;
60{
61     while (*s) {
62          if (isupper(*s))
63               *s = tolower(*s);
64          s++;
65     }
66     return;
67}
68
69trim(s)
70char *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.