Skip to content
Merged
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
10 changes: 7 additions & 3 deletions hash_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,10 @@ strbuf_t* init_printf_format(void)
int print_sfv_header_line(FILE* out, unsigned out_mode, file_t* file)
{
char buf[24];
unsigned out_flags = (out_mode & FileContentIsUtf8 ?
OutForceUtf8 | OutEscapePrefixed : OutEscapePrefixed);
unsigned out_flags = (out_mode & FileContentIsUtf8 ? OutForceUtf8 : 0);
#ifndef _WIN32
out_flags |= OutEscape;
#endif
/* skip stdin stream and message-texts passed by command-line */
if (FILE_ISSPECIAL(file))
return 0;
Expand All @@ -899,7 +901,9 @@ int print_sfv_header_line(FILE* out, unsigned out_mode, file_t* file)
if (rsh_fprintf(out, "; %s ", buf) < 0)
return -1;
print_time64(out, file->mtime, 1);
return PRINTF_RES(fprintf_file_t(out, " %s\n", file, out_flags));
if (rsh_fprintf(out, " ") < 0 || fprintf_file_t(out, NULL, file, out_flags) < 0)
return -1;
return PRINTF_RES(rsh_fprintf(out, "\n"));
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/test_rhash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,21 @@ if ! win32; then
TEST_RESULT=$( printf '\\00000000 a/\\n2\n' | $rhash -c --brief - 2>&1 | head -n1 | tr -d ' ' )
TEST_EXPECTED='\a/\n2OK'
check "$TEST_RESULT" "$TEST_EXPECTED" .
NAME_B='a/back\slash'
touch "$NAME_B"
SFV_FILE="$RHASH_TMP/special.sfv"
$rhash --sfv "$NAME_R" "$NAME_N" "$NAME_B" > "$SFV_FILE"
check "$?" "0" .
TEST_RESULT=$( sed -n '/^; *0 /s/^; *0 [^ ]* [^ ]* //p' "$SFV_FILE" )
TEST_EXPECTED=$( printf '%s\n' 'a/\r1' 'a/\n2' 'a/back\\slash' )
check "$TEST_RESULT" "$TEST_EXPECTED" .
$rhash -c --brief "$SFV_FILE" >/dev/null 2>&1
check "$?" "0" .
SFV_FILE="$RHASH_TMP/update-special.sfv"
$rhash --sfv --update "$SFV_FILE" "$NAME_R" "$NAME_N" "$NAME_B" >/dev/null 2>&1
check "$?" "0" .
$rhash -c --brief "$SFV_FILE" >/dev/null 2>&1
check "$?" "0" .
fi
fi
TEST_RESULT=$( $rhash -p '\63\1\277\x0f\x1\t\\ \x34\r' -m "" )
Expand Down
Loading