summaryrefslogtreecommitdiff
path: root/Src/text.c
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Src/text.c
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Src/text.c')
-rw-r--r--Src/text.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/Src/text.c b/Src/text.c
index 669037a2d..f55553ed0 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -253,6 +253,7 @@ struct tstack {
struct {
char *strs;
Wordcode end;
+ int nargs;
} _funcdef;
struct {
Wordcode end;
@@ -456,19 +457,31 @@ gettext2(Estate state)
if (!s) {
Wordcode p = state->pc;
Wordcode end = p + WC_FUNCDEF_SKIP(code);
+ int nargs = *state->pc++;
- taddlist(state, *state->pc++);
+ taddlist(state, nargs);
+ if (nargs)
+ taddstr(" ");
if (tjob) {
- taddstr(" () { ... }");
+ taddstr("() { ... }");
state->pc = end;
+ if (!nargs) {
+ /*
+ * Unnamed fucntion.
+ * We're not going to pull any arguments off
+ * later, so skip them now...
+ */
+ state->pc += *end;
+ }
stack = 1;
} else {
- taddstr(" () {");
+ taddstr("() {");
tindent++;
taddnl(1);
n = tpush(code, 1);
n->u._funcdef.strs = state->strs;
n->u._funcdef.end = end;
+ n->u._funcdef.nargs = nargs;
state->strs += *state->pc;
state->pc += 3;
}
@@ -478,6 +491,17 @@ gettext2(Estate state)
dec_tindent();
taddnl(0);
taddstr("}");
+ if (s->u._funcdef.nargs == 0) {
+ /* Unnamed function with post-arguments */
+ int nargs;
+ s->u._funcdef.end += *state->pc++;
+ nargs = *state->pc++;
+ if (nargs) {
+ taddstr(" ");
+ taddlist(state, nargs);
+ }
+ state->pc = s->u._funcdef.end;
+ }
stack = 1;
}
break;