diff options
author | Jérôme Laurens <jerome.laurens@u-bourgogne.fr> | 2010-05-13 06:59:02 +0000 |
---|---|---|
committer | Jérôme Laurens <jerome.laurens@u-bourgogne.fr> | 2010-05-13 06:59:02 +0000 |
commit | 44f26a3f760f07988625cb3200168e417f8eadaf (patch) | |
tree | 596be28913d1e93514d1b8a5945d8f69f0787594 /Build/source/texk/web2c | |
parent | 57bc1d45c213e7bc568a983bf780917fc11b5104 (diff) |
Code design change only: C macros added/modified in synctex.c to take luatex into account.
git-svn-id: svn://tug.org/texlive/trunk@18224 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r-- | Build/source/texk/web2c/synctexdir/ChangeLog | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/synctexdir/synctex.c | 1483 |
2 files changed, 764 insertions, 729 deletions
diff --git a/Build/source/texk/web2c/synctexdir/ChangeLog b/Build/source/texk/web2c/synctexdir/ChangeLog index 74772ed8b85..164d289dab4 100644 --- a/Build/source/texk/web2c/synctexdir/ChangeLog +++ b/Build/source/texk/web2c/synctexdir/ChangeLog @@ -1,3 +1,13 @@ +2010-05-13 Jerome Laurens <jerome.laurens@u-bourgogne.fr> + + * synctex.c, change in code design. + The macro layer is enhanced to take luatex into account. + Luatex can now safely use this file instead of luatexdir/utils/synctex.c, + provided luatexdir/utils/synctex-luatex.h is updated accordingly. + No change for pdftex not xetex. + + * synctex.c, typos fixed, some wrong "size_t" causing false warnings replaced by "int". + 2010-04-23 Peter Breitenlohner <peb@mppmu.mpg.de> * synctex_main.c, synctex_parser_local.h: #include "c-auto.h" diff --git a/Build/source/texk/web2c/synctexdir/synctex.c b/Build/source/texk/web2c/synctexdir/synctex.c index 1aafcc37dba..e5b711fa453 100644 --- a/Build/source/texk/web2c/synctexdir/synctex.c +++ b/Build/source/texk/web2c/synctexdir/synctex.c @@ -1,9 +1,9 @@ /* -Copyright (c) 2008, 2009 jerome DOT laurens AT u-bourgogne DOT fr +Copyright (c) 2008, 2009, 2010 jerome DOT laurens AT u-bourgogne DOT fr This file is part of the SyncTeX package. -Latest Revision: Wed Jul 1 11:18:09 UTC 2009 +Latest Revision: Wed May 12 12:08:40 UTC 2010 License: -------- @@ -67,7 +67,7 @@ Versioning: ----------- As synctex is embedded into different TeX implementation, there is an independent versionning system. -For TeX implementations, the actual version is: 2 +For TeX implementations, the actual version is: 3 For .synctex file format, the actual version is SYNCTEX_VERSION below Please, do not remove these explanations. @@ -84,6 +84,11 @@ I would appreciate to be listed as contributor and see "SyncTeX" highlighted. History: -------- +Version 3 +- very minor design change to take luatex into account +- typo fixed +- some size_t replaced by int + Version 2 Fri Sep 19 14:55:31 UTC 2008 - support for file names containing spaces. @@ -180,7 +185,7 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 /* WARNING: The 9 definitions below must be in sync with their eponym declarations in - the proper synctex-*.ch* file. + the proper synctex-*.ch* file or equivalent. */ # define synchronization_field_size 2 /* The default value is 2, it is suitable for original TeX and alike, @@ -210,12 +215,20 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 # define height_offset 3 /* see: @d height_offset=... */ +/* glue code: these only work with nodes of size medium_node_size */ +# define small_node_size 2 +/* see: @d small_node_size=2 {number of words to allocate for most node types} */ +# define medium_node_size (small_node_size+synchronization_field_size) +/* see: @d rule_node_size=4 */ +# define rule_node_size (4+synchronization_field_size) + /* Now define the local version of width(##), height(##) and depth(##) macros These only depend on the 3 macros above. */ # define SYNCTEX_TYPE(NODE) mem[NODE].hh.b0 # define rule_node 2 # define glue_node 10 # define kern_node 11 + # define SYNCTEX_SUBTYPE(NODE) mem[NODE].hh.b1 # define SYNCTEX_WIDTH(NODE) mem[NODE+width_offset].cint # define SYNCTEX_DEPTH(NODE) mem[NODE+depth_offset].cint @@ -246,6 +259,20 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 # define SYNCTEX_NO (0) # define SYNCTEX_NO_ERROR (0) +/* This macro layer was added to take luatex into account as suggested by T. Hoekwater. */ +# define SYNCTEX_GET_JOB_NAME() (gettexstring(jobname)) +# define SYNCTEX_GET_LOG_NAME() (gettexstring(texmflogname)) +# define SYNCTEX_CURRENT_TAG (curinput.synctextagfield) +# define SYNCTEX_GET_CURRENT_NAME() (gettexstring(curinput.namefield)) +# define SYNCTEX_GET_TOTAL_PAGES() (totalpages) +# define SYNCTEX_CURH curh +# define SYNCTEX_CURV curv +# define SYNCTEX_RULE_WD rulewd +# define SYNCTEX_RULE_HT ruleht +# define SYNCTEX_RULE_DP ruledp + +/* In the header file below, TEX-OR-MF-OR-MP is replaced by the real name (tex, etex...) + * Some macros will be redefined and additional headers will be imported */ # include "synctex-TEX-OR-MF-OR-MP.h" # include "synctex.h" @@ -256,15 +283,15 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 # include <stdarg.h> # include "zlib.h" -typedef void (*synctex_recorder_t)(halfword); /* recorders know how to record a node */ -typedef int (*synctex_fprintf_t)(void *, const char * , ...); /* print formatted to either FILE * or gzFile */ +typedef void (*synctex_recorder_t) (halfword); /* recorders know how to record a node */ +typedef int (*synctex_fprintf_t) (void *, const char *, ...); /* print formatted to either FILE * or gzFile */ # define SYNCTEX_BITS_PER_BYTE 8 /* Here are all the local variables gathered in one "synchronization context" */ static struct { void *file; /* the foo.synctex or foo.synctex.gz I/O identifier */ - synctex_fprintf_t fprintf; /* either fprintf or gzprintf */ + synctex_fprintf_t fprintf; /* either fprintf or gzprintf */ char *busy_name; /* the real "foo.synctex(busy)" or "foo.synctex.gz(busy)" name */ char *root_name; /* in general jobname.tex */ integer count; /* The number of interesting records in "foo.synctex" */ @@ -287,71 +314,71 @@ static struct { unsigned int warn:1; /* One shot warning flag */ unsigned int quoted:1; /* Whether the input file name was quoted by tex or not, for example "\"my input file.tex\"", unused by XeTeX */ unsigned int reserved:SYNCTEX_BITS_PER_BYTE*sizeof(int)-6; /* Align */ - } flags; + } flags; } synctex_ctxt = { NULL, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, {0,0,0,0,0,0,0}}; -#define SYNCTEX_FILE synctex_ctxt.file -#define SYNCTEX_IS_OFF (synctex_ctxt.flags.off) -#define SYNCTEX_NO_GZ (synctex_ctxt.flags.no_gz) -#define SYNCTEX_NOT_VOID (synctex_ctxt.flags.not_void) -#define SYNCTEX_WARNING_DISABLE (synctex_ctxt.flags.warn) -#define SYNCTEX_fprintf (*synctex_ctxt.fprintf) +# define SYNCTEX_FILE synctex_ctxt.file +# define SYNCTEX_IS_OFF (synctex_ctxt.flags.off) +# define SYNCTEX_NO_GZ (synctex_ctxt.flags.no_gz) +# define SYNCTEX_NOT_VOID (synctex_ctxt.flags.not_void) +# define SYNCTEX_WARNING_DISABLE (synctex_ctxt.flags.warn) +# define SYNCTEX_fprintf (*synctex_ctxt.fprintf) /* Initialize the options, synchronize the variables. * This is sent by *tex.web before any TeX macro is used. * */ void synctexinitcommand(void) { - /* This is a one shot function, any subsequent call is void */ - if (synctex_ctxt.flags.option_read) { - return; - } + /* This is a one shot function, any subsequent call is void */ + if (synctex_ctxt.flags.option_read) { + return; + } if (SYNCTEX_NO_OPTION == synctex_options) { /* No option given from the command line */ SYNCTEX_VALUE = 0; } else if (synctex_options == 0) { /* -synctex=0 was given: SyncTeX must be definitely disabled, - * any subsequent \synctex=1 will have no effect at all */ + * any subsequent \synctex=1 will have no effect at all */ SYNCTEX_IS_OFF = SYNCTEX_YES; SYNCTEX_VALUE = 0; } else { /* the command line options are not ignored */ - if(synctex_options < 0) { - SYNCTEX_NO_GZ = SYNCTEX_YES; - } - /* Initialize the content of the \synctex primitive */ - SYNCTEX_VALUE = synctex_options; + if (synctex_options < 0) { + SYNCTEX_NO_GZ = SYNCTEX_YES; + } + /* Initialize the content of the \synctex primitive */ + SYNCTEX_VALUE = synctex_options; } - synctex_ctxt.flags.option_read = SYNCTEX_YES; - return; + synctex_ctxt.flags.option_read = SYNCTEX_YES; + return; } /* Free all memory used, close and remove the file if any, * It is sent locally when there is a problem with synctex output. * It is sent by pdftex when a fatal error occurred in pdftex.web. */ -void synctexabort(boolean log_opened) +void synctexabort(boolean log_opened __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctex_abort\n"); -#endif +# endif if (SYNCTEX_FILE) { - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - remove(synctex_ctxt.busy_name); + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + remove(synctex_ctxt.busy_name); SYNCTEX_FREE(synctex_ctxt.busy_name); synctex_ctxt.busy_name = NULL; } - if(NULL != synctex_ctxt.root_name) { - SYNCTEX_FREE(synctex_ctxt.root_name); - synctex_ctxt.root_name = NULL; - } - SYNCTEX_IS_OFF = SYNCTEX_YES; /* disable synctex */ + if (NULL != synctex_ctxt.root_name) { + SYNCTEX_FREE(synctex_ctxt.root_name); + synctex_ctxt.root_name = NULL; + } + SYNCTEX_IS_OFF = SYNCTEX_YES; /* disable synctex */ } static inline int synctex_record_preamble(void); @@ -366,116 +393,120 @@ static const char *synctex_suffix_busy = "(busy)"; * Now all the output synchronization info is gathered in only one file. * It is possible to split this info into as many different output files as sheets * plus 1 for the control but the overall benefits are not so clear. - * For example foo-i.synctex would contain input synchronization - * information for page i alone. + * For example foo-i.synctex would contain input synchronization + * information for page i alone. */ static void *synctex_dot_open(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctex_dot_open\n"); printf("\nwarning: SYNCTEX_VALUE=%0X\n", SYNCTEX_VALUE); printf("\nwarning: synctex_options=%0X\n", synctex_options); # endif if (SYNCTEX_IS_OFF || !SYNCTEX_VALUE) { - return NULL; /* synchronization is disabled: do nothing */ + return NULL; /* synchronization is disabled: do nothing */ } if (SYNCTEX_FILE) { - return SYNCTEX_FILE; /* synchronization is alerady enabled */ + return SYNCTEX_FILE; /* synchronization is already enabled */ } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctex_dot_open 1\n"); # endif - /* this is the first time we are asked to open the file - this part of code is executed only once: - either SYNCTEX_FILE is nonnegative or synchronization is - definitely disabled. */ - { - size_t len; - char *tmp = gettexstring(jobname); - /* jobname was set by the \jobname command on the *TeX side */ - char * the_busy_name = xmalloc(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + strlen(synctex_suffix_busy) + 1); - if(!the_busy_name) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return NULL; - } -# if defined(XeTeX) - synctex_ctxt.flags.quoted = 0; - strcpy(the_busy_name, tmp); -# else - len = strlen(tmp); - if(len>0 && tmp[0]=='"' && tmp[len-1]=='"') { - /* We are certainly on a pdftex like engine and the input file name did contain spaces inside. - Quotes where added around that file name. We prefer to remove the quotes to have a human readable name. - As of Fri Sep 19 14:00:01 UTC 2008, the file names containing quotes are not supported by pdfTeX - nor SyncTeX. */ - synctex_ctxt.flags.quoted = 1;/* we will have to add quotes around the file name in the log file. */ - strcpy(the_busy_name, tmp+1);/* only copy what follows the leading " character */ - len = strlen(the_busy_name); - if((len>0) && (the_busy_name[len-1]=='"')) { - the_busy_name[len-1]='\0'; - } - } else { - synctex_ctxt.flags.quoted = 0; - strcpy(the_busy_name, tmp); - } -# endif - SYNCTEX_FREE(tmp); - tmp = NULL; - strcat(the_busy_name, synctex_suffix); - /* Initialize SYNCTEX_NO_GZ with the content of \synctex to let the user choose the format. */ - SYNCTEX_NO_GZ = SYNCTEX_VALUE<0?SYNCTEX_YES:SYNCTEX_NO; - if (!SYNCTEX_NO_GZ) { - strcat(the_busy_name, synctex_suffix_gz); - } - strcat(the_busy_name, synctex_suffix_busy); - if (SYNCTEX_NO_GZ) { - SYNCTEX_FILE = xfopen(the_busy_name, FOPEN_WBIN_MODE); - synctex_ctxt.fprintf = (synctex_fprintf_t)(&fprintf); - } else { - SYNCTEX_FILE = gzopen(the_busy_name, FOPEN_WBIN_MODE); - synctex_ctxt.fprintf = (synctex_fprintf_t)(&gzprintf); - } -#if SYNCTEX_DEBUG - printf("\nwarning: Synchronize DEBUG: synctex_dot_open 2\n"); -#endif - if (SYNCTEX_FILE) { - if(SYNCTEX_NO_ERROR != synctex_record_preamble()) { - synctexabort(0); - return NULL; - } - /* Initialization of the context */ - synctex_ctxt.magnification = 1000; - synctex_ctxt.unit = SYNCTEX_UNIT_FACTOR; - /* synctex_ctxt.busy_name was NULL before, it now owns the_busy_name */ - synctex_ctxt.busy_name = the_busy_name; - the_busy_name = NULL; - /* print the preamble, this is an quite an UTF8 file */ - if (NULL != synctex_ctxt.root_name) { - synctex_record_input(1,synctex_ctxt.root_name); - SYNCTEX_FREE(synctex_ctxt.root_name); - synctex_ctxt.root_name = NULL; - } - synctex_ctxt.count = 0; -#if SYNCTEX_DEBUG - fprintf(stdout, - "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX AVAILABLE\n"); -#endif - } else { - /* no .synctex file available, so disable synchronization */ - SYNCTEX_IS_OFF = SYNCTEX_YES; - SYNCTEX_VALUE = 0; - printf("\nSyncTeX warning: no synchronization, problem with %s\n",the_busy_name); - /* and free the_busy_name */ - SYNCTEX_FREE(the_busy_name); - the_busy_name = NULL; -#if SYNCTEX_DEBUG - fprintf(stdout, - "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX DISABLED\n"); -#endif - } - } + /* this is the first time we are asked to open the file + this part of code is executed only once: + either SYNCTEX_FILE is nonnegative or synchronization is + definitely disabled. */ + { + size_t len; + char *tmp = SYNCTEX_GET_JOB_NAME(); + /* jobname was set by the \jobname command on the *TeX side */ + char *the_busy_name = xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + + strlen(synctex_suffix_busy) + 1)); + if (!the_busy_name) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return NULL; + } +# if defined(XeTeX) + synctex_ctxt.flags.quoted = 0; + strcpy(the_busy_name, tmp); +# else + len = strlen(tmp); + if (len > 0 && tmp[0] == '"' && tmp[len - 1] == '"') { + /* We are certainly on a pdftex like engine and the input file name did contain spaces inside. + Quotes where added around that file name. We prefer to remove the quotes to have a human readable name. + As of Fri Sep 19 14:00:01 UTC 2008, the file names containing quotes are not supported by pdfTeX + nor SyncTeX. */ + synctex_ctxt.flags.quoted = 1; /* we will have to add quotes around the file name in the log file. */ + strcpy(the_busy_name, tmp + 1); /* only copy what follows the leading " character */ + len = strlen(the_busy_name); + if ((len > 0) && (the_busy_name[len - 1] == '"')) { + the_busy_name[len - 1] = '\0'; + } + } else { + synctex_ctxt.flags.quoted = 0; + strcpy(the_busy_name, tmp); + } +# endif + SYNCTEX_FREE(tmp); + tmp = NULL; + strcat(the_busy_name, synctex_suffix); + /* Initialize SYNCTEX_NO_GZ with the content of \synctex to let the user choose the format. */ + SYNCTEX_NO_GZ = SYNCTEX_VALUE < 0 ? SYNCTEX_YES : SYNCTEX_NO; + if (!SYNCTEX_NO_GZ) { + strcat(the_busy_name, synctex_suffix_gz); + } + strcat(the_busy_name, synctex_suffix_busy); + if (SYNCTEX_NO_GZ) { + SYNCTEX_FILE = xfopen(the_busy_name, FOPEN_WBIN_MODE); + synctex_ctxt.fprintf = (synctex_fprintf_t) (&fprintf); + } else { + SYNCTEX_FILE = gzopen(the_busy_name, FOPEN_WBIN_MODE); + synctex_ctxt.fprintf = (synctex_fprintf_t) (&gzprintf); + } +# if SYNCTEX_DEBUG + printf("\nwarning: Synchronize DEBUG: synctex_dot_open 2\n"); +# endif + if (SYNCTEX_FILE) { + if (SYNCTEX_NO_ERROR != synctex_record_preamble()) { + synctexabort(0); + return NULL; + } + /* Initialization of the context */ + synctex_ctxt.magnification = 1000; + synctex_ctxt.unit = SYNCTEX_UNIT_FACTOR; + /* synctex_ctxt.busy_name was NULL before, it now owns the_busy_name */ + synctex_ctxt.busy_name = the_busy_name; + the_busy_name = NULL; + /* print the preamble, this is an quite an UTF8 file */ + if (NULL != synctex_ctxt.root_name) { + synctex_record_input(1, synctex_ctxt.root_name); + SYNCTEX_FREE(synctex_ctxt.root_name); + synctex_ctxt.root_name = NULL; + } + synctex_ctxt.count = 0; +# if SYNCTEX_DEBUG + fprintf(stdout, + "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX AVAILABLE\n"); +# endif + } else { + /* no .synctex file available, so disable synchronization */ + SYNCTEX_IS_OFF = SYNCTEX_YES; + SYNCTEX_VALUE = 0; + printf("\nSyncTeX warning: no synchronization, problem with %s\n", + the_busy_name); + /* and free the_busy_name */ + SYNCTEX_FREE(the_busy_name); + the_busy_name = NULL; +# if SYNCTEX_DEBUG + fprintf(stdout, + "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX DISABLED\n"); +# endif + } + } return SYNCTEX_FILE; } @@ -501,13 +532,13 @@ void synctexstartinput(void) { static unsigned int synctex_tag_counter = 0; - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput %i", - synctex_tag_counter); + synctex_tag_counter); printf("\nwarning: SYNCTEX_VALUE=%i", SYNCTEX_VALUE); printf("\nwarning: synctex_options=%0X", synctex_options); -#endif +# endif if (SYNCTEX_IS_OFF) { return; @@ -522,31 +553,32 @@ void synctexstartinput(void) * this makes a lot of files... even in 32 bits * Maybe we will limit this to 16bits and * use the 16 other bits to store the column number */ - curinput.synctextagfield = 0; + SYNCTEX_CURRENT_TAG = 0; return; } - curinput.synctextagfield = synctex_tag_counter; /* -> *TeX.web */ + SYNCTEX_CURRENT_TAG = (int) synctex_tag_counter; /* -> *TeX.web */ if (synctex_tag_counter == 1) { /* this is the first file TeX ever opens, in general \jobname.tex we * 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 */ - synctex_ctxt.root_name = gettexstring(curinput.namefield); - /* we could initialize the unit field to 1 to avoid floating point exception - * when accidentaly dividing by the unit. - * This occurs when some SYNCTEX_IGNORE macro is not used. - * But this must not happen unexpectedly, so we leave the unit to 0 */ -#if SYNCTEX_DEBUG + * This is necessary because \jobname can be different */ + synctex_ctxt.root_name = SYNCTEX_GET_CURRENT_NAME(); + /* we could initialize the unit field to 1 to avoid floating point exception + * when accidentaly dividing by the unit. + * This occurs when some SYNCTEX_IGNORE macro is not used. + * But this must not happen unexpectedly, so we leave the unit to 0 */ +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput first END\n"); # endif return; } - if (SYNCTEX_FILE || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { - char *tmp = gettexstring(curinput.namefield); - synctex_record_input(curinput.synctextagfield,tmp); + if (SYNCTEX_FILE + || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { + char *tmp = SYNCTEX_GET_CURRENT_NAME(); + synctex_record_input(SYNCTEX_CURRENT_TAG,tmp); SYNCTEX_FREE(tmp); } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput END\n"); # endif return; @@ -575,127 +607,133 @@ static inline int synctex_record_postamble(void); */ void synctexterminate(boolean log_opened) { - char *tmp = NULL; - char * the_real_syncname = NULL; - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + char *tmp = NULL; + char *the_real_syncname = NULL; + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexterminate\n"); -#endif - if(log_opened && (tmp = gettexstring(texmflogname))) { - /* In version 1, the jobname was used but it caused problems regarding spaces in file names. */ - the_real_syncname = xmalloc(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + 1); - if(!the_real_syncname) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return; - } - strcpy(the_real_syncname, tmp); - SYNCTEX_FREE(tmp); - tmp = NULL; - /* now remove the last path extension which is in general log */ - tmp = the_real_syncname + strlen(the_real_syncname); - while(tmp>the_real_syncname) { - --tmp; - if(*tmp == '.') { - *tmp = '\0';/* end the string here */ - break; - } - } - strcat(the_real_syncname, synctex_suffix); - if (!SYNCTEX_NO_GZ) { - /* Remove any uncompressed synctex file, from a previous build. */ - remove(the_real_syncname); - strcat(the_real_syncname, synctex_suffix_gz); - } - /* allways remove the synctex output file before renaming it, windows requires it. */ - if(0 != remove(the_real_syncname) && errno == EACCES) { - fprintf(stderr,"SyncTeX: Can't remove %s (file is open or read only)\n",the_real_syncname); - } - if (SYNCTEX_FILE) { - if (SYNCTEX_NOT_VOID) { - synctex_record_postamble(); - /* close the synctex file*/ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - /* renaming the working synctex file */ - if(0 == rename(synctex_ctxt.busy_name,the_real_syncname)) { - if(log_opened) { - printf((synctex_ctxt.flags.quoted?"\nSyncTeX written on \"%s\"":"\nSyncTeX written on %s"), - the_real_syncname); /* SyncTeX also refers to the contents */ - } - } else { - fprintf(stderr,"SyncTeX: Can't rename %s to %s\n",synctex_ctxt.busy_name,the_real_syncname); - remove(synctex_ctxt.busy_name); - } - } else { - /* close and remove the synctex file because there are no pages of output */ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - remove(synctex_ctxt.busy_name); - } - } - if (SYNCTEX_NO_GZ) { - /* Remove any compressed synctex file, from a previous build. */ - strcat(the_real_syncname, synctex_suffix_gz); - remove(the_real_syncname); - } - } else if((tmp = gettexstring(jobname))) { - size_t len; - /* There was a problem with the output. - We just try to remove existing synctex output files - including the busy one. */ - the_real_syncname = xmalloc(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + 1); - if(!the_real_syncname) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return; - } -# if defined(XeTeX) - strcpy(the_real_syncname, tmp); -# else - len = strlen(tmp); - if(len>0 && tmp[0]=='"' && tmp[len-1]=='"') { - /* See above a similar situation. */ - strcpy(the_real_syncname, tmp+1);/* only copy what follows the leading " character */ - len = strlen(the_real_syncname); - if((len>0) && (the_real_syncname[len-1]=='"')) { - the_real_syncname[len-1]='\0'; - } - } else { - strcpy(the_real_syncname, tmp); - } -# endif - SYNCTEX_FREE(tmp); - tmp = NULL; - strcat(the_real_syncname, synctex_suffix); - remove(the_real_syncname); - strcat(the_real_syncname, synctex_suffix_gz); - remove(the_real_syncname); - if (SYNCTEX_FILE) { - /* close the synctex file*/ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - /* removing the working synctex file */ - remove(synctex_ctxt.busy_name); - } - } - SYNCTEX_FREE(synctex_ctxt.busy_name); - synctex_ctxt.busy_name = NULL; - SYNCTEX_FREE(the_real_syncname); - the_real_syncname = NULL; - synctexabort(0); +# endif + if (log_opened && (tmp = SYNCTEX_GET_LOG_NAME())) { + /* In version 1, the jobname was used but it caused problems regarding spaces in file names. */ + the_real_syncname = xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + 1)); + if (!the_real_syncname) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return; + } + strcpy(the_real_syncname, tmp); + SYNCTEX_FREE(tmp); + tmp = NULL; + /* now remove the last path extension which is in general log */ + tmp = the_real_syncname + strlen(the_real_syncname); + while (tmp > the_real_syncname) { + --tmp; + if (*tmp == '.') { + *tmp = '\0'; /* end the string here */ + break; + } + } + strcat(the_real_syncname, synctex_suffix); + if (!SYNCTEX_NO_GZ) { + /* Remove any uncompressed synctex file, from a previous build. */ + remove(the_real_syncname); + strcat(the_real_syncname, synctex_suffix_gz); + } + /* allways remove the synctex output file before renaming it, windows requires it. */ + if (0 != remove(the_real_syncname) && errno == EACCES) { + fprintf(stderr, + "SyncTeX: Can't remove %s (file is open or read only)\n", + the_real_syncname); + } + if (SYNCTEX_FILE) { + if (SYNCTEX_NOT_VOID) { + synctex_record_postamble(); + /* close the synctex file */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + /* renaming the working synctex file */ + if (0 == rename(synctex_ctxt.busy_name, the_real_syncname)) { + if (log_opened) { + printf((synctex_ctxt.flags.quoted ? "\nSyncTeX written on \"%s\"" : "\nSyncTeX written on %s"), the_real_syncname); /* SyncTeX also refers to the contents */ + } + } else { + fprintf(stderr, "SyncTeX: Can't rename %s to %s\n", + synctex_ctxt.busy_name, the_real_syncname); + remove(synctex_ctxt.busy_name); + } + } else { + /* close and remove the synctex file because there are no pages of output */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + remove(synctex_ctxt.busy_name); + } + } + if (SYNCTEX_NO_GZ) { + /* Remove any compressed synctex file, from a previous build. */ + strcat(the_real_syncname, synctex_suffix_gz); + remove(the_real_syncname); + } + } else if ((tmp = SYNCTEX_GET_JOB_NAME())) { + size_t len; + /* There was a problem with the output. + We just try to remove existing synctex output files + including the busy one. */ + the_real_syncname = xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + 1)); + if (!the_real_syncname) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return; + } +# if defined(XeTeX) + strcpy(the_real_syncname, tmp); +# else + len = strlen(tmp); + if (len > 0 && tmp[0] == '"' && tmp[len - 1] == '"') { + /* See above a similar situation. */ + strcpy(the_real_syncname, tmp + 1); /* only copy what follows the leading " character */ + len = strlen(the_real_syncname); + if ((len > 0) && (the_real_syncname[len - 1] == '"')) { + the_real_syncname[len - 1] = '\0'; + } + } else { + strcpy(the_real_syncname, tmp); + } +# endif + SYNCTEX_FREE(tmp); + tmp = NULL; + strcat(the_real_syncname, synctex_suffix); + remove(the_real_syncname); + strcat(the_real_syncname, synctex_suffix_gz); + remove(the_real_syncname); + if (SYNCTEX_FILE) { + /* close the synctex file */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + /* removing the working synctex file */ + remove(synctex_ctxt.busy_name); + } + } + SYNCTEX_FREE(synctex_ctxt.busy_name); + synctex_ctxt.busy_name = NULL; + SYNCTEX_FREE(the_real_syncname); + the_real_syncname = NULL; + synctexabort(0); } static inline int synctex_record_content(void); @@ -707,39 +745,40 @@ static inline int synctex_record_sheet(integer sheet); */ void synctexsheet(integer mag) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG - printf("\nSynchronize DEBUG: synctexsheet %i\n",mag); -#endif + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG + printf("\nSynchronize DEBUG: synctexsheet %i\n", mag); +# endif if (SYNCTEX_IS_OFF) { - if(SYNCTEX_VALUE && !SYNCTEX_WARNING_DISABLE) { - SYNCTEX_WARNING_DISABLE = SYNCTEX_YES; - printf("\nSyncTeX warning: Synchronization was disabled from\nthe command line with -synctex=0\nChanging the value of \\synctex has no effect."); - } + if (SYNCTEX_VALUE && !SYNCTEX_WARNING_DISABLE) { + SYNCTEX_WARNING_DISABLE = SYNCTEX_YES; + printf + ("\nSyncTeX warning: Synchronization was disabled from\nthe command line with -synctex=0\nChanging the value of \\synctex has no effect."); + } return; } - if (SYNCTEX_FILE || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { + if (SYNCTEX_FILE + || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { /* First possibility: the .synctex file is already open because SyncTeX was activated on the CLI - * or it was activated with the \synctex macro and the first page is already shipped out. - * Second possibility: tries to open the .synctex, useful if synchronization was enabled - * from the source file and not from the CLI. - * totalpages is defined in tex.web */ - if (totalpages == 0) { + * or it was activated with the \synctex macro and the first page is already shipped out. + * Second possibility: tries to open the .synctex, useful if synchronization was enabled + * from the source file and not from the CLI. */ + if (SYNCTEX_GET_TOTAL_PAGES() == 0) { /* Now it is time to properly set up the scale factor. */ - if(mag>0) { + if (mag > 0) { synctex_ctxt.magnification = mag; } - if(SYNCTEX_NO_ERROR != synctex_record_settings() - || SYNCTEX_NO_ERROR != synctex_record_content()) { - synctexabort(0); - return; - } + if (SYNCTEX_NO_ERROR != synctex_record_settings() + || SYNCTEX_NO_ERROR != synctex_record_content()) { + synctexabort(0); + return; + } } - synctex_record_sheet(totalpages+1); + synctex_record_sheet(SYNCTEX_GET_TOTAL_PAGES()+1); } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexsheet END\n"); -#endif +# endif return; } @@ -750,17 +789,17 @@ static inline int synctex_record_teehs(integer sheet); */ void synctexteehs(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexteehs\n"); -#endif - if (SYNCTEX_IS_OFF || !SYNCTEX_FILE ) { +# endif + if (SYNCTEX_IS_OFF || !SYNCTEX_FILE) { return; } - synctex_record_teehs(totalpages);/* not totalpages+1*/ -#if SYNCTEX_DEBUG + synctex_record_teehs(SYNCTEX_GET_TOTAL_PAGES());/* not SYNCTEX_GET_TOTAL_PAGES()+1*/ +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexteehs END\n"); -#endif +# endif return; } @@ -772,10 +811,10 @@ static inline void synctex_record_vlist(halfword p); * address of the vlist We assume that p is really a vlist node! */ void synctexvlist(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } @@ -783,8 +822,8 @@ void synctexvlist(halfword this_box) synctex_ctxt.recorder = NULL; /* reset */ synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_record_vlist(this_box); } @@ -796,10 +835,10 @@ static inline void synctex_record_tsilv(halfword p); * synctex_vlist sent at the beginning of that procedure. */ void synctextsilv(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctextsilv\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } @@ -807,8 +846,8 @@ void synctextsilv(halfword this_box) synctex_ctxt.node = this_box; /* 0 to reset */ synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL; synctex_record_tsilv(this_box); } @@ -817,20 +856,20 @@ static inline void synctex_record_void_vlist(halfword p); /* This message is sent when a void vlist will be shipped out. * There is no need to balance a void vlist. */ -void synctexvoidvlist(halfword p, halfword this_box) +void synctexvoidvlist(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidvlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } synctex_ctxt.node = p; /* reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, box_node_size); + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL; /* reset */ synctex_record_void_vlist(p); } @@ -843,18 +882,18 @@ static inline void synctex_record_hlist(halfword p); * address of the hlist We assume that p is really an hlist node! */ void synctexhlist(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } synctex_ctxt.node = this_box; /* 0 to reset */ synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL; /* reset */ synctex_record_hlist(this_box); } @@ -867,10 +906,10 @@ static inline void synctex_record_tsilh(halfword p); * synctex_hlist sent at the beginning of that procedure. */ void synctextsilh(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctextsilh\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } @@ -878,8 +917,8 @@ void synctextsilh(halfword this_box) synctex_ctxt.node = this_box; /* 0 to force next node to be recorded! */ synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL; /* reset */ synctex_record_tsilh(this_box); } @@ -888,36 +927,29 @@ static inline void synctex_record_void_hlist(halfword p); /* This message is sent when a void hlist will be shipped out. * There is no need to balance a void hlist. */ -void synctexvoidhlist(halfword p, halfword this_box) +void synctexvoidhlist(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } - /* the sync context has changed */ - if (synctex_ctxt.recorder != NULL) { - /* but was not yet recorded */ - (*synctex_ctxt.recorder) (synctex_ctxt.node); - } + /* the sync context has changed */ + if (synctex_ctxt.recorder != NULL) { + /* but was not yet recorded */ + (*synctex_ctxt.recorder) (synctex_ctxt.node); + } synctex_ctxt.node = p; /* 0 to reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,box_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, box_node_size); + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL; /* reset */ synctex_record_void_hlist(p); } -/* glue code: these only work with nodes of size medium_node_size */ -# define small_node_size 2 -/* see: @d small_node_size=2 {number of words to allocate for most node types} */ -# define medium_node_size (small_node_size+synchronization_field_size) -/* see: @d rule_node_size=4 */ -# define rule_node_size (4+synchronization_field_size) - /* IN THE SEQUEL, ALL NODE ARE medium_node_size'd, UNTIL THE CONTRARY IS MENTIONNED */ # undef SYNCTEX_IGNORE # define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ @@ -936,12 +968,12 @@ void synctex_math_recorder(halfword p); /* glue code this message is sent whenever an inline math node will ship out See: @ @<Output the non-|char_node| |p| for... */ -void synctexmath(halfword p, halfword this_box) +void synctexmath(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexmath\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -952,8 +984,8 @@ void synctexmath(halfword p, halfword this_box) synctex_ctxt.node = p; synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; synctex_ctxt.recorder = NULL;/* no need to record once more */ synctex_math_recorder(p);/* always record synchronously */ } @@ -967,45 +999,45 @@ static inline void synctex_record_rule(halfword p); # define SYNCTEX_IGNORE_RULE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ || (0 >= SYNCTEX_TAG_MODEL(NODE,rule_node_size)) \ || (0 >= SYNCTEX_LINE_MODEL(NODE,rule_node_size)) -void synctexhorizontalruleorglue(halfword p, halfword this_box) +void synctexhorizontalruleorglue(halfword p, halfword this_box + __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexglue\n"); -#endif - if (SYNCTEX_TYPE(p) == rule_node) { /* not medium_node_size so we can't use SYNCTEX_IGNORE */ - if (SYNCTEX_IGNORE_RULE(p)) { - return; - } - } - else { - if (SYNCTEX_IGNORE(p)) { - return; - } - } - synctex_ctxt.node = p; - synctex_ctxt.curh = curh; - synctex_ctxt.curv = curv; - synctex_ctxt.recorder = NULL; - switch(SYNCTEX_TYPE(p)) { - case rule_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,rule_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,rule_node_size); - synctex_record_rule(p);/* always record synchronously: maybe some text is outside the box */ - break; - case glue_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_record_glue(p);/* always record synchronously: maybe some text is outside the box */ - break; - case kern_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_record_kern(p);/* always record synchronously: maybe some text is outside the box */ - break; - default: - printf("\nSynchronize ERROR: unknown node type %i\n",SYNCTEX_TYPE(p)); - } +# endif + if (SYNCTEX_TYPE(p) == rule_node) { /* not medium_node_size so we can't use SYNCTEX_IGNORE */ + if (SYNCTEX_IGNORE_RULE(p)) { + return; + } + } else { + if (SYNCTEX_IGNORE(p)) { + return; + } + } + synctex_ctxt.node = p; + synctex_ctxt.curh = SYNCTEX_CURH; + synctex_ctxt.curv = SYNCTEX_CURV; + synctex_ctxt.recorder = NULL; + switch (SYNCTEX_TYPE(p)) { + case rule_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, rule_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, rule_node_size); + synctex_record_rule(p); /* always record synchronously: maybe some text is outside the box */ + break; + case glue_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); + synctex_record_glue(p); /* always record synchronously: maybe some text is outside the box */ + break; + case kern_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); + synctex_record_kern(p); /* always record synchronously: maybe some text is outside the box */ + break; + default: + printf("\nSynchronize ERROR: unknown node type %i\n", SYNCTEX_TYPE(p)); + } } void synctex_kern_recorder(halfword p); @@ -1014,10 +1046,10 @@ void synctex_kern_recorder(halfword p); See: @ @<Output the non-|char_node| |p| for... */ void synctexkern(halfword p, halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexkern\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -1026,27 +1058,27 @@ void synctexkern(halfword p, halfword this_box) if (synctex_ctxt.recorder != NULL) { /* but was not yet recorded */ (*synctex_ctxt.recorder) (synctex_ctxt.node); - } - if(synctex_ctxt.node == this_box) { + } + if (synctex_ctxt.node == this_box) { /* first node in the list */ synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = &synctex_kern_recorder; } else { synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = NULL; /* always record when the context has just changed * and when not the first node */ synctex_kern_recorder(p); } } else { - /* just update the geometry and type (for future improvements) */ + /* just update the geometry and type (for future improvements) */ synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = &synctex_kern_recorder; } } @@ -1060,12 +1092,12 @@ void synctexkern(halfword p, halfword this_box) void synctex_char_recorder(halfword p); /* this message is sent whenever a char node ships out */ -void synctexchar(halfword p, halfword this_box) +void synctexchar(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexchar\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -1088,13 +1120,13 @@ void synctex_node_recorder(halfword p); /* this message should be sent to record information for a node of an unknown type */ -void synctexnode(halfword p, halfword this_box) +void synctexnode(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexnode\n"); -#endif - if (SYNCTEX_IGNORE(p)) { +# endif + if (SYNCTEX_IGNORE(p)) { return; } /* always record, not very usefull yet */ @@ -1105,462 +1137,455 @@ void synctexnode(halfword p, halfword this_box) synchronously for the current location */ void synctexcurrent(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexcurrent\n"); -#endif - if (SYNCTEX_IGNORE(nothing)) { +# endif + if (SYNCTEX_IGNORE(nothing)) { return; } else { - size_t len = SYNCTEX_fprintf(SYNCTEX_FILE,"x%i,%i:%i,%i\n", - synctex_ctxt.tag,synctex_ctxt.line, - curh UNIT,curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; - return; - } - } + int len = SYNCTEX_fprintf(SYNCTEX_FILE, "x%i,%i:%i,%i\n", + synctex_ctxt.tag,synctex_ctxt.line, + SYNCTEX_CURH UNIT,SYNCTEX_CURV UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; + return; + } + } synctexabort(0); - return; + return; } -#pragma mark - -#pragma mark Glue code Recorders - /* Recording the settings */ static inline int synctex_record_settings(void) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_settings\n"); -#endif - if(NULL == SYNCTEX_FILE) { +# endif + if (NULL == SYNCTEX_FILE) { return SYNCTEX_NOERR; } - if(SYNCTEX_FILE) { - size_t len = SYNCTEX_fprintf(SYNCTEX_FILE,"Output:%s\nMagnification:%i\nUnit:%i\nX Offset:%i\nY Offset:%i\n", - SYNCTEX_OUTPUT,synctex_ctxt.magnification,synctex_ctxt.unit, - ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT), - ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT)); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; + if (SYNCTEX_FILE) { + int len = SYNCTEX_fprintf(SYNCTEX_FILE, "Output:%s\nMagnification:%i\nUnit:%i\nX Offset:%i\nY Offset:%i\n", + SYNCTEX_OUTPUT,synctex_ctxt.magnification,synctex_ctxt.unit, + ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT), + ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT)); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "SyncTeX..." line */ static inline int synctex_record_preamble(void) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_preamble\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"SyncTeX Version:%i\n",SYNCTEX_VERSION); - if(len>0) { - synctex_ctxt.total_length = len; - return SYNCTEX_NOERR; - } +# endif + len = + SYNCTEX_fprintf(SYNCTEX_FILE, "SyncTeX Version:%i\n", SYNCTEX_VERSION); + if (len > 0) { + synctex_ctxt.total_length = len; + return SYNCTEX_NOERR; + } synctexabort(0); - return -1; + return -1; } /* Recording a "Input:..." line */ static inline int synctex_record_input(integer tag, char *name) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_input\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Input:%i:%s\n",tag,name); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Input:%i:%s\n", tag, name); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "!..." line */ static inline int synctex_record_anchor(void) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_anchor\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"!%i\n",synctex_ctxt.total_length); - if(len>0) { - synctex_ctxt.total_length = len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "!%i\n", synctex_ctxt.total_length); + if (len > 0) { + synctex_ctxt.total_length = len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "Content" line */ static inline int synctex_record_content(void) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_content\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Content:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Content:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "{..." line */ static inline int synctex_record_sheet(integer sheet) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_sheet\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - size_t len = SYNCTEX_fprintf(SYNCTEX_FILE,"{%i\n",sheet); - if(len>0) { - synctex_ctxt.total_length += len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + int len = SYNCTEX_fprintf(SYNCTEX_FILE, "{%i\n", sheet); + if (len > 0) { + synctex_ctxt.total_length += len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "}..." line */ static inline int synctex_record_teehs(integer sheet) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_teehs\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - size_t len = SYNCTEX_fprintf(SYNCTEX_FILE,"}%i\n",sheet); - if(len>0) { - synctex_ctxt.total_length += len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + int len = SYNCTEX_fprintf(SYNCTEX_FILE, "}%i\n", sheet); + if (len > 0) { + synctex_ctxt.total_length += len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "v..." line */ static inline void synctex_record_void_vlist(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_void_vlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"v%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "v%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, + SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "[..." line */ static inline void synctex_record_vlist(halfword p) { - size_t len = 0; - SYNCTEX_NOT_VOID = SYNCTEX_YES; -#if SYNCTEX_DEBUG > 999 + int len = 0; + SYNCTEX_NOT_VOID = SYNCTEX_YES; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_vlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"[%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "[%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, + SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "]..." line */ -static inline void synctex_record_tsilv(halfword p) +static inline void synctex_record_tsilv(halfword p __attribute__ ((unused))) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilv\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"]\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return; - } - synctexabort(0); - return; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "]\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return; + } + synctexabort(0); + return; } /* Recording a "h..." line */ static inline void synctex_record_void_hlist(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_void_hlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"h%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "h%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, + SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "(..." line */ static inline void synctex_record_hlist(halfword p) { - size_t len = 0; - SYNCTEX_NOT_VOID = SYNCTEX_YES; -#if SYNCTEX_DEBUG > 999 + int len = 0; + SYNCTEX_NOT_VOID = SYNCTEX_YES; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_hlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"(%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "(%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, + SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a ")..." line */ -static inline void synctex_record_tsilh(halfword p) +static inline void synctex_record_tsilh(halfword p __attribute__ ((unused))) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilh\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,")\n"); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, ")\n"); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "Count..." line */ -static inline int synctex_record_count(void) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 +static inline int synctex_record_count(void) +{ + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_count\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Count:%i\n",synctex_ctxt.count); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Count:%i\n", synctex_ctxt.count); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "Postamble" section */ static inline int synctex_record_postamble(void) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_postamble\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - size_t len = SYNCTEX_fprintf(SYNCTEX_FILE,"Postamble:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - if(synctex_record_count() || synctex_record_anchor()) { - } else { - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Post scriptum:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - } - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + int len = SYNCTEX_fprintf(SYNCTEX_FILE, "Postamble:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + if (synctex_record_count() || synctex_record_anchor()) { + } else { + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Post scriptum:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + } + } + } + synctexabort(0); + return -1; } /* Recording a "g..." line */ static inline void synctex_record_glue(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_glue_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"g%i,%i:%i,%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "g%i,%i:%i,%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "k..." line */ static inline void synctex_record_kern(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_kern_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"k%i,%i:%i,%i:%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "k%i,%i:%i,%i:%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "r..." line */ static inline void synctex_record_rule(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilh\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"r%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,rule_node_size), - SYNCTEX_LINE_MODEL(p,rule_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - rulewd UNIT, - ruleht UNIT, - ruledp UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "r%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p,rule_node_size), + SYNCTEX_LINE_MODEL(p,rule_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_RULE_WD UNIT, SYNCTEX_RULE_HT UNIT, SYNCTEX_RULE_DP UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } - -#pragma mark - -#pragma mark Recorders - /* Recording a "$..." line */ void synctex_math_recorder(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_math_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"$%i,%i:%i,%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "$%i,%i:%i,%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "k..." line */ void synctex_kern_recorder(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_kern_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"k%i,%i:%i,%i:%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "k%i,%i:%i,%i:%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "c..." line */ -void synctex_char_recorder(halfword p) +void synctex_char_recorder(halfword p __attribute__ ((unused))) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 + int len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_char_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"c%i,%i\n", - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "c%i,%i\n", + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "?..." line, type, subtype and position */ void synctex_node_recorder(halfword p) { - size_t len = 0; -#if SYNCTEX_DEBUG > 999 - printf("\nSynchronize DEBUG: synctex_node_recorder(0x%x)\n",p); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"?%i,%i:%i,%i\n", - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - mem[p].hh.b0,mem[p].hh.b1); - if(len>0) { - synctex_ctxt.total_length += len; + int len = 0; +# if SYNCTEX_DEBUG > 999 + printf("\nSynchronize DEBUG: synctex_node_recorder(0x%x)\n", p); +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "?%i,%i:%i,%i\n", + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_TYPE(p), SYNCTEX_SUBTYPE(p)); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } # else |