1
0
mirror of https://github.com/facebook/zstd.git synced 2025-03-07 01:10:04 +02:00

Merge pull request #1479 from facebook/visualTest

Fix remaining Windows errors
This commit is contained in:
Yann Collet 2018-12-27 04:42:44 -08:00 committed by GitHub
commit 470344d33e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 14 deletions

View File

@ -3,6 +3,8 @@
branches:
only:
- master
- appveyorTest
- /visual*/
environment:
matrix:
- COMPILER: "gcc"

View File

@ -397,7 +397,7 @@
>
</File>
<File
RelativePath="..\..\..\programs\bench.c"
RelativePath="..\..\..\programs\benchfn.c"
>
</File>
<File
@ -405,7 +405,7 @@
>
</File>
<File
RelativePath="..\..\..\tests\util.c"
RelativePath="..\..\..\programs\util.c"
>
</File>
<File

View File

@ -337,7 +337,11 @@
>
</File>
<File
RelativePath="..\..\..\programs\bench.c"
RelativePath="..\..\..\programs\benchfn.c"
>
</File>
<File
RelativePath="..\..\..\programs\benchzstd.c"
>
</File>
<File

View File

@ -423,16 +423,29 @@ static FILE* FIO_openDstFile(const char* srcFileName, const char* dstFileName)
return stdout;
}
/* ensure dst is not the same file as src */
if (srcFileName != NULL) {
#ifdef _MSC_VER
/* note : Visual does not support file identification by inode.
* The following work-around is limited to detecting exact name repetition only,
* aka `filename` is considered different from `subdir/../filename` */
if (!strcmp(srcFileName, dstFileName)) {
DISPLAYLEVEL(1, "zstd: Refusing to open a output file which will overwrite the input file \n");
return NULL;
}
#else
stat_t srcStat;
stat_t dstStat;
if ( UTIL_getFileStat(srcFileName, &srcStat)
&& UTIL_getFileStat(dstFileName, &dstStat) ) {
if ( srcStat.st_dev == dstStat.st_dev
&& srcStat.st_ino == dstStat.st_ino ) {
if (UTIL_getFileStat(srcFileName, &srcStat)
&& UTIL_getFileStat(dstFileName, &dstStat)) {
if (srcStat.st_dev == dstStat.st_dev
&& srcStat.st_ino == dstStat.st_ino) {
DISPLAYLEVEL(1, "zstd: Refusing to open a output file which will overwrite the input file \n");
return NULL;
} } }
}
}
#endif
}
if (g_sparseFileSupport == 1) {
g_sparseFileSupport = ZSTD_SPARSE_DEFAULT;

View File

@ -26,6 +26,7 @@ extern "C" {
# define _CRT_SECURE_NO_DEPRECATE /* VS2005 - must be declared before <io.h> and <windows.h> */
# define snprintf sprintf_s /* snprintf unsupported by Visual <= 2013 */
# endif
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
#endif

Binary file not shown.

Binary file not shown.

View File

@ -125,7 +125,7 @@ $ZSTD --fast=9999999999 -f tmp && die "should have refused numeric value"
$ECHO "test : set compression level with environment variable ZSTD_CLEVEL"
ZSTD_CLEVEL=12 $ZSTD -f tmp # positive compression level
ZSTD_CLEVEL=-12 $ZSTD -f tmp # negative compression level
ZSTD_CLEVEL=+12 $ZSTD -f tmp # valid: verbose '+' sign
ZSTD_CLEVEL=+12 $ZSTD -f tmp # valid: verbose '+' sign
ZSTD_CLEVEL= $ZSTD -f tmp # empty env var, warn and revert to default setting
ZSTD_CLEVEL=- $ZSTD -f tmp # malformed env var, warn and revert to default setting
ZSTD_CLEVEL=a $ZSTD -f tmp # malformed env var, warn and revert to default setting
@ -133,7 +133,7 @@ ZSTD_CLEVEL=+a $ZSTD -f tmp # malformed env var, warn and revert to default set
ZSTD_CLEVEL=3a7 $ZSTD -f tmp # malformed env var, warn and revert to default setting
ZSTD_CLEVEL=50000000000 $ZSTD -f tmp # numeric value too large, warn and revert to default setting
$ECHO "test : override ZSTD_CLEVEL with command line option"
ZSTD_CLEVEL=12 $ZSTD --fast=3 -f tmp # overridden by command line option
ZSTD_CLEVEL=12 $ZSTD --fast=3 -f tmp # overridden by command line option
$ECHO "test : compress to stdout"
$ZSTD tmp -c > tmpCompressed
$ZSTD tmp --stdout > tmpCompressed # long command format
@ -192,8 +192,8 @@ chmod 400 tmpro.zst
$ZSTD -q tmpro && die "should have refused to overwrite read-only file"
$ZSTD -q -f tmpro
$ECHO "test: --no-progress flag"
$ZSTD tmpro -c --no-progress | $ZSTD -d -o "$INTOVOID" --no-progress
$ZSTD tmpro -cv --no-progress | $ZSTD -dv -o "$INTOVOID" --no-progress
$ZSTD tmpro -c --no-progress | $ZSTD -d -f -o "$INTOVOID" --no-progress
$ZSTD tmpro -cv --no-progress | $ZSTD -dv -f -o "$INTOVOID" --no-progress
rm -f tmpro tmpro.zst
$ECHO "test: overwrite input file (must fail)"
$ZSTD tmp -fo tmp && die "zstd compression overwrote the input file"
@ -232,7 +232,7 @@ rm tmp*
$ECHO "test : compress multiple files"
$ECHO hello > tmp1
$ECHO world > tmp2
$ZSTD tmp1 tmp2 -o "$INTOVOID"
$ZSTD tmp1 tmp2 -o "$INTOVOID" -f
$ZSTD tmp1 tmp2 -c | $ZSTD -t
$ZSTD tmp1 tmp2 -o tmp.zst
test ! -f tmp1.zst
@ -240,7 +240,7 @@ test ! -f tmp2.zst
$ZSTD tmp1 tmp2
$ZSTD -t tmp1.zst tmp2.zst
$ZSTD -dc tmp1.zst tmp2.zst
$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID"
$ZSTD tmp1.zst tmp2.zst -o "$INTOVOID" -f
$ZSTD -d tmp1.zst tmp2.zst -o tmp
touch tmpexists
$ZSTD tmp1 tmp2 -f -o tmpexists