2 * Copyright (c) 2004, Free Software Foundation,
4 * & Ximbiot <http://ximbiot.com>.
6 * You may distribute under the terms of the GNU General Public License as
7 * specified in the README file that comes with the CVS source distribution.
9 * This module uses the hash.c module to implement a stack.
18 do_push (stack, elem, isstring)
40 do_push (stack, elem, 0);
46 push_string (stack, elem)
50 do_push (stack, elem, 1);
56 do_pop (stack, isstring)
62 if (isempty (stack)) return NULL;
66 elem = stack->list->prev->key;
67 stack->list->prev->key = NULL;
71 elem = stack->list->prev->data;
72 stack->list->prev->data = NULL;
75 delnode (stack->list->prev);
85 return do_pop (stack, 0);
94 return do_pop (stack, 1);
100 do_unshift (stack, elem, isstring)
112 addnode_at_front(stack, p);
118 unshift (stack, elem)
122 do_unshift (stack, elem, 0);
128 unshift_string (stack, elem)
132 do_unshift (stack, elem, 1);
138 do_shift (stack, isstring)
144 if (isempty (stack)) return NULL;
148 elem = stack->list->next->key;
149 stack->list->next->key = NULL;
153 elem = stack->list->next->data;
154 stack->list->next->data = NULL;
156 delnode (stack->list->next);
166 return do_shift (stack, 0);
175 return do_shift (stack, 1);
184 if (stack->list == stack->list->next)