summary refs log tree commit diff
path: root/Test/V07pcre.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-08-14 11:17:48 +0100
committerPeter Stephenson <pws@zsh.org>2017-08-14 11:17:48 +0100
commit74aff4106a4272d86c637c472a04efd46bbec07e (patch)
treef859d94e5080bb710716f43a8a421ddc4c5532cc /Test/V07pcre.ztst
parentb5f40f415668be88f451dbce956597e77f1bc056 (diff)
downloadzsh-74aff4106a4272d86c637c472a04efd46bbec07e.tar.gz
zsh-74aff4106a4272d86c637c472a04efd46bbec07e.tar.xz
zsh-74aff4106a4272d86c637c472a04efd46bbec07e.zip
41542: Fix pcre logic for extracting matched parentheses.
When we went off the end of the array but measured the length
implicitly, we got lucky before.  After 41308 we were looking up lengths
in stale memory.

Rename some variables, clean up the logic, be easier to understand.

Add tests.
Diffstat (limited to 'Test/V07pcre.ztst')
-rw-r--r--Test/V07pcre.ztst24
1 files changed, 24 insertions, 0 deletions
diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst
index ab41d33dc..9feeb47fb 100644
--- a/Test/V07pcre.ztst
+++ b/Test/V07pcre.ztst
@@ -142,9 +142,33 @@
   print $?
   [[ foo -pcre-match ^g..$ ]]
   print $?
+  [[ ! foo -pcre-match ^g..$ ]]
+  print $?
 0:infix -pcre-match works
 >0
 >1
+>0
+
+# Bash mode; note zsh documents that variables not updated on match failure,
+# which remains different from bash
+  setopt bash_rematch
+  [[ "goo" -pcre-match ^f.+$ ]] ; print $?
+  [[ "foo" -pcre-match ^f.+$ ]] ; print -l $? _${^BASH_REMATCH[@]}
+  [[ "foot" -pcre-match ^f([aeiou]+)(.)$ ]]; print -l $? _${^BASH_REMATCH[@]}
+  [[ "foo" -pcre-match ^f.+$ ]] ; print -l $? _${^BASH_REMATCH[@]}
+  [[ ! "goo" -pcre-match ^f.+$ ]] ; print $?
+  unsetopt bash_rematch
+0:bash-compatibility works
+>1
+>0
+>_foo
+>0
+>_foot
+>_oo
+>_t
+>0
+>_foo
+>0
 
 # Subshell because crash on failure
   ( setopt re_match_pcre