summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/lib/texmfmp.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2013-12-03 14:32:09 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2013-12-03 14:32:09 +0000
commit5b0be858da5f93a678e7665f67921f8e63559f5a (patch)
tree8fd7977521cfc2ed41d72c599ffc50330b50c0e0 /Build/source/texk/web2c/lib/texmfmp.c
parente12d9594464166e09a2127166d663cedbcd9a050 (diff)
Support KANJI file name in (e)upTeX and XeTeX on Windows (from T. Tanaka)
git-svn-id: svn://tug.org/texlive/trunk@32308 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/lib/texmfmp.c')
-rw-r--r--Build/source/texk/web2c/lib/texmfmp.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c
index 515d68b0b50..548012365e2 100644
--- a/Build/source/texk/web2c/lib/texmfmp.c
+++ b/Build/source/texk/web2c/lib/texmfmp.c
@@ -628,7 +628,9 @@ void
maininit (int ac, string *av)
{
string main_input_file;
-
+#if (IS_upTeX || defined(XeTeX)) && defined(WIN32)
+ string enc;
+#endif
/* Save to pass along to topenin. */
argc = ac;
argv = av;
@@ -655,11 +657,51 @@ maininit (int ac, string *av)
kpse_set_program_name (argv[0], NULL);
initkanji ();
#endif
+#if defined(XeTeX) && defined(WIN32)
+ kpse_set_program_name (argv[0], NULL);
+#endif
+#if (IS_upTeX || defined(XeTeX)) && defined(WIN32)
+ enc = kpse_var_value("command_line_encoding");
+ if (enc) {
+#ifdef DEBUG
+ fprintf(stderr, "command_line_encoding (%s)\n", enc);
+#endif /* DEBUG */
+ if (!(strncmp(enc,"utf8",5) && strncmp(enc,"utf-8",6))) {
+ DWORD ret;
+ LPWSTR *argvw;
+ INT argcw, i;
+ string s;
+#ifdef DEBUG
+ HANDLE hStderr;
+ hStderr = GetStdHandle( STD_ERROR_HANDLE );
+#endif /* DEBUG */
+ file_system_codepage = CP_UTF8;
+ is_cp932_system = 0;
+ argvw = CommandLineToArgvW(GetCommandLineW(), &argcw);
+ argc = argcw;
+ argv = xmalloc(sizeof(char *)*(argcw+1));
+ for (i=0; i<argcw; i++) {
+ s = get_utf8_from_wstring(argvw[i], s=NULL);
+ argv[i] = s;
+#ifdef DEBUG
+ fprintf(stderr, "Commandline arguments %d:(%s) [", i, argv[i]);
+ WriteConsoleW( hStderr, argvw[i], wcslen(argvw[i]), &ret, NULL);
+ fprintf(stderr, "]\n");
+#endif /* DEBUG */
+ }
+ argv[argcw] = NULL;
+ }
+ }
+#endif
/* If the user says --help or --version, we need to notice early. And
since we want the --ini option, have to do it before getting into
the web (which would read the base file, etc.). */
+#if (IS_upTeX || defined(XeTeX)) && defined(WIN32)
+ parse_options (argc, argv);
+#else
parse_options (ac, av);
+#endif
#if IS_pTeX
/* In pTeX and friends, texmf.cnf is not recorded in the case of --recorder,
@@ -679,7 +721,7 @@ maininit (int ac, string *av)
/* Do this early so we can inspect kpse_invocation_name and
kpse_program_name below, and because we have to do this before
any path searching. */
-#if IS_pTeX
+#if IS_pTeX || (defined(XeTeX) && defined(WIN32))
if (user_progname)
kpse_reset_program_name (user_progname);
#else