bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash 2.05 printf mishandles %*b with negative fieldwidth


From: Paul Eggert
Subject: Bash 2.05 printf mishandles %*b with negative fieldwidth
Date: Fri, 27 Apr 2001 11:04:49 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7' 
-DCONF_VENDOR='sun' -DSHELL  -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib 
-I/opt/reb/include -g -O2
uname output: SunOS shade.twinsun.com 5.8 Generic_108528-07 sun4u sparc 
SUNW,Ultra-1
Machine Type: sparc-sun-solaris2.7

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        Bash mishandles the %b printf format if a negative field width
        is specified.  It treats it as if it were zero; but it is
        supposed to treat it as the absolute value of the field with
        with a '-' flag.

Repeat-By:
        $ printf '(%*b)(%*s)\n' -4 foo -4 bar
        (foo)(bar )

        There should be a space after the "foo".

Fix:

2001-04-27  Paul Eggert  <eggert@twinsun.com>

        * builtins/printf.def (printstr): Treat negative fieldwidth as
        a positive fieldwidth with left-justification.

===================================================================
RCS file: builtins/printf.def,v
retrieving revision 2.5.0.4
retrieving revision 2.5.0.5
diff -pu -r2.5.0.4 -r2.5.0.5
--- builtins/printf.def 2001/04/27 17:50:55     2.5.0.4
+++ builtins/printf.def 2001/04/27 18:01:33     2.5.0.5
@@ -378,6 +378,11 @@ printstr (fmt, string, len, fieldwidth, 
     {
       fmt++;
       fw = fieldwidth;
+      if (fw < 0)
+       {
+         fw = -fw;
+         ljust = 1;
+       }
     }
   else if (isdigit (*fmt))
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]