From b6468b01f7288789ef2e9bf548d81cdadb8ef053 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 12 Mar 2019 04:23:17 +0000 Subject: [PATCH] Show unkwon regexp option line git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index 42f1ff3fe5..e42aa9b595 100644 --- a/parse.y +++ b/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); }