diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-03-18 04:43:41 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-03-18 04:43:41 +0000 |
commit | e74c8ebbae4c03d35a7e1c03482f8e16b663fc1e (patch) | |
tree | b8680b8366705ab35700dae8a176511095fcbba7 /Build/source | |
parent | 668fc388420879aa8a600e4094a8babdd64f6b62 (diff) |
Support multi-byte characters in file names in SyncTeX for (e)upTeX (win32 only).
git-svn-id: svn://tug.org/texlive/trunk@36550 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/web2c/synctexdir/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/synctexdir/synctex.c | 86 |
2 files changed, 91 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/synctexdir/ChangeLog b/Build/source/texk/web2c/synctexdir/ChangeLog index 979e9c8e5d7..0f006eb9b7f 100644 --- a/Build/source/texk/web2c/synctexdir/ChangeLog +++ b/Build/source/texk/web2c/synctexdir/ChangeLog @@ -1,3 +1,8 @@ +2015-03-18 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + * synctex.c: Support multi-byte characters in file names in SyncTeX + for (e)upTeX (win32 only). + 2015-03-08 Peter Breitenlohner <peb@mppmu.mpg.de> * ac/synctex.a, am/synctex.am: Reorganize rules for libsynctex. diff --git a/Build/source/texk/web2c/synctexdir/synctex.c b/Build/source/texk/web2c/synctexdir/synctex.c index 4b0eb09bbd3..274c331083e 100644 --- a/Build/source/texk/web2c/synctexdir/synctex.c +++ b/Build/source/texk/web2c/synctexdir/synctex.c @@ -291,6 +291,14 @@ mem[NODE+TYPE##_node_size-synchronization_field_size+1].cint # define SYNCTEX_OFFSET_IS_PDF 0 # endif +#if defined(_WIN32) && (defined(upTeX) || defined(eupTeX)) +#define W32UPTEXSYNCTEX 1 +#include <wchar.h> +static char *chgto_oem(char *src); +static int fsyscp_remove(char *name); +#define remove fsyscp_remove +#endif + /* This macro layer was added to take luatex into account as suggested by T. Hoekwater. */ # if !defined(SYNCTEX_GET_JOB_NAME) # define SYNCTEX_GET_JOB_NAME() (gettexstring(jobname)) @@ -475,6 +483,67 @@ static const char *synctex_suffix_busy = "(busy)"; /* for kpse_absolute_p */ # include <kpathsea/absolute.h> +#ifdef W32UPTEXSYNCTEX +static char *chgto_oem(char *src) +{ + wchar_t *sw = NULL; + char *dst = NULL; + static int f_codepage = 0; + + if(f_codepage == 0) { + f_codepage = AreFileApisANSI() ? GetACP() : GetOEMCP(); + } + + if(f_codepage == file_system_codepage) { + dst = xstrdup(src); + return dst; + } + + sw = get_wstring_from_mbstring(file_system_codepage, src, sw); + dst = get_mbstring_from_wstring(f_codepage, sw, dst); + if(sw) free(sw); + return dst; +} + +static gzFile fsyscp_gzopen(const char *path, const char *mode) +{ + gzFile gzf; + wchar_t *pathw = NULL; + pathw = get_wstring_from_fsyscp(path, pathw); + gzf = gzopen_w(pathw, mode); + free(pathw); + return gzf; +} + +static int fsyscp_remove(char *s) +{ + wchar_t *sw = NULL; + int ret; + sw = get_wstring_from_fsyscp(s, sw); + ret = _wremove(sw); + if(sw) free(sw); + return ret; +} + +static int fsyscp_rename(char *s1, char *s2) +{ + wchar_t *sw1 = NULL, *sw2 = NULL; + int ret; + + sw1 = get_wstring_from_fsyscp(s1, sw1); + sw2 = get_wstring_from_fsyscp(s2, sw2); + ret = _wrename(sw1, sw2); + if(sw1) free(sw1); + if(sw2) free(sw2); + return ret; +} + +#undef fopen +#define fopen fsyscp_fopen +#define gzopen fsyscp_gzopen +#define rename fsyscp_rename +#endif + /* synctex_dot_open ensures that the foo.synctex file is open. * In case of problem, it definitely disables synchronization. * Now all the output synchronization info is gathered in only one file. @@ -663,7 +732,11 @@ void synctexstartinput(void) * do not know yet if synchronization will ever be enabled so we have * to store the file name, because we will need it later. * This is necessary because \jobname can be different */ +#ifdef W32UPTEXSYNCTEX + synctex_ctxt.root_name = chgto_oem(SYNCTEX_GET_CURRENT_NAME()); +#else synctex_ctxt.root_name = SYNCTEX_GET_CURRENT_NAME(); +#endif if (!strlen(synctex_ctxt.root_name)) { synctex_ctxt.root_name = xrealloc(synctex_ctxt.root_name, strlen("texput") + 1); strcpy(synctex_ctxt.root_name, "texput"); @@ -675,7 +748,11 @@ void synctexstartinput(void) } if (SYNCTEX_FILE || (SYNCTEX_NO_ERROR != synctex_dot_open())) { +#ifdef W32UPTEXSYNCTEX + char *tmp = chgto_oem(SYNCTEX_GET_CURRENT_NAME()); +#else char *tmp = SYNCTEX_GET_CURRENT_NAME(); +#endif /* Always record the input, even if SYNCTEX_VALUE is 0 */ synctex_record_input(SYNCTEX_CURRENT_TAG,tmp); SYNCTEX_FREE(tmp); @@ -768,8 +845,17 @@ void synctexterminate(boolean log_opened) tmp += strlen(output_directory) + strlen(DIR_SEP_STRING); } # endif +#ifdef W32UPTEXSYNCTEX + { + char *stmp = chgto_oem(tmp); + printf((synctex_ctxt.flags.quoted ? "\nSyncTeX written on \"%s\"" : "\nSyncTeX written on %s."), + stmp); + free(stmp); + } +#else printf((synctex_ctxt.flags.quoted ? "\nSyncTeX written on \"%s\"" : "\nSyncTeX written on %s."), tmp); +#endif tmp = NULL; } } else { |