From e2786604643f3453501aebcfe5d9037dbb6e8a77 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 12 May 2021 16:02:07 +0200 Subject: 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. :( --- src/dir_import.c | 10 ++++++++-- 1 file 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"); -- cgit v1.2.3