diff options
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 3 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/xdirname.c | 29 |
2 files changed, 13 insertions, 19 deletions
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 <kakuto@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 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--; |