Show unkwon regexp option line

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-03-12 04:23:17 +00:00
Родитель 60bddf589f
Коммит b6468b01f7
1 изменённых файлов: 11 добавлений и 2 удалений

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

@ -5633,9 +5633,18 @@ regx_options(struct parser_params *p)
options |= kopt;
pushback(p, c);
if (toklen(p)) {
static const char mesg[] = "unknown regexp options";
static const char sep[] = " - ";
const int mlen = (int)(sizeof(mesg) - 1 - (toklen(p) == 1));
const int seplen = (int)(sizeof(sep) - 1);
YYLTYPE loc;
RUBY_SET_YYLLOC(loc);
tokfix(p);
compile_error(p, "unknown regexp option%s - %*s",
toklen(p) > 1 ? "s" : "", toklen(p), tok(p));
tokspace(p, toklen(p) + mlen + seplen);
memmove(tok(p) + mlen + seplen, tok(p), toklen(p) + 1);
memcpy(tok(p), mesg, mlen);
memcpy(tok(p) + mlen, sep, seplen);
yyerror1(&loc, tok(p));
}
return options | RE_OPTION_ENCODING(kcode);
}