about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-14 19:22:45 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-14 19:22:45 +0000
commit6dbc34b0d464a274f6c760b13c1e568a83e0c3f6 (patch)
treeb3daf70fd7981418e8ce5b25051fb0d1d4609a70 /Src/exec.c
parentb4a7ad8269676f0fa281dab1ca1d09ed2a93a799 (diff)
downloadzsh-6dbc34b0d464a274f6c760b13c1e568a83e0c3f6.tar.gz
zsh-6dbc34b0d464a274f6c760b13c1e568a83e0c3f6.tar.xz
zsh-6dbc34b0d464a274f6c760b13c1e568a83e0c3f6.zip
23104: fix line numbers for DEBUGBEFORECMD
tidy up some wordcode definitions
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 487838a25..1d07bffcf 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -866,6 +866,35 @@ execlist(Estate state, int dont_change_job, int exiting)
     code = *state->pc++;
     while (wc_code(code) == WC_LIST && !breaks && !retflag) {
 	int donedebug;
+
+	ltype = WC_LIST_TYPE(code);
+	csp = cmdsp;
+
+	if ((!intrap || trapisfunc) && !ineval) {
+	    /*
+	     * Ensure we have a valid line number for debugging,
+	     * unless we are in an evaluated trap in which case
+	     * we retain the line number from the context.
+	     * This was added for DEBUGBEFORECMD but I've made
+	     * it unconditional to keep dependencies to a minimum.
+	     *
+	     * The line number is updated for individual pipelines.
+	     * This isn't necessary for debug traps since they only
+	     * run once per sublist.
+	     */
+	    wordcode code2 = *state->pc, lnp1 = 0;
+	    if (ltype & Z_SIMPLE) {
+		lnp1 = code2;
+	    } else if (wc_code(code2) == WC_SUBLIST) {
+		if (WC_SUBLIST_FLAGS(code2) == WC_SUBLIST_SIMPLE)
+		    lnp1 = state->pc[2];
+		else
+		    lnp1 = WC_PIPE_LINENO(state->pc[1]);
+	    }
+	    if (lnp1)
+		lineno = lnp1 - 1;
+	}
+
 	if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD)) {
 	    exiting = donetrap;
 	    ret = lastval;
@@ -881,9 +910,6 @@ execlist(Estate state, int dont_change_job, int exiting)
 	} else
 	    donedebug = 0;
 
-	ltype = WC_LIST_TYPE(code);
-	csp = cmdsp;
-
 	if (ltype & Z_SIMPLE) {
 	    next = state->pc + WC_LIST_SKIP(code);
 	    execsimple(state);