aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--debug.c18
2 files changed, 18 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f87d21d..f7996397 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/debug.c b/debug.c
index 949ebb49..357ce725 100644
--- a/debug.c
+++ b/debug.c
@@ -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;
}