BSD 4_4 release
[unix-history] / usr / src / old / sh / string.c
CommitLineData
f6227721 1#ifndef lint
0f4556f1 2static char sccsid[] = "@(#)string.c 4.2 8/11/83";
f6227721 3#endif
f477b550
KM
4
5#
6/*
7 * UNIX shell
8 *
9 * S. R. Bourne
10 * Bell Telephone Laboratories
11 *
12 */
13
14#include "defs.h"
15
16
17/* ======== general purpose string handling ======== */
18
19
20STRING movstr(a,b)
21 REG STRING a, b;
22{
23 WHILE *b++ = *a++ DONE
24 return(--b);
25}
26
27INT any(c,s)
28 REG CHAR c;
29 STRING s;
30{
31 REG CHAR d;
32
33 WHILE d = *s++
34 DO IF d==c
35 THEN return(TRUE);
36 FI
37 OD
38 return(FALSE);
39}
40
41INT cf(s1, s2)
42 REG STRING s1, s2;
43{
44 WHILE *s1++ == *s2
45 DO IF *s2++==0
46 THEN return(0);
47 FI
48 OD
49 return(*--s1 - *s2);
50}
51
52INT length(as)
53 STRING as;
54{
55 REG STRING s;
56
57 IF s=as THEN WHILE *s++ DONE FI
58 return(s-as);
59}