CLI : can select compression level > 9
authorYann Collet <yann.collet.73@gmail.com>
Wed, 11 Jun 2014 21:02:46 +0000 (22:02 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 11 Jun 2014 21:02:46 +0000 (22:02 +0100)
lz4hc.h
programs/Makefile
programs/lz4cli.c

diff --git a/lz4hc.h b/lz4hc.h
index b810978..deb2394 100644 (file)
--- a/lz4hc.h
+++ b/lz4hc.h
@@ -104,6 +104,7 @@ They just use the externally allocated memory area instead of allocating their o
 /**************************************
    Streaming Functions
 **************************************/
+/* Note : these streaming functions still follows the older model */
 void* LZ4_createHC (const char* inputBuffer);
 int   LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
 int   LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
index 35bfd06..811dda2 100644 (file)
@@ -165,6 +165,6 @@ test-mem: lz4 datagen
        rm tmp
 
 test-mem32: lz4c32 datagen
-# unfortunately, valgrind doesn't work with non-native binary. If someone knows how to valgrind-test a 32-bits exe on a 64-bits system...
+# unfortunately, valgrind doesn't seem to work with non-native binary. If someone knows how to do a valgrind-test on a 32-bits exe with a 64-bits system...
 
 endif
index e05a9a9..fd2721d 100644 (file)
@@ -344,6 +344,19 @@ int main(int argc, char** argv)
                 if (*argument=='s') { displayLevel=1; continue; }                                          // -s (silent mode)
 #endif // DISABLE_LZ4C_LEGACY_OPTIONS
 
+                if ((*argument>='0') && (*argument<='9'))
+                {
+                    cLevel = 0;
+                    while ((*argument >= '0') && (*argument <= '9'))
+                    {
+                        cLevel *= 10;
+                        cLevel += *argument - '0';
+                        argument++;
+                    }
+                    argument--;
+                    continue;
+                }
+
                 switch(argument[0])
                 {
                     // Display help
@@ -354,20 +367,6 @@ int main(int argc, char** argv)
                     // Compression (default)
                 case 'z': forceCompress = 1; break;
 
-                    // Compression level
-                case '0':
-                case '1':
-                case '2':
-                case '3':
-                case '4':
-                case '5':
-                case '6':
-                case '7':
-                case '8':
-                case '9':
-                case 'A':   /* non documented (hidden) */
-                    cLevel=*argument -'0'; break;
-
                     // Use Legacy format (for Linux kernel compression)
                 case 'l': legacy_format=1; break;