From 3feac8d180f5d766dc034668629c8eb8d62949a5 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Wed, 27 Dec 2017 07:15:12 +0000 Subject: fix a bug in xdirname.c (W32 only) git-svn-id: svn://tug.org/texlive/trunk@46148 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/kpathsea/ChangeLog | 3 ++- Build/source/texk/kpathsea/xdirname.c | 29 +++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 8ef4bdbfbe1..1511b4a0621 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,6 +1,7 @@ 2017-12-27 Akira Kakuto - * 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 diff --git a/Build/source/texk/kpathsea/xdirname.c b/Build/source/texk/kpathsea/xdirname.c index dd9a02ffbfb..2530e360f6f 100644 --- a/Build/source/texk/kpathsea/xdirname.c +++ b/Build/source/texk/kpathsea/xdirname.c @@ -32,7 +32,6 @@ xdirname (const_string name) unsigned limit = 0, loc; #if defined(WIN32) string p; - unsigned i, j; #endif /* Ignore a NULL name. */ @@ -53,20 +52,11 @@ xdirname (const_string name) 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 @@ xdirname (const_string name) } } 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--; -- cgit v1.2.3