]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added long comment --memlimit=
authorYann Collet <cyan@fb.com>
Fri, 14 Oct 2016 21:07:11 +0000 (14:07 -0700)
committerYann Collet <cyan@fb.com>
Fri, 14 Oct 2016 21:07:11 +0000 (14:07 -0700)
programs/zstdcli.c
tests/playTests.sh

index 3a284c31d2c91470fdf09cb33d488c20cd1aa60a..9a38ede7ade4a0b7135e217acb8de9338f70b561 100644 (file)
@@ -247,16 +247,16 @@ int main(int argCount, const char* argv[])
     if (!strcmp(programName, ZSTD_CAT)) { decode=1; forceStdout=1; displayLevel=1; outFileName=stdoutmark; }
 
     /* command switches */
-    for(argNb=1; argNb<argCount; argNb++) {
+    for (argNb=1; argNb<argCount; argNb++) {
         const char* argument = argv[argNb];
         if(!argument) continue;   /* Protection if argument empty */
 
         if (nextArgumentIsFile==0) {
 
             /* long commands (--long-word) */
-            if (!strcmp(argument, "--")) { nextArgumentIsFile=1; continue; }
+            if (!strcmp(argument, "--")) { nextArgumentIsFile=1; continue; }   /* only file names allowed from now on */
             if (!strcmp(argument, "--decompress")) { decode=1; continue; }
-            if (!strcmp(argument, "--force")) {  FIO_overwriteMode(); continue; }
+            if (!strcmp(argument, "--force")) { FIO_overwriteMode(); continue; }
             if (!strcmp(argument, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); }
             if (!strcmp(argument, "--help")) { displayOut=stdout; CLEAN_RETURN(usage_advanced(programName)); }
             if (!strcmp(argument, "--verbose")) { displayLevel++; continue; }
@@ -275,6 +275,13 @@ int main(int argCount, const char* argv[])
             if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(0); continue; }
             if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; }
 
+            /* long commands with arguments */
+            if (!strncmp(argument, "--memlimit=", strlen("--memlimit="))) {
+                argument += strlen("--memlimit=");
+                memLimit = readU32FromChar(&argument);
+                continue;
+            }
+
             /* '-' means stdin/stdout */
             if (!strcmp(argument, "-")){
                 if (!filenameIdx) {
index efb0f0cbdf8e8c30dec5b5a12a04798152973513..df9b167f513c4c67b6ba781c0e39d68cb9fd83b4 100755 (executable)
@@ -83,6 +83,7 @@ $ZSTD -d    < tmp.zst > $INTOVOID   # implicit stdout when stdin is used
 $ZSTD -d  - < tmp.zst > $INTOVOID
 $ECHO "test : impose memory limitation (must fail)"
 $ZSTD -d -f tmp.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
+$ZSTD -d -f tmp.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed"  # long command
 $ECHO "test : overwrite protection"
 $ZSTD -q tmp && die "overwrite check failed!"
 $ECHO "test : force overwrite"