diff options
Diffstat (limited to 'xml2tsv.c')
-rw-r--r-- | xml2tsv.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -19,6 +19,10 @@ #include "xml.h" #include "config.h" + +#define FALSE 0 +#define TRUE 1 + /* tag stack */ typedef struct { @@ -104,7 +108,7 @@ void print_cur_str(FILE *f, tstack_t *t){ /* global variables */ tstack_t st; - +char emitsep; /* xml callbacks */ @@ -174,12 +178,17 @@ xmlcommentend(XMLParser *x) void xmldata(XMLParser *x, const char *d, size_t dl) { + if (strcspn(d, " \t\n") && emitsep){ + printf("%c", SEP); + emitsep = FALSE; + } quote_print(stdout, d); } void xmldataend(XMLParser *x) { + emitsep = FALSE; } void @@ -197,7 +206,7 @@ xmldataentity(XMLParser *x, const char *d, size_t dl) void xmldatastart(XMLParser *x) { - printf("%c", SEP); + emitsep = TRUE; } void @@ -239,6 +248,7 @@ int main(void) { stack_init(&st); + emitsep = FALSE; XMLParser x = { 0 }; x.xmlattr = xmlattr; |