]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Print help when no arguments supplied to minideflate.
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 11 Mar 2022 23:42:14 +0000 (15:42 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 16 Mar 2022 10:42:45 +0000 (11:42 +0100)
test/minideflate.c

index 07ab2bd407ff86c755346bb1d5f0f36f42d00026..e1295afc89771ced198733b96b778df68ac8b6b0 100644 (file)
@@ -233,6 +233,12 @@ int main(int argc, char **argv) {
     FILE *fin = stdin;
     FILE *fout = stdout;
 
+
+    if (argc == 1) {
+        show_help();
+        return 64;   /* EX_USAGE */
+    }
+
     for (i = 1; i < argc; i++) {
         if ((strcmp(argv[i], "-m") == 0) && (i + 1 < argc))
             mem_level = atoi(argv[++i]);
@@ -313,6 +319,13 @@ int main(int argc, char **argv) {
         }
     }
 
+    if (window_bits == INT32_MAX) {
+        window_bits = MAX_WBITS;
+        /* Auto-detect wrapper for inflateInit */
+        if (uncompr)
+            window_bits += 32;
+    }
+
     if (uncompr) {
         inflate_params(fin, fout, read_buf_size, write_buf_size, window_bits, flush);
     } else {