Commit Graph

13 Commits

Author SHA1 Message Date
Ron Yorston
7105e4afdd printf: allow 0 as a flag and allow multiple flags
The '%' character in a format specification may be followed by
one or more flags from the list "+- #0".  BusyBox printf didn't
support the '0' flag or allow multiple flags to be provided.
As a result the formats '%0*d' and '%0 d' were considered to be
invalid.

The lack of support for '0' was pointed out by Andrew Snyder on the
musl mailing list:

   https://www.openwall.com/lists/musl/2021/12/14/2

function                                             old     new   delta
printf_main                                          860     891     +31
.rodata                                            99281   99282      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0)               Total: 32 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17 21:13:26 +01:00
Daniel Thau
7d06d6e186 awk: fix printf %%
A refactor of the awk printf code in
e2e3802987
appears to have broken the printf interpretation of two percent signs,
which normally outputs only one percent sign.

The patch below brings busybox awk printf behavior back into alignment
with the pre-e2e380 behavior, the busybox printf util, and other common
(awk and non-awk) printf implementations.

function                                             old     new   delta
awk_printf                                           626     672     +46

Signed-off-by: Daniel Thau <danthau at bedrocklinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-05 03:42:51 +02:00
Bernhard Reutner-Fischer
3db4e7f84c printf: fix printing +-prefixed numbers
Thanks to Cristian Ionescu-Idbohrn for noticing.

Also fix "%d" '  42' to skip leading whitespace.

function                                             old     new   delta
print_direc                                          435     454     +19
bb_strtoll                                            99     103      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0)               Total: 23 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2018-10-19 15:27:42 +02:00
Ron Yorston
1f27fa9838 testsuite: allow tests to work in paths containing spaces
Tweak some tests so they work when the path to the test directory or
$HOME contains spaces.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-09 20:35:48 +02:00
Dan Fandrich
eb2bf5b6bf Fix some test cases
The tar tests still don't pass, but at least now it's because of
a problem with Busybox and not the tests themselves.

Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03 17:09:51 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Mike Frysinger
caa79406aa tests: fix POSIX shell source style
The source command does not search $PWD, and bash recently fixed itself to
follow this behavior for /bin/sh.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-11-04 18:41:22 -05:00
Denys Vlasenko
bf4aeed129 printf: fix exit code on conversion error
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 22:22:04 +02:00
Denys Vlasenko
2441060beb fix or document testsuite failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-13 23:41:57 +02:00
Denis Vlasenko
5f116629d8 printf: do not print garbage on "%Ld". closes bug 4214.
function                                             old     new   delta
printf_main                                          633     637      +4
multiconvert                                          99      79     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-20)             Total: -16 bytes
2008-07-18 18:41:55 +00:00
Denis Vlasenko
a48656b441 printf: fix %b, fix several bugs in %*.*, fix compat issues with
aborting too early, support %zd; expand testsuite

function                                             old     new   delta
get_width_prec                                         -      46     +46
multiconvert                                          82      99     +17
conv_strtod                                           44      54     +10
print_direc                                          382     391      +9
printf_main                                          629     633      +4
conv_strtoul                                          20      16      -4
conv_strtol                                           20      16      -4
my_xstrtoul                                           20       -     -20
my_xstrtol                                            20       -     -20
my_xstrtod                                            21       -     -21
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 4/2 up/down: 86/-69)             Total: 17 bytes
2008-07-18 11:10:51 +00:00
Denis Vlasenko
0f683f818c printf: protect against bogus format specifiers. Hopefully closes bug 4184 2008-07-17 09:17:51 +00:00
Denis Vlasenko
50120dab4e added testsuite for printf by Cristian Ionescu-Idbohrn 2008-06-05 08:27:26 +00:00