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 (List
*stack
, void *elem
, int isstring
)
34 push (List
*stack
, void *elem
)
36 do_push (stack
, elem
, 0);
42 push_string (List
*stack
, char *elem
)
44 do_push (stack
, elem
, 1);
50 do_pop (List
*stack
, int isstring
)
54 if (isempty (stack
)) return NULL
;
58 elem
= stack
->list
->prev
->key
;
59 stack
->list
->prev
->key
= NULL
;
63 elem
= stack
->list
->prev
->data
;
64 stack
->list
->prev
->data
= NULL
;
67 delnode (stack
->list
->prev
);
76 return do_pop (stack
, 0);
82 pop_string (List
*stack
)
84 return do_pop (stack
, 1);
90 do_unshift (List
*stack
, void *elem
, int isstring
)
99 addnode_at_front(stack
, p
);
105 unshift (List
*stack
, void *elem
)
107 do_unshift (stack
, elem
, 0);
113 unshift_string (List
*stack
, char *elem
)
115 do_unshift (stack
, elem
, 1);
121 do_shift (List
*stack
, int isstring
)
125 if (isempty (stack
)) return NULL
;
129 elem
= stack
->list
->next
->key
;
130 stack
->list
->next
->key
= NULL
;
134 elem
= stack
->list
->next
->data
;
135 stack
->list
->next
->data
= NULL
;
137 delnode (stack
->list
->next
);
146 return do_shift (stack
, 0);
152 shift_string (List
*stack
)
154 return do_shift (stack
, 1);
160 isempty (List
*stack
)
162 if (stack
->list
== stack
->list
->next
)