mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
9a07915ae2
commit
aa8d393d8a
2 changed files with 5 additions and 1 deletions
4
parse.y
4
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;
|
||||
|
|
2
ruby.c
2
ruby.c
|
@ -2011,7 +2011,7 @@ load_file_internal(VALUE argp_v)
|
|||
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))) {
|
||||
|
|
Loading…
Add table
Reference in a new issue