After incrementing an unsigned char value, don't cast it back to
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Jun 2009 17:27:53 +0000 (17:27 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Jun 2009 17:27:53 +0000 (17:27 +0000)
unsigned char if you want to preserve its ordering! Fixes a bug
whereby an 0xFF character in a filename could trigger an assertion
failure (since du.c would sort the directory contents correctly but
trie.c would then expect it to be sorted wrong).

git-svn-id: svn://svn.tartarus.org/sgt/agedu@8595 cda61777-01e9-0310-a592-d414129be87e

trie.c

diff --git a/trie.c b/trie.c
index ddadddb..48302db 100644 (file)
--- a/trie.c
+++ b/trie.c
@@ -15,9 +15,9 @@
  */
 static int trieccmp(unsigned char a, unsigned char b)
 {
-    a = (a == '\0' ? '\0' : a == pathsep ? '\1' : a+1);
-    b = (b == '\0' ? '\0' : b == pathsep ? '\1' : b+1);
-    return (int)a - (int)b;
+    int ia = (a == '\0' ? '\0' : a == pathsep ? '\1' : a+1);
+    int ib = (b == '\0' ? '\0' : b == pathsep ? '\1' : b+1);
+    return ia - ib;
 }
 
 static int triencmp(const char *a, size_t alen,