From 6b7046c7c6b7d269067b2586f676c81a0c531420 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sat, 4 Jan 2020 11:12:02 +0000 Subject: quote \ appropriately --- xml2tsv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xml2tsv.c b/xml2tsv.c index 7363ce6..4f9f8eb 100644 --- a/xml2tsv.c +++ b/xml2tsv.c @@ -62,7 +62,7 @@ void print_no_cr(FILE *f, const char *s){ const char *tmp = s; size_t len; while (*tmp != '\0'){ - len = strcspn(tmp, "\n\t"); + len = strcspn(tmp, "\\\n\t"); fwrite(tmp, 1, len, f); tmp += len; if (*tmp == '\n'){ @@ -75,6 +75,10 @@ void print_no_cr(FILE *f, const char *s){ fprintf(f, "\\t"); tmp ++; } + else if (*tmp == '\\'){ + fprintf(f, "\\\\"); + tmp ++; + } } } @@ -103,7 +107,7 @@ void xmlattrentity(XMLParser *x, const char *t, size_t tl, const char *a, size_t al, const char *v, size_t vl) { - static char buf[16]; + char buf[16]; int n; if ((n = xml_entitytostr(v, buf, sizeof(buf))) > 0) -- cgit v1.2.3