зеркало из https://github.com/github/ruby.git
Do not warn CR inside string literal
This commit is contained in:
Родитель
7a51d979cf
Коммит
9cdc964d07
14
parse.y
14
parse.y
|
@ -6260,11 +6260,6 @@ parser_cr(struct parser_params *p, int c)
|
|||
p->lex.pcur++;
|
||||
c = '\n';
|
||||
}
|
||||
else if (!p->cr_seen) {
|
||||
p->cr_seen = TRUE;
|
||||
/* carried over with p->lex.nextline for nextc() */
|
||||
rb_warn0("encountered \\r in middle of line, treated as a mere space");
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -8833,7 +8828,14 @@ parser_yylex(struct parser_params *p)
|
|||
return 0;
|
||||
|
||||
/* white spaces */
|
||||
case ' ': case '\t': case '\f': case '\r':
|
||||
case '\r':
|
||||
if (!p->cr_seen) {
|
||||
p->cr_seen = TRUE;
|
||||
/* carried over with p->lex.nextline for nextc() */
|
||||
rb_warn0("encountered \\r in middle of line, treated as a mere space");
|
||||
}
|
||||
/* fall through */
|
||||
case ' ': case '\t': case '\f':
|
||||
case '\13': /* '\v' */
|
||||
space_seen = 1;
|
||||
#ifdef RIPPER
|
||||
|
|
|
@ -949,9 +949,14 @@ eom
|
|||
|
||||
def test_warning_for_cr
|
||||
feature8699 = '[ruby-core:56240] [Feature #8699]'
|
||||
assert_warning(/encountered \\r/, feature8699) do
|
||||
eval("\r""__id__\r")
|
||||
s = assert_warning(/encountered \\r/, feature8699) do
|
||||
eval("'\r'\r")
|
||||
end
|
||||
assert_equal("\r", s)
|
||||
s = assert_warning('') do
|
||||
eval("'\r'\r\n")
|
||||
end
|
||||
assert_equal("\r", s)
|
||||
end
|
||||
|
||||
def test_unexpected_fraction
|
||||
|
|
Загрузка…
Ссылка в новой задаче