From f39f39039c78588a0f062b3da87e623a609d0088 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 6 Sep 1999 12:38:34 +0000 Subject: zsh-users/2576 --- Src/subst.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Src/subst.c') diff --git a/Src/subst.c b/Src/subst.c index a86f1dc93..91a368d72 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1143,12 +1143,21 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) case PM_RIGHT_Z: case PM_RIGHT_Z | PM_RIGHT_B: if (strlen(val) < fwidth) { - t = (char *)ncalloc(fwidth + 1); - memset(t, (v->pm->flags & PM_RIGHT_B) ? ' ' : '0', fwidth); - if ((t0 = strlen(val)) > fwidth) - t0 = fwidth; - strcpy(t + (fwidth - t0), val); - val = t; + t = NULL; + if (v->pm->flags & PM_RIGHT_Z) { + for (t = val; iblank(*t); t++); + if (t && idigit(*t)) + val = t, t = NULL; + } + if (!t) { + t = (char *)ncalloc(fwidth + 1); + memset(t, (v->pm->flags & PM_RIGHT_B) ? ' ' : '0', + fwidth); + if ((t0 = strlen(val)) > fwidth) + t0 = fwidth; + strcpy(t + (fwidth - t0), val); + val = t; + } } else { t = (char *)ncalloc(fwidth + 1); t[fwidth] = '\0'; -- cgit 1.4.1