[Toybox] gunzip.c cleanup

enh enh at google.com
Mon Jan 8 17:27:28 PST 2018


the tests were here but never merged:
http://lists.landley.net/pipermail/toybox-landley.net/2017-April/008962.html

i did see the weird suffix addition stuff when i read the man page,
but since it was (a) the first time i'd heard of it in 25 years and
(b) disgusting, i thought i'd wait until someone actually needed it.

likewise the ignoring errors. that seemed like a bug rather than a
feature until proven otherwise.

but, yeah, i should have said so in TODO comments. (i thought i did
comment the former, but that may have been lost in the toybox
obfuscated c competition rewrite.)

On Wed, Jan 3, 2018 at 1:28 AM, Rob Landley <rob at landley.net> wrote:
> Poking at this, did I break it or was it never particularly tested?
>
>   $ ./zcat README
>   zcat: unknown suffix: README
>   $ cat README | ./gunzip | head -n 3
>   Toybox: all-in-one Linux command line.
>
>   --- Getting started
>   $ cat README | gunzip | head -n 3
>   gzip: stdin: not in gzip format
>
> I was trying to see if gzdopen(blah, "r") verifies the gzip header on
> the data stream and thus fails due to being fed non-gzip data, or if the
> first read() does that. (I dug up the zlib manual which says it doesn't
> use the filehandle until read so won't notice if it's invalid, so
> failure there is basically a malloc failure.)
>
> Also, there's a lot of error_exit() calls when the old gzip continues to
> the next argument instead:
>
>   $ cat ../README | gzip > one.gz
>   $ cat ../README | gzip > two.gz
>   $ touch one
>   $ sudo chattr +i one
>   $ gunzip one.gz two.gz
>   gzip: one already exists; do you wish to overwrite (y or n)? y
>   gzip: one: Operation not permitted
>   $ ls -l
>   total 12
>   -rw-rw-r-- 1 landley landley    0 Jan  3 03:22 one
>   -rw-rw-r-- 1 landley landley 3076 Jan  3 03:22 one.gz
>   -rw-rw-r-- 1 landley landley 6624 Jan  3 03:22 two
>
> And so on...
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list