xref: /titanic_44/usr/src/cmd/tbl/ts.c (revision 20c1c3551cb3b3117591ae38463d16aada597c48)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17  /* ts.c: minor string processing subroutines */
18 int
19 match(char *s1, char *s2)
20 {
21 	while (*s1 == *s2)
22 		if (*s1++ == '\0')
23 			return(1);
24 		else
25 			s2++;
26 	return(0);
27 }
28 
29 int
30 prefix(char *small, char *big)
31 {
32 int c;
33 while ((c= *small++) == *big++)
34 	if (c==0) return(1);
35 return(c==0);
36 }
37 
38 int
39 letter(int ch)
40 {
41 	if (ch >= 'a' && ch <= 'z')
42 		return(1);
43 	if (ch >= 'A' && ch <= 'Z')
44 		return(1);
45 	return(0);
46 }
47 
48 int
49 numb(char *str)
50 {
51 	/* convert to integer */
52 	int k;
53 	for (k=0; *str >= '0' && *str <= '9'; str++)
54 		k = k*10 + *str - '0';
55 	return(k);
56 }
57 
58 int
59 digit(int x)
60 {
61 	return(x>= '0' && x<= '9');
62 }
63 
64 int
65 max(int a, int b)
66 {
67 return( a>b ? a : b);
68 }
69 
70 void
71 tcopy(char *s, char *t)
72 {
73 	while (*s++ = *t++);
74 }
75