minor compatibility fixes
This commit is contained in:
parent
ccba7a0a29
commit
cc24124014
@ -22,12 +22,11 @@ It trades CPU time for compression ratio.
|
||||
> **Branch Policy:**
|
||||
|
||||
> - The "master" branch is considered stable, at all times.
|
||||
> - The "dev" branch is the one where all contributions must be merged
|
||||
> - The "dev" branch is the one where all contributions must be merged
|
||||
before being promoted to master.
|
||||
> + If you plan to propose a patch, please commit into the "dev" branch.
|
||||
> + If you plan to propose a patch, please commit into the "dev" branch,
|
||||
or its own feature branch.
|
||||
Direct commit to "master" are not permitted.
|
||||
> - Feature branches can also exist,
|
||||
for dedicated tests of larger modifications before merge into "dev" branch.
|
||||
|
||||
Benchmarks
|
||||
-------------------------
|
||||
|
@ -158,13 +158,13 @@ for files that have not been compressed with
|
||||
force write to standard output, even if it is the console
|
||||
|
||||
.TP
|
||||
.BR \-m
|
||||
.BR \-m ", " \--multiple
|
||||
Multiple file names.
|
||||
By default, the second filename is used as the output filename for the compressed file.
|
||||
With
|
||||
.B -m
|
||||
, you can specify any number of input filenames, each of them will be compressed
|
||||
with the resulting compressed file named
|
||||
, you can specify any number of input filenames. Each of them will be compressed
|
||||
independently, and the resulting name of the compressed file will be
|
||||
.B filename.lz4
|
||||
.
|
||||
|
||||
|
@ -266,7 +266,7 @@ int main(int argc, char** argv)
|
||||
forceCompress=0,
|
||||
main_pause=0,
|
||||
multiple_inputs=0,
|
||||
multiple_rv=0;
|
||||
operationResult=0;
|
||||
const char* input_filename=0;
|
||||
const char* output_filename=0;
|
||||
char* dynNameSpace=0;
|
||||
@ -295,12 +295,13 @@ int main(int argc, char** argv)
|
||||
/* long commands (--long-word) */
|
||||
if (!strcmp(argument, "--compress")) { forceCompress = 1; continue; }
|
||||
if ((!strcmp(argument, "--decompress"))
|
||||
|| (!strcmp(argument, "--uncompress"))) { decode = 1; continue; }
|
||||
|| (!strcmp(argument, "--uncompress"))) { decode = 1; continue; }
|
||||
if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; if (inFileNames==NULL) inFileNames = (const char**)malloc(argc * sizeof(char*)); continue; }
|
||||
if (!strcmp(argument, "--test")) { decode = 1; LZ4IO_setOverwrite(1); output_filename=nulmark; continue; }
|
||||
if (!strcmp(argument, "--force")) { LZ4IO_setOverwrite(1); continue; }
|
||||
if (!strcmp(argument, "--no-force")) { LZ4IO_setOverwrite(0); continue; }
|
||||
if ((!strcmp(argument, "--stdout"))
|
||||
|| (!strcmp(argument, "--to-stdout"))) { forceStdout=1; output_filename=stdoutmark; displayLevel=1; continue; }
|
||||
|| (!strcmp(argument, "--to-stdout"))) { forceStdout=1; output_filename=stdoutmark; displayLevel=1; continue; }
|
||||
if (!strcmp(argument, "--frame-crc")) { LZ4IO_setStreamChecksumMode(1); continue; }
|
||||
if (!strcmp(argument, "--no-frame-crc")) { LZ4IO_setStreamChecksumMode(0); continue; }
|
||||
if (!strcmp(argument, "--content-size")) { LZ4IO_setContentSize(1); continue; }
|
||||
@ -312,6 +313,7 @@ int main(int argc, char** argv)
|
||||
if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; }
|
||||
if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */
|
||||
|
||||
|
||||
/* Short commands (note : aggregated short commands are allowed) */
|
||||
if (argument[0]=='-')
|
||||
{
|
||||
@ -528,7 +530,7 @@ int main(int argc, char** argv)
|
||||
if (decode)
|
||||
{
|
||||
if (multiple_inputs)
|
||||
multiple_rv = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION);
|
||||
operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION);
|
||||
else
|
||||
DEFAULT_DECOMPRESSOR(input_filename, output_filename);
|
||||
}
|
||||
@ -543,7 +545,7 @@ int main(int argc, char** argv)
|
||||
else
|
||||
{
|
||||
if (multiple_inputs)
|
||||
multiple_rv = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel);
|
||||
operationResult = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel);
|
||||
else
|
||||
DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel);
|
||||
}
|
||||
@ -552,6 +554,6 @@ int main(int argc, char** argv)
|
||||
if (main_pause) waitEnter();
|
||||
free(dynNameSpace);
|
||||
free((void*)inFileNames);
|
||||
if (multiple_rv != 0) return multiple_rv;
|
||||
if (operationResult != 0) return operationResult;
|
||||
return 0;
|
||||
}
|
||||
|
@ -509,21 +509,21 @@ int LZ4IO_compressMultipleFilenames(const char** inFileNamesTable, int ifntSize,
|
||||
{
|
||||
int i;
|
||||
int missing_files = 0;
|
||||
FILE *ifp;
|
||||
char* outFileName = (char*)malloc(FNSPACE);
|
||||
size_t ofnSize = FNSPACE;
|
||||
const size_t suffixSize = strlen(suffix);
|
||||
|
||||
for (i=0; i<ifntSize; i++)
|
||||
{
|
||||
ifp = fopen(inFileNamesTable[i], "r");
|
||||
size_t ifnSize;
|
||||
FILE* ifp = fopen(inFileNamesTable[i], "r");
|
||||
if (ifp == NULL) {
|
||||
DISPLAYLEVEL(2, "Unable to access file for processing: %s\n", inFileNamesTable[i]);
|
||||
missing_files++;
|
||||
continue;
|
||||
}
|
||||
fclose(ifp);
|
||||
size_t ifnSize = strlen(inFileNamesTable[i]);
|
||||
ifnSize = strlen(inFileNamesTable[i]);
|
||||
if (ofnSize <= ifnSize+suffixSize+1) { free(outFileName); ofnSize = ifnSize + 20; outFileName = (char*)malloc(ofnSize); }
|
||||
strcpy(outFileName, inFileNamesTable[i]);
|
||||
strcat(outFileName, suffix);
|
||||
@ -539,25 +539,27 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz
|
||||
int i;
|
||||
int skipped_files = 0;
|
||||
int missing_files = 0;
|
||||
FILE *ifp;
|
||||
char* outFileName = (char*)malloc(FNSPACE);
|
||||
size_t ofnSize = FNSPACE;
|
||||
size_t suffixSize = strlen(suffix);
|
||||
const size_t suffixSize = strlen(suffix);
|
||||
char* ifnSuffix = (char*)malloc(suffixSize + 1);
|
||||
|
||||
for (i=0; i<ifntSize; i++)
|
||||
{
|
||||
ifp = fopen(inFileNamesTable[i], "r");
|
||||
if (ifp == NULL) {
|
||||
size_t ifnSize;
|
||||
FILE* ifp = fopen(inFileNamesTable[i], "r");
|
||||
if (ifp == NULL)
|
||||
{
|
||||
DISPLAYLEVEL(2, "Unable to access file for processing: %s\n", inFileNamesTable[i]);
|
||||
missing_files++;
|
||||
continue;
|
||||
}
|
||||
fclose(ifp);
|
||||
size_t ifnSize = strlen(inFileNamesTable[i]);
|
||||
ifnSize = strlen(inFileNamesTable[i]);
|
||||
strcpy(ifnSuffix, inFileNamesTable[i] + ifnSize - suffixSize);
|
||||
if (ofnSize <= ifnSize-suffixSize+1) { free(outFileName); ofnSize = ifnSize + 20; outFileName = (char*)malloc(ofnSize); }
|
||||
if (ifnSize <= suffixSize || strcmp(ifnSuffix, suffix) != 0) {
|
||||
if (ifnSize <= suffixSize || strcmp(ifnSuffix, suffix) != 0)
|
||||
{
|
||||
DISPLAYLEVEL(2, "File extension doesn't match expected LZ4_EXTENSION (%4s); will not process file: %s\n", suffix, inFileNamesTable[i]);
|
||||
skipped_files++;
|
||||
continue;
|
||||
@ -567,6 +569,7 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz
|
||||
LZ4IO_decompressFilename(inFileNamesTable[i], outFileName);
|
||||
}
|
||||
free(outFileName);
|
||||
free(ifnSuffix);
|
||||
if (skipped_files > 0) return 1;
|
||||
if (missing_files > 0) return 1;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user