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