summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-04 09:24:17 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-04 09:24:17 +0900
commitaa8d393d8a69d1a5780d338692f75e2dd821c5b0 (patch)
treee1fd917a1fb60972107646eb987dc23307a04b7c /parse.y
parent9a07915ae21d5a8e39d7dab6b609be033f2e2d7d (diff)
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.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y4
1 files changed, 4 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 311bbba80b..a35b526ab3 100644
--- a/parse.y
+++ b/parse.y
@@ -6015,6 +6015,10 @@ nextline(struct parser_params *p)
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;