1 /* hash.c - hash table lookup strings -
2 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 * BUGS, GRIPES, APOLOGIA etc.
23 * A typical user doesn't need ALL this: I intend to make a library out
24 * of it one day - Dean Elsner.
25 * Also, I want to change the definition of a symbol to (address,length)
26 * so I can put arbitrary binary in the names stored. [see hsh.c for that]
28 * This slime is common coupled inside the module. Com-coupling (and other
29 * vandalism) was done to speed running time. The interfaces at the
30 * module's edges are adequately clean.
32 * There is no way to (a) run a test script through this heap and (b)
33 * compare results with previous scripts, to see if we have broken any
34 * code. Use GNU (f)utilities to do this. A few commands assist test.
35 * The testing is awkward: it tries to be both batch & interactive.
36 * For now, interactive rules!
40 * The idea is to implement a symbol table. A test jig is here.
41 * Symbols are arbitrary strings; they can't contain '\0'.
42 * [See hsh.c for a more general symbol flavour.]
43 * Each symbol is associated with a char*, which can point to anything
44 * you want, allowing an arbitrary property list for each symbol.
46 * The basic operations are:
48 * new creates symbol table, returns handle
49 * find (symbol) returns char*
50 * insert (symbol,char*) error if symbol already in table
51 * delete (symbol) returns char* if symbol was in table
52 * apply so you can delete all symbols before die()
53 * die destroy symbol table (free up memory)
55 * Supplementary functions include:
57 * say how big? what % full?
58 * replace (symbol,newval) report previous value
59 * jam (symbol,value) assert symbol:=value
61 * You, the caller, have control over errors: this just reports them.
63 * This package requires malloc(), free().
64 * Malloc(size) returns NULL or address of char[size].
65 * Free(address) frees same.
69 * The code and its structures are re-enterent.
71 * Before you do anything else, you must call hash_new() which will
72 * return the address of a hash-table-control-block. You then use
73 * this address as a handle of the symbol table by passing it to all
74 * the other hash_...() functions. The only approved way to recover
75 * the memory used by the symbol table is to call hash_die() with the
76 * handle of the symbol table.
78 * Before you call hash_die() you normally delete anything pointed to
79 * by individual symbols. After hash_die() you can't use that symbol
82 * The char* you associate with a symbol may not be NULL (0) because
83 * NULL is returned whenever a symbol is not in the table. Any other
84 * value is OK, except DELETED, #defined below.
86 * When you supply a symbol string for insertion, YOU MUST PRESERVE THE
87 * STRING until that symbol is deleted from the table. The reason is that
88 * only the address you supply, NOT the symbol string itself, is stored
89 * in the symbol table.
91 * You may delete and add symbols arbitrarily.
92 * Any or all symbols may have the same 'value' (char *). In fact, these
93 * routines don't do anything with your symbol values.
95 * You have no right to know where the symbol:char* mapping is stored,
96 * because it moves around in memory; also because we may change how it
97 * works and we don't want to break your code do we? However the handle
98 * (address of struct hash_control) is never changed in
99 * the life of the symbol table.
101 * What you CAN find out about a symbol table is:
102 * how many slots are in the hash table?
103 * how many slots are filled with symbols?
104 * (total hashes,collisions) for (reads,writes) (*)
105 * All of the above values vary in time.
106 * (*) some of these numbers will not be meaningful if we change the
112 * Hash table is an array of hash_entries; each entry is a pointer to a
113 * a string and a user-supplied value 1 char* wide.
115 * The array always has 2 ** n elements, n>0, n integer.
116 * There is also a 'wall' entry after the array, which is always empty
117 * and acts as a sentinel to stop running off the end of the array.
118 * When the array gets too full, we create a new array twice as large
119 * and re-hash the symbols into the new array, then forget the old array.
120 * (Of course, we copy the values into the new array before we junk the
129 #define TRUE (!FALSE)
130 #endif /* no FALSE yet */
133 #define min(a, b) ((a) < (b) ? (a) : (b))
137 #define error as_fatal
139 static char _deleted_
[1];
140 #define DELETED ((PTR)_deleted_) /* guarenteed unique address */
141 #define START_POWER (10) /* power of two: size of new hash table */
143 /* TRUE if a symbol is in entry @ ptr. */
144 #define islive(ptr) (ptr->hash_string && ptr->hash_string!=DELETED)
147 /* Number of slots in hash table. The wall does not count here.
148 We expect this is always a power of 2. */
150 /* Number of hash_ask calls. */
153 /* Number of collisions (total). This may exceed STAT_ACCESS if we
154 have lots of collisions/access. */
157 /* Slots used right now. */
159 /* How many string compares? */
162 /* Size of statistics block... this must be last. */
165 #define STAT__READ (0) /* reading */
166 #define STAT__WRITE (1) /* writing */
168 /* When we grow a hash table, by what power of two do we increase it? */
169 #define GROW_FACTOR 1
170 /* When should we grow it? */
171 #define FULL_VALUE(N) ((N) / 4)
173 /* #define SUSPECT to do runtime checks */
174 /* #define TEST to be a test jig for hash...() */
177 /* TEST: use smaller hash table */
179 #define START_POWER (3)
181 #define START_SIZE (8)
183 #define START_FULL (4)
186 struct hash_control
{
187 struct hash_entry
*hash_where
;/* address of hash table */
188 int hash_sizelog
; /* Log of ( hash_mask + 1 ) */
189 int hash_mask
; /* masks a hash into index into table */
190 int hash_full
; /* when hash_stat[STAT_USED] exceeds this, */
192 struct hash_entry
*hash_wall
; /* point just after last (usable) entry */
193 /* here we have some statistics */
194 int hash_stat
[STATLENGTH
]; /* lies & statistics */
197 /*------------------ plan ---------------------------------- i = internal
199 struct hash_control * c;
200 struct hash_entry * e; i
201 int b[z]; buffer for statistics
203 char * s; symbol string (address) [ key ]
204 char * v; value string (address) [datum]
205 boolean f; TRUE if we found s in hash table i
206 char * t; error string; 0 means OK
207 int a; access type [0...n) i
209 c=hash_new () create new hash_control
211 hash_die (c) destroy hash_control (and hash table)
212 table should be empty.
213 doesn't check if table is empty.
214 c has no meaning after this.
216 hash_say (c,b,z) report statistics of hash_control.
217 also report number of available statistics.
219 v=hash_delete (c,s) delete symbol, return old value if any.
220 ask() NULL means no old value.
223 v=hash_replace (c,s,v) replace old value of s with v.
224 ask() NULL means no old value: no table change.
227 t=hash_insert (c,s,v) insert (s,v) in c.
228 ask() return error string.
229 f it is an error to insert if s is already
231 if any error, c is unchanged.
233 t=hash_jam (c,s,v) assert that new value of s will be v. i
234 ask() it may decide to GROW the table. i
237 t=hash_grow (c) grow the hash table. i
238 jam() will invoke JAM. i
240 ?=hash_apply (c,y) apply y() to every symbol in c.
241 y evtries visited in 'unspecified' order.
243 v=hash_find (c,s) return value of s, or NULL if s not in c.
247 f,e=hash_ask() (c,s,a) return slot where s SHOULD live. i
248 code() maintain collision stats in c. i
250 .=hash_code (c,s) compute hash-code for s, i
251 from parameters of c. i
255 /* Returned by hash_ask() to stop extra testing. hash_ask() wants to
256 return both a slot and a status. This is the status. TRUE: found
257 symbol FALSE: absent: empty or deleted slot Also returned by
258 hash_jam(). TRUE: we replaced a value FALSE: we inserted a value. */
259 static char hash_found
;
261 static struct hash_entry
*hash_ask
PARAMS ((struct hash_control
*,
263 static int hash_code
PARAMS ((struct hash_control
*, const char *));
264 static const char *hash_grow
PARAMS ((struct hash_control
*));
266 /* Create a new hash table. Return NULL if failed; otherwise return handle
267 (address of struct hash). */
268 struct hash_control
*
271 struct hash_control
*retval
;
272 struct hash_entry
*room
; /* points to hash table */
273 struct hash_entry
*wall
;
274 struct hash_entry
*entry
;
275 int *ip
; /* scan stats block of struct hash_control */
276 int *nd
; /* limit of stats block */
278 room
= (struct hash_entry
*) xmalloc (sizeof (struct hash_entry
)
279 /* +1 for the wall entry */
280 * ((1 << START_POWER
) + 1));
281 retval
= (struct hash_control
*) xmalloc (sizeof (struct hash_control
));
283 nd
= retval
->hash_stat
+ STATLENGTH
;
284 for (ip
= retval
->hash_stat
; ip
< nd
; ip
++)
287 retval
->hash_stat
[STAT_SIZE
] = 1 << START_POWER
;
288 retval
->hash_mask
= (1 << START_POWER
) - 1;
289 retval
->hash_sizelog
= START_POWER
;
290 /* works for 1's compl ok */
291 retval
->hash_where
= room
;
293 wall
= room
+ (1 << START_POWER
);
294 retval
->hash_full
= FULL_VALUE (1 << START_POWER
);
295 for (entry
= room
; entry
<= wall
; entry
++)
296 entry
->hash_string
= NULL
;
301 * h a s h _ d i e ( )
303 * Table should be empty, but this is not checked.
304 * To empty the table, try hash_apply()ing a symbol deleter.
305 * Return to free memory both the hash table and it's control
307 * 'handle' has no meaning after this function.
308 * No errors are recoverable.
312 struct hash_control
*handle
;
314 free ((char *) handle
->hash_where
);
315 free ((char *) handle
);
320 * h a s h _ s a y ( )
322 * Return the size of the statistics table, and as many statistics as
323 * we can until either (a) we have run out of statistics or (b) caller
324 * has run out of buffer.
325 * NOTE: hash_say treats all statistics alike.
326 * These numbers may change with time, due to insertions, deletions
327 * and expansions of the table.
328 * The first "statistic" returned is the length of hash_stat[].
329 * Then contents of hash_stat[] are read out (in ascending order)
330 * until your buffer or hash_stat[] is exausted.
333 hash_say (handle
, buffer
, bufsiz
)
334 struct hash_control
*handle
;
335 int buffer
[ /*bufsiz*/ ];
338 int *nd
; /* limit of statistics block */
339 int *ip
; /* scan statistics */
341 ip
= handle
->hash_stat
;
342 nd
= ip
+ min (bufsiz
- 1, STATLENGTH
);
343 if (bufsiz
> 0) /* trust nothing! bufsiz<=0 is dangerous */
345 *buffer
++ = STATLENGTH
;
346 for (; ip
< nd
; ip
++, buffer
++)
355 * h a s h _ d e l e t e ( )
357 * Try to delete a symbol from the table.
358 * If it was there, return its value (and adjust STAT_USED).
359 * Otherwise, return NULL.
360 * Anyway, the symbol is not present after this function.
363 PTR
/* NULL if string not in table, else */
364 /* returns value of deleted symbol */
365 hash_delete (handle
, string
)
366 struct hash_control
*handle
;
370 struct hash_entry
*entry
;
372 entry
= hash_ask (handle
, string
, STAT__WRITE
);
375 retval
= entry
->hash_value
;
376 entry
->hash_string
= DELETED
;
377 handle
->hash_stat
[STAT_USED
] -= 1;
379 if (handle
->hash_stat
[STAT_USED
] < 0)
381 error ("hash_delete");
383 #endif /* def SUSPECT */
393 * h a s h _ r e p l a c e ( )
395 * Try to replace the old value of a symbol with a new value.
396 * Normally return the old value.
397 * Return NULL and don't change the table if the symbol is not already
401 hash_replace (handle
, string
, value
)
402 struct hash_control
*handle
;
406 struct hash_entry
*entry
;
409 entry
= hash_ask (handle
, string
, STAT__WRITE
);
412 retval
= entry
->hash_value
;
413 entry
->hash_value
= value
;
424 * h a s h _ i n s e r t ( )
426 * Insert a (symbol-string, value) into the hash table.
427 * Return an error string, 0 means OK.
428 * It is an 'error' to insert an existing symbol.
431 const char * /* return error string */
432 hash_insert (handle
, string
, value
)
433 struct hash_control
*handle
;
437 struct hash_entry
*entry
;
441 if (handle
->hash_stat
[STAT_USED
] > handle
->hash_full
)
443 retval
= hash_grow (handle
);
447 entry
= hash_ask (handle
, string
, STAT__WRITE
);
454 entry
->hash_value
= value
;
455 entry
->hash_string
= string
;
456 handle
->hash_stat
[STAT_USED
] += 1;
463 * h a s h _ j a m ( )
465 * Regardless of what was in the symbol table before, after hash_jam()
466 * the named symbol has the given value. The symbol is either inserted or
467 * (its value is) replaced.
468 * An error message string is returned, 0 means OK.
470 * WARNING: this may decide to grow the hashed symbol table.
471 * To do this, we call hash_grow(), WHICH WILL recursively CALL US.
473 * We report status internally: hash_found is TRUE if we replaced, but
474 * false if we inserted.
477 hash_jam (handle
, string
, value
)
478 struct hash_control
*handle
;
483 struct hash_entry
*entry
;
486 if (handle
->hash_stat
[STAT_USED
] > handle
->hash_full
)
488 retval
= hash_grow (handle
);
492 entry
= hash_ask (handle
, string
, STAT__WRITE
);
495 entry
->hash_string
= string
;
496 handle
->hash_stat
[STAT_USED
] += 1;
498 entry
->hash_value
= value
;
504 * h a s h _ g r o w ( )
506 * Grow a new (bigger) hash table from the old one.
507 * We choose to double the hash table's size.
508 * Return a human-scrutible error string: 0 if OK.
509 * Warning! This uses hash_jam(), which had better not recurse
510 * back here! Hash_jam() conditionally calls us, but we ALWAYS
515 hash_grow (handle
) /* make a hash table grow */
516 struct hash_control
*handle
;
518 struct hash_entry
*newwall
;
519 struct hash_entry
*newwhere
;
520 struct hash_entry
*newtrack
;
521 struct hash_entry
*oldtrack
;
522 struct hash_entry
*oldwhere
;
523 struct hash_entry
*oldwall
;
533 * capture info about old hash table
535 oldwhere
= handle
->hash_where
;
536 oldwall
= handle
->hash_wall
;
538 oldused
= handle
->hash_stat
[STAT_USED
];
541 * attempt to get enough room for a hash table twice as big
543 temp
= handle
->hash_stat
[STAT_SIZE
];
544 newwhere
= ((struct hash_entry
*)
545 xmalloc ((unsigned long) ((temp
<< GROW_FACTOR
+ 1)
546 /* +1 for wall slot */
547 * sizeof (struct hash_entry
))));
548 if (newwhere
== NULL
)
552 * have enough room: now we do all the work.
553 * double the size of everything in handle.
555 handle
->hash_mask
= ((handle
->hash_mask
+ 1) << GROW_FACTOR
) - 1;
556 handle
->hash_stat
[STAT_SIZE
] <<= GROW_FACTOR
;
557 newsize
= handle
->hash_stat
[STAT_SIZE
];
558 handle
->hash_where
= newwhere
;
559 handle
->hash_full
<<= GROW_FACTOR
;
560 handle
->hash_sizelog
+= GROW_FACTOR
;
561 handle
->hash_wall
= newwall
= newwhere
+ newsize
;
562 /* Set all those pesky new slots to vacant. */
563 for (newtrack
= newwhere
; newtrack
<= newwall
; newtrack
++)
564 newtrack
->hash_string
= NULL
;
565 /* We will do a scan of the old table, the hard way, using the
566 * new control block to re-insert the data into new hash table. */
567 handle
->hash_stat
[STAT_USED
] = 0;
568 for (oldtrack
= oldwhere
; oldtrack
< oldwall
; oldtrack
++)
569 if (((string
= oldtrack
->hash_string
) != NULL
) && string
!= DELETED
)
570 if ((retval
= hash_jam (handle
, string
, oldtrack
->hash_value
)))
574 if (handle
->hash_stat
[STAT_USED
] != oldused
)
578 /* We have a completely faked up control block.
579 Return the old hash table. */
580 free ((char *) oldwhere
);
587 * h a s h _ a p p l y ( )
589 * Use this to scan each entry in symbol table.
590 * For each symbol, this calls (applys) a nominated function supplying the
591 * symbol's value (and the symbol's name).
592 * The idea is you use this to destroy whatever is associted with
593 * any values in the table BEFORE you destroy the table with hash_die.
594 * Of course, you can use it for other jobs; whenever you need to
595 * visit all extant symbols in the table.
597 * We choose to have a call-you-back idea for two reasons:
598 * asthetic: it is a neater idea to use apply than an explicit loop
599 * sensible: if we ever had to grow the symbol table (due to insertions)
600 * then we would lose our place in the table when we re-hashed
601 * symbols into the new table in a different order.
603 * The order symbols are visited depends entirely on the hashing function.
604 * Whenever you insert a (symbol, value) you risk expanding the table. If
605 * you do expand the table, then the hashing function WILL change, so you
606 * MIGHT get a different order of symbols visited. In other words, if you
607 * want the same order of visiting symbols as the last time you used
608 * hash_apply() then you better not have done any hash_insert()s or
609 * hash_jam()s since the last time you used hash_apply().
611 * In future we may use the value returned by your nominated function.
612 * One idea is to abort the scan if, after applying the function to a
613 * certain node, the function returns a certain code.
615 * The function you supply should be of the form:
616 * void myfunct(string,value)
617 * char * string; |* the symbol's name *|
618 * char * value; |* the symbol's value *|
625 hash_apply (handle
, function
)
626 struct hash_control
*handle
;
629 struct hash_entry
*entry
;
630 struct hash_entry
*wall
;
632 wall
= handle
->hash_wall
;
633 for (entry
= handle
->hash_where
; entry
< wall
; entry
++)
635 if (islive (entry
)) /* silly code: tests entry->string twice! */
637 (*function
) (entry
->hash_string
, entry
->hash_value
);
644 * h a s h _ f i n d ( )
646 * Given symbol string, find value (if any).
647 * Return found value or NULL.
650 hash_find (handle
, string
)
651 struct hash_control
*handle
;
654 struct hash_entry
*entry
;
656 entry
= hash_ask (handle
, string
, STAT__READ
);
658 return entry
->hash_value
;
664 * h a s h _ a s k ( )
666 * Searches for given symbol string.
667 * Return the slot where it OUGHT to live. It may be there.
668 * Return hash_found: TRUE only if symbol is in that slot.
669 * Access argument is to help keep statistics in control block.
672 static struct hash_entry
* /* string slot, may be empty or deleted */
673 hash_ask (handle
, string
, access_type
)
674 struct hash_control
*handle
;
679 struct hash_entry
*slot
;
680 int collision
; /* count collisions */
684 /* start looking here */
685 hcode
= hash_code (handle
, string
);
686 slot
= handle
->hash_where
+ (hcode
& handle
->hash_mask
);
688 handle
->hash_stat
[STAT_ACCESS
+ access_type
] += 1;
689 collision
= strcmps
= 0;
691 while (((s
= slot
->hash_string
) != NULL
) && s
!= DELETED
)
698 if (slot
->h
== hcode
)
700 if (!strcmp (string
, s
))
712 * in use: we found string slot
714 * at wall: we fell off: wrap round ????
715 * in table: dig here slot
716 * at DELETED: dig here slot
718 if (slot
== handle
->hash_wall
)
720 slot
= handle
->hash_where
;/* now look again */
721 while (((s
= slot
->hash_string
) != NULL
) && s
!= DELETED
)
728 if (slot
->h
== hcode
)
730 if (!strcmp (string
, s
))
742 * in use: we found it slot
743 * empty: wall: ERROR IMPOSSIBLE !!!!
744 * in table: dig here slot
745 * DELETED:dig here slot
748 handle
->hash_stat
[STAT_COLLIDE
+ access_type
] += collision
;
749 handle
->hash_stat
[STAT_STRCMP
+ access_type
] += strcmps
;
752 return slot
; /* also return hash_found */
758 * Does hashing of symbol string to hash number.
762 hash_code (handle
, string
)
763 struct hash_control
*handle
;
766 #if 1 /* There seems to be some interesting property of this function
767 that prevents the bfd version below from being an adequate
768 substitute. @@ Figure out what this property is! */
769 long h
; /* hash code built here */
770 long c
; /* each character lands here */
771 int n
; /* Amount to shift h by */
773 n
= (handle
->hash_sizelog
- 3);
775 while ((c
= *string
++) != 0)
778 h
= (h
<< 3) + (h
>> n
) + c
;
784 unsigned int len
= 0;
787 while ((c
= *string
++) != 0)
793 h
+= len
+ (len
<< 17);
800 hash_print_statistics (file
, name
, h
)
803 struct hash_control
*h
;
805 unsigned long sz
, used
, pct
;
810 sz
= h
->hash_stat
[STAT_SIZE
];
811 used
= h
->hash_stat
[STAT_USED
];
812 pct
= (used
* 100 + sz
/ 2) / sz
;
814 fprintf (file
, "%s hash statistics:\n\t%d/%d slots used (%d%%)\n",
815 name
, used
, sz
, pct
);
817 #define P(name, off) \
818 fprintf (file, "\t%-16s %6dr + %6dw = %7d\n", name, \
819 h->hash_stat[off+STAT__READ], \
820 h->hash_stat[off+STAT__WRITE], \
821 h->hash_stat[off+STAT__READ] + h->hash_stat[off+STAT__WRITE])
823 P ("accesses:", STAT_ACCESS
);
824 P ("collisions:", STAT_COLLIDE
);
825 P ("string compares:", STAT_STRCMP
);
831 * Here is a test program to exercise above.
835 #define TABLES (6) /* number of hash tables to maintain */
836 /* (at once) in any testing */
837 #define STATBUFSIZE (12) /* we can have 12 statistics */
839 int statbuf
[STATBUFSIZE
]; /* display statistics here */
840 char answer
[100]; /* human farts here */
841 char *hashtable
[TABLES
]; /* we test many hash tables at once */
842 char *h
; /* points to curent hash_control */
850 int number
; /* number 0:TABLES-1 of current hashed */
862 printf ("type h <RETURN> for help\n");
865 printf ("hash_test command: ");
868 if (isupper (command
))
869 command
= tolower (command
); /* ecch! */
873 printf ("old hash table #=%d.\n", number
);
877 for (pp
= hashtable
; pp
< hashtable
+ TABLES
; pp
++)
879 printf ("address of hash table #%d control block is %xx\n"
880 ,pp
- hashtable
, *pp
);
884 hash_apply (h
, applicatee
);
887 hash_apply (h
, destroy
);
891 p
= hash_find (h
, name
= what ("symbol"));
892 printf ("value of \"%s\" is \"%s\"\n", name
, p
? p
: "NOT-PRESENT");
895 printf ("# show old, select new default hash table number\n");
896 printf ("? display all hashtable control block addresses\n");
897 printf ("a apply a simple display-er to each symbol in table\n");
898 printf ("d die: destroy hashtable\n");
899 printf ("f find value of nominated symbol\n");
900 printf ("h this help\n");
901 printf ("i insert value into symbol\n");
902 printf ("j jam value into symbol\n");
903 printf ("n new hashtable\n");
904 printf ("r replace a value with another\n");
905 printf ("s say what %% of table is used\n");
906 printf ("q exit this program\n");
907 printf ("x delete a symbol from table, report its value\n");
910 p
= hash_insert (h
, name
= what ("symbol"), value
= what ("value"));
913 printf ("symbol=\"%s\" value=\"%s\" error=%s\n", name
, value
,
918 p
= hash_jam (h
, name
= what ("symbol"), value
= what ("value"));
921 printf ("symbol=\"%s\" value=\"%s\" error=%s\n", name
, value
, p
);
925 h
= hashtable
[number
] = (char *) hash_new ();
930 p
= hash_replace (h
, name
= what ("symbol"), value
= what ("value"));
931 printf ("old value was \"%s\"\n", p
? p
: "{}");
934 hash_say (h
, statbuf
, STATBUFSIZE
);
935 for (ip
= statbuf
; ip
< statbuf
+ STATBUFSIZE
; ip
++)
942 p
= hash_delete (h
, name
= what ("symbol"));
943 printf ("old value was \"%s\"\n", p
? p
: "{}");
946 printf ("I can't understand command \"%c\"\n", command
);
959 printf (" %s : ", description
);
961 /* will one day clean up answer here */
962 retval
= malloc (strlen (answer
) + 1);
967 (void) strcpy (retval
, answer
);
972 destroy (string
, value
)
982 applicatee (string
, value
)
986 printf ("%.20s-%.20s\n", string
, value
);
989 whattable () /* determine number: what hash table to use */
990 /* also determine h: points to hash_control */
995 printf (" what hash table (%d:%d) ? ", 0, TABLES
- 1);
997 sscanf (answer
, "%d", &number
);
998 if (number
>= 0 && number
< TABLES
)
1000 h
= hashtable
[number
];
1003 printf ("warning: current hash-table-#%d. has no hash-control\n", number
);
1009 printf ("invalid hash table number: %d\n", number
);
1016 #endif /* #ifdef TEST */