about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/parameter.c5
-rw-r--r--Src/builtin.c2
-rw-r--r--Src/exec.c2
-rw-r--r--Src/hashtable.c2
-rw-r--r--Src/init.c2
-rw-r--r--Src/text.c14
6 files changed, 10 insertions, 17 deletions
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index b6c8c5608..4e1205ec8 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -390,7 +390,7 @@ getfunction(UNUSED(HashTable ht), const char *name, int dis)
 				((shf->node.flags & PM_TAGGED) ? "Ut" : "U") :
 				((shf->node.flags & PM_TAGGED) ? "t" : "")));
 	} else {
-	    char *t = getpermtext(shf->funcdef, NULL), *n, *h;
+	    char *t = getpermtext(shf->funcdef, NULL, 1), *n, *h;
 
 	    if (shf->funcdef->flags & EF_RUN) {
 		n = nicedupstring(name);
@@ -455,7 +455,8 @@ scanfunctions(UNUSED(HashTable ht), ScanFunc func, int flags, int dis)
 				    ((shf->node.flags & PM_TAGGED) ? "Ut" : "U") :
 				    ((shf->node.flags & PM_TAGGED) ? "t" : "")));
 		    } else {
-			char *t = getpermtext(((Shfunc) hn)->funcdef, NULL), *n;
+			char *t = getpermtext(((Shfunc) hn)->funcdef, NULL, 1);
+			char *n;
 
 			if (((Shfunc) hn)->funcdef->flags & EF_RUN) {
 			    n = nicedupstring(hn->nam);
diff --git a/Src/builtin.c b/Src/builtin.c
index 69f0aaa6e..8adc7fcb1 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5725,7 +5725,7 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		if (!siglists[sig])
 		    printf("trap -- '' %s\n", name);
 		else {
-		    s = getpermtext(siglists[sig], NULL);
+		    s = getpermtext(siglists[sig], NULL, 0);
 		    printf("trap -- ");
 		    quotedzputs(s, stdout);
 		    printf(" %s\n", name);
diff --git a/Src/exec.c b/Src/exec.c
index f1c5788bf..a8098e5f8 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1084,7 +1084,7 @@ execlist(Estate state, int dont_change_job, int exiting)
 	    noerrexit = 1;
 	    if (ltype & Z_SIMPLE) /* skip the line number */
 		pc2++;
-	    pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2));
+	    pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2, 0));
 
 	    exiting = donetrap;
 	    ret = lastval;
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 212882b3f..bc2a4f22e 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -887,7 +887,7 @@ printshfuncnode(HashNode hn, int printflags)
 	if (f->node.flags & PM_UNDEFINED)
 	    printf("%c undefined\n\t", hashchar);
 	else
-	    t = getpermtext(f->funcdef, NULL);
+	    t = getpermtext(f->funcdef, NULL, 1);
 	if (f->node.flags & PM_TAGGED)
 	    printf("%c traced\n\t", hashchar);
 	if (!t) {
diff --git a/Src/init.c b/Src/init.c
index 923b94876..4c08c8c65 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -168,7 +168,7 @@ loop(int toplevel, int justonce)
 		else
 		    addlinknode(args, "");
 		addlinknode(args, dupstring(getjobtext(prog, NULL)));
-		addlinknode(args, cmdstr = getpermtext(prog, NULL));
+		addlinknode(args, cmdstr = getpermtext(prog, NULL, 0));
 
 		callhookfunc("preexec", args, 1, NULL);
 
diff --git a/Src/text.c b/Src/text.c
index eabb51268..074afe581 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -118,7 +118,7 @@ taddnl(void)
 
 /**/
 mod_export char *
-getpermtext(Eprog prog, Wordcode c)
+getpermtext(Eprog prog, Wordcode c, int start_indent)
 {
     struct estate s;
 
@@ -131,6 +131,7 @@ getpermtext(Eprog prog, Wordcode c)
     s.pc = c;
     s.strs = prog->strs;
 
+    tindent = start_indent;
     tnewlins = 1;
     tbuf = (char *)zalloc(tsiz = 32);
     tptr = tbuf;
@@ -162,6 +163,7 @@ getjobtext(Eprog prog, Wordcode c)
     s.pc = c;
     s.strs = prog->strs;
 
+    tindent = 0;
     tnewlins = 0;
     tbuf = NULL;
     tptr = jbuf;
@@ -245,16 +247,6 @@ 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))