allow octal format and check the format a bit more strict - 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 eb921bbad3f1120270014eaad9b2cba8a2958130
 (DIR) parent f022807e57f81d93643e6126487e37f47132b13e
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon, 21 Feb 2022 17:16:38 +0100
       
       allow octal format and check the format a bit more strict
       
       Diffstat:
         M json2tsv.1                          |       4 +++-
         M json2tsv.c                          |      10 +++++++++-
       
       2 files changed, 12 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/json2tsv.1 b/json2tsv.1
       @@ -1,4 +1,4 @@
       -.Dd September 25, 2021
       +.Dd February 20, 2022
        .Dt JSON2TSV 1
        .Os
        .Sh NAME
       @@ -50,6 +50,8 @@ separators can be specified in the following formats:
        \\t for a TAB character.
        .It
        \\xXX for a character specified in the hexadecimal format as XX.
       +.It
       +\\NNN for a character specified in the octal format as NNN.
        .El
        .Pp
        Otherwise: if a single character is specified this character will be used.
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -138,12 +138,20 @@ readchar(const char *s)
                        return *s;
                } else if (*s == '\\') {
                        s++;
       +                if (*s == 'x')
       +                        return readnum(++s, 16); /* hexadecimal */
       +                else if (isdigit((unsigned char)*s))
       +                        return readnum(s, 8); /* octal */
       +
       +                if (*(s + 1)) {
       +                        fprintf(stderr, "unsupported format\n");
       +                        exit(3);
       +                }
                        switch (*s) {
                        case '\\': return '\\';
                        case 't': return '\t';
                        case 'n': return '\n';
                        case 'r': return '\r';
       -                case 'x': return readnum(++s, 16); /* hexadecimal */
                        default:
                                fprintf(stderr, "unsupported escape character\n");
                                exit(3);