Do only one call to GetVersionEx in the common case.
[pspp] / lib / filevercmp.c
index 99c07db9cc83398fc0b2b14c661f29db9e73c4fc..20522d1c4c387ae9b505ad8156b75d2a92a206ed 100644 (file)
@@ -135,11 +135,27 @@ filevercmp (const char *s1, const char *s2)
   if (simple_cmp == 0)
     return 0;
 
-  /* handle hidden files */
-  while (*s1 == '.' || *s2 == '.')
+  /* special handle for "", "." and ".." */
+  if (!*s1)
+    return -1;
+  if (!*s2)
+    return 1;
+  if (0 == strcmp (".", s1))
+    return -1;
+  if (0 == strcmp (".", s2))
+    return 1;
+  if (0 == strcmp ("..", s1))
+    return -1;
+  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 == '.')
     {
-      if (*s1 != *s2)
-       return *s1 - *s2;
       s1++;
       s2++;
     }