From 29037c1f55fd2bd24808e2d193e1024d8a6bd362 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 2 Dec 2022 15:22:32 +0100 Subject: [PATCH] autfilt: print match count even on parse errors * bin/autfilt.cc: If -c is used, print the match_count even in present of parse errors. * tests/core/readsave.test: Adjust. * NEWS: Mention the bug. --- NEWS | 3 +++ bin/autfilt.cc | 12 +++++++----- tests/core/readsave.test | 13 +++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 96e3d3431..ec6cff1bf 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ New in spot 2.11.2.dev (not yet released) (e.g., when the State: header declare many more states than the body of the file). It now warns about those. + - 'autfilt -c ...' should display a match count even in present of + parse errors. + New in spot 2.11.2 (2022-10-26) Command-line tools: diff --git a/bin/autfilt.cc b/bin/autfilt.cc index e16ef770a..7cff60e8b 100644 --- a/bin/autfilt.cc +++ b/bin/autfilt.cc @@ -1763,15 +1763,17 @@ main(int argc, char** argv) post.set_level(level); autfilt_processor processor(post, o.dict); - if (processor.run()) - return 2; - - // Diagnose unused -x options - extra_options.report_unused_options(); + int err = processor.run(); if (automaton_format == Count) std::cout << match_count << std::endl; + // Diagnose unused -x options + if (!err) + extra_options.report_unused_options(); + else + return 2; + check_cout(); return match_count ? 0 : 1; }); diff --git a/tests/core/readsave.test b/tests/core/readsave.test index dd4e2efaf..3780b4766 100755 --- a/tests/core/readsave.test +++ b/tests/core/readsave.test @@ -963,7 +963,8 @@ EOF test `autfilt -c --is-inherently-weak input7` = 1 test `autfilt -c --is-weak input7` = 0 test `autfilt -c --is-stutter-invariant input7` = 1 -autfilt --check input7 -H >output7 +autfilt --check input7 -H >output7 && exit 0 +test $? -eq 2 cat >expected7 <oneline.hoa -autfilt input8 --stats='%h' >oneline2.hoa -autfilt input8 --stats='%H' >oneline3.hoa -autfilt input8 --randomize --stats='%h' >oneline4.hoa -autfilt input8 --randomize --stats='%H' >oneline5.hoa +autfilt input8 -Hl >oneline.hoa && exit 1 +autfilt input8 --stats='%h' >oneline2.hoa && exit 1 +autfilt input8 --stats='%H' >oneline3.hoa && exit 1 +autfilt input8 --randomize --stats='%h' >oneline4.hoa && exit 1 +autfilt input8 --randomize --stats='%H' >oneline5.hoa && exit 1 diff oneline.hoa oneline2.hoa diff oneline.hoa oneline3.hoa diff oneline.hoa oneline4.hoa && exit 1