Skip to content

Commit

Permalink
Revert "Warn EOF char in comment"
Browse files Browse the repository at this point in the history
This reverts commit 69ec3f7.
  • Loading branch information
nurse committed Nov 11, 2019
1 parent ba5b51c commit fd69f82
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
29 changes: 4 additions & 25 deletions parse.y
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 0 additions & 9 deletions test/ruby/test_parse.rb
Expand Up @@ -720,15 +720,6 @@ def test_embedded_rd_error
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 `_'/)
Expand Down
6 changes: 0 additions & 6 deletions test/ruby/test_syntax.rb
Expand Up @@ -943,12 +943,6 @@ def test_warning_for_cr
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)
Expand Down

0 comments on commit fd69f82

Please sign in to comment.