Hi Jim,
Jim Meyering schrieb:
> Would you like to write the patch (including NEWS and
> a small doc update), following these guidelines?
> 
>   http://git.sv.gnu.org/cgit/coreutils.git/plain/HACKING
I've just tested a bit, and it seems that its enough to hack around the
first place where the blank can appear (bsd tools) or not (openssl).
Since the patch is really small I would like to ask you for a review
without urging me to go through all the git stuff; if you accept the
simple patch then I will follow up with the docs / NEWS update.
I've tested this patch successfully with both bsd and openssl format.
The first hunk is not needed, but I thought while on it we can save
there a line ....

thanks, G√ľnter.

--- src/md5sum.c.orig   2009-09-01 13:01:16.000000000 +0200
+++ src/md5sum.c        2009-10-03 19:13:27.000000000 +0200
@@ -251,11 +251,10 @@
 split_3 (char *s, size_t s_len,
          unsigned char **hex_digest, int *binary, char **file_name)
 {
-  size_t i;
+  size_t i = 0;
   bool escaped_filename = false;
   size_t algo_name_len;

-  i = 0;
   while (ISWHITE (s[i]))
     ++i;

@@ -263,11 +262,14 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
     {
-      if (strncmp (s + i + algo_name_len, " (", 2) == 0)
+      size_t j = i + algo_name_len;
+      while (ISWHITE (s[j]))
+        ++j;
+
+      if (strncmp (s + j, "(", 1) == 0)
         {
           *binary = 0;
-          return bsd_split_3 (s +      i + algo_name_len + 2,
-                              s_len - (i + algo_name_len + 2),
+          return bsd_split_3 (s + j + 1, s_len - (j + 1),
                               hex_digest, file_name);
         }
     }
--- src/md5sum.c.orig	2009-09-01 13:01:16.000000000 +0200
+++ src/md5sum.c	2009-10-03 19:13:27.000000000 +0200
@@ -251,11 +251,10 @@
 split_3 (char *s, size_t s_len,
          unsigned char **hex_digest, int *binary, char **file_name)
 {
-  size_t i;
+  size_t i = 0;
   bool escaped_filename = false;
   size_t algo_name_len;
 
-  i = 0;
   while (ISWHITE (s[i]))
     ++i;
 
@@ -263,11 +262,14 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
     {
-      if (strncmp (s + i + algo_name_len, " (", 2) == 0)
+      size_t j = i + algo_name_len;
+      while (ISWHITE (s[j]))
+        ++j;
+
+      if (strncmp (s + j, "(", 1) == 0)
         {
           *binary = 0;
-          return bsd_split_3 (s +      i + algo_name_len + 2,
-                              s_len - (i + algo_name_len + 2),
+          return bsd_split_3 (s + j + 1, s_len - (j + 1),
                               hex_digest, file_name);
         }
     }

Reply via email to