summaryrefslogtreecommitdiff
path: root/xml2tsv.c
diff options
context:
space:
mode:
Diffstat (limited to 'xml2tsv.c')
-rw-r--r--xml2tsv.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/xml2tsv.c b/xml2tsv.c
index cee5b97..36aef3a 100644
--- a/xml2tsv.c
+++ b/xml2tsv.c
@@ -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;