aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-14 07:30:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-14 07:30:41 +0000
commit791253eff274858991d987032f80c16f13752c0e (patch)
treef1ea4781b0f94526245b8cbeb7c297089023e206
parentf15f863e3eee0c99ef5ce6def3f1c234d37f9ca1 (diff)
downloadruby-791253eff274858991d987032f80c16f13752c0e.tar.gz
parse.y: curtail scanning
* parse.y (parser_yyerror): curtail scanning range, not to exceed the max margin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index ab4f8ae233..dde6df8cfe 100644
--- a/parse.y
+++ b/parse.y
@@ -5255,18 +5255,21 @@ parser_yyerror(struct parser_params *parser, const char *msg)
const char *p, *pe;
const char *pre = "", *post = "";
const char *code = "", *caret = "", *newline = "";
+ const char *lim;
char *buf;
long len;
int i;
p = lex_p;
- while (lex_pbeg < p) {
+ lim = p - lex_pbeg > max_line_margin ? p - max_line_margin : lex_pbeg;
+ while (lim < p) {
if (*(p-1) == '\n') break;
p--;
}
pe = lex_p;
- while (pe < lex_pend) {
+ lim = lex_pend - pe > max_line_margin ? pe + max_line_margin : lex_pend;
+ while (pe < lim) {
if (*pe == '\n') break;
pe++;
}