Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,13 @@ static const char** UTIL_createLinePointers(char* buffer, size_t numLines, size_
len++;
}

#if defined(_WIN32)
/* note: read in binary mode, so the CRT no longer folds CRLF; CR is legal in a filename elsewhere */
if (len > 0 && buffer[pos + len - 1] == '\r') {
buffer[pos + len - 1] = '\0';
}
#endif

/* Move past this string and its null terminator */
pos += len;
if (pos < bufferSize) pos++; /* Skip the null terminator if we're not at buffer end */
Expand Down
17 changes: 17 additions & 0 deletions tests/playTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,23 @@ zstd -f --filelist=tmp_symLink
test -f tmp2.zst
test -f tmp1.zst

# CR is only stripped when _WIN32 is defined: MSVC and MinGW, but not Cygwin
stripsCR=false
if [ "$isWindows" = true ] ; then
case "$UNAME" in
MINGW*|MSYS*) stripsCR=true ;;
esac
fi

if [ "$stripsCR" = true ] ; then
println "test : file list with Windows CRLF line endings, --filelist=FILE" # (#4349)
rm -f *.zst
printf 'tmp1\r\ntmp2\r\n' > tmp_crlfList
zstd -f --filelist=tmp_crlfList
test -f tmp1.zst
test -f tmp2.zst
fi

println "test : compress multiple files reading them from multiple files, --filelist=FILE"
rm -f *.zst
println "Hello world!, file3" > tmp3
Expand Down
Loading