Skip to content

Instantly share code, notes, and snippets.

@kronos
Created February 5, 2010 02:46
Show Gist options
  • Save kronos/295440 to your computer and use it in GitHub Desktop.
Save kronos/295440 to your computer and use it in GitHub Desktop.
From 5230be23327e670e4d33bfc40c7209145ab02b7b Mon Sep 17 00:00:00 2001
From: Ivan Samsonov <hronya@gmail.com>
Date: Fri, 5 Feb 2010 05:45:38 +0300
Subject: [PATCH] Repair $~ variable
---
kernel/common/string.rb | 1 +
kernel/delta/kernel.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/kernel/common/string.rb b/kernel/common/string.rb
index c811f0e..132b613 100644
--- a/kernel/common/string.rb
+++ b/kernel/common/string.rb
@@ -1297,6 +1297,7 @@ class String
def rpartition(pattern)
if pattern.kind_of? Regexp
if m = pattern.search_region(self, 0, size, false)
+ Rubinius::VariableScope.of_sender.last_match = m
[m.pre_match, m[0], m.post_match]
end
else
diff --git a/kernel/delta/kernel.rb b/kernel/delta/kernel.rb
index 2f7dbe3..1d6d708 100644
--- a/kernel/delta/kernel.rb
+++ b/kernel/delta/kernel.rb
@@ -76,7 +76,7 @@ module Kernel
# Same as $!, for any accesses we might miss.
# HACK. I doubt this is correct, because of how it will be called.
- get = proc { Regex.last_match }
+ get = proc { Regexp.last_match }
Rubinius::Globals.set_hook(:$~, get, nil)
get = proc { ARGV }
--
1.6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment