summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakuji Tanaka <KXD02663@nifty.ne.jp>2014-01-13 07:44:13 +0000
committerTakuji Tanaka <KXD02663@nifty.ne.jp>2014-01-13 07:44:13 +0000
commit671c56f896d842f33df4fb1d4289ccd9652c8544 (patch)
treeb82a65a73aa0ddad362b7a1a8f0fff2c5cbd6f85
parentf8c54bdc25d73289044df7559ede61c3a19c7b97 (diff)
kpathsea [WIN32]: add a new function for _wpopen()
git-svn-id: svn://tug.org/texlive/trunk@32647 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/kpathsea/ChangeLog4
-rw-r--r--Build/source/texk/kpathsea/knj.c34
-rw-r--r--Build/source/texk/kpathsea/knj.h1
3 files changed, 39 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 82e3d453d0b..d0d9b46c209 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,7 @@
+2014-01-13 TANAKA Takuji <KXD02663@nifty.ne.jp>
+
+ * knj.[ch]: Add a new function fsyscp_popen(). (Windows only)
+
2014-01-08 TANAKA Takuji <KXD02663@nifty.ne.jp>
* knj.c: Allow encoding name "" for non-utf8 command line.
diff --git a/Build/source/texk/kpathsea/knj.c b/Build/source/texk/kpathsea/knj.c
index b6112ed6258..2f38500f005 100644
--- a/Build/source/texk/kpathsea/knj.c
+++ b/Build/source/texk/kpathsea/knj.c
@@ -163,6 +163,40 @@ fsyscp_fopen (const char *filename, const char *mode)
return f;
}
+/*
+ popen by file system codepage
+*/
+FILE *
+fsyscp_popen (const char *command, const char *mode)
+{
+ FILE *f;
+ wchar_t *commandw, modew[4];
+ int i;
+#if defined (KPSE_COMPAT_API)
+ kpathsea kpse;
+#endif
+ assert(command && mode);
+
+ commandw = get_wstring_from_fsyscp(command, commandw=NULL);
+ for(i=0; (modew[i]=(wchar_t)mode[i]); i++) {} /* mode[i] must be ASCII */
+ f = _wpopen(commandw, modew);
+#if defined (KPSE_COMPAT_API)
+ if (f != NULL) {
+ kpse = kpse_def;
+ if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) {
+ DEBUGF_START ();
+ fprintf (stderr, "fsyscp_popen(%s [", command);
+ WriteConsoleW( GetStdHandle( STD_ERROR_HANDLE ), commandw, wcslen( commandw ), NULL, NULL );
+ fprintf (stderr, "], %s) => 0x%lx\n", mode, (unsigned long) f);
+ DEBUGF_END ();
+ }
+ }
+#endif
+ free(commandw);
+
+ return f;
+}
+
void
get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
{
diff --git a/Build/source/texk/kpathsea/knj.h b/Build/source/texk/kpathsea/knj.h
index 3bef4e3f90f..8bfe7df290e 100644
--- a/Build/source/texk/kpathsea/knj.h
+++ b/Build/source/texk/kpathsea/knj.h
@@ -33,6 +33,7 @@ extern KPSEDLL wchar_t* get_wstring_from_mbstring(int cp, const char *mbstr, wch
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 FILE* fsyscp_popen(const char *command, const char *mode);
extern KPSEDLL void get_command_line_args_utf8(const char *enc, int *p_ac, char ***p_av);
#ifdef __cplusplus