Introduction
Introduction Statistics Contact Development Disclaimer Help
use stack_empty in stack-related functions - xml2tsv - a simple xml-to-tsv conv…
Log
Files
Refs
Tags
README
LICENSE
---
commit 8401a64f99c614fa5e32c1b34e5499e0ab948d85
parent 2245701946acd39e542918839c9dd80b19f6902e
Author: KatolaZ <[email protected]>
Date: Sun, 5 Jan 2020 07:47:33 +0000
use stack_empty in stack-related functions
Diffstat:
M xml2tsv.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git 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;
}
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.