diff options
author | Oliver Kiddle <opk@zsh.org> | 2024-01-26 07:33:38 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2024-01-26 07:33:38 +0100 |
commit | 698af7bc1387462c8e87767d7eaeb7e30c6f0b2b (patch) | |
tree | 1c21f23ef05fc90b5747e41c5d7d0915f9096071 /Src | |
parent | 742049a4cbd9c4f1683081cb812aef994415f112 (diff) | |
download | zsh-698af7bc1387462c8e87767d7eaeb7e30c6f0b2b.tar.gz zsh-698af7bc1387462c8e87767d7eaeb7e30c6f0b2b.tar.xz zsh-698af7bc1387462c8e87767d7eaeb7e30c6f0b2b.zip |
52405, 52502: add empty elements to $match for optional captures that don't match
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Modules/pcre.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index e48ae3ae5..a49d1a307 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -391,6 +391,8 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)) pcre_mdata = pcre2_match_data_create_from_pattern(pcre_pattern, NULL); ret = pcre2_match(pcre_pattern, (PCRE2_SPTR) plaintext, subject_len, offset_start, 0, pcre_mdata, mcontext); + if (ret > 0) + ret = pcre2_get_ovector_count(pcre_mdata); } if (ret==0) return_value = 0; @@ -479,7 +481,8 @@ cond_pcre_match(char **a, int id) break; } else if (r>0) { - zpcre_get_substrings(pcre_pat, lhstr_plain, pcre_mdata, r, svar, avar, + uint32_t ovec_count = pcre2_get_ovector_count(pcre_mdata); + zpcre_get_substrings(pcre_pat, lhstr_plain, pcre_mdata, ovec_count, svar, avar, ".pcre.match", 0, isset(BASHREMATCH), !isset(BASHREMATCH)); return_value = 1; break; |