diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-05 09:05:21 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-05 09:05:21 +0000 |
commit | 7ce1d5735832e51bc13e255f2e8549873c9688ff (patch) | |
tree | 4118a3d83afcbbf385bc43a0dfd576849b2bb1ad /Src | |
parent | 52f401a4a7c90e338bd70b807c05e66ce3f2b783 (diff) | |
download | zsh-7ce1d5735832e51bc13e255f2e8549873c9688ff.tar.gz zsh-7ce1d5735832e51bc13e255f2e8549873c9688ff.tar.xz zsh-7ce1d5735832e51bc13e255f2e8549873c9688ff.zip |
25615: $ZSH_DEBUG_CMD for use in DEBUG traps
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 7 | ||||
-rw-r--r-- | Src/text.c | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c index a46dfd683..a147dacd5 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1069,9 +1069,14 @@ execlist(Estate state, int dont_change_job, int exiting) } if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD) && !intrap) { + Wordcode pc2 = state->pc; int oerrexit_opt = opts[ERREXIT]; + Param pm; opts[ERREXIT] = 0; noerrexit = 1; + if (ltype & Z_SIMPLE) /* skip the line number */ + pc2++; + pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2)); exiting = donetrap; ret = lastval; @@ -1085,6 +1090,8 @@ execlist(Estate state, int dont_change_job, int exiting) */ donedebug = isset(ERREXIT) ? 2 : 1; opts[ERREXIT] = oerrexit_opt; + if (pm) + unsetparam_pm(pm, 0, 1); } else donedebug = intrap ? 1 : 0; diff --git a/Src/text.c b/Src/text.c index 7fdc5757f..eabb51268 100644 --- a/Src/text.c +++ b/Src/text.c @@ -135,7 +135,6 @@ getpermtext(Eprog prog, Wordcode c) tbuf = (char *)zalloc(tsiz = 32); tptr = tbuf; tlim = tbuf + tsiz; - tindent = 1; tjob = 0; if (prog->len) gettext2(&s); @@ -167,7 +166,6 @@ getjobtext(Eprog prog, Wordcode c) tbuf = NULL; tptr = jbuf; tlim = tptr + JOBTEXTSIZE - 1; - tindent = 1; tjob = 1; gettext2(&s); *tptr = '\0'; @@ -247,6 +245,16 @@ gettext2(Estate state) int stack = 0; wordcode code; + /* + * Hack for parsing "simple" format of function definitions. + * In this case there is no surrounding context so the initial + * indent should be zero. + */ + if (wc_code(*state->pc) == WC_FUNCDEF) + tindent = 0; + else + tindent = 1; + while (1) { if (stack) { if (!(s = tstack)) |