* parse.y (parser_read_escape, parser_tokadd_escape): allow a hex or
octal encoded character after \c. This seemed to be prohibited at r13836, but its ChangeLog mentions nothing about this prohibition. So I assume this prohibition is not intended. [ruby-core:27229] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
11e078fb04
commit
3cd67ce505
@ -1,3 +1,10 @@
|
|||||||
|
Sun May 16 21:51:04 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* parse.y (parser_read_escape, parser_tokadd_escape): allow a hex or
|
||||||
|
octal encoded character after \c. This seemed to be prohibited at
|
||||||
|
r13836, but its ChangeLog mentions nothing about this prohibition.
|
||||||
|
So I assume this prohibition is not intended. [ruby-core:27229]
|
||||||
|
|
||||||
Sun May 16 21:14:04 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Sun May 16 21:14:04 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* ruby/test_rubyoptions.rb (TestRubyOptions#test_segv_test):
|
* ruby/test_rubyoptions.rb (TestRubyOptions#test_segv_test):
|
||||||
|
4
parse.y
4
parse.y
@ -5568,14 +5568,12 @@ parser_read_escape(struct parser_params *parser, int flags,
|
|||||||
|
|
||||||
case '0': case '1': case '2': case '3': /* octal constant */
|
case '0': case '1': case '2': case '3': /* octal constant */
|
||||||
case '4': case '5': case '6': case '7':
|
case '4': case '5': case '6': case '7':
|
||||||
if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
|
|
||||||
pushback(c);
|
pushback(c);
|
||||||
c = scan_oct(lex_p, 3, &numlen);
|
c = scan_oct(lex_p, 3, &numlen);
|
||||||
lex_p += numlen;
|
lex_p += numlen;
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
case 'x': /* hex constant */
|
case 'x': /* hex constant */
|
||||||
if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
|
|
||||||
c = tok_hex(&numlen);
|
c = tok_hex(&numlen);
|
||||||
if (numlen == 0) return 0;
|
if (numlen == 0) return 0;
|
||||||
return c;
|
return c;
|
||||||
@ -5648,7 +5646,6 @@ parser_tokadd_escape(struct parser_params *parser, rb_encoding **encp)
|
|||||||
|
|
||||||
case '0': case '1': case '2': case '3': /* octal constant */
|
case '0': case '1': case '2': case '3': /* octal constant */
|
||||||
case '4': case '5': case '6': case '7':
|
case '4': case '5': case '6': case '7':
|
||||||
if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
|
|
||||||
{
|
{
|
||||||
ruby_scan_oct(--lex_p, 3, &numlen);
|
ruby_scan_oct(--lex_p, 3, &numlen);
|
||||||
if (numlen == 0) goto eof;
|
if (numlen == 0) goto eof;
|
||||||
@ -5658,7 +5655,6 @@ parser_tokadd_escape(struct parser_params *parser, rb_encoding **encp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case 'x': /* hex constant */
|
case 'x': /* hex constant */
|
||||||
if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
|
|
||||||
{
|
{
|
||||||
tok_hex(&numlen);
|
tok_hex(&numlen);
|
||||||
if (numlen == 0) goto eof;
|
if (numlen == 0) goto eof;
|
||||||
|
@ -54,11 +54,14 @@ class TestRubyLiteral < Test::Unit::TestCase
|
|||||||
assert_equal "\n", "\n"
|
assert_equal "\n", "\n"
|
||||||
bug2500 = '[ruby-core:27228]'
|
bug2500 = '[ruby-core:27228]'
|
||||||
%w[c C- M-].each do |pre|
|
%w[c C- M-].each do |pre|
|
||||||
["u", "x", %w[u{ }]].each do |open, close|
|
["u", %w[u{ }]].each do |open, close|
|
||||||
str = "\"\\#{pre}\\#{open}5555#{close}\""
|
str = "\"\\#{pre}\\#{open}5555#{close}\""
|
||||||
assert_raise(SyntaxError, "#{bug2500} eval(#{str})") {eval(str)}
|
assert_raise(SyntaxError, "#{bug2500} eval(#{str})") {eval(str)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
assert_equal "\x13", "\c\x33"
|
||||||
|
assert_equal "\x13", "\C-\x33"
|
||||||
|
assert_equal "\xB3", "\M-\x33"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dstring
|
def test_dstring
|
||||||
|
Loading…
x
Reference in New Issue
Block a user