Created
September 29, 2010 00:37
-
-
Save kronos/602088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 5d1905e0feff7f6a80e1194b52b81ba6b7fc6ba1 Mon Sep 17 00:00:00 2001 | |
| From: Ivan Samsonov <[email protected]> | |
| Date: Wed, 29 Sep 2010 04:29:23 +0400 | |
| Subject: [PATCH 1/2] Add additional String#split spec using single space pattern | |
| --- | |
| spec/ruby/core/string/split_spec.rb | 1 + | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb | |
| index b6927c6..665fb21 100644 | |
| --- a/spec/ruby/core/string/split_spec.rb | |
| +++ b/spec/ruby/core/string/split_spec.rb | |
| @@ -82,6 +82,7 @@ describe "String#split with String" do | |
| it "ignores leading and continuous whitespace when string is a single space" do | |
| " now's the time ".split(' ').should == ["now's", "the", "time"] | |
| " now's the time ".split(' ', -1).should == ["now's", "the", "time", ""] | |
| + " now's the time ".split(' ', 3).should == ["now's", "the", "time "] | |
| "\t\n a\t\tb \n\r\r\nc\v\vd\v ".split(' ').should == ["a", "b", "c", "d"] | |
| "a\x00a b".split(' ').should == ["a\x00a", "b"] | |
| -- | |
| 1.6.6.1 | |
| From 96d85b42affdddbe6629a73aa8a6948095095169 Mon Sep 17 00:00:00 2001 | |
| From: Ivan Samsonov <[email protected]> | |
| Date: Wed, 29 Sep 2010 04:30:58 +0400 | |
| Subject: [PATCH 2/2] Fix String#split edge case. Fixes #505 | |
| --- | |
| kernel/common/string.rb | 2 +- | |
| 1 files changed, 1 insertions(+), 1 deletions(-) | |
| diff --git a/kernel/common/string.rb b/kernel/common/string.rb | |
| index 72445fb..92b2019 100644 | |
| --- a/kernel/common/string.rb | |
| +++ b/kernel/common/string.rb | |
| @@ -1673,7 +1673,7 @@ class String | |
| collapsed = match.collapsing? | |
| - if !collapsed || (match.begin(0) != 0) | |
| + unless (collapsed || spaces) && (match.begin(0) == 0) | |
| ret << match.pre_match_from(last_match ? last_match.end(0) : 0) | |
| ret.push(*match.captures.compact) | |
| end | |
| -- | |
| 1.6.6.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment