diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-05 16:24:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-05 16:24:29 +0200 |
commit | 71016baf5524d739d1dd4d9110b111a7c3ddcaf9 (patch) | |
tree | 4d012db2dc2dd20e0956c0b188e52ab43059d2cc /coreutils | |
parent | 0f952c249e30834a3ee5cd821e9afc3197b05f9c (diff) | |
download | busybox-w32-71016baf5524d739d1dd4d9110b111a7c3ddcaf9.tar.gz busybox-w32-71016baf5524d739d1dd4d9110b111a7c3ddcaf9.tar.bz2 busybox-w32-71016baf5524d739d1dd4d9110b111a7c3ddcaf9.zip |
printf: accept negative numbers for %x; sh: overflowed numbers are 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/printf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c index 0b004eaeb..2beea7189 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -78,6 +78,14 @@ static int multiconvert(const char *arg, void *result, converter convert) | |||
78 | static void FAST_FUNC conv_strtoull(const char *arg, void *result) | 78 | static void FAST_FUNC conv_strtoull(const char *arg, void *result) |
79 | { | 79 | { |
80 | *(unsigned long long*)result = bb_strtoull(arg, NULL, 0); | 80 | *(unsigned long long*)result = bb_strtoull(arg, NULL, 0); |
81 | /* both coreutils 6.10 and bash 3.2: | ||
82 | * $ printf '%x\n' -2 | ||
83 | * fffffffffffffffe | ||
84 | * Mimic that: | ||
85 | */ | ||
86 | if (errno) { | ||
87 | *(unsigned long long*)result = bb_strtoll(arg, NULL, 0); | ||
88 | } | ||
81 | } | 89 | } |
82 | static void FAST_FUNC conv_strtoll(const char *arg, void *result) | 90 | static void FAST_FUNC conv_strtoll(const char *arg, void *result) |
83 | { | 91 | { |