Introduction
Introduction Statistics Contact Development Disclaimer Help
check capacity before each write, reset name of object keys always on ':' - jso…
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit c12ff5a298eaa6efaa2651b5ea16dde24dae1147
parent 65cdb7d2d32ee17246328b50c5a0ae4deab585fb
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 15 Oct 2019 00:46:31 +0200
check capacity before each write, reset name of object keys always on ':'
Diffstat:
M json2tsv.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/json2tsv.c b/json2tsv.c
@@ -126,14 +126,15 @@ parsejson(void (*cb)(struct json_node *, size_t, const ch…
*errstr = "object member, but not in an object…
goto end;
}
- if (v || nodes[depth].type == TYPE_STRING) {
- value[v] = '\0';
- if (capacity(&(nodes[depth].name), &(nodes[dep…
- goto end;
- memcpy(nodes[depth].name, value, v);
- nodes[depth].name[v] = '\0';
- v = 0;
- }
+
+ if (capacity(&value, &vz, v, 1) == -1)
+ goto end;
+ value[v] = '\0';
+ if (capacity(&(nodes[depth].name), &(nodes[depth].name…
+ goto end;
+ memcpy(nodes[depth].name, value, v);
+ nodes[depth].name[v] = '\0';
+ v = 0;
nodes[depth].type = TYPE_PRIMITIVE;
break;
case '"':
@@ -186,14 +187,14 @@ parsejson(void (*cb)(struct json_node *, size_t, const ch…
}
cp = (hi << 10) + lo -…
}
- if (capacity(&value, &vz, v, 5…
+ if (capacity(&value, &vz, v, 4…
goto end;
v += codepointtoutf8(cp, &valu…
continue;
default:
continue; /* ignore unknown es…
}
- if (capacity(&value, &vz, v, 2) == -1)
+ if (capacity(&value, &vz, v, 1) == -1)
goto end;
value[v++] = c;
} else if (c == '\\') {
@@ -201,7 +202,7 @@ parsejson(void (*cb)(struct json_node *, size_t, const char…
} else if (c == '"') {
break;
} else {
- if (capacity(&value, &vz, v, 2) == -1)
+ if (capacity(&value, &vz, v, 1) == -1)
goto end;
value[v++] = c;
}
@@ -253,7 +254,7 @@ parsejson(void (*cb)(struct json_node *, size_t, const char…
}
break;
default:
- if (capacity(&value, &vz, v, 2) == -1)
+ if (capacity(&value, &vz, v, 1) == -1)
goto end;
value[v++] = c;
}
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.