]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/tbl/ts.c
cwfs: fix listen filedescriptor leaks
[plan9front.git] / sys / src / cmd / tbl / ts.c
1 /* ts.c: minor string processing subroutines */
2 #include "t.h"
3
4 int
5 match (char *s1, char *s2)
6 {
7         while (*s1 == *s2)
8                 if (*s1++ == '\0')
9                         return(1);
10                 else
11                         s2++;
12         return(0);
13 }
14
15
16 int
17 prefix(char *small, char *big)
18 {
19         int     c;
20
21         while ((c = *small++) == *big++)
22                 if (c == 0) 
23                         return(1);
24         return(c == 0);
25 }
26
27
28 int
29 letter (int ch)
30 {
31         if (ch >= 'a' && ch <= 'z')
32                 return(1);
33         if (ch >= 'A' && ch <= 'Z')
34                 return(1);
35         return(0);
36 }
37
38
39 int
40 numb(char *str)
41 {
42                                 /* convert to integer */
43         int     k;
44         for (k = 0; *str >= '0' && *str <= '9'; str++)
45                 k = k * 10 + *str - '0';
46         return(k);
47 }
48
49
50 int
51 digit(int x)
52 {
53         return(x >= '0' && x <= '9');
54 }
55
56
57 int
58 max(int a, int b)
59 {
60         return( a > b ? a : b);
61 }
62
63
64 void
65 tcopy (char *s, char *t)
66 {
67         while (*s++ = *t++)
68                 ;
69 }
70
71