diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-12 06:59:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-12 06:59:57 +0000 |
commit | c48b4209c267299f52ad51b0e8d639679999465a (patch) | |
tree | 0eccd86184fdd6bebf2bb47fd26dd9e2d4646413 | |
parent | 9af743fe0e8c7aa7a25a6805a64d499aab3032af (diff) | |
download | ruby-c48b4209c267299f52ad51b0e8d639679999465a.tar.gz |
parse.y: CR in middle
* parse.y (parser_whole_match_p): treat CR in middle of a line as a
mere whitespace.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 6 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 8 |
3 files changed, 18 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Mon Aug 12 15:59:50 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_whole_match_p): treat CR in middle of a line as a + mere whitespace. + Mon Aug 12 15:16:58 2013 Koichi Sasada <ko1@atdot.net> * class.c (rb_prepend_module): make T_ICLASS object shady because @@ -6375,7 +6375,11 @@ parser_whole_match_p(struct parser_params *parser, while (*p && ISSPACE(*p)) p++; } n = lex_pend - (p + len); - if (n < 0 || (n > 0 && p[len] != '\n' && p[len] != '\r')) return FALSE; + if (n < 0) return FALSE; + if (n > 0 && p[len] != '\n') { + if (p[len] != '\r') return FALSE; + if (n <= 1 || p[len+1] != '\n') return FALSE; + } return strncmp(eos, p, len) == 0; } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 99470691ef..f5ff8a7810 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -377,6 +377,14 @@ eom EOS end + def test_heredoc_cr + assert_syntax_error("puts <<""EOS\n""ng\n""EOS\r""NO\n", /can't find string "EOS" anywhere before EOF/) + end + + def test__END___cr + assert_syntax_error("__END__\r<<<<<\n", /unexpected <</) + end + private def not_label(x) @result = x; @not_label ||= nil end |