[patch] coreutils/printf.c
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Fri May 30 10:25:24 UTC 2008
On Fri, 30 May 2008, Bernhard Fischer wrote:
> On Thu, May 29, 2008 at 11:53:03PM +0200, Cristian Ionescu-Idbohrn wrote:
> >@@ -8540,6 +8541,9 @@
> > { BUILTIN_NOSPEC "let", letcmd },
> > #endif
> > { BUILTIN_ASSIGN "local", localcmd },
> >+#if ENABLE_ASH_BUILTIN_PRINTF
> >+ { BUILTIN_REGULAR "[", printfcmd },
> >+#endif
>
> are you sure that "[" is correct here?
Of course it isn't. And that possibly has something to do with the
odd behaviour I experienced:
| On the negative side, the above command line outputs all 100000
| lines to stdout, even if I redirect to /dev/null
> Sounds a bit like it should be "printf", but i didn't look..
Of course it should.
Brain and fingers temporarily disconnected :)
Corrected patch attached.
What I'm unsure about is if this:
- p = xmalloc((unsigned) (length + 1));
+ p = alloca(length + 1);
is a good move. I ran this command line:
# ./busybox ash -c 'for x in 1;do S=; for N in $(seq 1 100000);do \
C=${C}x;done; printf "%s\n" $C >/dev/null;done'
to check if anything gets smashed, but no bad surprise.
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) reposts this
on one of my boxes:
function old new delta
.rodata 76384 76416 +32
builtintab 336 344 +8
collect_fork 112 119 +7
make_device 1146 1152 +6
send_tree 369 373 +4
diffreg 1741 1743 +2
count_lines 68 70 +2
passwd_main 989 987 -2
print_direc 456 443 -13
diff_main 837 823 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/3 up/down: 61/-29) Total: 32 bytes
text data bss dec hex filename
342426 1977 17792 362195 586d3 busybox_old
342450 1977 17792 362219 586eb busybox_unstripped
Another one reports +6 bytes (another gcc version).
Cheers,
--
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bb-ash-printf-builtin.patch
Type: text/x-diff
Size: 3877 bytes
Desc:
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080530/011f61f8/attachment.bin
More information about the busybox
mailing list