From e414f69f002041303b5360fd025e4a206204b413 Mon Sep 17 00:00:00 2001 From: Jérôme Laurens Date: Wed, 26 Apr 2017 02:17:22 +0000 Subject: SyncTeX: fixed crash threat thanks to Akura Kakuto. Fixed newline bug on pdftex without breaking lualatex. git-svn-id: svn://tug.org/texlive/trunk@44052 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/texk/web2c/synctexdir/synctex-luatex.h | 3 ++ .../source/texk/web2c/synctexdir/synctex-pdftex.h | 1 + Build/source/texk/web2c/synctexdir/synctex-tex.h | 1 + Build/source/texk/web2c/synctexdir/synctex.c | 33 +++++++++++++++------- 4 files changed, 28 insertions(+), 10 deletions(-) (limited to 'Build/source/texk/web2c/synctexdir') diff --git a/Build/source/texk/web2c/synctexdir/synctex-luatex.h b/Build/source/texk/web2c/synctexdir/synctex-luatex.h index f9146581ff4..6142bcc99d5 100644 --- a/Build/source/texk/web2c/synctexdir/synctex-luatex.h +++ b/Build/source/texk/web2c/synctexdir/synctex-luatex.h @@ -82,3 +82,6 @@ authorization from the copyright holder. /* New LuaTeX (0.87.0) or later */ #define glue_node 12 #define kern_node 13 + +# define SYNCTEX_PRE_NL "" +# define SYNCTEX_POST_NL "\n" diff --git a/Build/source/texk/web2c/synctexdir/synctex-pdftex.h b/Build/source/texk/web2c/synctexdir/synctex-pdftex.h index dd61943ec5d..42638a11ce5 100644 --- a/Build/source/texk/web2c/synctexdir/synctex-pdftex.h +++ b/Build/source/texk/web2c/synctexdir/synctex-pdftex.h @@ -69,3 +69,4 @@ extern void synctexpdfxform(halfword p); extern void synctexmrofxfdp(); extern void synctexpdfrefxform(int objnum); +#define SYNCTEX_interaction interaction diff --git a/Build/source/texk/web2c/synctexdir/synctex-tex.h b/Build/source/texk/web2c/synctexdir/synctex-tex.h index c1ca933c586..d20143e8c94 100644 --- a/Build/source/texk/web2c/synctexdir/synctex-tex.h +++ b/Build/source/texk/web2c/synctexdir/synctex-tex.h @@ -49,3 +49,4 @@ Thu Jun 19 09:39:21 UTC 2008 */ #include "texd.h" +#define SYNCTEX_interaction interaction diff --git a/Build/source/texk/web2c/synctexdir/synctex.c b/Build/source/texk/web2c/synctexdir/synctex.c index 1cd5872af77..66397d164ae 100644 --- a/Build/source/texk/web2c/synctexdir/synctex.c +++ b/Build/source/texk/web2c/synctexdir/synctex.c @@ -454,7 +454,6 @@ static inline void _synctex_read_command_line_option(void) { SYNCTEX_VALUE = 0; } else { /* the command line options are not ignored */ - synctex_options|=1; if (synctex_options < 0) { SYNCTEX_NO_GZ = SYNCTEX_YES; synctex_ctxt.options = -synctex_options; @@ -462,6 +461,7 @@ static inline void _synctex_read_command_line_option(void) { SYNCTEX_NO_GZ = SYNCTEX_NO; synctex_ctxt.options = synctex_options; } + synctex_options|=1; /* Do it when positive */ /* Initialize the content of the \synctex primitive */ SYNCTEX_VALUE = synctex_options; } @@ -657,11 +657,6 @@ static void *synctex_dot_open(void) tmp = NULL; strcat(the_busy_name, synctex_suffix); /* Initialize SYNCTEX_NO_GZ with the content of \synctex to let the user choose the format. */ -#define SYNCTEX_GZ_LEN(WHAT)\ -(SYNCTEX_NO_GZ_AUX_NAME?0:strlen(WHAT)) - if (!SYNCTEX_NO_GZ_AUX_NAME) { - strcat(the_busy_name, synctex_suffix_gz); - } strcat(the_busy_name, synctex_suffix_busy); if (SYNCTEX_NO_GZ) { SYNCTEX_FILE = fopen(the_busy_name, FOPEN_W_MODE); @@ -875,7 +870,7 @@ void synctexterminate(boolean log_opened) the_real_syncname = xmalloc((unsigned)(strlen(tmp) + strlen(synctex_suffix) - + SYNCTEX_GZ_LEN(synctex_suffix_gz) + + strlen(synctex_suffix_gz) + 1)); if (!the_real_syncname) { SYNCTEX_FREE(tmp); @@ -927,17 +922,35 @@ void synctexterminate(boolean log_opened) tmp += strlen(output_directory) + strlen(DIR_SEP_STRING); } # endif +#ifndef SYNCTEX_interaction +# define SYNCTEX_interaction 1 +#endif + if (SYNCTEX_interaction>0) { #ifdef W32UPTEXSYNCTEX { char *stmp = chgto_oem(tmp); - printf((synctex_ctxt.flags.quoted ? "SyncTeX written on \"%s\"" : "\nSyncTeX written on %s.\n"), + printf((synctex_ctxt.flags.quoted ? "SyncTeX written on \"%s\"\n" : "\nSyncTeX written on %s.\n"), stmp); free(stmp); } #else - printf((synctex_ctxt.flags.quoted ? "SyncTeX written on \"%s\"\n" : "SyncTeX written on %s.\n"), +#ifndef SYNCTEX_PRE_NL +# define SYNCTEX_PRE_NL "\n" +#endif +#ifndef SYNCTEX_POST_NL +# define SYNCTEX_POST_NL "" +#endif + printf((synctex_ctxt.flags.quoted ? + SYNCTEX_PRE_NL + "SyncTeX written on \"%s\"" + SYNCTEX_POST_NL : + SYNCTEX_PRE_NL + "SyncTeX written on %s." + SYNCTEX_POST_NL + ), tmp); #endif + } tmp = NULL; } } else { @@ -969,7 +982,7 @@ void synctexterminate(boolean log_opened) the_real_syncname = xmalloc((size_t) (len + strlen(synctex_suffix) - + SYNCTEX_GZ_LEN(synctex_suffix_gz) + + strlen(synctex_suffix_gz) + 1)); if (!the_real_syncname) { SYNCTEX_FREE(tmp); -- cgit v1.2.3