Added GNU separator --, to specifies that all following arguments are necessary file names (and not commands). Suggested by @chipturner (#230)

This commit is contained in:
Yann Collet 2016-07-04 18:16:16 +02:00
parent 23f05ccc6b
commit f9cac7a734
3 changed files with 141 additions and 134 deletions

1
NEWS
View File

@ -1,4 +1,5 @@
v0.7.3 v0.7.3
added : `--` separator, stating that all following arguments are file names. Suggested by Chip Turner.
added : OpenBSD target, by Juan Francisco Cantero Hurtado added : OpenBSD target, by Juan Francisco Cantero Hurtado
v0.7.2 v0.7.2

View File

@ -735,7 +735,7 @@ static seq_t ZSTD_decodeSequence(seqState_t* seqState)
if (MEM_32bits() && (mlBits+llBits>24)) BIT_reloadDStream(&(seqState->DStream)); if (MEM_32bits() && (mlBits+llBits>24)) BIT_reloadDStream(&(seqState->DStream));
seq.litLength = LL_base[llCode] + ((llCode>15) ? BIT_readBits(&(seqState->DStream), llBits) : 0); /* <= 16 bits */ seq.litLength = LL_base[llCode] + ((llCode>15) ? BIT_readBits(&(seqState->DStream), llBits) : 0); /* <= 16 bits */
if (MEM_32bits() | if (MEM_32bits() ||
(totalBits > 64 - 7 - (LLFSELog+MLFSELog+OffFSELog)) ) BIT_reloadDStream(&(seqState->DStream)); (totalBits > 64 - 7 - (LLFSELog+MLFSELog+OffFSELog)) ) BIT_reloadDStream(&(seqState->DStream));
/* ANS state update */ /* ANS state update */

View File

@ -34,7 +34,7 @@
#include "util.h" /* Compiler options, UTIL_HAS_CREATEFILELIST */ #include "util.h" /* Compiler options, UTIL_HAS_CREATEFILELIST */
#include <string.h> /* strcmp, strlen */ #include <string.h> /* strcmp, strlen */
#include <ctype.h> /* toupper */ #include <ctype.h> /* toupper */
#include <errno.h> #include <errno.h> /* errno */
#include "fileio.h" #include "fileio.h"
#ifndef ZSTD_NOBENCH #ifndef ZSTD_NOBENCH
# include "bench.h" /* BMK_benchFiles, BMK_SetNbIterations */ # include "bench.h" /* BMK_benchFiles, BMK_SetNbIterations */
@ -205,7 +205,8 @@ int main(int argCount, const char** argv)
dictBuild=0, dictBuild=0,
nextArgumentIsOutFileName=0, nextArgumentIsOutFileName=0,
nextArgumentIsMaxDict=0, nextArgumentIsMaxDict=0,
nextArgumentIsDictID=0; nextArgumentIsDictID=0,
nextArgumentIsFile=0;
unsigned cLevel = 1; unsigned cLevel = 1;
unsigned cLevelLast = 1; unsigned cLevelLast = 1;
unsigned recursive = 0; unsigned recursive = 0;
@ -247,7 +248,10 @@ int main(int argCount, const char** argv)
const char* argument = argv[argNb]; const char* argument = argv[argNb];
if(!argument) continue; /* Protection if argument empty */ if(!argument) continue; /* Protection if argument empty */
if (nextArgumentIsFile==0) {
/* long commands (--long-word) */ /* long commands (--long-word) */
if (!strcmp(argument, "--")) { nextArgumentIsFile=1; continue; }
if (!strcmp(argument, "--decompress")) { decode=1; continue; } 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, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); }
@ -388,19 +392,6 @@ int main(int argCount, const char** argv)
continue; continue;
} /* if (argument[0]=='-') */ } /* if (argument[0]=='-') */
if (nextEntryIsDictionary) {
nextEntryIsDictionary = 0;
dictFileName = argument;
continue;
}
if (nextArgumentIsOutFileName) {
nextArgumentIsOutFileName = 0;
outFileName = argument;
if (!strcmp(outFileName, "-")) outFileName = stdoutmark;
continue;
}
if (nextArgumentIsMaxDict) { if (nextArgumentIsMaxDict) {
nextArgumentIsMaxDict = 0; nextArgumentIsMaxDict = 0;
maxDictSize = readU32FromChar(&argument); maxDictSize = readU32FromChar(&argument);
@ -415,6 +406,21 @@ int main(int argCount, const char** argv)
continue; continue;
} }
} /* if (nextArgumentIsAFile==0) */
if (nextEntryIsDictionary) {
nextEntryIsDictionary = 0;
dictFileName = argument;
continue;
}
if (nextArgumentIsOutFileName) {
nextArgumentIsOutFileName = 0;
outFileName = argument;
if (!strcmp(outFileName, "-")) outFileName = stdoutmark;
continue;
}
/* add filename to list */ /* add filename to list */
filenameTable[filenameIdx++] = argument; filenameTable[filenameIdx++] = argument;
} }