20 |
|
|
21 |
|
#include "copyright.h" |
22 |
|
|
23 |
+ |
#include <string.h> |
24 |
+ |
#include <stdlib.h> |
25 |
+ |
|
26 |
+ |
#include "rtmisc.h" |
27 |
+ |
#include "rterror.h" |
28 |
+ |
#include "rtio.h" |
29 |
+ |
|
30 |
|
#ifndef NHASH |
31 |
< |
#define NHASH 509 /* hash table size (prime!) */ |
31 |
> |
#define NHASH 2039 /* hash table size (prime!) */ |
32 |
|
#endif |
33 |
|
|
34 |
|
typedef struct s_head { |
40 |
|
|
41 |
|
#define hash(s) (shash(s)%NHASH) |
42 |
|
|
36 |
– |
extern char *savestr(), *strcpy(), *malloc(); |
37 |
– |
|
38 |
– |
#define NULL 0 |
39 |
– |
|
43 |
|
#define string(sp) ((char *)((sp)+1)) |
44 |
|
|
45 |
|
#define salloc(str) (S_HEAD *)malloc(sizeof(S_HEAD)+1+strlen(str)) |
48 |
|
|
49 |
|
|
50 |
|
char * |
51 |
< |
savestr(str) /* save a string */ |
49 |
< |
char *str; |
51 |
> |
savestr(char *str) /* save a string */ |
52 |
|
{ |
53 |
< |
register int hval; |
54 |
< |
register S_HEAD *sp; |
53 |
> |
int hval; |
54 |
> |
S_HEAD *sp; |
55 |
|
|
56 |
|
if (str == NULL) |
57 |
|
return(NULL); |
58 |
+ |
if (!*str) |
59 |
+ |
return ""; |
60 |
|
hval = hash(str); |
61 |
|
for (sp = stab[hval]; sp != NULL; sp = sp->next) |
62 |
|
if (!strcmp(str, string(sp))) { |
76 |
|
|
77 |
|
|
78 |
|
void |
79 |
< |
freestr(s) /* free a string */ |
76 |
< |
char *s; |
79 |
> |
freestr(char *s) /* free a string */ |
80 |
|
{ |
81 |
|
int hval; |
82 |
< |
register S_HEAD *spl, *sp; |
82 |
> |
S_HEAD *spl, *sp; |
83 |
|
|
84 |
< |
if (s == NULL) |
84 |
> |
if (s == NULL || !*s) |
85 |
|
return; |
86 |
|
hval = hash(s); |
87 |
|
for (spl = NULL, sp = stab[hval]; sp != NULL; spl = sp, sp = sp->next) |
99 |
|
|
100 |
|
|
101 |
|
int |
102 |
< |
shash(s) |
100 |
< |
register char *s; |
102 |
> |
shash(char *s) |
103 |
|
{ |
104 |
< |
register int h = 0; |
104 |
> |
int h = 0; |
105 |
|
|
106 |
|
while (*s) |
107 |
|
h = (h<<1 & 0x7fff) ^ (*s++ & 0xff); |