replace control characters (including newline and tab), simplify dataentity handler - grabtitle - stupid HTML title grabber
 (HTM) git clone git://git.codemadness.org/grabtitle
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0cca681092b680c5b80da62771d47fa383be6cd1
 (DIR) parent 074560f704de31a111ed6c73edbb1f9c84413aa7
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun,  9 Dec 2018 11:33:20 +0100
       
       replace control characters (including newline and tab), simplify dataentity handler
       
       Diffstat:
         M grabtitle.c                         |      15 ++++++++++++---
       
       1 file changed, 12 insertions(+), 3 deletions(-)
       ---
 (DIR) 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 isshort)
        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