1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2 /* All Rights Reserved */ 3 4 5 /* 6 * Copyright (c) 1980 Regents of the University of California. 7 * All rights reserved. The Berkeley software License Agreement 8 * specifies the terms and conditions for redistribution. 9 */ 10 11 /* 12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13 * All Rights Reserved. 14 */ 15 16 #pragma ident "%Z%%M% %I% %E% SMI" 17 18 19 #include <stdio.h> 20 #include <locale.h> 21 22 hash (s) 23 char *s; 24 { 25 int c, n; 26 for(n=0; c= *s; s++) 27 n += (c*n+ c << (n%4)); 28 return(n>0 ? n : -n); 29 } 30 31 err (s, a) 32 char *s; 33 { 34 fprintf(stderr, gettext("Error: ")); 35 fprintf(stderr, s, a); 36 putc('\n', stderr); 37 exit(1); 38 } 39 40 prefix(t, s) 41 char *t, *s; 42 { 43 int c; 44 45 while ((c= *t++) == *s++) 46 if (c==0) return(1); 47 return(c==0 ? 1: 0); 48 } 49 50 char * 51 mindex(s, c) 52 char *s; 53 { 54 register char *p; 55 for( p=s; *p; p++) 56 if (*p ==c) 57 return(p); 58 return(0); 59 } 60 61 zalloc(m,n) 62 { 63 char *calloc(); 64 int t; 65 # if D1 66 fprintf(stderr, "calling calloc for %d*%d bytes\n",m,n); 67 # endif 68 t = (int) calloc(m,n); 69 # if D1 70 fprintf(stderr, "calloc returned %o\n", t); 71 # endif 72 return(t); 73 } 74