xref: /onnv-gate/usr/src/cmd/tbl/ts.c (revision 381:1a7f0e46092a)
1*381Smuffin /*
2*381Smuffin  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
3*381Smuffin  * Use is subject to license terms.
4*381Smuffin  */
5*381Smuffin 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
15*381Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
170Sstevel@tonic-gate  /* ts.c: minor string processing subroutines */
18*381Smuffin int
match(char * s1,char * s2)19*381Smuffin match(char *s1, char *s2)
200Sstevel@tonic-gate {
210Sstevel@tonic-gate 	while (*s1 == *s2)
220Sstevel@tonic-gate 		if (*s1++ == '\0')
230Sstevel@tonic-gate 			return(1);
240Sstevel@tonic-gate 		else
250Sstevel@tonic-gate 			s2++;
260Sstevel@tonic-gate 	return(0);
270Sstevel@tonic-gate }
28*381Smuffin 
29*381Smuffin int
prefix(char * small,char * big)30*381Smuffin prefix(char *small, char *big)
310Sstevel@tonic-gate {
320Sstevel@tonic-gate int c;
330Sstevel@tonic-gate while ((c= *small++) == *big++)
340Sstevel@tonic-gate 	if (c==0) return(1);
350Sstevel@tonic-gate return(c==0);
360Sstevel@tonic-gate }
37*381Smuffin 
38*381Smuffin int
letter(int ch)39*381Smuffin letter(int ch)
40*381Smuffin {
410Sstevel@tonic-gate 	if (ch >= 'a' && ch <= 'z')
420Sstevel@tonic-gate 		return(1);
430Sstevel@tonic-gate 	if (ch >= 'A' && ch <= 'Z')
440Sstevel@tonic-gate 		return(1);
450Sstevel@tonic-gate 	return(0);
46*381Smuffin }
47*381Smuffin 
48*381Smuffin int
numb(char * str)49*381Smuffin numb(char *str)
50*381Smuffin {
510Sstevel@tonic-gate 	/* convert to integer */
520Sstevel@tonic-gate 	int k;
530Sstevel@tonic-gate 	for (k=0; *str >= '0' && *str <= '9'; str++)
540Sstevel@tonic-gate 		k = k*10 + *str - '0';
550Sstevel@tonic-gate 	return(k);
56*381Smuffin }
57*381Smuffin 
58*381Smuffin int
digit(int x)59*381Smuffin digit(int x)
60*381Smuffin {
610Sstevel@tonic-gate 	return(x>= '0' && x<= '9');
62*381Smuffin }
63*381Smuffin 
64*381Smuffin int
max(int a,int b)65*381Smuffin max(int a, int b)
660Sstevel@tonic-gate {
670Sstevel@tonic-gate return( a>b ? a : b);
680Sstevel@tonic-gate }
69*381Smuffin 
70*381Smuffin void
tcopy(char * s,char * t)71*381Smuffin tcopy(char *s, char *t)
720Sstevel@tonic-gate {
730Sstevel@tonic-gate 	while (*s++ = *t++);
740Sstevel@tonic-gate }
75