From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19032 invoked from network); 6 Sep 1999 12:33:36 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 Sep 1999 12:33:36 -0000 Received: (qmail 9338 invoked by alias); 6 Sep 1999 12:33:13 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2576 Received: (qmail 9331 invoked from network); 6 Sep 1999 12:33:13 -0000 Date: Mon, 6 Sep 1999 14:33:03 +0200 (MET DST) Message-Id: <199909061233.OAA02343@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-users@sunsite.auc.dk In-reply-to: Gabor's message of Sun, 5 Sep 1999 08:57:22 -0400 Subject: Re: typeset -Z broken? Gabor wrote: > Here is the relevant part of the man page > > > -Z Right justify and fill with leading zeros if > the first non-blank character is a digit and > the -L flag has not been set. If n is > nonzero it defines the width of the field; > otherwise it is determined by the width of > the value of the first assignment. > > yet, when I use this I get left padding with zeros even on names that don't > start with a digit Hm, I hope this makes it work the way it should. Bye Sven --- os/subst.c Mon Sep 6 13:08:29 1999 +++ Src/subst.c Mon Sep 6 14:31:44 1999 @@ -1143,12 +1143,21 @@ 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'; -- Sven Wischnowsky wischnow@informatik.hu-berlin.de