xref: /illumos-gate/usr/src/cmd/tbl/ts.c (revision 2a8bcb4e)
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 
157c478bd9Sstevel@tonic-gate  /* ts.c: minor string processing subroutines */
16*b5514887Smuffin int
match(char * s1,char * s2)17*b5514887Smuffin match(char *s1, char *s2)
187c478bd9Sstevel@tonic-gate {
197c478bd9Sstevel@tonic-gate 	while (*s1 == *s2)
207c478bd9Sstevel@tonic-gate 		if (*s1++ == '\0')
217c478bd9Sstevel@tonic-gate 			return(1);
227c478bd9Sstevel@tonic-gate 		else
237c478bd9Sstevel@tonic-gate 			s2++;
247c478bd9Sstevel@tonic-gate 	return(0);
257c478bd9Sstevel@tonic-gate }
26*b5514887Smuffin 
27*b5514887Smuffin int
prefix(char * small,char * big)28*b5514887Smuffin prefix(char *small, char *big)
297c478bd9Sstevel@tonic-gate {
307c478bd9Sstevel@tonic-gate int c;
317c478bd9Sstevel@tonic-gate while ((c= *small++) == *big++)
327c478bd9Sstevel@tonic-gate 	if (c==0) return(1);
337c478bd9Sstevel@tonic-gate return(c==0);
347c478bd9Sstevel@tonic-gate }
35*b5514887Smuffin 
36*b5514887Smuffin int
letter(int ch)37*b5514887Smuffin letter(int ch)
38*b5514887Smuffin {
397c478bd9Sstevel@tonic-gate 	if (ch >= 'a' && ch <= 'z')
407c478bd9Sstevel@tonic-gate 		return(1);
417c478bd9Sstevel@tonic-gate 	if (ch >= 'A' && ch <= 'Z')
427c478bd9Sstevel@tonic-gate 		return(1);
437c478bd9Sstevel@tonic-gate 	return(0);
44*b5514887Smuffin }
45*b5514887Smuffin 
46*b5514887Smuffin int
numb(char * str)47*b5514887Smuffin numb(char *str)
48*b5514887Smuffin {
497c478bd9Sstevel@tonic-gate 	/* convert to integer */
507c478bd9Sstevel@tonic-gate 	int k;
517c478bd9Sstevel@tonic-gate 	for (k=0; *str >= '0' && *str <= '9'; str++)
527c478bd9Sstevel@tonic-gate 		k = k*10 + *str - '0';
537c478bd9Sstevel@tonic-gate 	return(k);
54*b5514887Smuffin }
55*b5514887Smuffin 
56*b5514887Smuffin int
digit(int x)57*b5514887Smuffin digit(int x)
58*b5514887Smuffin {
597c478bd9Sstevel@tonic-gate 	return(x>= '0' && x<= '9');
60*b5514887Smuffin }
61*b5514887Smuffin 
62*b5514887Smuffin int
max(int a,int b)63*b5514887Smuffin max(int a, int b)
647c478bd9Sstevel@tonic-gate {
657c478bd9Sstevel@tonic-gate return( a>b ? a : b);
667c478bd9Sstevel@tonic-gate }
67*b5514887Smuffin 
68*b5514887Smuffin void
tcopy(char * s,char * t)69*b5514887Smuffin tcopy(char *s, char *t)
707c478bd9Sstevel@tonic-gate {
717c478bd9Sstevel@tonic-gate 	while (*s++ = *t++);
727c478bd9Sstevel@tonic-gate }
73