[PATCH] coreutils tac (was: coreutils tac)

Tito farmatito at tiscali.it
Sun Jan 6 09:31:07 UTC 2008


On Sunday 06 January 2008 07:28:47 Denys Vlasenko wrote:
> On Wednesday 02 January 2008 15:23, Natanael Copa wrote:
> > Denys, whats the status on the tac patch?
> 
> Version which does inversion in memory is appled to svn.
> It handles non terminated last line the same as coreutils,
> but mishandles NULs.
Hi,
Denis, did you forget svn add again?  :-)

Why it mishandles NULs?
I thought that i've got it right in version 2 of my patch (attached):

              /* Get line and add it to the start of the temp linked list. */
                while ((line = xmalloc_fgets(f))) {
                        if (temp_list && !last_char_is(temp_list->data, '\n'))
                                /* Last line ended with '\0' so concatenate them. */
                                 temp_list->data = xasprintf("%s%s", temp_list->data, line);
                        else
                                llist_add_to(&temp_list, line); 
                }

this was the test file i used (attached):
055 056 057 000 057 056 055 010

result is:

GNU tac
tac prova4
789987

busybox
 ./busybox tac prova4
789987

Ciao,
TIto
> --
> vda
> 

-------------- next part --------------
789 987
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tac.c
Type: text/x-csrc
Size: 1896 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080106/80c2d501/attachment-0002.c 


More information about the busybox mailing list