1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 78b4b981cf839312bcb8ef26f3a422f70fc072a4 Mon Sep 17 00:00:00 2001
From: Ivan Samsonov <[email protected]>
Date: Wed, 6 Jan 2010 09:37:21 +0300
Subject: [PATCH] Fix String#hex spec

---
 spec/tags/ruby/core/string/hex_tags.txt |    1 -
 vm/builtin/string.cpp                   |   11 ++++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
 delete mode 100644 spec/tags/ruby/core/string/hex_tags.txt

diff --git a/spec/tags/ruby/core/string/hex_tags.txt b/spec/tags/ruby/core/string/hex_tags.txt
deleted file mode 100644
index 5cfbe37..0000000
--- a/spec/tags/ruby/core/string/hex_tags.txt
+++ /dev/null
@@ -1 +0,0 @@
-fails:String#hex does not accept a sequence of underscores as part of a number
diff --git a/vm/builtin/string.cpp b/vm/builtin/string.cpp
index 81f3892..ccc35b0 100644
--- a/vm/builtin/string.cpp
+++ b/vm/builtin/string.cpp
@@ -638,9 +638,14 @@ namespace rubinius {
       // If it's an underscore, remember that. An underscore is valid iff
       // it followed by a valid character for this base.
       if(chr == '_') {
-        // Double underscore is forbidden in strict mode.
-        if(underscore && strict == Qtrue) {
-          return (Integer*)Qnil;
+        if(underscore) {
+          // Double underscore is forbidden in strict mode.
+          if(strict == Qtrue) {
+            return (Integer*)Qnil;
+          } else {
+            // Stop parse number after two underscores in a row
+            goto return_value;
+          }
         }
         underscore = true;
         continue;
-- 
1.6.1