Commit | Line | Data |
---|---|---|
f477b550 KM |
1 | /* string.c 4.1 82/05/07 */ |
2 | ||
3 | # | |
4 | /* | |
5 | * UNIX shell | |
6 | * | |
7 | * S. R. Bourne | |
8 | * Bell Telephone Laboratories | |
9 | * | |
10 | */ | |
11 | ||
12 | #include "defs.h" | |
13 | ||
14 | ||
15 | /* ======== general purpose string handling ======== */ | |
16 | ||
17 | ||
18 | STRING movstr(a,b) | |
19 | REG STRING a, b; | |
20 | { | |
21 | WHILE *b++ = *a++ DONE | |
22 | return(--b); | |
23 | } | |
24 | ||
25 | INT any(c,s) | |
26 | REG CHAR c; | |
27 | STRING s; | |
28 | { | |
29 | REG CHAR d; | |
30 | ||
31 | WHILE d = *s++ | |
32 | DO IF d==c | |
33 | THEN return(TRUE); | |
34 | FI | |
35 | OD | |
36 | return(FALSE); | |
37 | } | |
38 | ||
39 | INT cf(s1, s2) | |
40 | REG STRING s1, s2; | |
41 | { | |
42 | WHILE *s1++ == *s2 | |
43 | DO IF *s2++==0 | |
44 | THEN return(0); | |
45 | FI | |
46 | OD | |
47 | return(*--s1 - *s2); | |
48 | } | |
49 | ||
50 | INT length(as) | |
51 | STRING as; | |
52 | { | |
53 | REG STRING s; | |
54 | ||
55 | IF s=as THEN WHILE *s++ DONE FI | |
56 | return(s-as); | |
57 | } |