JSON string `s` (quoted) unquoted; \\ and \" unescaped. */
| 533 | |
| 534 | /* JSON string `s` (quoted) unquoted; \\ and \" unescaped. */ |
| 535 | static const char *dk_json_string(dk_t *d, const char *s) { |
| 536 | size_t l = s ? strlen(s) : 0; |
| 537 | if (l < PAIR_LEN || s[0] != '"') { |
| 538 | return s; |
| 539 | } |
| 540 | char *out = cbm_arena_alloc(d->a, l); |
| 541 | size_t n = 0; |
| 542 | for (size_t i = SKIP_ONE; out && i + SKIP_ONE < l; i++) { |
| 543 | if (s[i] == '\\' && i + PAIR_LEN < l) { |
| 544 | i++; |
| 545 | } |
| 546 | out[n++] = s[i]; |
| 547 | } |
| 548 | if (out) { |
| 549 | out[n] = '\0'; |
| 550 | } |
| 551 | return out; |
| 552 | } |
| 553 | |
| 554 | /* The strings of a json_string_array node. */ |
| 555 | static int dk_json_array(dk_t *d, TSNode arr, const char **out, int max) { |
no test coverage detected