From f5ced88b5ae851a5a64ede9d83640a1108485a4c Mon Sep 17 00:00:00 2001 From: pgen Date: Sat, 19 Jun 2021 15:01:43 +0200 Subject: Correctly handles the order of the -i/-e options Correct the code to comply with the manual regarding the order of appearance of -i and -e on the command line. --- smenu.c | 6 +++--- tests/in-ex-clusions/t0007.good | 11 +++++++++++ tests/in-ex-clusions/t0007.in | 1 + tests/in-ex-clusions/t0007.tst | 4 ++++ tests/in-ex-clusions/t0008.good | 11 +++++++++++ tests/in-ex-clusions/t0008.in | 1 + tests/in-ex-clusions/t0008.tst | 4 ++++ 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 tests/in-ex-clusions/t0007.good create mode 120000 tests/in-ex-clusions/t0007.in create mode 100644 tests/in-ex-clusions/t0007.tst create mode 100644 tests/in-ex-clusions/t0008.good create mode 120000 tests/in-ex-clusions/t0008.in create mode 100644 tests/in-ex-clusions/t0008.tst diff --git a/smenu.c b/smenu.c index b52f56a..d014cf4 100644 --- a/smenu.c +++ b/smenu.c @@ -5338,15 +5338,15 @@ exclude_re_action(char * ctx_name, char * opt_name, char * param, int nb_values, char ** values, int nb_opt_data, void ** opt_data, int nb_ctx_data, void ** ctx_data) { - int * pattern_def_exclude = opt_data[0]; + int * pattern_def_include = opt_data[0]; char ** exclude_pattern = opt_data[1]; langinfo_t * langinfo = opt_data[2]; misc_t * misc = opt_data[3]; /* Set the default behaviour if not already set. */ /* """"""""""""""""""""""""""""""""""""""""""""" */ - if (*pattern_def_exclude == -1) - *pattern_def_exclude = 0; + if (*pattern_def_include == -1) + *pattern_def_include = 1; if (*exclude_pattern == NULL) *exclude_pattern = concat("(", values[0], ")", (char *)0); diff --git a/tests/in-ex-clusions/t0007.good b/tests/in-ex-clusions/t0007.good new file mode 100644 index 0000000..2cb10b9 --- /dev/null +++ b/tests/in-ex-clusions/t0007.good @@ -0,0 +1,11 @@ +$ OUT=$(smenu -e2 -i1 t0007.in) + +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +0:07 2:24 24:24 25:24 48:24 49:24 +$ + +$ echo ":$OUT:" + +:1: + +$ exit 0 diff --git a/tests/in-ex-clusions/t0007.in b/tests/in-ex-clusions/t0007.in new file mode 120000 index 0000000..0abc8f1 --- /dev/null +++ b/tests/in-ex-clusions/t0007.in @@ -0,0 +1 @@ +data1 \ No newline at end of file diff --git a/tests/in-ex-clusions/t0007.tst b/tests/in-ex-clusions/t0007.tst new file mode 100644 index 0000000..5fe32e3 --- /dev/null +++ b/tests/in-ex-clusions/t0007.tst @@ -0,0 +1,4 @@ +\S[150]\s[10]OUT=$(smenu -e2 -i1 t0007.in) +\S[150]\s[150]\r +\S[150]\s[10]echo ":$\s[10]OUT:" +exit 0 diff --git a/tests/in-ex-clusions/t0008.good b/tests/in-ex-clusions/t0008.good new file mode 100644 index 0000000..7c0b135 --- /dev/null +++ b/tests/in-ex-clusions/t0008.good @@ -0,0 +1,11 @@ +$ OUT=$(smenu -i1 -e2 t0008.in) + +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +0:07 2:24 4:24 6:24 8:24 10:24 12:24 14:24 16:24 24:24 25:24 48:24 49:24 +$ + +$ echo ":$OUT:" + +:1: + +$ exit 0 diff --git a/tests/in-ex-clusions/t0008.in b/tests/in-ex-clusions/t0008.in new file mode 120000 index 0000000..0abc8f1 --- /dev/null +++ b/tests/in-ex-clusions/t0008.in @@ -0,0 +1 @@ +data1 \ No newline at end of file diff --git a/tests/in-ex-clusions/t0008.tst b/tests/in-ex-clusions/t0008.tst new file mode 100644 index 0000000..fe20bef --- /dev/null +++ b/tests/in-ex-clusions/t0008.tst @@ -0,0 +1,4 @@ +\S[150]\s[10]OUT=$(smenu -i1 -e2 t0008.in) +\S[150]\s[150]\r +\S[150]\s[10]echo ":$\s[10]OUT:" +exit 0 -- cgit v1.2.3