xref: /titanic_44/usr/src/cmd/tbl/ts.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1*b5514887Smuffin /*
2*b5514887Smuffin  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
3*b5514887Smuffin  * Use is subject to license terms.
4*b5514887Smuffin  */
5*b5514887Smuffin 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
15*b5514887Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate  /* ts.c: minor string processing subroutines */
18*b5514887Smuffin int
match(char * s1,char * s2)19*b5514887Smuffin match(char *s1, char *s2)
207c478bd9Sstevel@tonic-gate {
217c478bd9Sstevel@tonic-gate 	while (*s1 == *s2)
227c478bd9Sstevel@tonic-gate 		if (*s1++ == '\0')
237c478bd9Sstevel@tonic-gate 			return(1);
247c478bd9Sstevel@tonic-gate 		else
257c478bd9Sstevel@tonic-gate 			s2++;
267c478bd9Sstevel@tonic-gate 	return(0);
277c478bd9Sstevel@tonic-gate }
28*b5514887Smuffin 
29*b5514887Smuffin int
prefix(char * small,char * big)30*b5514887Smuffin prefix(char *small, char *big)
317c478bd9Sstevel@tonic-gate {
327c478bd9Sstevel@tonic-gate int c;
337c478bd9Sstevel@tonic-gate while ((c= *small++) == *big++)
347c478bd9Sstevel@tonic-gate 	if (c==0) return(1);
357c478bd9Sstevel@tonic-gate return(c==0);
367c478bd9Sstevel@tonic-gate }
37*b5514887Smuffin 
38*b5514887Smuffin int
letter(int ch)39*b5514887Smuffin letter(int ch)
407c478bd9Sstevel@tonic-gate {
417c478bd9Sstevel@tonic-gate 	if (ch >= 'a' && ch <= 'z')
427c478bd9Sstevel@tonic-gate 		return(1);
437c478bd9Sstevel@tonic-gate 	if (ch >= 'A' && ch <= 'Z')
447c478bd9Sstevel@tonic-gate 		return(1);
457c478bd9Sstevel@tonic-gate 	return(0);
467c478bd9Sstevel@tonic-gate }
47*b5514887Smuffin 
48*b5514887Smuffin int
numb(char * str)49*b5514887Smuffin numb(char *str)
507c478bd9Sstevel@tonic-gate {
517c478bd9Sstevel@tonic-gate 	/* convert to integer */
527c478bd9Sstevel@tonic-gate 	int k;
537c478bd9Sstevel@tonic-gate 	for (k=0; *str >= '0' && *str <= '9'; str++)
547c478bd9Sstevel@tonic-gate 		k = k*10 + *str - '0';
557c478bd9Sstevel@tonic-gate 	return(k);
567c478bd9Sstevel@tonic-gate }
57*b5514887Smuffin 
58*b5514887Smuffin int
digit(int x)59*b5514887Smuffin digit(int x)
607c478bd9Sstevel@tonic-gate {
617c478bd9Sstevel@tonic-gate 	return(x>= '0' && x<= '9');
627c478bd9Sstevel@tonic-gate }
63*b5514887Smuffin 
64*b5514887Smuffin int
max(int a,int b)65*b5514887Smuffin max(int a, int b)
667c478bd9Sstevel@tonic-gate {
677c478bd9Sstevel@tonic-gate return( a>b ? a : b);
687c478bd9Sstevel@tonic-gate }
69*b5514887Smuffin 
70*b5514887Smuffin void
tcopy(char * s,char * t)71*b5514887Smuffin tcopy(char *s, char *t)
727c478bd9Sstevel@tonic-gate {
737c478bd9Sstevel@tonic-gate 	while (*s++ = *t++);
747c478bd9Sstevel@tonic-gate }
75