Permalink
Browse files

Captureless Matches generically get pseudo [0]

  • Loading branch information...
1 parent 891071d commit c7b485208df448a4c427b912e01fd6390350f966 @sorear committed Feb 25, 2011
Showing with 13 additions and 3 deletions.
  1. +7 −0 lib/Cursor.cs
  2. +1 −3 lib/SAFE.setting
  3. +5 −0 test2.pl
View
@@ -585,11 +585,15 @@ public Cursor(IP6 proto, string text, IP6 actions)
it = it.prev;
}
+ if (str == "0" && caps.Count() == 0)
+ caps.Unshift(Kernel.NewROScalar(this));
+
return FixupList(caps);
}
public void UnpackCaps(IP6 into) {
List<VarDeque> posr = new List<VarDeque>();
+ posr.Add(new VarDeque());
Dictionary<string,VarDeque> namr = new Dictionary<string,VarDeque>();
CapInfo it = captures;
@@ -609,6 +613,9 @@ public Cursor(IP6 proto, string text, IP6 actions)
it = it.prev;
}
+ if (posr[0].Count() == 0)
+ posr[0].Unshift(Kernel.NewROScalar(this));
+
VarHash nam = new VarHash();
Variable[] pos = new Variable[posr.Count];
View
@@ -1024,9 +1024,7 @@ my class Regex is Sub {
(ternary (iter_hasflat (l iter))
(letn val (vvarlist_shift (l iter))
(set_status (s $*/) (l val))
- (return (ternary
- (obj_getdef (obj_at_key (l val) {"0"}))
- (newrwlistvar (@ (l val))) (l val))))
+ (return (newrwlistvar (@ (l val))) (l val)))
(prog))))
(set_status (s $*/) {Match})
{Any})
View
@@ -2,6 +2,11 @@
use Test;
use MONKEY_TYPING;
+{
+ "foo" ~~ /\w+/;
+ is $0, "foo", 'Match[0] returns whole match if no parens';
+}
+
#is $?FILE, 'test.pl', '$?FILE works';
#is $?ORIG.substr(0,5), '# vim', '$?ORIG works';

0 comments on commit c7b4852

Please sign in to comment.