summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xml2tsv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/xml2tsv.c b/xml2tsv.c
index 635ae37..960c2de 100644
--- a/xml2tsv.c
+++ b/xml2tsv.c
@@ -26,6 +26,10 @@ typedef struct {
char st[DEPTH_MAX][STR_MAX];
} tstack_t;
+int stack_empty(tstack_t *t){
+ return (t->top < 0);
+}
+
int stack_push(tstack_t *t, const char *c){
if (t->top < DEPTH_MAX){
t->top ++;
@@ -37,21 +41,17 @@ int stack_push(tstack_t *t, const char *c){
}
char* stack_pop(tstack_t *t){
- if (t->top >= 0)
+ if (!stack_empty(t))
return t->st[t->top--];
return NULL;
}
char* stack_peek(tstack_t *t){
- if (t->top >= 0)
+ if (!stack_empty(t))
return t->st[t->top];
return NULL;
}
-int stack_empty(tstack_t *t){
- return (t->top < 0);
-}
-
void stack_init(tstack_t *t){
t->top = -1;
}