summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-15 14:53:00 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-15 14:53:00 +0000
commitf9acab1f4298f909624440d98996ffe1b7b6da82 (patch)
tree0628d29da1cfce380822fcc89a579fd333eb7c05
parent4f8090c71cca18a8f7c1b923f398cc9d6712f810 (diff)
merge revision(s) r44926: [Backport #8756] [Backport #9248]
* parse.y (IDSET_ATTRSET_FOR_INTERN): fix off-by-one bug. * parse.y (rb_enc_symname_type): junk ID succeeded by '=' is also attrset ID. [ruby-core:60668] [Bug #8756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--parse.y5
-rw-r--r--test/-ext-/symbol/test_type.rb4
-rw-r--r--test/ruby/test_struct.rb4
-rw-r--r--version.h2
5 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index aee5139145..4a120205cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Feb 15 23:46:31 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (IDSET_ATTRSET_FOR_INTERN): fix off-by-one bug.
+
+ * parse.y (rb_enc_symname_type): junk ID succeeded by '=' is also
+ attrset ID. [ruby-core:60668] [Bug #8756]
+
Sat Feb 15 23:42:04 2014 Richo Healy <richo@psych0tik.net>
* test/ruby/test_struct.rb: Add regression test for question marks and
diff --git a/parse.y b/parse.y
index 9f10260eae..da512a6243 100644
--- a/parse.y
+++ b/parse.y
@@ -10095,7 +10095,7 @@ rb_enc_symname_p(const char *name, rb_encoding *enc)
}
#define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
-#define IDSET_ATTRSET_FOR_INTERN (~(~0U<<ID_SCOPE_MASK) & ~(1U<<ID_ATTRSET))
+#define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
static int
rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_atttset)
@@ -10181,7 +10181,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
type = ID_JUNK;
++m;
- break;
+ if (m + 1 < e || *m != '=') break;
+ /* fall through */
case '=':
if (!(allowed_atttset & (1U << type))) return -1;
type = ID_ATTRSET;
diff --git a/test/-ext-/symbol/test_type.rb b/test/-ext-/symbol/test_type.rb
index d6816754c8..034d8bc0fd 100644
--- a/test/-ext-/symbol/test_type.rb
+++ b/test/-ext-/symbol/test_type.rb
@@ -105,6 +105,10 @@ module Test_Symbol
assert_equal(:"[foo]=", Bug::Symbol.attrset("[foo]"))
assert_symtype(Bug::Symbol.attrset("[foo]"), :attrset?)
assert_equal(:[]=, Bug::Symbol.attrset(:[]))
+ assert_symtype(Bug::Symbol.attrset("foo?="), :attrset?)
+ assert_equal(:"foo?=", Bug::Symbol.attrset(:foo?))
+ assert_symtype(Bug::Symbol.attrset("foo!="), :attrset?)
+ assert_equal(:"foo!=", Bug::Symbol.attrset(:foo!))
end
end
end
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index ee8bf3184a..72cb5f480b 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -319,6 +319,8 @@ module TestStruct
x = Object.new
o = klass.new("test", x)
assert_same(x, o.b?)
+ o.send("b?=", 42)
+ assert_equal(42, o.b?)
end
def test_bang_mark_in_member
@@ -326,6 +328,8 @@ module TestStruct
x = Object.new
o = klass.new("test", x)
assert_same(x, o.b!)
+ o.send("b!=", 42)
+ assert_equal(42, o.b!)
end
class TopStruct < Test::Unit::TestCase
diff --git a/version.h b/version.h
index 4cd7aecb74..159c12e06b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2014-02-15"
-#define RUBY_PATCHLEVEL 409
+#define RUBY_PATCHLEVEL 410
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 2