diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-04 11:56:32 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-04 11:56:32 +0000 |
commit | 1491bd20a6acc228027bb0ef69f72b48aa6a572d (patch) | |
tree | bf28cbb1c4453dcaa76bbffe5d08a957fea30408 /Build/source/texk/kpathsea/xdirtest.c | |
parent | be0be9e57afa091468dd619092180640d8c29a38 (diff) |
kpathsea: More changes to reduce diffs with W32TeX
git-svn-id: svn://tug.org/texlive/trunk@23405 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/xdirtest.c')
-rw-r--r-- | Build/source/texk/kpathsea/xdirtest.c | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/xdirtest.c b/Build/source/texk/kpathsea/xdirtest.c new file mode 100644 index 00000000000..47163e3889d --- /dev/null +++ b/Build/source/texk/kpathsea/xdirtest.c @@ -0,0 +1,148 @@ +/* xdirtest.c: standalone test xdirname() and xbasename(). + + Copyright 1999 Karl Berry. + Copyright 2005 Olaf Weber. + Copyright 2011 Peter Breitenlohner. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#include <kpathsea/config.h> + +static const char *tab[] = { +/* UNC names */ +#if defined (WIN32) + "\\\\neuromancer\\fptex\\bin\\win32\\kpsewhich.exe", + "\\\\neuromancer\\fptex\\win32\\kpsewhich.exe", + "\\\\neuromancer\\fptex\\kpsewhich.exe", + "\\\\neuromancer\\kpsewhich.exe", + "//server.host/share/file", + "//server.host//share", /* malformed */ + "//server.host", /* malformed */ + "//.host/share", /* not UNC name */ +#endif + "//neuromancer/kpsewhich.exe", +/* names with device */ +#if defined (WIN32) + "p:\\bin\\win32\\kpsewhich.exe", + "p:\\win32\\kpsewhich.exe", + "p:\\kpsewhich.exe", + "p:bin\\win32\\kpsewhich.exe", + "p:win32\\kpsewhich.exe", +#endif + "p:win32//kpsewhich.exe", + "p:kpsewhich.exe", + "p:///kpsewhich.exe", +/* 'normal' names */ + "/usr/bin/win32/kpsewhich.exe", + "/usr/bin/kpsewhich.exe", + "/usr/kpsewhich.exe", + "///usr/kpsewhich.exe", + "///kpsewhich.exe", + "", + NULL +}; + +#if defined (WIN32) +static const char *ktab[] = { +/* UNC names */ + "\\\\serverK\\\\shareK\\\\file", + "\\\\serverKK\\shareKK\\file", + "\\\\serverK\\\\shareK\\", + "\\\\serverKK\\shareKK", +/* 'normal' names */ + "\\abcK\\deKKfK\\\\hijK\\", + "\\abcKKdeKKfKK\\hijKK", + "\\abcK\\deKKfK\\", + "\\abcKKdeKKfKK", + NULL +}; + +static char * +to_kanji (const char *str) { + char *p, *ret = xstrdup(str); + + for (p = ret; *p; p++) + if (*p == 'K') + *p = 0x81; + + return ret; +} + +static char * +from_kanji (char *str) { + char *p; + + for (p = str; *p; p++) + if ((unsigned char) *p == 0x81) + *p = 'K'; + + return str; +} + +static void +do_kanji (void) { + const char **p; + + printf("\nAssuming CP %s 932\n", is_cp932_system ? "is" : "is not"); + + for (p = ktab; *p; p++) { + char *q = to_kanji(*p); + char *r = xdirname(q); + + printf("%s -> %s + %s\n", *p, from_kanji(r), *p + (xbasename(q)-q)); + + free (r); + free (q); + } +} + +static void +kanji_test(void) { + int save_cp932 = is_cp932_system; + + printf("\nTesting 2-Byte Kanji (CP 932, SJIS) codes with 'K' representing 0x81\n"); + + is_cp932_system = 1; /* pretend CP is 932 */ + do_kanji(); + + is_cp932_system = 0; /* pretend CP is not 932 */ + do_kanji(); + + is_cp932_system = save_cp932; +} +#endif + +int main(int argc, char **argv) +{ + const char **p; + kpathsea kpse = kpathsea_new(); + + kpathsea_set_program_name (kpse, argv[0], NULL); + + printf("\n%s: name -> xdirname(name) + xbasename(name)\n\n", + kpse->invocation_short_name); + + for (p = tab; *p; p++) { + char *q = xdirname(*p); + + printf("%s -> %s + %s\n", *p, q, xbasename(*p)); + free (q); + } + +#if defined (WIN32) + kanji_test(); +#endif + + return 0; +} |