xref: /illumos-gate/usr/src/cmd/tbl/ts.c (revision 4c3888b8f38c903370e022661d08aba393db3911)
1 /*
2  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved. The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15  /* ts.c: minor string processing subroutines */
16 int
17 match(char *s1, char *s2)
18 {
19 	while (*s1 == *s2)
20 		if (*s1++ == '\0')
21 			return(1);
22 		else
23 			s2++;
24 	return(0);
25 }
26 
27 int
28 prefix(char *small, char *big)
29 {
30 int c;
31 while ((c= *small++) == *big++)
32 	if (c==0) return(1);
33 return(c==0);
34 }
35 
36 int
37 letter(int ch)
38 {
39 	if (ch >= 'a' && ch <= 'z')
40 		return(1);
41 	if (ch >= 'A' && ch <= 'Z')
42 		return(1);
43 	return(0);
44 }
45 
46 int
47 numb(char *str)
48 {
49 	/* convert to integer */
50 	int k;
51 	for (k=0; *str >= '0' && *str <= '9'; str++)
52 		k = k*10 + *str - '0';
53 	return(k);
54 }
55 
56 int
57 digit(int x)
58 {
59 	return(x>= '0' && x<= '9');
60 }
61 
62 int
63 max(int a, int b)
64 {
65 return( a>b ? a : b);
66 }
67 
68 void
69 tcopy(char *s, char *t)
70 {
71 	while (*s++ = *t++);
72 }
73