Blob
1 /* ts.c: minor string processing subroutines */2 #include "t.h"4 int5 match (char *s1, char *s2)6 {7 while (*s1 == *s2)8 if (*s1++ == '\0')9 return(1);10 else11 s2++;12 return(0);13 }16 int17 prefix(char *small, char *big)18 {19 int c;21 while ((c = *small++) == *big++)22 if (c == 0)23 return(1);24 return(c == 0);25 }28 int29 letter (int ch)30 {31 if (ch >= 'a' && ch <= 'z')32 return(1);33 if (ch >= 'A' && ch <= 'Z')34 return(1);35 return(0);36 }39 int40 numb(char *str)41 {42 /* convert to integer */43 int k;44 for (k = 0; *str >= '0' && *str <= '9'; str++)45 k = k * 10 + *str - '0';46 return(k);47 }50 int51 digit(int x)52 {53 return(x >= '0' && x <= '9');54 }57 int58 max(int a, int b)59 {60 return( a > b ? a : b);61 }64 void65 tcopy (char *s, char *t)66 {67 while (*s++ = *t++)68 ;69 }