diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-05-02 23:09:47 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-05-02 23:09:47 +0000 |
commit | 255276b0f5ede7ae938255567c712e0d7de9f3da (patch) | |
tree | 6d6a676ea53be42d5c5343cd97f6594d790e09ca /Build/source/texk/dvipdfm-x | |
parent | d518626eefba2ee3d247bd7ce2c53892ee0e272c (diff) |
support file names always in default code page of OS
git-svn-id: svn://tug.org/texlive/trunk@50953 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x')
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dpxfile.c | 57 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/mfileio.h | 5 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfximage.c | 21 |
4 files changed, 77 insertions, 12 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 951d5f9e136..549710ad3c8 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,9 @@ +2019-05-03 Akira Kakuto <kakuto@w32tex.org> + + * dpxfile.c, mfileio.h, pdfximage.c: Support non-ascii file + names in default code page of OS irrespective of values of a + variable 'command_line_encoding' (Windows only). + 2019-05-03 Shunsaku Hirata <shunsaku.hirata74@gmail.com> * pdfobj.c, pdfobj.h: Add support for ASCIIHex and ASCII85 diff --git a/Build/source/texk/dvipdfm-x/dpxfile.c b/Build/source/texk/dvipdfm-x/dpxfile.c index e6f87125ce4..d0afe8dcdfa 100644 --- a/Build/source/texk/dvipdfm-x/dpxfile.c +++ b/Build/source/texk/dvipdfm-x/dpxfile.c @@ -1,5 +1,5 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2019 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -159,6 +159,10 @@ miktex_find_psheader_file (const char *filename, char *buf) static char _tmpbuf[PATH_MAX+1]; #endif /* MIKTEX */ +#if defined(WIN32) +extern int utf8name_failed; +#endif /* WIN32 */ + static int exec_spawn (char *cmd) { char **cmdv, **qv; @@ -240,15 +244,32 @@ static int exec_spawn (char *cmd) ret = _spawnvp(_P_WAIT, *cmdv, (const char* const*)cmdv); #else cmdvw = xcalloc (i + 2, sizeof (wchar_t *)); - qv = cmdv; - qvw = cmdvw; - while (*qv) { - *qvw = get_wstring_from_fsyscp(*qv, *qvw=NULL); - qv++; - qvw++; + if (utf8name_failed == 0) { + qv = cmdv; + qvw = cmdvw; + while (*qv) { + *qvw = get_wstring_from_fsyscp(*qv, *qvw=NULL); + qv++; + qvw++; + } + *qvw = NULL; + ret = _wspawnvp (_P_WAIT, *cmdvw, (const wchar_t* const*) cmdvw); + } else { + int tmpcp; + tmpcp = file_system_codepage; + file_system_codepage = win32_codepage; + qv = cmdv; + qvw = cmdvw; + while (*qv) { + *qvw = get_wstring_from_fsyscp(*qv, *qvw=NULL); + qv++; + qvw++; + } + *qvw = NULL; + file_system_codepage = tmpcp; + utf8name_failed = 0; + ret = _wspawnvp (_P_WAIT, *cmdvw, (const wchar_t* const*) cmdvw); } - *qvw = NULL; - ret = _wspawnvp (_P_WAIT, *cmdvw, (const wchar_t* const*) cmdvw); if (cmdvw) { qvw = cmdvw; while (*qvw) { @@ -1242,3 +1263,21 @@ qcheck_filetype (const char *fqpn, dpx_res_type type) return r; } + +#if defined(WIN32) +FILE *generic_fsyscp_fopen (const char *filename, const char *mode) +{ + FILE *f; + + f = fsyscp_fopen (filename, mode); + + if (f == NULL && file_system_codepage != win32_codepage) { + int tmpcp = file_system_codepage; + file_system_codepage = win32_codepage; + f = fsyscp_fopen (filename, mode); + file_system_codepage = tmpcp; + } + + return f; +} +#endif /* WIN32 */ diff --git a/Build/source/texk/dvipdfm-x/mfileio.h b/Build/source/texk/dvipdfm-x/mfileio.h index daa7c9b1cbd..30d6a8d83c8 100644 --- a/Build/source/texk/dvipdfm-x/mfileio.h +++ b/Build/source/texk/dvipdfm-x/mfileio.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2019 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -36,7 +36,8 @@ int mfclose (FILE *file, const char *function, int line); mfclose((file),__FUNCTION__,__LINE__) #else #if defined(WIN32) -#define MFOPEN(name,mode) fsyscp_fopen((name),(mode)) +extern FILE *generic_fsyscp_fopen(const char *fname, const char *mode); +#define MFOPEN(name,mode) generic_fsyscp_fopen((name),(mode)) #else #define MFOPEN(name,mode) fopen((name),(mode)) #endif diff --git a/Build/source/texk/dvipdfm-x/pdfximage.c b/Build/source/texk/dvipdfm-x/pdfximage.c index e480190f7d8..f613d5b1df0 100644 --- a/Build/source/texk/dvipdfm-x/pdfximage.c +++ b/Build/source/texk/dvipdfm-x/pdfximage.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2019 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -363,6 +363,10 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, #define dpx_fopen(n,m) (MFOPEN((n),(m))) #define dpx_fclose(f) (MFCLOSE((f))) +#if defined(WIN32) +int utf8name_failed = 0; +#endif /* WIN32 */ + int pdf_ximage_findresource (const char *ident, load_options options) { @@ -394,8 +398,23 @@ pdf_ximage_findresource (const char *ident, load_options options) strcpy(fullname, f); } else { /* try loading image */ +#if defined(WIN32) + utf8name_failed = 0; +#endif /* WIN32 */ fullname = dpx_find_file(ident, "_pic_", ""); +#if defined(WIN32) + if (!fullname && file_system_codepage != win32_codepage) { + int tmpcp = file_system_codepage; + utf8name_failed = 1; + file_system_codepage = win32_codepage; + fullname = dpx_find_file(ident, "_pic_", ""); + file_system_codepage = tmpcp; + } +#endif /* WIN32 */ if (!fullname) { +#if defined(WIN32) + utf8name_failed = 0; +#endif /* WIN32 */ WARN("Error locating image file \"%s\"", ident); return -1; } |