aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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++;
}