OSSP CVS Repository

ossp - Check-in [3641]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3641
Date: 2003-Oct-13 16:01:38 (local)
2003-Oct-13 14:01:38 (UTC)
User:thl
Branch:
Comment: improve readability, find and fix str1 == NULL bug
Tickets:
Inspections:
Files:
ossp-pkg/fsl/fsl.c      1.64 -> 1.65     9 inserted, 6 deleted

ossp-pkg/fsl/fsl.c 1.64 -> 1.65

--- fsl.c        2003/10/13 13:35:51     1.64
+++ fsl.c        2003/10/13 14:01:38     1.65
@@ -374,16 +374,19 @@
 /* alphabetically compare two filenames, use with qsort(3) */
 static int fnamecmp(const void *str1, const void *str2)
 {
-    if ((*(const char **)str1 != NULL) && (*(const char **)str2 != NULL))
-        return strcmp(*(const char **)str1, *(const char **)str2);
+    const char *s1 = *(const char **)str1;
+    const char *s2 = *(const char **)str2;
+
+    if ((s1 != NULL) && (s2 != NULL))
+        return strcmp(s1, s2);
 
     /* this must never happen but be prepared for the impossible */
 
-    if ((*(const char **)str1 != NULL) && (*(const char **)str2 == NULL))
-        return strcmp(*(const char **)str1, "");
+    if ((s1 != NULL) && (s2 == NULL))
+        return strcmp(s1, "");
 
-    if ((*(const char **)str1 == NULL) && (*(const char **)str2 != NULL))
-        return strcmp("", *(const char **)str1);
+    if ((s1 == NULL) && (s2 != NULL))
+        return strcmp("", s2);
 
     return strcmp("", "");
 }

CVSTrac 2.0.1