diff options
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -2068,12 +2068,23 @@ 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); + /* + * FIXME: The check for zero and code that goes with it + * are probably fragile. A break with no arguments can + * cause this in certain cases. Try to review how this works. + */ + 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; } |