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

dev
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
added : `--` separator, stating that all following arguments are file names. Suggested by Chip Turner.
added : OpenBSD target, by Juan Francisco Cantero Hurtado
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));
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));
/* ANS state update */

View File

@ -34,7 +34,7 @@
#include "util.h" /* Compiler options, UTIL_HAS_CREATEFILELIST */
#include <string.h> /* strcmp, strlen */
#include <ctype.h> /* toupper */
#include <errno.h>
#include <errno.h> /* errno */
#include "fileio.h"
#ifndef ZSTD_NOBENCH
# include "bench.h" /* BMK_benchFiles, BMK_SetNbIterations */
@ -205,7 +205,8 @@ int main(int argCount, const char** argv)
dictBuild=0,
nextArgumentIsOutFileName=0,
nextArgumentIsMaxDict=0,
nextArgumentIsDictID=0;
nextArgumentIsDictID=0,
nextArgumentIsFile=0;
unsigned cLevel = 1;
unsigned cLevelLast = 1;
unsigned recursive = 0;
@ -247,7 +248,10 @@ int main(int argCount, const char** argv)
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, "--decompress")) { decode=1; continue; }
if (!strcmp(argument, "--force")) { FIO_overwriteMode(); continue; }
if (!strcmp(argument, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); }
@ -282,7 +286,7 @@ int main(int argCount, const char** argv)
argument++;
while (argument[0]!=0) {
#ifndef ZSTD_NOCOMPRESS
#ifndef ZSTD_NOCOMPRESS
/* compression Level */
if ((*argument>='0') && (*argument<='9')) {
cLevel = readU32FromChar(&argument);
@ -291,7 +295,7 @@ int main(int argCount, const char** argv)
CLEAN_RETURN(badusage(programName));
continue;
}
#endif
#endif
switch(argument[0])
{
@ -333,7 +337,7 @@ int main(int argCount, const char** argv)
/* recursive */
case 'r': recursive=1; argument++; break;
#ifndef ZSTD_NOBENCH
#ifndef ZSTD_NOBENCH
/* Benchmark */
case 'b': bench=1; argument++; break;
@ -364,7 +368,7 @@ int main(int argCount, const char** argv)
BMK_SetBlockSize(bSize);
}
break;
#endif /* ZSTD_NOBENCH */
#endif /* ZSTD_NOBENCH */
/* Dictionary Selection level */
case 's':
@ -374,11 +378,11 @@ int main(int argCount, const char** argv)
/* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
case 'p': argument++;
#ifndef ZSTD_NOBENCH
#ifndef ZSTD_NOBENCH
if ((*argument>='0') && (*argument<='9')) {
BMK_setAdditionalParam(readU32FromChar(&argument));
} else
#endif
#endif
main_pause=1;
break;
/* unknown command */
@ -388,19 +392,6 @@ int main(int argCount, const char** argv)
continue;
} /* if (argument[0]=='-') */
if (nextEntryIsDictionary) {
nextEntryIsDictionary = 0;
dictFileName = argument;
continue;
}
if (nextArgumentIsOutFileName) {
nextArgumentIsOutFileName = 0;
outFileName = argument;
if (!strcmp(outFileName, "-")) outFileName = stdoutmark;
continue;
}
if (nextArgumentIsMaxDict) {
nextArgumentIsMaxDict = 0;
maxDictSize = readU32FromChar(&argument);
@ -415,6 +406,21 @@ int main(int argCount, const char** argv)
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 */
filenameTable[filenameIdx++] = argument;
}