bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Carriage Return Patch for md5sum


From: Martin Scharrer
Subject: Carriage Return Patch for md5sum
Date: Wed, 1 Dec 2004 13:48:57 +0100
User-agent: KMail/1.7.1

Hello Gnu Team,

I had problems with md5 checksum files generated under MS Windows, because 
md5sum doesn't remove trailing carriage returns ('\r') on the end of the lines, 
just trailing newlines. 
When you are checking the files the '\r' will be handled as part of the 
filename and you get many error lines like:
: No such file or directory
: FAILED open or read

So I add under the original code:
      /* Remove any trailing newline.  */
      if (line[line_length - 1] == '\n')
        line[--line_length] = '\0';

the code lines:

      /* Remove any trailing carriage return (for DOS/Windows checksum files). 
*/
      if (line[line_length - 1] == '\r')
        line[--line_length] = '\0';

to make md5sum compatible to DOS/Windows checksum files.

Here is the patch:

--- coreutils-5.2.1_orig/src/md5sum.c   2004-01-21 23:27:02.000000000 +0100
+++ coreutils-5.2.1/src/md5sum.c        2004-12-01 13:34:30.000000000 +0100
@@ -426,6 +426,10 @@
       if (line[line_length - 1] == '\n')
        line[--line_length] = '\0';

+      /* Remove any trailing carriage return (for DOS/Windows checksum files). 
*/
+      if (line[line_length - 1] == '\r')
+       line[--line_length] = '\0';
+
       err = split_3 (line, line_length, &hex_digest, &binary, &filename);
       if (err || !hex_digits (hex_digest))
        {


Best regards,
Martin Scharrer






reply via email to

[Prev in Thread] Current Thread [Next in Thread]