aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
commit624d70844fe63068132adb7c66ea3f8a231e56a7 (patch)
tree79781e2b0e24b5e478804001c83fcde64602f502 /debug.c
parentda83b6857bf0a67b15fc75d31a0b6802ac9baffe (diff)
parentf934f2192779db0091d1706d97d1fd43cb26dc9a (diff)
downloadegawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.gz
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.bz2
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.zip
Merge branch 'master' into comment
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/debug.c b/debug.c
index 2d9f74e8..9903a376 100644
--- a/debug.c
+++ b/debug.c
@@ -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;
}