diff options
author | Yorhel <git@yorhel.nl> | 2021-05-12 16:02:07 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-05-12 16:04:36 +0200 |
commit | e2786604643f3453501aebcfe5d9037dbb6e8a77 (patch) | |
tree | 325705a67e11e3808168fea878bf03aa5719ebfe | |
parent | ca51d4ed1a0f61042fc43d2a7ae8732351431654 (diff) |
dir_import: Accept JSON data after the last object
This should really have been accepted from the start. Adding extra
elements to the top-level array might be useful for aux. data related to
the scanned files, e.g. map of seen uid/gids to names, information about
the scanned dev ids, etc. But since ncdu would throw an error on further
array elements, adding such information can't be done without breaking
compat with older versions. :(
-rw-r--r-- | src/dir_import.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dir_import.c b/src/dir_import.c index cdb94a0..287a381 100644 --- a/src/dir_import.c +++ b/src/dir_import.c @@ -568,8 +568,14 @@ static int item(uint64_t dev) { static int footer(void) { - C(cons()); - E(*ctx->buf != ']', "Expected ']'"); + while(1) { + C(cons()); + if(*ctx->buf == ']') + break; + E(*ctx->buf != ',', "Expected ',' or ']'"); + con(1); + C(cons() || rval()); + } con(1); C(cons()); E(*ctx->buf, "Trailing garbage"); |