Revert "Warn EOF char in comment"

This reverts commit 69ec3f70fa.
This commit is contained in:
NARUSE, Yui 2019-11-11 17:37:21 +09:00
Родитель ba5b51ca59
Коммит fd69f82675
3 изменённых файлов: 4 добавлений и 40 удалений

29
parse.y
Просмотреть файл

@ -6191,30 +6191,7 @@ parser_str_new(const char *ptr, long len, rb_encoding *enc, int func, rb_encodin
return str;
}
static const char *
eof_char(int c)
{
switch (c) {
case '\0': return "\\0";
case '\004': return "^D";
case '\032': return "^Z";
}
return 0;
}
static void
lex_goto_eol(struct parser_params *p)
{
const char *pcur = p->lex.pcur, *pend = p->lex.pend;
for (; pcur < pend; pcur++) {
const char *eof = eof_char(*pcur);
if (eof) {
rb_warning1("encountered %s in comment, just ignored in this version", WARN_S(eof));
break;
}
}
p->lex.pcur = pend; /* pcur */
}
#define lex_goto_eol(p) ((p)->lex.pcur = (p)->lex.pend)
#define lex_eol_p(p) ((p)->lex.pcur >= (p)->lex.pend)
#define lex_eol_n_p(p,n) ((p)->lex.pcur+(n) >= (p)->lex.pend)
#define peek(p,c) peek_n(p, (c), 0)
@ -7421,7 +7398,9 @@ word_match_p(struct parser_params *p, const char *word, long len)
if (p->lex.pcur + len == p->lex.pend) return 1;
int c = (unsigned char)p->lex.pcur[len];
if (ISSPACE(c)) return 1;
if (eof_char(c)) return 1;
switch (c) {
case '\0': case '\004': case '\032': return 1;
}
return 0;
}

Просмотреть файл

@ -720,15 +720,6 @@ x = __ENCODING__
assert_syntax_error("=begin", error)
end
def test_embedded_rd_warning
[["\0", "\\0"], ["\C-d", "^D"], ["\C-z", "^Z"]].each do |eof, mesg|
mesg = /encountered #{Regexp.quote(mesg)}/
assert_warning(mesg) {eval("=begin\n#{eof}\n=end")}
assert_warning(mesg) {eval("=begin#{eof}\n=end")}
assert_warning(mesg) {eval("=begin\n=end#{eof}\n")}
end
end
def test_float
assert_equal(1.0/0, eval("1e10000"))
assert_syntax_error('1_E', /trailing `_'/)

Просмотреть файл

@ -943,12 +943,6 @@ eom
end
end
def test_warning_for_eof_in_comment
assert_warning(/encountered \\0/) {eval("#\0")}
assert_warning(/encountered \^D/) {eval("#\C-d")}
assert_warning(/encountered \^Z/) {eval("#\C-z")}
end
def test_unexpected_fraction
msg = /unexpected fraction/
assert_syntax_error("0x0.0", msg)