[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bash 2.05 printf mishandles %.0b
From: |
Paul Eggert |
Subject: |
Bash 2.05 printf mishandles %.0b |
Date: |
Fri, 27 Apr 2001 10:55:26 -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 zero precision is specified.
It ignores the precision; it should print nothing instead.
Repeat-By:
$ printf '%.0b-%.0s\n' foo bar
foo-
The correct output is '-'. Solaris ksh handles this correctly.
Fix:
2001-04-27 Paul Eggert <eggert@twinsun.com>
* builtins/printf.def (printstr):
Print nothing if a zero precision is specified.
===================================================================
RCS file: builtins/printf.def,v
retrieving revision 2.5.0.3
retrieving revision 2.5.0.4
diff -pu -r2.5.0.3 -r2.5.0.4
--- builtins/printf.def 2001/04/27 17:24:33 2.5.0.3
+++ builtins/printf.def 2001/04/27 17:50:55 2.5.0.4
@@ -362,7 +362,8 @@ printstr (fmt, string, len, fieldwidth,
if (*fmt == '%')
fmt++;
- ljust = fw = pr = 0;
+ ljust = fw = 0;
+ pr = -1;
/* skip flags */
while (strchr (SKIP1, *fmt))
@@ -412,7 +413,7 @@ printstr (fmt, string, len, fieldwidth,
#endif
/* chars from string to print */
- nc = (pr > 0 && pr <= len) ? pr : len;
+ nc = (0 <= pr && pr < len) ? pr : len;
padlen = fw - nc;
if (padlen < 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bash 2.05 printf mishandles %.0b,
Paul Eggert <=