* Add a .gitignore file
* Various cleanups to zgz.
* Remove the unnecessary -l, -t, and -v flags from zgz.
+ * Allow the empty string as an original filename in zgz, rather than
+ treating the empty string as a flag to not store an original filename.
-- Josh Triplett <josh@freedesktop.org> Thu, 27 Nov 2008 19:54:29 -0800
main(int argc, char **argv)
{
const char *progname = argv[0];
- char origname[BUFLEN] = { 0 };
+ char *origname = NULL;
int len;
int ch;
case 'o':
if (nflag)
fprintf(stderr, "%s: ignoring original-name because no-name was passed\n", progname);
- strncpy(origname, optarg, BUFLEN);
+ origname = optarg;
break;
case 'k':
if (strcmp(optarg, "buggy-bsd") == 0) {
if (mflag != 0)
mtime = 0;
if (nflag != 0)
- origname = "";
+ origname = NULL;
i = snprintf(outbufp, BUFLEN, "%c%c%c%c%c%c%c%c%c%c%s",
GZIP_MAGIC0, GZIP_MAGIC1, Z_DEFLATED,
- *origname ? ORIG_NAME : 0,
+ origname ? ORIG_NAME : 0,
mtime & 0xff,
(mtime >> 8) & 0xff,
(mtime >> 16) & 0xff,
(mtime >> 24) & 0xff,
xflag >= 0 ? xflag :
numflag == 1 ? 4 : numflag == 9 ? 2 : 0,
- osflag, origname);
+ osflag, origname ? origname : "");
if (i >= BUFLEN)
/* this need PATH_MAX > BUFLEN ... */
maybe_err("snprintf");
- if (*origname)
+ if (origname)
i++;
z.next_out = (unsigned char *)outbufp + i;
}
if (S_ISREG(sb.st_mode))
- handle_file(path, strlen(origname) ? origname : basename(path), &sb);
+ handle_file(path, origname ? origname : basename(path), &sb);
else
maybe_warnx("%s is not a regular file", path);
}