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.
This commit is contained in:
Alexandre Duret-Lutz 2022-12-02 15:22:32 +01:00
parent a032abf0c5
commit 29037c1f55
3 changed files with 17 additions and 11 deletions

3
NEWS
View file

@ -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:

View file

@ -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;
});

View file

@ -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 <<EOF
HOA: v1
States: 3
@ -1004,11 +1005,11 @@ EOF
test `autfilt -c --is-inherently-weak input8` = 0
test `autfilt -c --is-weak input8` = 0
autfilt input8 -Hl >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