Introduction
Introduction Statistics Contact Development Disclaimer Help
replace control characters (including newline and tab), simplify dataentity han…
git clone git://git.codemadness.org/grabtitle
Log
Files
Refs
README
LICENSE
---
commit 0cca681092b680c5b80da62771d47fa383be6cd1
parent 074560f704de31a111ed6c73edbb1f9c84413aa7
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 9 Dec 2018 11:33:20 +0100
replace control characters (including newline and tab), simplify dataentity han…
Diffstat:
M grabtitle.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/grabtitle.c b/grabtitle.c
@@ -1,5 +1,6 @@
#include <sys/types.h>
+#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -43,9 +44,17 @@ xmltagend(XMLParser *p, const char *t, size_t tl, int isshor…
static void
xmldata(XMLParser *p, const char *d, size_t dl)
{
+ size_t i;
+
if (!istitle)
return;
- fwrite(d, 1, dl, stdout);
+
+ for (i = 0; *d && i < dl; i++, d++) {
+ if (iscntrl((unsigned char)*d))
+ putchar(' ');
+ else
+ putchar(*d);
+ }
}
static void
@@ -58,9 +67,9 @@ xmldataentity(XMLParser *p, const char *d, size_t dl)
return;
if ((len = xml_entitytostr(d, buf, sizeof(buf))))
- fwrite(buf, 1, len, stdout);
+ xmldata(p, buf, (size_t)len);
else
- fwrite(d, 1, dl, stdout);
+ xmldata(p, d, dl);
}
int
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.