diff options
author | Werner Koch <[email protected]> | 2025-03-12 10:09:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-03-12 10:09:52 +0000 |
commit | c12b7d047e75808dfc8918f42962b4c8d1dead91 (patch) | |
tree | 887db74e0d613a9f3152b561343c2db7923ec953 /common/t-recsel.c | |
parent | Update autogen.sh from upstream to version 2025-03-10 (diff) | |
download | gnupg-c12b7d047e75808dfc8918f42962b4c8d1dead91.tar.gz gnupg-c12b7d047e75808dfc8918f42962b4c8d1dead91.zip |
common: Add a flag for left anchored substring match to recsel.
* common/recsel.c (struct recsel_expr_s): Add field lefta.
(recsel_parse_expr): Parse it.
(recsel_select): Implement selection.
--
This flags makes it for example easy to select keys last updated from
an ldap server:
gpg --list-filter 'select=origin=ks && -^ url =~ ldap' \
-k --with-key-origin
Diffstat (limited to 'common/t-recsel.c')
-rw-r--r-- | common/t-recsel.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/common/t-recsel.c b/common/t-recsel.c index 2d5a95d25..ff68e54c3 100644 --- a/common/t-recsel.c +++ b/common/t-recsel.c @@ -225,9 +225,27 @@ run_test_2 (void) if (!recsel_select (se, test_2_getval, NULL)) fail (0, 0); FREEEXPR(); - ADDEXPR ("uid =~ @"); + ADDEXPR ("uid !~ @"); + if (recsel_select (se, test_2_getval, NULL)) + fail (0, 0); + + FREEEXPR(); + ADDEXPR ("uid =~ foo@"); + if (!recsel_select (se, test_2_getval, NULL)) + fail (0, 0); + FREEEXPR(); + ADDEXPR ("uid =~ oo@"); + if (!recsel_select (se, test_2_getval, NULL)) + fail (0, 0); + FREEEXPR(); + /* Again but with left anchored substring. */ + ADDEXPR ("-^ uid =~ foo@"); if (!recsel_select (se, test_2_getval, NULL)) fail (0, 0); + FREEEXPR(); + ADDEXPR ("-^ uid =~ oo@"); + if (recsel_select (se, test_2_getval, NULL)) + fail (0, 0); FREEEXPR(); ADDEXPR ("keyid == 0x12345678"); |