Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: typeset -Z broken? -R broken too?



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