| 23 |
|
#include <string.h> |
| 24 |
|
#include <stdlib.h> |
| 25 |
|
|
| 26 |
< |
#include "standard.h" |
| 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 { |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
char * |
| 51 |
< |
savestr(str) /* save a string */ |
| 50 |
< |
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 */ |
| 77 |
< |
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) |
| 101 |
< |
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); |