summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorTakuji Tanaka <KXD02663@nifty.ne.jp>2013-12-31 00:52:54 +0000
committerTakuji Tanaka <KXD02663@nifty.ne.jp>2013-12-31 00:52:54 +0000
commit1aae882b478be67d401b4d94e2c7b607dd23f10e (patch)
treef2ed9f77c21d7e770dc8f1b6360566768ec40764 /Build
parentbd344bcd4173e2f20b56a41f894f0354d05ddc4d (diff)
bug fix about error check when fopen (Windows only)
git-svn-id: svn://tug.org/texlive/trunk@32519 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog6
-rw-r--r--Build/source/texk/kpathsea/knj.c72
-rw-r--r--Build/source/texk/kpathsea/knj.h5
-rw-r--r--Build/source/texk/kpathsea/progname.c5
-rw-r--r--Build/source/texk/web2c/lib/ChangeLog6
-rw-r--r--Build/source/texk/web2c/lib/openclose.c6
-rw-r--r--Build/source/texk/web2c/lib/texmfmp.c31
7 files changed, 96 insertions, 35 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 9ffda1014e1..874e0405a6f 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-31 TANAKA Takuji <KXD02663@nifty.ne.jp>
+
+ * knj.c, knj.h: Add new functions fsyscp_fopen() and
+ get_command_line_args_utf8() (Windows only)
+ * progname.c: Refine initialization for KANJI (Windows only)
+
2013-12-03 TANAKA Takuji <KXD02663@nifty.ne.jp>
* elt-dirs.c, knj.c, knj.h, progname.c, readable.c: Support KANJI
diff --git a/Build/source/texk/kpathsea/knj.c b/Build/source/texk/kpathsea/knj.c
index eeb1120e913..efdaaeabe33 100644
--- a/Build/source/texk/kpathsea/knj.c
+++ b/Build/source/texk/kpathsea/knj.c
@@ -127,3 +127,75 @@ fsyscp_xfopen (const char *filename, const char *mode)
return f;
}
+
+/*
+ fopen by file system codepage
+*/
+FILE *
+fsyscp_fopen (const char *filename, const char *mode)
+{
+ FILE *f;
+ wchar_t *fnamew, modew[4];
+#if defined (KPSE_COMPAT_API)
+ kpathsea kpse;
+#endif
+ assert(filename && mode);
+
+ fnamew = get_wstring_from_fsyscp(filename, fnamew=NULL);
+ get_wstring_from_fsyscp(mode, modew);
+ f = _wfopen(fnamew, modew);
+#if defined (KPSE_COMPAT_API)
+ if (f != NULL) {
+ kpse = kpse_def;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) {
+ DEBUGF_START ();
+ fprintf (stderr, "fsyscp_fopen(%s [", filename);
+ WriteConsoleW( GetStdHandle( STD_ERROR_HANDLE ), fnamew, wcslen( fnamew ), NULL, NULL );
+ fprintf (stderr, "], %s) => 0x%lx\n", mode, (unsigned long) f);
+ DEBUGF_END ();
+ }
+ }
+#endif
+ free(fnamew);
+
+ return f;
+}
+
+void
+get_command_line_args_utf8 (const_string enc, int *p_ac, string **p_av)
+{
+ int argc;
+ string *argv;
+
+ if (!enc) return;
+#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;
+ }
+ *p_ac = argc;
+ *p_av = argv;
+}
diff --git a/Build/source/texk/kpathsea/knj.h b/Build/source/texk/kpathsea/knj.h
index 0629213a309..00db79c5e24 100644
--- a/Build/source/texk/kpathsea/knj.h
+++ b/Build/source/texk/kpathsea/knj.h
@@ -19,6 +19,9 @@
#ifndef KPATHSEA_KNJ_H
#define KPATHSEA_KNJ_H
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -32,6 +35,8 @@ extern KPSEDLL int isknj2(int c);
extern KPSEDLL wchar_t* get_wstring_from_mbstring(int cp, const char *mbstr, wchar_t *wstr);
extern KPSEDLL char* get_mbstring_from_wstring(int cp, const wchar_t *wstr, char *mbstr);
extern KPSEDLL FILE* fsyscp_xfopen(const char *filename, const char *mode);
+extern KPSEDLL FILE* fsyscp_fopen(const char *filename, const char *mode);
+extern KPSEDLL void get_command_line_args_utf8(const_string enc, int *p_ac, string **p_av);
#ifdef __cplusplus
}
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c
index 5952936579b..c4fe781011c 100644
--- a/Build/source/texk/kpathsea/progname.c
+++ b/Build/source/texk/kpathsea/progname.c
@@ -501,13 +501,14 @@ kpathsea_set_program_name (kpathsea kpse, const_string argv0,
}
#if defined(WIN32)
- cp = GetACP();
+ if (!file_system_codepage)
+ file_system_codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
+ cp = file_system_codepage;
if (cp == 932 || cp == 936 || cp == 950) {
is_cp932_system = cp;
}
else
is_cp932_system = 0;
- file_system_codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
#if defined(__MINGW32__)
/* Set various info about user. Among many things,
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog
index c81beaad816..37271167d37 100644
--- a/Build/source/texk/web2c/lib/ChangeLog
+++ b/Build/source/texk/web2c/lib/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-31 TANAKA Takuji <KXD02663@nifty.ne.jp>
+
+ * openclose.c: bug fix about error check when fopen.
+ Use fsyscp_fopen() instead of fsyscp_xfopen() (Windows only)
+ * texmfmp.c: Use get_command_line_args_utf8() (Windows only)
+
2013-12-03 TANAKA Takuji <KXD02663@nifty.ne.jp>
* openclose.c, texmfmp.c: Support KANJI file name in (e)upTeX and
diff --git a/Build/source/texk/web2c/lib/openclose.c b/Build/source/texk/web2c/lib/openclose.c
index 35301b5187c..55743231f57 100644
--- a/Build/source/texk/web2c/lib/openclose.c
+++ b/Build/source/texk/web2c/lib/openclose.c
@@ -170,7 +170,7 @@ open_input (FILE **f_ptr, int filefmt, const_string fopen_mode)
if (output_directory && !kpse_absolute_p (nameoffile+1, false)) {
fname = concat3 (output_directory, DIR_SEP_STRING, nameoffile + 1);
#if defined(WIN32)
- *f_ptr = fsyscp_xfopen (fname, fopen_mode);
+ *f_ptr = fsyscp_fopen (fname, fopen_mode);
#else
*f_ptr = fopen (fname, fopen_mode);
#endif
@@ -191,7 +191,7 @@ open_input (FILE **f_ptr, int filefmt, const_string fopen_mode)
if (filefmt < 0) {
/* no_file_path, for BibTeX .aux files and MetaPost things. */
#if defined(WIN32)
- *f_ptr = fsyscp_xfopen(nameoffile + 1, fopen_mode);
+ *f_ptr = fsyscp_fopen(nameoffile + 1, fopen_mode);
#else
*f_ptr = fopen(nameoffile + 1, fopen_mode);
#endif
@@ -292,7 +292,7 @@ open_output (FILE **f_ptr, const_string fopen_mode)
/* Is the filename openable as given? */
#if defined(WIN32)
- *f_ptr = fsyscp_xfopen (fname, fopen_mode);
+ *f_ptr = fsyscp_fopen (fname, fopen_mode);
#else
*f_ptr = fopen (fname, fopen_mode);
#endif
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c
index 548012365e2..4ae5c262602 100644
--- a/Build/source/texk/web2c/lib/texmfmp.c
+++ b/Build/source/texk/web2c/lib/texmfmp.c
@@ -662,36 +662,7 @@ maininit (int ac, string *av)
#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;
- }
- }
+ get_command_line_args_utf8(enc, &argc, &argv);
#endif
/* If the user says --help or --version, we need to notice early. And