rename TYPE_* to JSON_TYPE_* - 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 e569792c8bc41e19f1702ae57bbfbebc9fc64bff
 (DIR) parent cc245b50c91a1d3b3618773f289a3d4bb670df75
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun, 29 Dec 2019 18:34:39 +0100
       
       rename TYPE_* to JSON_TYPE_*
       
       Diffstat:
         M json.c                              |      20 ++++++++++----------
         M json.h                              |      12 ++++++------
         M json2tsv.c                          |       7 ++++---
       
       3 files changed, 20 insertions(+), 19 deletions(-)
       ---
 (DIR) diff --git a/json.c b/json.c
       @@ -121,7 +121,7 @@ handlechr:
                                expect = EXPECT_VALUE;
                                break;
                        case '"':
       -                        nodes[depth].type = TYPE_STRING;
       +                        nodes[depth].type = JSON_TYPE_STRING;
                                escape = 0;
                                len = 0;
                                while (1) {
       @@ -221,11 +221,11 @@ escchr:
        
                                nodes[depth].index = 0;
                                if (c == '[') {
       -                                nodes[depth].type = TYPE_ARRAY;
       +                                nodes[depth].type = JSON_TYPE_ARRAY;
                                        expect = EXPECT_ARRAY_VALUE;
                                } else if (c == '{') {
                                        iskey = 1;
       -                                nodes[depth].type = TYPE_OBJECT;
       +                                nodes[depth].type = JSON_TYPE_OBJECT;
                                        expect = EXPECT_OBJECT_STRING;
                                }
        
       @@ -240,8 +240,8 @@ escchr:
                        case ']':
                        case '}':
                                if (!depth ||
       -                           (c == ']' && nodes[depth - 1].type != TYPE_ARRAY) ||
       -                           (c == '}' && nodes[depth - 1].type != TYPE_OBJECT))
       +                           (c == ']' && nodes[depth - 1].type != JSON_TYPE_ARRAY) ||
       +                           (c == '}' && nodes[depth - 1].type != JSON_TYPE_OBJECT))
                                        JSON_INVALID(); /* unbalanced nodes */
        
                                nodes[--depth].index++;
       @@ -252,7 +252,7 @@ escchr:
                                        JSON_INVALID(); /* unbalanced nodes */
        
                                nodes[depth - 1].index++;
       -                        if (nodes[depth - 1].type == TYPE_OBJECT) {
       +                        if (nodes[depth - 1].type == JSON_TYPE_OBJECT) {
                                        iskey = 1;
                                        expect = EXPECT_STRING;
                                } else {
       @@ -262,7 +262,7 @@ escchr:
                        case 't': /* true */
                                if (GETNEXT() != 'r' || GETNEXT() != 'u' || GETNEXT() != 'e')
                                        JSON_INVALID();
       -                        nodes[depth].type = TYPE_BOOL;
       +                        nodes[depth].type = JSON_TYPE_BOOL;
                                cb(nodes, depth + 1, "true");
                                expect = EXPECT_END;
                                break;
       @@ -270,19 +270,19 @@ escchr:
                                if (GETNEXT() != 'a' || GETNEXT() != 'l' || GETNEXT() != 's' ||
                                    GETNEXT() != 'e')
                                        JSON_INVALID();
       -                        nodes[depth].type = TYPE_BOOL;
       +                        nodes[depth].type = JSON_TYPE_BOOL;
                                cb(nodes, depth + 1, "false");
                                expect = EXPECT_END;
                                break;
                        case 'n': /* null */
                                if (GETNEXT() != 'u' || GETNEXT() != 'l' || GETNEXT() != 'l')
                                        JSON_INVALID();
       -                        nodes[depth].type = TYPE_NULL;
       +                        nodes[depth].type = JSON_TYPE_NULL;
                                cb(nodes, depth + 1, "null");
                                expect = EXPECT_END;
                                break;
                        default: /* number */
       -                        nodes[depth].type = TYPE_NUMBER;
       +                        nodes[depth].type = JSON_TYPE_NUMBER;
                                p = 0;
                                pri[p++] = c;
                                expect = EXPECT_END;
 (DIR) diff --git a/json.h b/json.h
       @@ -1,12 +1,12 @@
        #include <stdint.h>
        
        enum JSONType {
       -        TYPE_ARRAY     = 'a',
       -        TYPE_OBJECT    = 'o',
       -        TYPE_STRING    = 's',
       -        TYPE_BOOL      = 'b',
       -        TYPE_NULL      = '?',
       -        TYPE_NUMBER    = 'n'
       +        JSON_TYPE_ARRAY  = 'a',
       +        JSON_TYPE_OBJECT = 'o',
       +        JSON_TYPE_STRING = 's',
       +        JSON_TYPE_BOOL   = 'b',
       +        JSON_TYPE_NULL   = '?',
       +        JSON_TYPE_NUMBER = 'n'
        };
        
        enum JSONError {
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -43,12 +43,13 @@ processnode(struct json_node *nodes, size_t depth, const char *value)
                        printvalue(nodes[i].name);
        
                        if (i + 1 == depth &&
       -                    (nodes[i].type == TYPE_OBJECT || nodes[i].type == TYPE_ARRAY))
       +                    (nodes[i].type == JSON_TYPE_OBJECT ||
       +                     nodes[i].type == JSON_TYPE_ARRAY))
                                continue;
        
       -                if (nodes[i].type == TYPE_OBJECT) {
       +                if (nodes[i].type == JSON_TYPE_OBJECT) {
                                putchar('.');
       -                } else if (nodes[i].type == TYPE_ARRAY) {
       +                } else if (nodes[i].type == JSON_TYPE_ARRAY) {
                                if (nflag) {
                                        printf("[%zu]", nodes[i].index);
                                } else {