[PATCH] coreutils tac (was: coreutils tac)
Tito
farmatito at tiscali.it
Fri Dec 28 21:36:26 UTC 2007
On Friday 28 December 2007 16:39:27 Natanael Copa wrote:
> On Tue, 2007-12-25 at 15:48 +0000, Denys Vlasenko wrote:
> > On Tuesday 25 December 2007 08:45, Natanael Copa wrote:
> > > Hi,
> > >
> > > Seems like someone posted a tac applet some time ago:
> > > http://www.uclibc.org/lists/busybox/2003-July/008813.html
> > >
> > > It looks like tac is needed for shorewall. Is there interest for an
> > > updated patch of tac?
> >
> > Why not.
>
> Attatched.
>
> > > Do you think its acceptable to make a tempfile when stdin is used, as in
> > > the patch above?
> >
> > You can try to do it in memory... or control it with command-line switch.
>
> GNU coreutils's tac uses tempfile. Seems like the most reasonable
> choice.
>
> I took the patch from
> http://www.uclibc.org/lists/busybox/2003-July/008813.html and adapted it
> to current libbb (some name changes since 2003). Then I modified the
> tac.c to reduce size. Here is the bloatcheck for my changes.
>
> function old new delta
> concat_tmpdir_file - 102 +102
> static.template 4 - -4
> static.tempdir 4 - -4
> .rodata 9426 9412 -14
> tac_main 447 431 -16
> mktemp_main 212 179 -33
> tac_file 187 - -187
> ------------------------------------------------------------------------------
> (add/remove: 1/3 grow/shrink: 0/3 up/down: 102/-258) Total: -156
> bytes
> text data bss dec hex filename
> 86428 1501 4484 92413 168fd busybox_old
> 86280 1497 4480 92257 16861 busybox_unstripped
>
>
> A few notes:
> * I introduced a new libbb func: concat_tmpdir_file(), which will
> concatenate getenv("TMPDIR") or "/tmp" with given filename. This was to
> avoid duplicate code with mktemp applet.
>
> * Old patch copied any file that fstat() reported as not regular file to
> temp file. My patch will try mmap all files and copy to tempfile if mmap
> fails. So if there are any non regular files that still are mmap'able
> those will not be copied. I dont know if it makes any difference in
> real life (probably not).
>
> * applet is marked as NOFORK.
>
> > --
> > vda
>
> -nc
>
Hi,
just for fun I've created an alternative version of tac
using only linked lists in memory. Probably the size
is smaller but I haven't checked it yet as I
would like to hear first the opinion of the list
members about it. For the same reason i haven't
attached a patch but only a drop in replacement
of tac.c.
Hints, critics, improvements and correction
are always welcome!!!
Ciao,
Tito
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tac.c
Type: text/x-csrc
Size: 1734 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071228/aa389c5a/attachment-0002.c
More information about the busybox
mailing list