1 diff -Nur recode-3.6.orig/src/combine.c recode-3.6/src/combine.c
2 --- recode-3.6.orig/src/combine.c Sat Jul 1 21:08:35 2000
3 +++ recode-3.6/src/combine.c Sun Oct 27 12:01:29 2002
5 if (before_options || after_options)
8 - table = hash_initialize (0, NULL, combined_hash, combined_compare, NULL);
9 + table = _recode_hash_initialize (0, NULL, combined_hash, combined_compare, NULL);
17 - if (!hash_insert (table, data))
18 + if (!_recode_hash_insert (table, data))
23 while (value = get_byte (subtask), value != EOF)
25 unsigned short lookup = value;
26 - unsigned short *result = hash_lookup (table, &lookup);
27 + unsigned short *result = _recode_hash_lookup (table, &lookup);
32 while (get_ucs2 (&value, subtask))
34 unsigned short lookup = value;
35 - unsigned short *result = hash_lookup (table, &lookup);
36 + unsigned short *result = _recode_hash_lookup (table, &lookup);
43 unsigned short lookup = value;
44 - unsigned short *result = hash_lookup (table, &lookup);
45 + unsigned short *result = _recode_hash_lookup (table, &lookup);
52 unsigned short lookup = value;
53 - unsigned short *result = hash_lookup (table, &lookup);
54 + unsigned short *result = _recode_hash_lookup (table, &lookup);
61 lookup.character = character;
62 - state = hash_lookup (table, &lookup);
63 + state = _recode_hash_lookup (table, &lookup);
66 if (state= (struct state *) malloc (sizeof (struct state)), !state)
68 state->unshift = NULL;
71 - if (!hash_insert (table, state))
72 + if (!_recode_hash_insert (table, state))
79 lookup.character = character;
80 - return hash_lookup (table, &lookup);
81 + return _recode_hash_lookup (table, &lookup);
86 if (before_options || after_options)
89 - table = hash_initialize (0, NULL, state_hash, state_compare, state_free);
90 + table = _recode_hash_initialize (0, NULL, state_hash, state_compare, state_free);
94 diff -Nur recode-3.6.orig/src/hash.c recode-3.6/src/hash.c
95 --- recode-3.6.orig/src/hash.c Mon Jan 22 17:55:31 2001
96 +++ recode-3.6/src/hash.c Sun Oct 27 12:01:29 2002
101 -hash_get_n_buckets (const Hash_table *table)
102 +_recode_hash_get_n_buckets (const Hash_table *table)
104 return table->n_buckets;
107 /* Return the number of slots in use (non-empty buckets). */
110 -hash_get_n_buckets_used (const Hash_table *table)
111 +_recode_hash_get_n_buckets_used (const Hash_table *table)
113 return table->n_buckets_used;
116 /* Return the number of active entries. */
119 -hash_get_n_entries (const Hash_table *table)
120 +_recode_hash_get_n_entries (const Hash_table *table)
122 return table->n_entries;
125 /* Return the length of the longest chain (bucket). */
128 -hash_get_max_bucket_length (const Hash_table *table)
129 +_recode_hash_get_max_bucket_length (const Hash_table *table)
131 struct hash_entry *bucket;
132 unsigned max_bucket_length = 0;
137 -hash_table_ok (const Hash_table *table)
138 +_recode_hash_table_ok (const Hash_table *table)
140 struct hash_entry *bucket;
141 unsigned n_buckets_used = 0;
142 @@ -196,12 +196,12 @@
146 -hash_print_statistics (const Hash_table *table, FILE *stream)
147 +_recode_hash_print_statistics (const Hash_table *table, FILE *stream)
149 - unsigned n_entries = hash_get_n_entries (table);
150 - unsigned n_buckets = hash_get_n_buckets (table);
151 - unsigned n_buckets_used = hash_get_n_buckets_used (table);
152 - unsigned max_bucket_length = hash_get_max_bucket_length (table);
153 + unsigned n_entries = _recode_hash_get_n_entries (table);
154 + unsigned n_buckets = _recode_hash_get_n_buckets (table);
155 + unsigned n_buckets_used = _recode_hash_get_n_buckets_used (table);
156 + unsigned max_bucket_length = _recode_hash_get_max_bucket_length (table);
158 fprintf (stream, "# entries: %u\n", n_entries);
159 fprintf (stream, "# buckets: %u\n", n_buckets);
161 entry from the table. Otherwise, return NULL. */
164 -hash_lookup (const Hash_table *table, const void *entry)
165 +_recode_hash_lookup (const Hash_table *table, const void *entry)
167 struct hash_entry *bucket
168 = table->bucket + table->hasher (entry, table->n_buckets);
170 /* Return the first data in the table, or NULL if the table is empty. */
173 -hash_get_first (const Hash_table *table)
174 +_recode_hash_get_first (const Hash_table *table)
176 struct hash_entry *bucket;
179 Return NULL if there is no more entries. */
182 -hash_get_next (const Hash_table *table, const void *entry)
183 +_recode_hash_get_next (const Hash_table *table, const void *entry)
185 struct hash_entry *bucket
186 = table->bucket + table->hasher (entry, table->n_buckets);
191 -hash_get_entries (const Hash_table *table, void **buffer,
192 +_recode_hash_get_entries (const Hash_table *table, void **buffer,
193 unsigned buffer_size)
195 unsigned counter = 0;
197 returns nonzero. When it returns zero, the walking is interrupted. */
200 -hash_do_for_each (const Hash_table *table, Hash_processor processor,
201 +_recode_hash_do_for_each (const Hash_table *table, Hash_processor processor,
202 void *processor_data)
204 unsigned counter = 0;
206 may not be good for your application." */
209 -hash_string (const char *string, unsigned n_buckets)
210 +_recode_hash_string (const char *string, unsigned n_buckets)
215 (By the way, what happened to this excellent man? Is he still alive?) */
218 -hash_string (const char *string, unsigned n_buckets)
219 +_recode_hash_string (const char *string, unsigned n_buckets)
227 -hash_reset_tuning (Hash_tuning *tuning)
228 +_recode_hash_reset_tuning (Hash_tuning *tuning)
230 *tuning = default_tuning;
236 -hash_initialize (unsigned candidate, const Hash_tuning *tuning,
237 +_recode_hash_initialize (unsigned candidate, const Hash_tuning *tuning,
238 Hash_hasher hasher, Hash_comparator comparator,
239 Hash_data_freer data_freer)
245 -hash_clear (Hash_table *table)
246 +_recode_hash_clear (Hash_table *table)
248 struct hash_entry *bucket;
249 struct hash_entry *cursor;
254 -hash_free (Hash_table *table)
255 +_recode_hash_free (Hash_table *table)
257 struct hash_entry *bucket;
258 struct hash_entry *cursor;
259 @@ -773,14 +773,14 @@
260 exact number of buckets desired. */
263 -hash_rehash (Hash_table *table, unsigned candidate)
264 +_recode_hash_rehash (Hash_table *table, unsigned candidate)
266 Hash_table *new_table;
267 struct hash_entry *bucket;
268 struct hash_entry *cursor;
269 struct hash_entry *next;
271 - new_table = hash_initialize (candidate, table->tuning, table->hasher,
272 + new_table = _recode_hash_initialize (candidate, table->tuning, table->hasher,
273 table->comparator, table->data_freer);
274 if (new_table == NULL)
277 Return NULL if the storage required for insertion cannot be allocated. */
280 -hash_insert (Hash_table *table, const void *entry)
281 +_recode_hash_insert (Hash_table *table, const void *entry)
284 struct hash_entry *bucket;
286 * tuning->growth_threshold));
288 /* If the rehash fails, arrange to return NULL. */
289 - if (!hash_rehash (table, candidate))
290 + if (!_recode_hash_rehash (table, candidate))
295 table, don't modify the table and return NULL. */
298 -hash_delete (Hash_table *table, const void *entry)
299 +_recode_hash_delete (Hash_table *table, const void *entry)
302 struct hash_entry *bucket;
304 : (table->n_buckets * tuning->shrink_factor
305 * tuning->growth_threshold));
307 - hash_rehash (table, candidate);
308 + _recode_hash_rehash (table, candidate);
316 -hash_print (const Hash_table *table)
317 +_recode_hash_print (const Hash_table *table)
319 struct hash_entry *bucket;
321 diff -Nur recode-3.6.orig/src/hash.h recode-3.6/src/hash.h
322 --- recode-3.6.orig/src/hash.h Thu Aug 3 03:21:15 2000
323 +++ recode-3.6/src/hash.h Sun Oct 27 12:01:29 2002
325 typedef struct hash_table Hash_table;
327 /* Information and lookup. */
328 -unsigned hash_get_n_buckets PARAMS ((const Hash_table *));
329 -unsigned hash_get_n_buckets_used PARAMS ((const Hash_table *));
330 -unsigned hash_get_n_entries PARAMS ((const Hash_table *));
331 -unsigned hash_get_max_bucket_length PARAMS ((const Hash_table *));
332 -bool hash_table_ok PARAMS ((const Hash_table *));
333 -void hash_print_statistics PARAMS ((const Hash_table *, FILE *));
334 -void *hash_lookup PARAMS ((const Hash_table *, const void *));
335 +unsigned _recode_hash_get_n_buckets PARAMS ((const Hash_table *));
336 +unsigned _recode_hash_get_n_buckets_used PARAMS ((const Hash_table *));
337 +unsigned _recode_hash_get_n_entries PARAMS ((const Hash_table *));
338 +unsigned _recode_hash_get_max_bucket_length PARAMS ((const Hash_table *));
339 +bool _recode_hash_table_ok PARAMS ((const Hash_table *));
340 +void _recode_hash_print_statistics PARAMS ((const Hash_table *, FILE *));
341 +void *_recode_hash_lookup PARAMS ((const Hash_table *, const void *));
344 -void *hash_get_first PARAMS ((const Hash_table *));
345 -void *hash_get_next PARAMS ((const Hash_table *, const void *));
346 -unsigned hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
347 -unsigned hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
348 +void *_recode_hash_get_first PARAMS ((const Hash_table *));
349 +void *_recode_hash_get_next PARAMS ((const Hash_table *, const void *));
350 +unsigned _recode_hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
351 +unsigned _recode_hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
353 /* Allocation and clean-up. */
354 -unsigned hash_string PARAMS ((const char *, unsigned));
355 -void hash_reset_tuning PARAMS ((Hash_tuning *));
356 -Hash_table *hash_initialize PARAMS ((unsigned, const Hash_tuning *,
357 +unsigned _recode_hash_string PARAMS ((const char *, unsigned));
358 +void _recode_hash_reset_tuning PARAMS ((Hash_tuning *));
359 +Hash_table *_recode_hash_initialize PARAMS ((unsigned, const Hash_tuning *,
360 Hash_hasher, Hash_comparator,
362 -void hash_clear PARAMS ((Hash_table *));
363 -void hash_free PARAMS ((Hash_table *));
364 +void _recode_hash_clear PARAMS ((Hash_table *));
365 +void _recode_hash_free PARAMS ((Hash_table *));
367 /* Insertion and deletion. */
368 -bool hash_rehash PARAMS ((Hash_table *, unsigned));
369 -void *hash_insert PARAMS ((Hash_table *, const void *));
370 -void *hash_delete PARAMS ((Hash_table *, const void *));
371 +bool _recode_hash_rehash PARAMS ((Hash_table *, unsigned));
372 +void *_recode_hash_insert PARAMS ((Hash_table *, const void *));
373 +void *_recode_hash_delete PARAMS ((Hash_table *, const void *));
374 diff -Nur recode-3.6.orig/src/html.c recode-3.6/src/html.c
375 --- recode-3.6.orig/src/html.c Fri Aug 18 23:34:28 2000
376 +++ recode-3.6/src/html.c Sun Oct 27 12:01:29 2002
377 @@ -425,14 +425,14 @@
378 if (before_options || after_options)
381 - table = hash_initialize (0, NULL, code_hash, code_compare, NULL);
382 + table = _recode_hash_initialize (0, NULL, code_hash, code_compare, NULL);
386 for (cursor = translations; cursor->code; cursor++)
387 if (cursor->flags & mask
388 && (!request->diacritics_only || cursor->code > 128))
389 - if (!hash_insert (table, cursor))
390 + if (!_recode_hash_insert (table, cursor))
393 step->step_type = RECODE_UCS2_TO_STRING;
395 struct ucs2_to_string *entry;
398 - entry = hash_lookup (table, &lookup);
399 + entry = _recode_hash_lookup (table, &lookup);
402 const char *cursor = entry->string;
405 struct ucs2_to_string const *data = void_data;
407 - return hash_string (data->string, table_size);
408 + return _recode_hash_string (data->string, table_size);
411 /*----------------------------------------.
412 @@ -606,14 +606,14 @@
413 if (before_options || after_options)
416 - table = hash_initialize (0, NULL, string_hash, string_compare, NULL);
417 + table = _recode_hash_initialize (0, NULL, string_hash, string_compare, NULL);
421 for (cursor = translations; cursor->code; cursor++)
422 if (cursor->flags & mask
423 && (!request->diacritics_only || cursor->code > 128))
424 - if (!hash_insert (table, cursor))
425 + if (!_recode_hash_insert (table, cursor))
428 step->step_type = RECODE_STRING_TO_UCS2;
430 struct ucs2_to_string *entry;
432 lookup.string = buffer;
433 - entry = hash_lookup (subtask->step->step_table, &lookup);
434 + entry = _recode_hash_lookup (subtask->step->step_table, &lookup);
437 put_ucs2 (entry->code, subtask);
438 diff -Nur recode-3.6.orig/src/names.c recode-3.6/src/names.c
439 --- recode-3.6.orig/src/names.c Wed Dec 6 20:41:29 2000
440 +++ recode-3.6/src/names.c Sun Oct 27 12:01:29 2002
443 RECODE_CONST_ALIAS alias = void_alias;
445 - return hash_string (alias->name, limit);
446 + return _recode_hash_string (alias->name, limit);
451 outer->number_of_symbols = 0;
454 - = hash_initialize (800, NULL, alias_hasher, alias_comparator, free);
455 + = _recode_hash_initialize (800, NULL, alias_hasher, alias_comparator, free);
456 if (!outer->alias_table)
463 - if (alias = hash_lookup (outer->alias_table, &lookup), alias)
464 + if (alias = _recode_hash_lookup (outer->alias_table, &lookup), alias)
467 /* If we reach this point, find_type is necessarily one of SYMBOL_CREATE_*.
470 alias->symbol = symbol;
471 alias->implied_surfaces = NULL;
472 - if (!hash_insert (outer->alias_table, alias))
473 + if (!_recode_hash_insert (outer->alias_table, alias))
478 symbol = alias->symbol;
481 - if (alias = hash_lookup (outer->alias_table, &lookup), alias)
482 + if (alias = _recode_hash_lookup (outer->alias_table, &lookup), alias)
484 if (alias->symbol == symbol)
488 alias->symbol = symbol;
489 alias->implied_surfaces = NULL;
490 - if (!hash_insert (outer->alias_table, alias))
491 + if (!_recode_hash_insert (outer->alias_table, alias))
496 struct make_argmatch_walk walk; /* wanderer's data */
499 - hash_print_statistics (outer->alias_table, stderr);
500 + _recode_hash_print_statistics (outer->alias_table, stderr);
503 /* It may happen that new modules are added only once all initialisation
506 walk.charset_counter = 0;
507 walk.surface_counter = 0;
508 - hash_do_for_each (outer->alias_table, make_argmatch_walker_1, &walk);
509 + _recode_hash_do_for_each (outer->alias_table, make_argmatch_walker_1, &walk);
511 /* Allocate the argmatch and realname arrays, each with a NULL sentinel. */
515 walk.charset_counter = 0;
516 walk.surface_counter = 0;
517 - hash_do_for_each (outer->alias_table, make_argmatch_walker_2, &walk);
518 + _recode_hash_do_for_each (outer->alias_table, make_argmatch_walker_2, &walk);
523 /* Count how many symbols we have. */
526 - hash_do_for_each (outer->alias_table, list_symbols_walker_1, &walk);
527 + _recode_hash_do_for_each (outer->alias_table, list_symbols_walker_1, &walk);
529 /* Allocate a structure to hold them. */
532 /* Copy all symbols in it. */
535 - hash_do_for_each (outer->alias_table, list_symbols_walker_2, &walk);
536 + _recode_hash_do_for_each (outer->alias_table, list_symbols_walker_2, &walk);
540 diff -Nur recode-3.6.orig/src/outer.c recode-3.6/src/outer.c
541 --- recode-3.6.orig/src/outer.c Wed Aug 30 22:16:14 2000
542 +++ recode-3.6/src/outer.c Sun Oct 27 12:01:53 2002
544 if (outer->pair_restriction)
545 free (outer->pair_restriction);
546 if (outer->alias_table)
547 - hash_free (outer->alias_table);
548 + _recode_hash_free (outer->alias_table);
549 if (outer->argmatch_charset_array)
550 free (outer->argmatch_charset_array);
551 if (outer->one_to_same)
552 diff -Nur recode-3.6.orig/src/recode.c recode-3.6/src/recode.c
553 --- recode-3.6.orig/src/recode.c Sat Jul 1 20:22:55 2000
554 +++ recode-3.6/src/recode.c Sun Oct 27 12:01:29 2002
555 @@ -419,14 +419,14 @@
556 if (before_options || after_options)
559 - table = hash_initialize (0, NULL,
560 + table = _recode_hash_initialize (0, NULL,
561 ucs2_to_byte_hash, ucs2_to_byte_compare, NULL);
565 if (!ALLOC (data, 256, struct ucs2_to_byte))
568 + _recode_hash_free (table);
574 data[counter].code = code_to_ucs2 (step->after, counter);
575 data[counter].byte = counter;
576 - if (!hash_insert (table, data + counter))
577 + if (!_recode_hash_insert (table, data + counter))
580 + _recode_hash_free (table);
585 while (get_ucs2 (&input_value, subtask))
587 lookup.code = input_value;
588 - entry = hash_lookup (table, &lookup);
589 + entry = _recode_hash_lookup (table, &lookup);
591 put_byte (entry->byte, subtask);
593 diff -Nur recode-3.6.orig/src/testdump.c recode-3.6/src/testdump.c
594 --- recode-3.6.orig/src/testdump.c Thu Jun 29 17:23:52 2000
595 +++ recode-3.6/src/testdump.c Sun Oct 27 12:01:29 2002
597 size_t size; /* number of different characters */
598 struct ucs2_to_count **array; /* array into hash table items */
600 - table = hash_initialize (0, NULL,
601 + table = _recode_hash_initialize (0, NULL,
602 ucs2_to_count_hash, ucs2_to_count_compare, free);
605 @@ -168,21 +168,21 @@
606 struct ucs2_to_count *entry;
608 lookup.code = character;
609 - entry = hash_lookup (table, &lookup);
610 + entry = _recode_hash_lookup (table, &lookup);
615 if (!ALLOC (entry, 1, struct ucs2_to_count))
618 + _recode_hash_free (table);
621 entry->code = character;
623 - if (!hash_insert (table, entry))
624 + if (!_recode_hash_insert (table, entry))
627 + _recode_hash_free (table);
631 @@ -192,14 +192,14 @@
635 - size = hash_get_n_entries (table);
636 + size = _recode_hash_get_n_entries (table);
638 if (!ALLOC (array, size, struct ucs2_to_count *))
641 + _recode_hash_free (table);
644 - hash_get_entries (table, (void **) array, size);
645 + _recode_hash_get_entries (table, (void **) array, size);
647 qsort (array, size, sizeof (struct ucs2_to_count *), compare_item);
654 + _recode_hash_free (table);
656 SUBTASK_RETURN (subtask);