From: Pádraig Brady Date: Fri, 7 Nov 2025 13:55:39 +0000 (+0000) Subject: md5sum: fix --text with the MSYS2 runtime X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f265b515e5b93cef9bef0c4994622574c55a1ba;p=thirdparty%2Fcoreutils.git md5sum: fix --text with the MSYS2 runtime Note the use of "rt" is non-standard, but we're restricting its use here to systems that define O_BINARY, which should invariably support "rt" mode. * src/digest.c (): Where significant, explicitly use "rt" mode with --text, as MSYS2 defaults to binary mode for fopen'd files (though not for standard streams). * NEWS: Mention the bug fix. Fixes https://github.com/coreutils/coreutils/issues/123 --- diff --git a/NEWS b/NEWS index e334a07fa3..61d7842528 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + md5sum --text correctly translates CRLF line endings with the MSYS2 runtime. + This also applies to the sha*sum and b2sum utilities. + [This bug was present in "the beginning".] + * Noteworthy changes in release 9.9 (2025-11-10) [stable] diff --git a/src/digest.c b/src/digest.c index 58b9c9ec1f..f330bc1e93 100644 --- a/src/digest.c +++ b/src/digest.c @@ -1121,7 +1121,7 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result, } else { - fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r")); + fp = fopen (filename, O_BINARY ? (*binary ? "rb" : "rt") : "r"); if (fp == nullptr) { if (ignore_missing && errno == ENOENT)