ruby-changes:30700
From: nobu <ko1@a...>
Date: Mon, 2 Sep 2013 23:46:36 +0900 (JST)
Subject: [ruby-changes:30700] nobu:r42779 (trunk): parse.y: valid suffix word only
nobu 2013-09-02 23:46:25 +0900 (Mon, 02 Sep 2013) New Revision: 42779 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42779 Log: parse.y: valid suffix word only * parse.y (parser_str_options): use valid suffix word only, as well as numeric literal, for the backward comatibility. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_string.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42778) +++ ChangeLog (revision 42779) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Sep 2 23:46:10 2013 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parser_str_options): use valid suffix word only, as well as + numeric literal, for the backward comatibility. + Mon Sep 2 22:55:59 2013 Tanaka Akira <akr@f...> * bignum.c (ISDIGIT): Unused macro removed. Index: parse.y =================================================================== --- parse.y (revision 42778) +++ parse.y (revision 42779) @@ -6000,8 +6000,8 @@ static int https://github.com/ruby/ruby/blob/trunk/parse.y#L6000 parser_str_options(struct parser_params *parser) { int c, options = 0; + const char *save_p = lex_p; - newtok(); while (c = nextc(), ISALPHA(c)) { switch (c) { #if STR_OPTION_FROZEN @@ -6015,18 +6015,11 @@ parser_str_options(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L6015 break; #endif default: - tokadd(c); - break; + lex_p = save_p; + return 0; } } pushback(c); - - if (toklen()) { - tokfix(); - compile_error(PARSER_ARG "unknown string option%s - %s", - toklen() > 1 ? "s" : "", tok()); - } - return options; } Index: test/ruby/test_string.rb =================================================================== --- test/ruby/test_string.rb (revision 42778) +++ test/ruby/test_string.rb (revision 42779) @@ -2194,11 +2194,14 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L2194 end def test_unknown_string_option - assert_raises(SyntaxError) do + str = nil + assert_nothing_raised(SyntaxError) do eval(%{ - "hello"x + str = begin"hello"end }) end + assert_equal "hello", str + assert_not_predicate str, :frozen? end def test_frozen_string -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/