diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-07 09:50:06 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-07 09:50:06 +0000 |
commit | 5a83e2bbe2ff16067c71aecf3dfdd9fabb639af7 (patch) | |
tree | c0a901b38e0815da1dd523dc1483637a2d429ebf /Src/subst.c | |
parent | fa30cd0b62827e85c86b1191c2b19d21183e4bfe (diff) | |
download | zsh-5a83e2bbe2ff16067c71aecf3dfdd9fabb639af7.tar.gz zsh-5a83e2bbe2ff16067c71aecf3dfdd9fabb639af7.tar.xz zsh-5a83e2bbe2ff16067c71aecf3dfdd9fabb639af7.zip |
zsh-users/2578
Diffstat (limited to 'Src/subst.c')
-rw-r--r-- | Src/subst.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/Src/subst.c b/Src/subst.c index 91a368d72..b808cb233 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1142,27 +1142,28 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) case PM_RIGHT_B: case PM_RIGHT_Z: case PM_RIGHT_Z | PM_RIGHT_B: - if (strlen(val) < fwidth) { - 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) { + { + int zero = 1; + + if (strlen(val) < fwidth) { + if (v->pm->flags & PM_RIGHT_Z) { + for (t = val; iblank(*t); t++); + if (!*t || !idigit(*t)) + zero = 0; + } t = (char *)ncalloc(fwidth + 1); - memset(t, (v->pm->flags & PM_RIGHT_B) ? ' ' : '0', - fwidth); + memset(t, (((v->pm->flags & PM_RIGHT_B) || !zero) ? + ' ' : '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'; + strncpy(t, val + strlen(val) - fwidth, fwidth); + val = t; } - } else { - t = (char *)ncalloc(fwidth + 1); - t[fwidth] = '\0'; - strncpy(t, val + strlen(val) - fwidth, fwidth); - val = t; } break; } |