diff options
author | KatolaZ <katolaz@freaknet.org> | 2020-01-04 11:12:02 +0000 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2020-01-04 11:12:02 +0000 |
commit | 6b7046c7c6b7d269067b2586f676c81a0c531420 (patch) | |
tree | 3e798f1881ebeb19b08a926e5dd80a5c94e002a3 | |
parent | e555494626790aabcb838227d8e7115bf3081da8 (diff) |
quote \ appropriately
-rw-r--r-- | xml2tsv.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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) |