diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | debug.c | 18 |
2 files changed, 18 insertions, 6 deletions
@@ -1,3 +1,9 @@ +2013-09-24 Arnold D. Robbins <arnold@skeeve.com> + + * debug.c (find_rule): Handle case where lineno is zero. Can happen + if break is given without a line number on a current line. Thanks + to Ray Song <i@maskray.me> for the report. + 2013-09-19 Arnold D. Robbins <arnold@skeeve.com> * dfa.c (parse_bracket_exp): Use code from grep to keep things within @@ -2068,12 +2068,18 @@ find_rule(char *src, long lineno) { INSTRUCTION *rp; - assert(lineno > 0); - for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) { - if ((rp - 1)->source_file == src - && lineno >= (rp + 1)->first_line - && lineno <= (rp + 1)->last_line) - return (rp - 1); + if (lineno == 0) { + for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) { + if ((rp - 1)->source_file == src && (rp - 1)->source_line > 0) + return (rp - 1); + } + } else { + for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) { + if ((rp - 1)->source_file == src + && lineno >= (rp + 1)->first_line + && lineno <= (rp + 1)->last_line) + return (rp - 1); + } } return NULL; } |