compatibility: replace iscntrl with own ISCNTRL macro - json2tsv - JSON to TSV converter
 (HTM) git clone git://git.codemadness.org/json2tsv
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1ebc23030bb37e0f9399328ec3a6968e35758351
 (DIR) parent ca7aea61b3a593c782c7da48ec3e6552b47a698e
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon, 28 Mar 2022 18:42:11 +0200
       
       compatibility: replace iscntrl with own ISCNTRL macro
       
       It is unspecified if the C locale iscntrl is compatible with ASCII or not so
       force it to be.
       
       Diffstat:
         M json2tsv.c                          |       7 +++++--
       
       1 file changed, 5 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -14,6 +14,9 @@
        
        #include "json.h"
        
       +/* control-character in the ASCII range 0-127: compatible with UTF-8 */
       +#define ISCNTRL(c) ((c) < ' ' || (c) == 0x7f)
       +
        static int nflag = 0; /* -n flag: show indices count for arrays */
        static int rflag = 0; /* -r flag: show all control-characters */
        static int fs = '\t', rs = '\n';
       @@ -31,7 +34,7 @@ tsv_printvalue(const char *s)
                        case '\t': putchar('\\'); putchar('t'); break;
                        default:
                                /* ignore other control chars */
       -                        if (!rflag && iscntrl((unsigned char)*s))
       +                        if (!rflag && ISCNTRL((unsigned char)*s))
                                        continue;
                                putchar(*s);
                        }
       @@ -52,7 +55,7 @@ rs_printvalue(const char *s)
                                break;
                        default:
                                /* ignore other control chars */
       -                        if (!rflag && iscntrl((unsigned char)*s))
       +                        if (!rflag && ISCNTRL((unsigned char)*s))
                                        continue;
                                putchar(*s);
                        }