diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-12 04:23:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-12 04:23:17 +0000 |
commit | b6468b01f7288789ef2e9bf548d81cdadb8ef053 (patch) | |
tree | cb92645db1dcc873aff0aa9a0c3f9e45afacd6f3 /parse.y | |
parent | 60bddf589fb518c6b84515749775dc78458aeaad (diff) | |
download | ruby-b6468b01f7288789ef2e9bf548d81cdadb8ef053.tar.gz |
Show unkwon regexp option line
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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); } |