From b6e782589e2672aba4deab7f5068c11afd357952 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 11 Mar 2025 10:14:46 +0100 Subject: [PATCH] bin: handle '--parity=X --colored-parity' like '--colored-parity=X' Fixes #602. * bin/common_post.cc (-P, -p): Do not overwrite an existing parity specification if none were given. * tests/core/parity2.test: Test this. --- bin/common_post.cc | 9 +++++- tests/core/parity2.test | 66 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/bin/common_post.cc b/bin/common_post.cc index fdb1dc903..7bead8135 100644 --- a/bin/common_post.cc +++ b/bin/common_post.cc @@ -231,7 +231,14 @@ parse_opt_post(int key, char* arg, struct argp_state*) if (arg) type = XARGMATCH(key == 'P' ? "--parity" : "--colored-parity", arg, parity_args, parity_types); - else + else if (!(type & spot::postprocessor::Parity)) + // If no argument was given, we just require Parity. + // However, if a Parity condition was already set before, + // don't overwrite it. This way if someone mistakenly write + // `--parity='max even' --colored` without realizing that + // `--colored` is just the abbreviation for + // `--colored-parity=...` with the default argument, we + // won't reset the 'max even' setting. type = spot::postprocessor::Parity; if (key == 'p') colored = spot::postprocessor::Colored; diff --git a/tests/core/parity2.test b/tests/core/parity2.test index 8fb35e365..b2b95f790 100755 --- a/tests/core/parity2.test +++ b/tests/core/parity2.test @@ -26,7 +26,19 @@ for x in P 'Pmin odd' 'Pmax even' p 'pmin odd' 'pmax even'; do autfilt --name=%M --high "-$x" >>res2 ltl2tgba -D "-$x" FGa 'GFa & GFb' '(p0 W XXGp0) & GFp1 & FGp2' >>res3 ltl2tgba FGa 'GFa & GFb' '(p0 W XXGp0) & GFp1 & FGp2' | - autfilt -D --name=%M --high "-$x" >>res4 + autfilt -D --name=%M --high "-$x" >>res4 + ( + ## --colored is normally short for --colored-parity=any + ## But in case someone types something like + ## --parity='max odd' --colored + ## let's make sure we handle it like --colored-parity='max odd'. + echo "=== -$x ===" + ltl2tgba FGa 'GFa & GFb' '(p0 W XXGp0) & GFp1 & FGp2' \ + "-$x" --stats='%[]g' + echo "=== -$x --colored ===" + ltl2tgba FGa 'GFa & GFb' '(p0 W XXGp0) & GFp1 & FGp2' \ + "-$x" --colored --stats='%[]g' + ) >> res5 done cat >expected<expected5 < XXXb)' -f '(p0 W XXGp0) & GFp1 & FGp2'