1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
parent 60bddf589f
commit b6468b01f7

13
parse.y
View file

@ -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);
}