parse.y: attrset from junk ID
* 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/trunk@44926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bb7ae984f8
commit
5b56c1c42b
@ -1,3 +1,10 @@
|
|||||||
|
Thu Feb 13 15:43:16 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]
|
||||||
|
|
||||||
Thu Feb 13 11:06:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Feb 13 11:06:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: check if pthread_setname_np is available.
|
* configure.in: check if pthread_setname_np is available.
|
||||||
|
5
parse.y
5
parse.y
@ -10222,7 +10222,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_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
|
static int
|
||||||
rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
|
rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
|
||||||
@ -10309,7 +10309,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;
|
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
|
||||||
type = ID_JUNK;
|
type = ID_JUNK;
|
||||||
++m;
|
++m;
|
||||||
break;
|
if (m + 1 < e || *m != '=') break;
|
||||||
|
/* fall through */
|
||||||
case '=':
|
case '=':
|
||||||
if (!(allowed_attrset & (1U << type))) return -1;
|
if (!(allowed_attrset & (1U << type))) return -1;
|
||||||
type = ID_ATTRSET;
|
type = ID_ATTRSET;
|
||||||
|
@ -115,6 +115,10 @@ module Test_Symbol
|
|||||||
assert_equal(:"[foo]=", Bug::Symbol.attrset("[foo]"))
|
assert_equal(:"[foo]=", Bug::Symbol.attrset("[foo]"))
|
||||||
assert_symtype(Bug::Symbol.attrset("[foo]"), :attrset?)
|
assert_symtype(Bug::Symbol.attrset("[foo]"), :attrset?)
|
||||||
assert_equal(:[]=, Bug::Symbol.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
|
end
|
||||||
end
|
end
|
||||||
|
@ -289,6 +289,8 @@ module TestStruct
|
|||||||
x = Object.new
|
x = Object.new
|
||||||
o = klass.new("test", x)
|
o = klass.new("test", x)
|
||||||
assert_same(x, o.b?)
|
assert_same(x, o.b?)
|
||||||
|
o.send("b?=", 42)
|
||||||
|
assert_equal(42, o.b?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bang_mark_in_member
|
def test_bang_mark_in_member
|
||||||
@ -296,6 +298,8 @@ module TestStruct
|
|||||||
x = Object.new
|
x = Object.new
|
||||||
o = klass.new("test", x)
|
o = klass.new("test", x)
|
||||||
assert_same(x, o.b!)
|
assert_same(x, o.b!)
|
||||||
|
o.send("b!=", 42)
|
||||||
|
assert_equal(42, o.b!)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_setter_method_returns_value
|
def test_setter_method_returns_value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user