ruby-changes:55986
From: Nobuyoshi <ko1@a...>
Date: Tue, 4 Jun 2019 09:36:33 +0900 (JST)
Subject: [ruby-changes:55986] Nobuyoshi Nakada: aa8d393d8a (trunk): EOF by 2 ^D on a TTY
https://git.ruby-lang.org/ruby.git/commit/?id=aa8d393d8a From aa8d393d8a69d1a5780d338692f75e2dd821c5b0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 4 Jun 2019 09:24:17 +0900 Subject: EOF by 2 ^D on a TTY Terminate the input from a TTY by 2 ^D at the middle of line, like as many programs, `cat`, `perl` and so on, do. By the first ^D, the line will be sent without a newline, and then EOF will be send by the next ^D. diff --git a/parse.y b/parse.y index 311bbba..a35b526 100644 --- a/parse.y +++ b/parse.y @@ -6015,6 +6015,10 @@ nextline(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L6015 if (p->eofp) return -1; + if (p->lex.pend > p->lex.pbeg && *(p->lex.pend-1) != '\n') { + goto end_of_input; + } + if (!p->lex.input || NIL_P(v = lex_getline(p))) { end_of_input: p->eofp = 1; diff --git a/ruby.c b/ruby.c index 944b6c7..e016197 100644 --- a/ruby.c +++ b/ruby.c @@ -2011,7 +2011,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L2011 else if (!NIL_P(c)) { rb_io_ungetbyte(f, c); } - else { + if (NIL_P(c)) { argp->f = f = Qnil; } if (!(opt->dump & ~DUMP_BIT(version_v))) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/