From ce90fcdbbd53f002e86a50be3b61a72df3588ca0 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 13 Jun 2011 14:38:26 +0000 Subject: [PATCH] * parse.y (parser_parse_string): flush delayed token. based on a patch by Masaya Tarui in [ruby-dev:43762]. Bug #4544 * parse.y (yylex): revert r24557. delayed token at the end of string should be flushed already by the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ parse.y | 13 +++++++++++++ test/ripper/test_scanner_events.rb | 17 +++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bd5332a9b..a32b2107b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Jun 13 23:38:23 2011 Nobuyoshi Nakada + + * parse.y (parser_parse_string): flush delayed token. based on a + patch by Masaya Tarui in [ruby-dev:43762]. Bug #4544 + + * parse.y (yylex): revert r24557. delayed token at the end of + string should be flushed already by the above change. + Mon Jun 13 23:33:31 2011 Nobuyoshi Nakada * ext/io/console/console.c (console_dev): console should be diff --git a/parse.y b/parse.y index 06f96ce6cd..60e5a3b8b1 100644 --- a/parse.y +++ b/parse.y @@ -5984,6 +5984,18 @@ parser_parse_string(struct parser_params *parser, NODE *quote) tokfix(); set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); + +#ifdef RIPPER + if (!NIL_P(parser->delayed)){ + ptrdiff_t len = lex_p - parser->tokp; + if (len > 0) { + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } + ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); + parser->tokp = lex_p; + } +#endif + return tSTRING_CONTENT; } @@ -7853,6 +7865,7 @@ yylex(void *p) #ifdef RIPPER if (!NIL_P(parser->delayed)) { ripper_dispatch_delayed_token(parser, t); + return t; } if (t != 0) ripper_dispatch_scan_event(parser, t); diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 25e4b13e6c..9005e46f4e 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -67,10 +67,17 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase [[3, 0], :on_heredoc_end, "EOS"]], Ripper.lex("<