texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5379] Fix comparing file names on MS-Windows/MS-DOS for "-a -w".


From: Eli Zaretskii
Subject: [5379] Fix comparing file names on MS-Windows/MS-DOS for "-a -w".
Date: Thu, 19 Sep 2013 09:00:49 +0000

Revision: 5379
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5379
Author:   eliz
Date:     2013-09-19 09:00:48 +0000 (Thu, 19 Sep 2013)
Log Message:
-----------
Fix comparing file names on MS-Windows/MS-DOS for "-a -w".

 info/info-utils.c (fncmp): For MS-DOS/MS-Windows, a new function
 for comparing file names disregarding letter-case and
 forward/backslash differences; for Posix platforms, a macro that
 expands into a strcmp call.
 (info_namelist_add): Use fncmp instead of strcmp.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/info-utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2013-09-17 21:53:44 UTC (rev 5378)
+++ trunk/ChangeLog     2013-09-19 09:00:48 UTC (rev 5379)
@@ -1,3 +1,11 @@
+2013-09-19  Eli Zaretskii  <address@hidden>
+
+       * info/info-utils.c (fncmp): For MS-DOS/MS-Windows, a new function
+       for comparing file names disregarding letter-case and
+       forward/backslash differences; for Posix platforms, a macro that
+       expands into a strcmp call.
+       (info_namelist_add): Use fncmp instead of strcmp.
+
 2013-09-13  Karl Berry  <address@hidden>
 
        * pretest 5.1.90.

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2013-09-17 21:53:44 UTC (rev 5378)
+++ trunk/info/info-utils.c     2013-09-19 09:00:48 UTC (rev 5379)
@@ -880,6 +880,29 @@
   return n;
 }
 
+#if defined(__MSDOS__) || defined(__MINGW32__)
+/* Cannot use FILENAME_CMP here, since that does not consider forward-
+   and back-slash characters equal.  */
+static int
+fncmp (const char *fn1, const char *fn2)
+{
+  const char *s1 = fn1, *s2 = fn2;
+
+  while (tolower (*s1) == tolower (*s2)
+        || (IS_SLASH (*s1) && IS_SLASH (*s2)))
+    {
+      if (*s1 == 0)
+       return 0;
+      s1++;
+      s2++;
+    }
+
+  return tolower (*s1) - tolower (*s2);
+}
+#else
+# define fncmp(s,t) strcmp(s,t)
+#endif
+
 struct info_namelist_entry
 {
   struct info_namelist_entry *next;
@@ -892,7 +915,7 @@
   struct info_namelist_entry *p;
 
   for (p = *ptop; p; p = p->next)
-    if (strcmp (p->name, name) == 0)
+    if (fncmp (p->name, name) == 0)
       return 1;
 
   p = xmalloc (sizeof (*p) + strlen (name));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]