[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
printf treats arguments of "%c" not as expected
From: |
Yunfeng Wang |
Subject: |
printf treats arguments of "%c" not as expected |
Date: |
Wed, 22 Jun 2011 20:28:05 +0800 |
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include
-I../bash/lib -g -O2 -Wall
uname output: Linux loco 2.6.38-2-686 #1 SMP Tue Mar 29 17:27:45 UTC
2011 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu
Bash Version: 4.1
Patch Level: 5
Release Status: release
Description:
The builtin printf does not print arguments of format "%c" as described
in printf(3). /usr/bin/printf from coreutils has the same problem.
Repeat-By:
$ printf %c 65 66 67
666
The expected output is ABC, i.e. characters with ASCII code of 65 66 67
Fix:
--- bash-4.1/builtins/printf.def 2009-11-21 04:31:23.000000000 +0800
+++ bash-4.1-new/builtins/printf.def 2011-06-22 19:25:30.000000000 +0800
@@ -385,9 +385,9 @@
{
case 'c':
{
- char p;
+ int p;
- p = getchr ();
+ p = getintmax ();
PF(start, p);
break;
}
- printf treats arguments of "%c" not as expected,
Yunfeng Wang <=