ckolivas / lrzip

Long Range Zip
http://lrzip.kolivas.org
GNU General Public License v2.0
618 stars 76 forks source link

Does IS_FROM_FILE #define really do what it is supposed to? #177

Closed pete4abw closed 3 years ago

pete4abw commented 3 years ago

#define IS_FROM_FILE ( !!(control->inFILE) && !STDIN )

So control->inFILE only contains the C internal FILE stdin and STDIN merely indicates that.

Look at all the ways it is used in lrzip.c.

lrzip.c:        if (!STDIN && !IS_FROM_FILE) {
lrzip.c:        if ( IS_FROM_FILE ) {
lrzip.c:        if ( ! IS_FROM_FILE ) {
lrzip.c:        if ( IS_FROM_FILE )
lrzip.c:                if (!STDIN && !IS_FROM_FILE)
lrzip.c:        if ( !IS_FROM_FILE )
lrzip.c:        if (!STDIN && ! IS_FROM_FILE) close(fd_in);
lrzip.c:        if ( IS_FROM_FILE )
lrzip.c:        if (! IS_FROM_FILE && STDIN && (fd_in > 0))

Seems counterintuitive. Does the following mean If it is NOT piped and NOT a file? No. It works out that it IS a file.

/*
  decompress one file from the command line
*/
bool decompress_file(rzip_control *control)
{
    char *tmp, *tmpoutfile, *infilecopy = NULL;
    int fd_in, fd_out = -1, fd_hist = -1;
    i64 expected_size = 0, free_space;
    struct statvfs fbuf;

    if (!STDIN && !IS_FROM_FILE) {
pete4abw commented 3 years ago

See comment thread on #77 .