texlive[46148] Build/source/texk/kpathsea: fix a bug in xdirname.c

commits+kakuto at tug.org commits+kakuto at tug.org
Wed Dec 27 08:15:12 CET 2017


Revision: 46148
          http://tug.org/svn/texlive?view=revision&revision=46148
Author:   kakuto
Date:     2017-12-27 08:15:12 +0100 (Wed, 27 Dec 2017)
Log Message:
-----------
fix a bug in xdirname.c (W32 only)

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/xdirname.c

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2017-12-27 05:44:22 UTC (rev 46147)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2017-12-27 07:15:12 UTC (rev 46148)
@@ -1,6 +1,7 @@
 2017-12-27  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
-	* xbasename.c, xdirname.c: Remove IS_KANJI test for UNC names.
+	* xbasename.c, xdirname.c: Remove IS_KANJI test for UNC names,
+	and fix a W32 bug in xdirname.c.
 	Report by Douglas McKenna:
 	http://tug.org/pipermail/tex-k/2017-December/002840.html
 

Modified: trunk/Build/source/texk/kpathsea/xdirname.c
===================================================================
--- trunk/Build/source/texk/kpathsea/xdirname.c	2017-12-27 05:44:22 UTC (rev 46147)
+++ trunk/Build/source/texk/kpathsea/xdirname.c	2017-12-27 07:15:12 UTC (rev 46148)
@@ -32,7 +32,6 @@
     unsigned limit = 0, loc;
 #if defined(WIN32)
     string p;
-    unsigned i, j;
 #endif
 
     /* Ignore a NULL name. */
@@ -53,20 +52,11 @@
             limit = 0;
     }
 
-#if defined(WIN32)
-    j = loc = limit;
-    if (j > 2) j++;
-    for (i = j; name[i]; i++) {
-        if (IS_DIR_SEP (name[i])) {
-            j = i;
-            for (i++; IS_DIR_SEP (name[i]); i++)
-                ;
-            loc = i + 1;
-        }
-#if defined (KPSE_COMPAT_API)
-        else if (IS_KANJI(name+i)) i++;
-#endif
-    }
+#if defined(WIN32) && defined (KPSE_COMPAT_API)
+    for (loc = strlen (name); loc > limit &&
+         (!IS_DIR_SEP (name[loc-1]) ||
+         (loc > 1 && IS_KANJI(name+loc-2))); loc--)
+        ;
 #else
     for (loc = strlen (name); loc > limit && !IS_DIR_SEP (name[loc-1]); loc--)
         ;
@@ -87,9 +77,12 @@
         }
     } else {
         /* If have ///a, must return /, so don't strip off everything.  */
-#if defined(WIN32)
-        loc = j;
-        if (loc == limit && IS_DIR_SEP (name[loc])) loc++;
+#if defined(WIN32) && defined (KPSE_COMPAT_API)
+        while (loc > limit+1 && IS_DIR_SEP (name[loc-1])) {
+            if (loc > 1 && IS_KANJI(name+loc-2))
+                break;
+            loc--;
+        }
 #else
         while (loc > limit+1 && IS_DIR_SEP (name[loc-1])) {
             loc--;



More information about the tex-live-commits mailing list