merge revision(s) 58080,58138: [Backport #13363]

keep line number after unterminated string literal

	* parse.y (parser_parse_string): keep line number even after an
	  unterminated string literal.  it does not matter in the parser,
	  ripper needs this value after this error.
	parse.y: unterminated content token

	* parse.y (parser_parse_string): defer the end token to next
	  reading, to yield tSTRING_CONTENT with the unterminated content.
	  [Bug #13363]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2017-04-30 13:59:21 +00:00
parent 410c048a3a
commit c884cbd810
4 changed files with 26 additions and 9 deletions

View file

@ -1,3 +1,17 @@
Sun Apr 30 22:55:41 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
keep line number after unterminated string literal
* parse.y (parser_parse_string): keep line number even after an
unterminated string literal. it does not matter in the parser,
ripper needs this value after this error.
parse.y: unterminated content token
* parse.y (parser_parse_string): defer the end token to next
reading, to yield tSTRING_CONTENT with the unterminated content.
[Bug #13363]
Sun Apr 30 22:52:38 2017 Marcus Stollsteimer <sto.mar@web.de>
* io.c: [DOC] expand docs for IO#puts

View file

@ -6502,16 +6502,14 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
pushback(c);
if (tokadd_string(func, term, paren, &quote->nd_nest,
&enc) == -1) {
ruby_sourceline = nd_line(quote);
if (parser->eofp) {
if (func & STR_FUNC_REGEXP) {
if (parser->eofp)
compile_error(PARSER_ARG "unterminated regexp meets end of file");
return tREGEXP_END;
}
else {
if (parser->eofp)
compile_error(PARSER_ARG "unterminated string meets end of file");
return tSTRING_END;
}
quote->u2.id = -1;
}
}

View file

@ -109,6 +109,9 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
[[3, 0], :on_heredoc_end, "EOS"]
],
Ripper.lex("<<~EOS\n heredoc\nEOS")
assert_equal [[[1, 0], :on_tstring_beg, "'"],
[[1, 1], :on_tstring_content, "foo"]],
Ripper.lex("'foo")
end
def test_location
@ -131,6 +134,8 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
assert_location %Q["a\nb\r\nc"]
assert_location "print(<<""EOS)\nheredoc\nEOS\n"
assert_location "print(<<-\"EOS\")\nheredoc\n EOS\n"
assert_location "'foo'"
assert_location "'foo"
end
def assert_location(src)

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.5"
#define RUBY_RELEASE_DATE "2017-04-30"
#define RUBY_PATCHLEVEL 307
#define RUBY_PATCHLEVEL 308
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 4