21 |
/* TODO: |
/* TODO: |
22 |
- Use an obstack to manage the node memory. |
- Use an obstack to manage the node memory. |
23 |
- Implement the macroized magic values with the API. |
- Implement the macroized magic values with the API. |
|
- Have each node be a pushdown stack to eliminate the shadowed flag. |
|
24 |
*/ |
*/ |
25 |
|
|
26 |
#include "hash.h" |
#include "hash.h" |
342 |
} |
} |
343 |
} |
} |
344 |
|
|
345 |
/* Carefully insert each node in BUCKET into HASH. The nodes are |
/* Insert each node in BUCKET into HASH. Relative ordering of nodes |
346 |
inserted in reverse order to preserve the relative ordering of |
is not preserved. */ |
|
all sets of nodes with the same key. */ |
|
347 |
void |
void |
348 |
m4_hash_bucket_insert (m4_hash *hash, m4_hash_node *bucket) |
m4_hash_bucket_insert (m4_hash *hash, m4_hash_node *bucket) |
349 |
{ |
{ |
350 |
assert (hash); |
assert (hash); |
351 |
assert (bucket); |
assert (bucket); |
352 |
|
|
353 |
if (M4_HASH_NODE_NEXT (bucket)) |
do |
354 |
{ |
{ |
355 |
/* Recurse to the end of the list. */ |
m4_hash_node *next = M4_HASH_NODE_NEXT (bucket); |
|
m4_hash_bucket_insert (hash, M4_HASH_NODE_NEXT (bucket)); |
|
356 |
|
|
357 |
/* Break links as the stack unwinds. */ |
/* Break link to rest of the bucket before reinserting. */ |
358 |
M4_HASH_NODE_NEXT (bucket) = 0; |
M4_HASH_NODE_NEXT (bucket) = 0; |
359 |
} |
m4_hash_node_insert (hash, bucket); |
360 |
|
|
361 |
/* Insert each node, from last to first, as the stack unwinds. */ |
bucket = next; |
362 |
m4_hash_node_insert (hash, bucket); |
} |
363 |
|
while (bucket); |
364 |
} |
} |
365 |
|
|
366 |
|
|