Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: typeset -Z broken? -R broken too?
- X-seq: zsh-users 2578
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: typeset -Z broken? -R broken too?
- Date: Tue, 7 Sep 1999 10:41:31 +0200 (MET DST)
- In-reply-to: Gabor's message of Mon, 6 Sep 1999 11:19:08 -0400
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
Gabor wrote:
> It appears that -R is broken, too.
>
> ...
>
> Also, even with the fix here is zsh for -Z
Ah. The documentation for `-Z' wasn't clear enough for me...
Bye
Sven
--- os/subst.c Mon Sep 6 14:51:27 1999
+++ Src/subst.c Tue Sep 7 10:37:14 1999
@@ -1142,27 +1142,28 @@
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;
}
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author