filevercmp: correct today's change
authorKamil Dudka <kdudka@redhat.com>
Thu, 9 Apr 2009 16:07:15 +0000 (18:07 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 9 Apr 2009 17:26:48 +0000 (19:26 +0200)
* lib/filevercmp.c: Also handle coreutils' test inputs.
* tests/test-filevercmp.c: Add inputs from one of coreutils' test scripts.

ChangeLog
lib/filevercmp.c
tests/test-filevercmp.c

index 0e45e71dcea216cd7dfd3dc93be6ae1c4e9a0b83..004d784a8da7860ba9b1e629c20b845c41314896 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-04-09  Kamil Dudka  <kdudka@redhat.com>
 
+       filevercmp: correct today's change
+       * lib/filevercmp.c: Also handle coreutils' test inputs.
+       * tests/test-filevercmp.c: Add inputs from one of coreutils' test scripts.
+
        Fix regression in 'filevercmp' module. Thanks Sven Joachim
        for reporting it.
        * lib/filevercmp.c: Special handle for "", "." and "..".
index caa4891c9c4045021a43b38db5727f9cb97c53b0..20522d1c4c387ae9b505ad8156b75d2a92a206ed 100644 (file)
@@ -149,6 +149,17 @@ filevercmp (const char *s1, const char *s2)
   if (0 == strcmp ("..", s2))
     return 1;
 
+  /* special handle for other hidden files */
+  if (*s1 == '.' && *s2 != '.')
+    return -1;
+  if (*s1 != '.' && *s2 == '.')
+    return 1;
+  if (*s1 == '.' && *s2 == '.')
+    {
+      s1++;
+      s2++;
+    }
+
   /* "cut" file suffixes */
   s1_pos = s1;
   s2_pos = s2;
index 700e182777338026f5ffb8a6cc0f78ce4db9d0b1..ca88eb3caf365429a3143aaa28010b0c78c965d2 100644 (file)
@@ -40,10 +40,23 @@ static const char *const examples[] =
   "",
   ".",
   "..",
+  ".0",
+  ".9",
+  ".A",
+  ".Z",
   ".a~",
   ".a",
   ".b~",
   ".b",
+  ".z",
+  ".zz~",
+  ".zz",
+  ".zz.~1~",
+  ".zz.0",
+  "0",
+  "9",
+  "A",
+  "Z",
   "a~",
   "a",
   "a.b~",
@@ -74,6 +87,11 @@ static const char *const examples[] =
   "nss_ldap-1.0-0.1a.tar.gz",
   "nss_ldap-10beta1.fc8.tar.gz",
   "nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild",
+  "z",
+  "zz~",
+  "zz",
+  "zz.~1~",
+  "zz.0",
   "#.b#",
   NULL
 };