Skip to content

Commit

Permalink
merges r32067 from trunk into ruby_1_9_2.
Browse files Browse the repository at this point in the history
--
* parse.y (parser_parse_string): flush delayed token.  based on a
  patch by Masaya Tarui in [ruby-dev:43762].  Bug ruby#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/branches/ruby_1_9_2@32384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
yugui committed Jul 3, 2011
1 parent 877a9a7 commit 78f0aeb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
Mon Jun 13 23:38:23 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>

* 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:05:01 2011 Tanaka Akira <akr@fsij.org>

* ext/socket/unixsocket.c (unix_send_io): race condition fixed.
Expand Down
4 changes: 2 additions & 2 deletions ext/socket/unixsocket.c
Expand Up @@ -248,7 +248,7 @@ unix_send_io(VALUE sock, VALUE val)
#endif

arg.fd = fptr->fd;
while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) {
while ((int)BLOCKING_REGION(sendmsg_blocking, &arg) == -1) {
if (!rb_io_wait_writable(arg.fd))
rb_sys_fail("sendmsg(2)");
}
Expand Down Expand Up @@ -335,7 +335,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
#endif

arg.fd = fptr->fd;
while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
while ((int)BLOCKING_REGION(recvmsg_blocking, &arg) == -1) {
if (!rb_io_wait_readable(arg.fd))
rb_sys_fail("recvmsg(2)");
}
Expand Down
13 changes: 13 additions & 0 deletions parse.y
Expand Up @@ -5973,6 +5973,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;
}

Expand Down Expand Up @@ -7821,6 +7833,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);
Expand Down
17 changes: 15 additions & 2 deletions test/ripper/test_scanner_events.rb
Expand Up @@ -67,10 +67,17 @@ def test_lex
[[3, 0], :on_heredoc_end, "EOS"]],
Ripper.lex("<<EOS\nheredoc\nEOS")
assert_equal [[[1, 0], :on_regexp_beg, "/"],
[[1, 1], :on_tstring_content, "foo\n"],
[[2, 0], :on_tstring_content, "bar"],
[[1, 1], :on_tstring_content, "foo\nbar"],
[[2, 3], :on_regexp_end, "/"]],
Ripper.lex("/foo\nbar/")
assert_equal [[[1, 0], :on_regexp_beg, "/"],
[[1, 1], :on_tstring_content, "foo\n\u3020"],
[[2, 3], :on_regexp_end, "/"]],
Ripper.lex("/foo\n\u3020/")
assert_equal [[[1, 0], :on_tstring_beg, "'"],
[[1, 1], :on_tstring_content, "foo\n\xe3\x80\xa0"],
[[2, 3], :on_tstring_end, "'"]],
Ripper.lex("'foo\n\xe3\x80\xa0'")
end

def test_location
Expand Down Expand Up @@ -534,6 +541,12 @@ def test_tstring_content
scan('tstring_content', '"abc#{1}def"')
assert_equal ['sym'],
scan('tstring_content', ':"sym"')
assert_equal ['a b c'],
scan('tstring_content', ':"a b c"'),
"bug#4544"
assert_equal ["a\nb\nc"],
scan('tstring_content', ":'a\nb\nc'"),
"bug#4544"
end

def test_tstring_end
Expand Down
2 changes: 1 addition & 1 deletion version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_PATCHLEVEL 283
#define RUBY_PATCHLEVEL 284
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1
Expand Down

0 comments on commit 78f0aeb

Please sign in to comment.