parent
1ead0c5d5a
commit
8e414b586d
|
@ -219,10 +219,8 @@ U64 UTIL_getTotalFileSize(const char* const * const fileNamesTable, unsigned nbF
|
||||||
* or 0, if there is no new line */
|
* or 0, if there is no new line */
|
||||||
static size_t readLineFromFile(char* buf, size_t len, FILE* file)
|
static size_t readLineFromFile(char* buf, size_t len, FILE* file)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "readLineFromFile \n");
|
|
||||||
assert(!feof(file));
|
assert(!feof(file));
|
||||||
CONTROL( fgets(buf, (int) len, file) == buf ); /* requires success */
|
CONTROL( fgets(buf, (int) len, file) == buf ); /* requires success */
|
||||||
fprintf(stderr, "line = %s \n", buf);
|
|
||||||
if (strlen(buf)==0) return 0;
|
if (strlen(buf)==0) return 0;
|
||||||
return strlen(buf) - (buf[strlen(buf)-1] == '\n'); /* -1 to ignore final '\n' character */
|
return strlen(buf) - (buf[strlen(buf)-1] == '\n'); /* -1 to ignore final '\n' character */
|
||||||
}
|
}
|
||||||
|
@ -244,8 +242,6 @@ readLinesFromFile(void* dst, size_t dstCapacity,
|
||||||
|
|
||||||
assert(dst != NULL);
|
assert(dst != NULL);
|
||||||
|
|
||||||
fprintf(stderr, "readLinesFromFile %s \n", inputFileName);
|
|
||||||
|
|
||||||
if(!inputFile) {
|
if(!inputFile) {
|
||||||
if (g_utilDisplayLevel >= 1) perror("zstd:util:readLinesFromFile");
|
if (g_utilDisplayLevel >= 1) perror("zstd:util:readLinesFromFile");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -258,7 +254,6 @@ readLinesFromFile(void* dst, size_t dstCapacity,
|
||||||
buf[pos+lineLength] = '\0'; /* replace '\n' with '\0'*/
|
buf[pos+lineLength] = '\0'; /* replace '\n' with '\0'*/
|
||||||
pos += lineLength + 1;
|
pos += lineLength + 1;
|
||||||
++nbFiles;
|
++nbFiles;
|
||||||
fprintf(stderr, "nbFiles = %i \n", nbFiles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROL( fclose(inputFile) == 0 );
|
CONTROL( fclose(inputFile) == 0 );
|
||||||
|
@ -346,8 +341,6 @@ UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2)
|
||||||
size_t newTotalTableSize;
|
size_t newTotalTableSize;
|
||||||
char* buf;
|
char* buf;
|
||||||
|
|
||||||
fprintf(stderr, "UTIL_concatenateTwoTables \n");
|
|
||||||
|
|
||||||
FileNamesTable* const newTable = UTIL_createFileNamesTable(NULL, 0, NULL);
|
FileNamesTable* const newTable = UTIL_createFileNamesTable(NULL, 0, NULL);
|
||||||
CONTROL( newTable != NULL );
|
CONTROL( newTable != NULL );
|
||||||
|
|
||||||
|
@ -357,7 +350,6 @@ UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2)
|
||||||
CONTROL ( buf != NULL );
|
CONTROL ( buf != NULL );
|
||||||
|
|
||||||
newTable->buf = buf;
|
newTable->buf = buf;
|
||||||
fprintf(stderr, "Size table1 = %u , table2 = %u \n", (unsigned)table1->tableSize, (unsigned)table2->tableSize);
|
|
||||||
newTable->tableSize = table1->tableSize + table2->tableSize;
|
newTable->tableSize = table1->tableSize + table2->tableSize;
|
||||||
newTable->fileNames = (const char **) calloc(newTable->tableSize, sizeof(*(newTable->fileNames)));
|
newTable->fileNames = (const char **) calloc(newTable->tableSize, sizeof(*(newTable->fileNames)));
|
||||||
CONTROL ( newTable->fileNames != NULL );
|
CONTROL ( newTable->fileNames != NULL );
|
||||||
|
@ -380,7 +372,6 @@ UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2)
|
||||||
pos += curLen+1;
|
pos += curLen+1;
|
||||||
} }
|
} }
|
||||||
assert(pos <= newTotalTableSize);
|
assert(pos <= newTotalTableSize);
|
||||||
fprintf(stderr, "newTableIdx = %u , newTable->tableSize = %u \n", newTableIdx, (unsigned)newTable->tableSize);
|
|
||||||
newTable->tableSize = newTableIdx;
|
newTable->tableSize = newTableIdx;
|
||||||
|
|
||||||
UTIL_freeFileNamesTable(table1);
|
UTIL_freeFileNamesTable(table1);
|
||||||
|
|
|
@ -333,6 +333,14 @@ test -f tmp2
|
||||||
test -f tmp3
|
test -f tmp3
|
||||||
test -f tmp4
|
test -f tmp4
|
||||||
|
|
||||||
|
println "test : survive a list of files which is text garbage (--file=FILE)"
|
||||||
|
./datagen > tmp_badList
|
||||||
|
$ZSTD -f --file=tmp_badList && die "should have failed : list is text garbage"
|
||||||
|
|
||||||
|
println "test : survive a list of files which is binary garbage (--file=FILE)"
|
||||||
|
./datagen -P0 -g1M > tmp_badList
|
||||||
|
$ZSTD -qq -f --file=tmp_badList && die "should have failed : list is binary garbage" # let's avoid printing binary garbage on console
|
||||||
|
|
||||||
rm -rf tmp*
|
rm -rf tmp*
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue