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:
parent
23f05ccc6b
commit
f9cac7a734
1
NEWS
1
NEWS
@ -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
|
||||||
|
@ -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 */
|
||||||
|
@ -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,146 +248,165 @@ 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 */
|
||||||
|
|
||||||
/* long commands (--long-word) */
|
if (nextArgumentIsFile==0) {
|
||||||
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); }
|
|
||||||
if (!strcmp(argument, "--help")) { displayOut=stdout; CLEAN_RETURN(usage_advanced(programName)); }
|
|
||||||
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
|
||||||
if (!strcmp(argument, "--quiet")) { displayLevel--; continue; }
|
|
||||||
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; displayLevel-=(displayLevel==2); continue; }
|
|
||||||
if (!strcmp(argument, "--ultra")) { FIO_setMaxWLog(0); continue; }
|
|
||||||
if (!strcmp(argument, "--check")) { FIO_setChecksumFlag(2); continue; }
|
|
||||||
if (!strcmp(argument, "--no-check")) { FIO_setChecksumFlag(0); continue; }
|
|
||||||
if (!strcmp(argument, "--no-dictID")) { FIO_setDictIDFlag(0); continue; }
|
|
||||||
if (!strcmp(argument, "--sparse")) { FIO_setSparseWrite(2); continue; }
|
|
||||||
if (!strcmp(argument, "--no-sparse")) { FIO_setSparseWrite(0); continue; }
|
|
||||||
if (!strcmp(argument, "--test")) { decode=1; outFileName=nulmark; FIO_overwriteMode(); continue; }
|
|
||||||
if (!strcmp(argument, "--train")) { dictBuild=1; outFileName=g_defaultDictName; continue; }
|
|
||||||
if (!strcmp(argument, "--maxdict")) { nextArgumentIsMaxDict=1; continue; }
|
|
||||||
if (!strcmp(argument, "--dictID")) { nextArgumentIsDictID=1; continue; }
|
|
||||||
if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(0); continue; }
|
|
||||||
if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; }
|
|
||||||
|
|
||||||
/* '-' means stdin/stdout */
|
/* long commands (--long-word) */
|
||||||
if (!strcmp(argument, "-")){
|
if (!strcmp(argument, "--")) { nextArgumentIsFile=1; continue; }
|
||||||
if (!filenameIdx) {
|
if (!strcmp(argument, "--decompress")) { decode=1; continue; }
|
||||||
filenameIdx=1, filenameTable[0]=stdinmark;
|
if (!strcmp(argument, "--force")) { FIO_overwriteMode(); continue; }
|
||||||
outFileName=stdoutmark;
|
if (!strcmp(argument, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); }
|
||||||
displayLevel-=(displayLevel==2);
|
if (!strcmp(argument, "--help")) { displayOut=stdout; CLEAN_RETURN(usage_advanced(programName)); }
|
||||||
continue;
|
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
||||||
} }
|
if (!strcmp(argument, "--quiet")) { displayLevel--; continue; }
|
||||||
|
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; displayLevel-=(displayLevel==2); continue; }
|
||||||
|
if (!strcmp(argument, "--ultra")) { FIO_setMaxWLog(0); continue; }
|
||||||
|
if (!strcmp(argument, "--check")) { FIO_setChecksumFlag(2); continue; }
|
||||||
|
if (!strcmp(argument, "--no-check")) { FIO_setChecksumFlag(0); continue; }
|
||||||
|
if (!strcmp(argument, "--no-dictID")) { FIO_setDictIDFlag(0); continue; }
|
||||||
|
if (!strcmp(argument, "--sparse")) { FIO_setSparseWrite(2); continue; }
|
||||||
|
if (!strcmp(argument, "--no-sparse")) { FIO_setSparseWrite(0); continue; }
|
||||||
|
if (!strcmp(argument, "--test")) { decode=1; outFileName=nulmark; FIO_overwriteMode(); continue; }
|
||||||
|
if (!strcmp(argument, "--train")) { dictBuild=1; outFileName=g_defaultDictName; continue; }
|
||||||
|
if (!strcmp(argument, "--maxdict")) { nextArgumentIsMaxDict=1; continue; }
|
||||||
|
if (!strcmp(argument, "--dictID")) { nextArgumentIsDictID=1; continue; }
|
||||||
|
if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(0); continue; }
|
||||||
|
if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; }
|
||||||
|
|
||||||
/* Decode commands (note : aggregated commands are allowed) */
|
/* '-' means stdin/stdout */
|
||||||
if (argument[0]=='-') {
|
if (!strcmp(argument, "-")){
|
||||||
argument++;
|
if (!filenameIdx) {
|
||||||
|
filenameIdx=1, filenameTable[0]=stdinmark;
|
||||||
while (argument[0]!=0) {
|
outFileName=stdoutmark;
|
||||||
#ifndef ZSTD_NOCOMPRESS
|
displayLevel-=(displayLevel==2);
|
||||||
/* compression Level */
|
|
||||||
if ((*argument>='0') && (*argument<='9')) {
|
|
||||||
cLevel = readU32FromChar(&argument);
|
|
||||||
dictCLevel = cLevel;
|
|
||||||
if (dictCLevel > ZSTD_maxCLevel())
|
|
||||||
CLEAN_RETURN(badusage(programName));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} }
|
||||||
#endif
|
|
||||||
|
|
||||||
switch(argument[0])
|
/* Decode commands (note : aggregated commands are allowed) */
|
||||||
{
|
if (argument[0]=='-') {
|
||||||
/* Display help */
|
argument++;
|
||||||
case 'V': displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); /* Version Only */
|
|
||||||
case 'H':
|
|
||||||
case 'h': displayOut=stdout; CLEAN_RETURN(usage_advanced(programName));
|
|
||||||
|
|
||||||
/* Decoding */
|
while (argument[0]!=0) {
|
||||||
case 'd': decode=1; argument++; break;
|
#ifndef ZSTD_NOCOMPRESS
|
||||||
|
/* compression Level */
|
||||||
|
if ((*argument>='0') && (*argument<='9')) {
|
||||||
|
cLevel = readU32FromChar(&argument);
|
||||||
|
dictCLevel = cLevel;
|
||||||
|
if (dictCLevel > ZSTD_maxCLevel())
|
||||||
|
CLEAN_RETURN(badusage(programName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Force stdout, even if stdout==console */
|
switch(argument[0])
|
||||||
case 'c': forceStdout=1; outFileName=stdoutmark; displayLevel-=(displayLevel==2); argument++; break;
|
{
|
||||||
|
/* Display help */
|
||||||
|
case 'V': displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); /* Version Only */
|
||||||
|
case 'H':
|
||||||
|
case 'h': displayOut=stdout; CLEAN_RETURN(usage_advanced(programName));
|
||||||
|
|
||||||
/* Use file content as dictionary */
|
/* Decoding */
|
||||||
case 'D': nextEntryIsDictionary = 1; argument++; break;
|
case 'd': decode=1; argument++; break;
|
||||||
|
|
||||||
/* Overwrite */
|
/* Force stdout, even if stdout==console */
|
||||||
case 'f': FIO_overwriteMode(); forceStdout=1; argument++; break;
|
case 'c': forceStdout=1; outFileName=stdoutmark; displayLevel-=(displayLevel==2); argument++; break;
|
||||||
|
|
||||||
/* Verbose mode */
|
/* Use file content as dictionary */
|
||||||
case 'v': displayLevel=4; argument++; break;
|
case 'D': nextEntryIsDictionary = 1; argument++; break;
|
||||||
|
|
||||||
/* Quiet mode */
|
/* Overwrite */
|
||||||
case 'q': displayLevel--; argument++; break;
|
case 'f': FIO_overwriteMode(); forceStdout=1; argument++; break;
|
||||||
|
|
||||||
/* keep source file (default); for gzip/xz compatibility */
|
/* Verbose mode */
|
||||||
case 'k': FIO_setRemoveSrcFile(0); argument++; break;
|
case 'v': displayLevel=4; argument++; break;
|
||||||
|
|
||||||
/* Checksum */
|
/* Quiet mode */
|
||||||
case 'C': argument++; FIO_setChecksumFlag(2); break;
|
case 'q': displayLevel--; argument++; break;
|
||||||
|
|
||||||
/* test compressed file */
|
/* keep source file (default); for gzip/xz compatibility */
|
||||||
case 't': decode=1; outFileName=nulmark; argument++; break;
|
case 'k': FIO_setRemoveSrcFile(0); argument++; break;
|
||||||
|
|
||||||
/* dictionary name */
|
/* Checksum */
|
||||||
case 'o': nextArgumentIsOutFileName=1; argument++; break;
|
case 'C': argument++; FIO_setChecksumFlag(2); break;
|
||||||
|
|
||||||
/* recursive */
|
/* test compressed file */
|
||||||
case 'r': recursive=1; argument++; break;
|
case 't': decode=1; outFileName=nulmark; argument++; break;
|
||||||
|
|
||||||
#ifndef ZSTD_NOBENCH
|
/* dictionary name */
|
||||||
/* Benchmark */
|
case 'o': nextArgumentIsOutFileName=1; argument++; break;
|
||||||
case 'b': bench=1; argument++; break;
|
|
||||||
|
|
||||||
/* range bench (benchmark only) */
|
/* recursive */
|
||||||
case 'e':
|
case 'r': recursive=1; argument++; break;
|
||||||
/* compression Level */
|
|
||||||
|
#ifndef ZSTD_NOBENCH
|
||||||
|
/* Benchmark */
|
||||||
|
case 'b': bench=1; argument++; break;
|
||||||
|
|
||||||
|
/* range bench (benchmark only) */
|
||||||
|
case 'e':
|
||||||
|
/* compression Level */
|
||||||
|
argument++;
|
||||||
|
cLevelLast = readU32FromChar(&argument);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Modify Nb Iterations (benchmark only) */
|
||||||
|
case 'i':
|
||||||
argument++;
|
argument++;
|
||||||
cLevelLast = readU32FromChar(&argument);
|
{ U32 const iters = readU32FromChar(&argument);
|
||||||
|
BMK_setNotificationLevel(displayLevel);
|
||||||
|
BMK_SetNbIterations(iters);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Modify Nb Iterations (benchmark only) */
|
/* cut input into blocks (benchmark only) */
|
||||||
case 'i':
|
case 'B':
|
||||||
argument++;
|
argument++;
|
||||||
{ U32 const iters = readU32FromChar(&argument);
|
{ size_t bSize = readU32FromChar(&argument);
|
||||||
BMK_setNotificationLevel(displayLevel);
|
if (toupper(*argument)=='K') bSize<<=10, argument++; /* allows using KB notation */
|
||||||
BMK_SetNbIterations(iters);
|
if (toupper(*argument)=='M') bSize<<=20, argument++;
|
||||||
|
if (toupper(*argument)=='B') argument++;
|
||||||
|
BMK_setNotificationLevel(displayLevel);
|
||||||
|
BMK_SetBlockSize(bSize);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* ZSTD_NOBENCH */
|
||||||
|
|
||||||
|
/* Dictionary Selection level */
|
||||||
|
case 's':
|
||||||
|
argument++;
|
||||||
|
dictSelect = readU32FromChar(&argument);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
|
||||||
|
case 'p': argument++;
|
||||||
|
#ifndef ZSTD_NOBENCH
|
||||||
|
if ((*argument>='0') && (*argument<='9')) {
|
||||||
|
BMK_setAdditionalParam(readU32FromChar(&argument));
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
main_pause=1;
|
||||||
|
break;
|
||||||
|
/* unknown command */
|
||||||
|
default : CLEAN_RETURN(badusage(programName));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
/* cut input into blocks (benchmark only) */
|
|
||||||
case 'B':
|
|
||||||
argument++;
|
|
||||||
{ size_t bSize = readU32FromChar(&argument);
|
|
||||||
if (toupper(*argument)=='K') bSize<<=10, argument++; /* allows using KB notation */
|
|
||||||
if (toupper(*argument)=='M') bSize<<=20, argument++;
|
|
||||||
if (toupper(*argument)=='B') argument++;
|
|
||||||
BMK_setNotificationLevel(displayLevel);
|
|
||||||
BMK_SetBlockSize(bSize);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif /* ZSTD_NOBENCH */
|
|
||||||
|
|
||||||
/* Dictionary Selection level */
|
|
||||||
case 's':
|
|
||||||
argument++;
|
|
||||||
dictSelect = readU32FromChar(&argument);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
|
|
||||||
case 'p': argument++;
|
|
||||||
#ifndef ZSTD_NOBENCH
|
|
||||||
if ((*argument>='0') && (*argument<='9')) {
|
|
||||||
BMK_setAdditionalParam(readU32FromChar(&argument));
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
main_pause=1;
|
|
||||||
break;
|
|
||||||
/* unknown command */
|
|
||||||
default : CLEAN_RETURN(badusage(programName));
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
} /* if (argument[0]=='-') */
|
||||||
|
|
||||||
|
if (nextArgumentIsMaxDict) {
|
||||||
|
nextArgumentIsMaxDict = 0;
|
||||||
|
maxDictSize = readU32FromChar(&argument);
|
||||||
|
if (toupper(*argument)=='K') maxDictSize <<= 10;
|
||||||
|
if (toupper(*argument)=='M') maxDictSize <<= 20;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
} /* if (argument[0]=='-') */
|
if (nextArgumentIsDictID) {
|
||||||
|
nextArgumentIsDictID = 0;
|
||||||
|
dictID = readU32FromChar(&argument);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* if (nextArgumentIsAFile==0) */
|
||||||
|
|
||||||
if (nextEntryIsDictionary) {
|
if (nextEntryIsDictionary) {
|
||||||
nextEntryIsDictionary = 0;
|
nextEntryIsDictionary = 0;
|
||||||
@ -401,20 +421,6 @@ int main(int argCount, const char** argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextArgumentIsMaxDict) {
|
|
||||||
nextArgumentIsMaxDict = 0;
|
|
||||||
maxDictSize = readU32FromChar(&argument);
|
|
||||||
if (toupper(*argument)=='K') maxDictSize <<= 10;
|
|
||||||
if (toupper(*argument)=='M') maxDictSize <<= 20;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextArgumentIsDictID) {
|
|
||||||
nextArgumentIsDictID = 0;
|
|
||||||
dictID = readU32FromChar(&argument);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add filename to list */
|
/* add filename to list */
|
||||||
filenameTable[filenameIdx++] = argument;
|
filenameTable[filenameIdx++] = argument;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user