add changes from PR #142

modernize
Serge A. Zaitsev 6 years ago
parent aa4c1c73b0
commit 428ad5fa68

@ -27,6 +27,7 @@ static inline void *realloc_it(void *ptrmem, size_t size) {
static int dump(const char *js, jsmntok_t *t, size_t count, int indent) { static int dump(const char *js, jsmntok_t *t, size_t count, int indent) {
int i, j, k; int i, j, k;
jsmntok_t *key;
if (count == 0) { if (count == 0) {
return 0; return 0;
} }
@ -40,11 +41,15 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent) {
printf("\n"); printf("\n");
j = 0; j = 0;
for (i = 0; i < t->size; i++) { for (i = 0; i < t->size; i++) {
for (k = 0; k < indent; k++) for (k = 0; k < indent; k++) {
printf(" "); printf(" ");
j += dump(js, t + 1 + j, count - j, indent + 1); }
key = t + 1 + j;
j += dump(js, key, count - j, indent + 1);
if (key->size > 0) {
printf(": "); printf(": ");
j += dump(js, t + 1 + j, count - j, indent + 1); j += dump(js, t + 1 + j, count - j, indent + 1);
}
printf("\n"); printf("\n");
} }
return j + 1; return j + 1;
@ -52,8 +57,9 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent) {
j = 0; j = 0;
printf("\n"); printf("\n");
for (i = 0; i < t->size; i++) { for (i = 0; i < t->size; i++) {
for (k = 0; k < indent - 1; k++) for (k = 0; k < indent - 1; k++) {
printf(" "); printf(" ");
}
printf(" - "); printf(" - ");
j += dump(js, t + 1 + j, count - j, indent + 1); j += dump(js, t + 1 + j, count - j, indent + 1);
printf("\n"); printf("\n");

Loading…
Cancel
Save