ruby-changes:55019
From: nobu <ko1@a...>
Date: Tue, 12 Mar 2019 13:23:22 +0900 (JST)
Subject: [ruby-changes:55019] nobu:r67226 (trunk): Show unkwon regexp option line
nobu 2019-03-12 13:23:17 +0900 (Tue, 12 Mar 2019) New Revision: 67226 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67226 Log: Show unkwon regexp option line Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 67225) +++ parse.y (revision 67226) @@ -5633,9 +5633,18 @@ regx_options(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L5633 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/