2 * Copyright (C) 2004-2005 The Free Software Foundation, Inc.
4 * Portions Copyright (C) 2004-2005 Derek Price, Ximbiot <http://ximbiot.com>,
7 * You may distribute under the terms of the GNU General Public License as
8 * specified in the README file that comes with the CVS source distribution.
10 * This module uses the hash.c module to implement a stack.
19 do_push (stack, elem, isstring)
41 do_push (stack, elem, 0);
47 push_string (stack, elem)
51 do_push (stack, elem, 1);
57 do_pop (stack, isstring)
63 if (isempty (stack)) return NULL;
67 elem = stack->list->prev->key;
68 stack->list->prev->key = NULL;
72 elem = stack->list->prev->data;
73 stack->list->prev->data = NULL;
76 delnode (stack->list->prev);
86 return do_pop (stack, 0);
95 return do_pop (stack, 1);
101 do_unshift (stack, elem, isstring)
113 addnode_at_front(stack, p);
119 unshift (stack, elem)
123 do_unshift (stack, elem, 0);
129 unshift_string (stack, elem)
133 do_unshift (stack, elem, 1);
139 do_shift (stack, isstring)
145 if (isempty (stack)) return NULL;
149 elem = stack->list->next->key;
150 stack->list->next->key = NULL;
154 elem = stack->list->next->data;
155 stack->list->next->data = NULL;
157 delnode (stack->list->next);
167 return do_shift (stack, 0);
176 return do_shift (stack, 1);
185 if (stack->list == stack->list->next)