quote \ appropriately - xml2tsv - a simple xml-to-tsv converter, based on xmlparser
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 6b7046c7c6b7d269067b2586f676c81a0c531420
(DIR) parent e555494626790aabcb838227d8e7115bf3081da8
(HTM) Author: KatolaZ <katolaz@freaknet.org>
Date: Sat, 4 Jan 2020 11:12:02 +0000
quote \ appropriately
Diffstat:
M xml2tsv.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
(DIR) diff --git 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)