зеркало из https://github.com/github/ruby.git
parse.y: trim newline in erred code
* parse.y (parser_yyerror): trim a newline at the end of the erred code which was replaced with an extra space in the succeeding cursor line. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0a5b4c13ad
Коммит
60023cf452
1
parse.y
1
parse.y
|
@ -4689,6 +4689,7 @@ parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
|
|||
|
||||
pt = (p->ruby_sourceline == yylloc->end_pos.lineno) ?
|
||||
p->lex.pbeg + yylloc->end_pos.column : p->lex.pend;
|
||||
if ((p->lex.pbeg < pt) && (*(pt-1) == '\n')) pt--;
|
||||
ptr = ptr_end = pt < pend ? pt : pend;
|
||||
lim = ptr - p->lex.pbeg > max_line_margin ? ptr - max_line_margin : p->lex.pbeg;
|
||||
while ((lim < ptr) && (*(ptr-1) != '\n')) ptr--;
|
||||
|
|
|
@ -1142,6 +1142,12 @@ eom
|
|||
end;
|
||||
end
|
||||
|
||||
def test_syntax_error_at_newline
|
||||
expected = "\n ^"
|
||||
assert_syntax_error("%[abcdef", expected)
|
||||
assert_syntax_error("%[abcdef\n", expected)
|
||||
end
|
||||
|
||||
def test_invalid_jump
|
||||
assert_in_out_err(%w[-e redo], "", [], /^-e:1: /)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче