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