Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / RCS / brkstring.c,v
1 head     1.4;
2 branch   ;
3 access   ;
4 symbols  ;
5 locks    ; strict;
6 comment  @ * @;
7
8
9 1.4
10 date     90.04.05.15.31.43;  author sources;  state Exp;
11 branches ;
12 next     1.3;
13
14 1.3
15 date     90.04.05.14.48.52;  author sources;  state Exp;
16 branches ;
17 next     1.2;
18
19 1.2
20 date     90.02.06.12.59.16;  author sources;  state Exp;
21 branches ;
22 next     1.1;
23
24 1.1
25 date     90.02.06.12.58.59;  author sources;  state Exp;
26 branches ;
27 next     ;
28
29
30 desc
31 @@
32
33
34 1.4
35 log
36 @add ID
37 @
38 text
39 @/* brkstring.c - break string into an array of strings */
40 #ifndef lint
41 static char ident[] = "@@(#)$Id:$";
42 #endif  lint
43
44 #include "../h/mh.h"
45
46
47 static char *broken[MAXARGS+1]; /* array of substring start addresses */
48 static brkany();
49
50 char  **brkstring (strg, brksep, brkterm)
51 register char  *strg;
52 register char  *brksep,
53                *brkterm;
54 {
55     register int    bi;
56     register char   c,
57                    *sp;
58
59     sp = strg;                  /* scan string, replacing separators with
60                                    zeroes */
61
62     for (bi = 0; bi < MAXARGS; bi++) {
63                                 /* and entering start addrs in "broken" */
64         while (brkany (c = *sp, brksep))
65             *sp++ = 0;
66         if (!c || brkany (c, brkterm)) {
67             *sp = 0;
68             broken[bi] = 0;
69             return broken;      /* terminator found, finish up */
70         }
71
72         broken[bi] = sp;        /* set next start addr */
73         while ((c = *++sp) && !brkany (c, brksep) && !brkany (c, brkterm))
74                 continue;
75     }
76     broken[MAXARGS] = 0;        /* reached limit of MAXARGS substrings */
77
78     return broken;
79 }
80
81
82 static  brkany (chr, strg)      /* returns 1 if chr in strg, 0 otherwise  */
83 register char   chr,
84                *strg;
85 {
86     register char  *sp;
87
88     if (strg)
89         for (sp = strg; *sp; sp++)
90             if (chr == *sp)
91                 return 1;
92     return 0;
93 }
94 @
95
96
97 1.3
98 log
99 @add ID
100 @
101 text
102 @d3 1
103 a3 1
104 static char ident[] = "$Id:";
105 @
106
107
108 1.2
109 log
110 @ANSI Compilance
111 @
112 text
113 @d2 3
114 @
115
116
117 1.1
118 log
119 @Initial revision
120 @
121 text
122 @d7 1
123 @