diff options
author | Jérôme Laurens <jerome.laurens@u-bourgogne.fr> | 2017-10-31 11:50:59 +0000 |
---|---|---|
committer | Jérôme Laurens <jerome.laurens@u-bourgogne.fr> | 2017-10-31 11:50:59 +0000 |
commit | 8caa49bc37510e71dde53e40258d76036b746cdd (patch) | |
tree | df135b90922301a42ee3a4c963ea23808186f4f3 /Build/source | |
parent | 078f485b749b5ca35cd28897fddaae16e530b86d (diff) |
SyncTeX parser 1.22
git-svn-id: svn://tug.org/texlive/trunk@45654 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
10 files changed, 1143 insertions, 1066 deletions
diff --git a/Build/source/texk/web2c/synctexdir/synctex_main.c b/Build/source/texk/web2c/synctexdir/synctex_main.c index 7b28bd6db4b..01f269673f5 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_main.c +++ b/Build/source/texk/web2c/synctexdir/synctex_main.c @@ -4,67 +4,67 @@ This file is part of the __SyncTeX__ package. [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details ## License -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE - -Except as contained in this notice, the name of the copyright holder -shall not be used in advertising or otherwise to promote the sale, -use or other dealings in this Software without prior written -authorization from the copyright holder. - -Acknowledgments: ----------------- -The author received useful remarks from the pdfTeX developers, especially Hahn The Thanh, -and significant help from XeTeX developer Jonathan Kew - -Nota Bene: ----------- -If you include or use a significant part of the synctex package into a software, -I would appreciate to be listed as contributor and see "SyncTeX" highlighted. - -Version 1.2 -Thu Jun 19 09:39:21 UTC 2008 - -History: --------- - -- the -d option for an input directory - -Important notice: ------------------ -This file is named "synctex_main.c". -This is the command line interface to the synctex_parser.c. -*/ + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE + + Except as contained in this notice, the name of the copyright holder + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization from the copyright holder. + + Acknowledgments: + ---------------- + The author received useful remarks from the pdfTeX developers, especially Hahn The Thanh, + and significant help from XeTeX developer Jonathan Kew + + Nota Bene: + ---------- + If you include or use a significant part of the synctex package into a software, + I would appreciate to be listed as contributor and see "SyncTeX" highlighted. + + Version 1.2 + Thu Jun 19 09:39:21 UTC 2008 + + History: + -------- + + - the -d option for an input directory + + Important notice: + ----------------- + This file is named "synctex_main.c". + This is the command line interface to the synctex_parser.c. + */ # ifdef __linux__ # define _ISOC99_SOURCE /* to get the fmax() prototype */ # endif -# ifdef SYNCTEX_WORK +# ifdef __SYNCTEX_WORK__ # include <synctex_parser_c-auto.h> /* for inline && HAVE_xxx */ # else @@ -84,17 +84,18 @@ This is the command line interface to the synctex_parser.c. /* The code below uses strlcat and strlcpy, which avoids security warnings with some compilers. However, if these are not available we simply use the old, unchecked versions; this is OK because all the uses in this code are working with a buffer that's been - allocated based on measuring the strings involved. */ -# ifndef HAVE_STRLCAT -# define strlcat(dst, src, size) strcat((dst), (src)) -# endif -# ifndef HAVE_STRLCPY -# define strlcpy(dst, src, size) strcpy((dst), (src)) -# endif -# ifndef HAVE_FMAX -# define fmax my_fmax + allocated based on measuring the strings involved. + */ +#ifndef HAVE_STRLCAT +# define strlcat(dst, src, size) strcat((dst), (src)) +#endif +#ifndef HAVE_STRLCPY +# define strlcpy(dst, src, size) strcpy((dst), (src)) +#endif +#ifndef HAVE_FMAX +# define fmax my_fmax inline static double my_fmax(double x, double y) { return (x < y) ? y : x; } -# endif +#endif #ifdef WIN32 # define snprintf _snprintf @@ -123,811 +124,811 @@ int synctex_test(int argc, char *argv[]); int main(int argc, char *argv[]) { - int arg_index = 1; - printf("This is SyncTeX command line utility, version " SYNCTEX_CLI_VERSION_STRING "\n"); + int arg_index = 1; + printf("This is SyncTeX command line utility, version " SYNCTEX_CLI_VERSION_STRING "\n"); if(arg_index<argc) { - if(0==strcmp("help",argv[arg_index])) { - if(++arg_index<argc) { - if(0==strcmp("view",argv[arg_index])) { - synctex_help_view(NULL); - return 0; - } else if(0==strcmp("edit",argv[arg_index])) { - synctex_help_edit(NULL); - return 0; - } else if(0==strcmp("update",argv[arg_index])) { - synctex_help_update(NULL); - return 0; - } - } - synctex_help(NULL); - return 0; - } else if(0==strcmp("view",argv[arg_index])) { - return synctex_view(argc-arg_index-1,argv+arg_index+1); - } else if(0==strcmp("edit",argv[arg_index])) { - return synctex_edit(argc-arg_index-1,argv+arg_index+1); - } else if(0==strcmp("update",argv[arg_index])) { - return synctex_update(argc-arg_index-1,argv+arg_index+1); - } else if(0==strcmp("test",argv[arg_index])) { - return synctex_test(argc-arg_index-1,argv+arg_index+1); - } - } - synctex_help("Missing options"); - return 0; + if(0==strcmp("help",argv[arg_index])) { + if(++arg_index<argc) { + if(0==strcmp("view",argv[arg_index])) { + synctex_help_view(NULL); + return 0; + } else if(0==strcmp("edit",argv[arg_index])) { + synctex_help_edit(NULL); + return 0; + } else if(0==strcmp("update",argv[arg_index])) { + synctex_help_update(NULL); + return 0; + } + } + synctex_help(NULL); + return 0; + } else if(0==strcmp("view",argv[arg_index])) { + return synctex_view(argc-arg_index-1,argv+arg_index+1); + } else if(0==strcmp("edit",argv[arg_index])) { + return synctex_edit(argc-arg_index-1,argv+arg_index+1); + } else if(0==strcmp("update",argv[arg_index])) { + return synctex_update(argc-arg_index-1,argv+arg_index+1); + } else if(0==strcmp("test",argv[arg_index])) { + return synctex_test(argc-arg_index-1,argv+arg_index+1); + } + } + synctex_help("Missing options"); + return 0; } static void synctex_usage(const char * error,va_list ap) { - if(error) { - fprintf(stderr,"SyncTeX ERROR: "); - vfprintf(stderr,error,ap); - fprintf(stderr,"\n"); - } - fprintf((error?stderr:stdout), - "usage: synctex <subcommand> [options] [args]\n" - "Synchronize TeXnology command-line client, version " SYNCTEX_VERSION_STRING "\n\n" - "The Synchronization TeXnology by Jérôme Laurens is a rather new feature of recent TeX engines.\n" - "It allows to synchronize between input and output, which means to\n" - "navigate from the source document to the typeset material and vice versa.\n\n" - ); - return; + if(error) { + fprintf(stderr,"SyncTeX ERROR: "); + vfprintf(stderr,error,ap); + fprintf(stderr,"\n"); + } + fprintf((error?stderr:stdout), + "usage: synctex <subcommand> [options] [args]\n" + "Synchronize TeXnology command-line client, version " SYNCTEX_VERSION_STRING "\n\n" + "The Synchronization TeXnology by Jérôme Laurens is a rather new feature of recent TeX engines.\n" + "It allows to synchronize between input and output, which means to\n" + "navigate from the source document to the typeset material and vice versa.\n\n" + ); + return; } void synctex_help(const char * error,...) { - va_list v; - va_start(v, error); - synctex_usage(error, v); - va_end(v); - fprintf((error?stderr:stdout), - "Available subcommands:\n" - " view to perform forwards synchronization\n" - " edit to perform backwards synchronization\n" - " update to update a synctex file after a dvi/xdv to pdf filter\n" - " help this help\n\n" - "Type 'synctex help <subcommand>' for help on a specific subcommand.\n" - "There is also an undocumented test subcommand.\n" - ); - return; + va_list v; + va_start(v, error); + synctex_usage(error, v); + va_end(v); + fprintf((error?stderr:stdout), + "Available subcommands:\n" + " view to perform forwards synchronization\n" + " edit to perform backwards synchronization\n" + " update to update a synctex file after a dvi/xdv to pdf filter\n" + " help this help\n\n" + "Type 'synctex help <subcommand>' for help on a specific subcommand.\n" + "There is also an undocumented test subcommand.\n" + ); + return; } void synctex_help_view(const char * error,...) { - va_list v; - va_start(v, error); - synctex_usage(error, v); - va_end(v); - fputs("synctex view: forwards or direct synchronization,\n" - "command sent by the editor to view the output corresponding to the position under the mouse\n" - "\n" - "usage: synctex view -i line:column:[page_hint:]input -o output [-d directory] [-x viewer-command] [-h before/offset:middle/after]\n" - "\n" - "-i line:column:[page_hint:]input\n" - " specify the line, column, optional page hint and input file.\n" - " The line and column are 1 based integers,\n" - " they allow to identify every character in a file.\n" - " column is the offset of a character relative to the containing line.\n" - " Pass 0 if this information is not relevant.\n" + va_list v; + va_start(v, error); + synctex_usage(error, v); + va_end(v); + fputs("synctex view: forwards or direct synchronization,\n" + "command sent by the editor to view the output corresponding to the position under the mouse\n" + "\n" + "usage: synctex view -i line:column:[page_hint:]input -o output [-d directory] [-x viewer-command] [-h before/offset:middle/after]\n" + "\n" + "-i line:column:[page_hint:]input\n" + " specify the line, column, optional page hint and input file.\n" + " The line and column are 1 based integers,\n" + " they allow to identify every character in a file.\n" + " column is the offset of a character relative to the containing line.\n" + " Pass 0 if this information is not relevant.\n" " page_hint is the currently displayed page number.\n" " If there is an answer on that page, it will be returned.\n" " Pass 0 if this information is not available to you.\n" " input is either the name of the main source file or an included document.\n" - " It must be the very name as understood by TeX, id est the name exactly as it appears in the log file.\n" - " It does not matter if the file actually exists or not, except that the command is not really useful.\n" - " \n" - "-o output\n" - " is the full or relative path of the output file (with any relevant path extension).\n" - " This file must exist.\n" - " \n" - "-d directory\n" - " is the directory containing the synctex file, in case it is different from the directory of the output.\n" - " This directory must exist.\n" - " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" - " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" - " The other ones are simply removed, if the authorization is granted\n" - " \n" - "-x viewer-command\n" - " Normally the synctex tool outputs its result to the stdout.\n" - " It is possible to launch an external tool with the result.\n" - " The viewer-command is a printf like format string with following specifiers.\n" - " %{output} is the name specifier of the main document, without path extension.\n" - " %{page} is the 0 based page number specifier, %{page+1} is the 1 based page number specifier.\n" - " To synchronize by point, %{x} is the x coordinate specifier, %{y} is the y coordinate specifier,\n" - " both in dots and relative to the top left corner of the page.\n" - " To synchronize by box,\n" - " %{h} is the horizontal coordinate specifier of the origin of the enclosing box,\n" - " %{v} is the vertical coordinate specifier of the origin of the enclosing box,\n" - " both in dots and relative to the upper left corner of the page.\n" - " They may be different from the preceding pair of coordinates.\n" - " %{width} is the width specifier, %{height} is the height specifier of the enclosing box.\n" - " The latter dimension is naturally counted from bottom to top.\n" - " There is no notion of depth for such a box.\n" - " To synchronize by content, %{before} is the word before,\n" - " %{offset} is the offset specifier, %{middle} is the middle word, and %{after} is the word after.\n" - "\n" - " If no viewer command is provided, the content of the SYNCTEX_VIEWER environment variable is used instead.\n" - "\n" - "-h before/offset:middle/after\n" - " This hint allows a forwards synchronization by contents.\n" - " Instead of giving a character offset in a line, you can give full words.\n" - " A full word is a sequence of characters (excepting '/').\n" - " You will choose full words in the source document that will certainly appear unaltered in the output.\n" - " The \"middle\" word contains the character under the mouse at position offset.\n" - " \"before\" is a full word preceding middle and \"after\" is following it.\n" - " The before or after word can be missing, they are then considered as void strings.\n" - " \n" - "The result is a list of records. In general the first one is the most accurate but\n" - "it is the responsibility of the client to decide which one best fits the user needs.\n", - (error?stderr:stdout) - ); - return; + " It must be the very name as understood by TeX, id est the name exactly as it appears in the log file.\n" + " It does not matter if the file actually exists or not, except that the command is not really useful.\n" + " \n" + "-o output\n" + " is the full or relative path of the output file (with any relevant path extension).\n" + " This file must exist.\n" + " \n" + "-d directory\n" + " is the directory containing the synctex file, in case it is different from the directory of the output.\n" + " This directory must exist.\n" + " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" + " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" + " The other ones are simply removed, if the authorization is granted\n" + " \n" + "-x viewer-command\n" + " Normally the synctex tool outputs its result to the stdout.\n" + " It is possible to launch an external tool with the result.\n" + " The viewer-command is a printf like format string with following specifiers.\n" + " %{output} is the name specifier of the main document, without path extension.\n" + " %{page} is the 0 based page number specifier, %{page+1} is the 1 based page number specifier.\n" + " To synchronize by point, %{x} is the x coordinate specifier, %{y} is the y coordinate specifier,\n" + " both in dots and relative to the top left corner of the page.\n" + " To synchronize by box,\n" + " %{h} is the horizontal coordinate specifier of the origin of the enclosing box,\n" + " %{v} is the vertical coordinate specifier of the origin of the enclosing box,\n" + " both in dots and relative to the upper left corner of the page.\n" + " They may be different from the preceding pair of coordinates.\n" + " %{width} is the width specifier, %{height} is the height specifier of the enclosing box.\n" + " The latter dimension is naturally counted from bottom to top.\n" + " There is no notion of depth for such a box.\n" + " To synchronize by content, %{before} is the word before,\n" + " %{offset} is the offset specifier, %{middle} is the middle word, and %{after} is the word after.\n" + "\n" + " If no viewer command is provided, the content of the SYNCTEX_VIEWER environment variable is used instead.\n" + "\n" + "-h before/offset:middle/after\n" + " This hint allows a forwards synchronization by contents.\n" + " Instead of giving a character offset in a line, you can give full words.\n" + " A full word is a sequence of characters (excepting '/').\n" + " You will choose full words in the source document that will certainly appear unaltered in the output.\n" + " The \"middle\" word contains the character under the mouse at position offset.\n" + " \"before\" is a full word preceding middle and \"after\" is following it.\n" + " The before or after word can be missing, they are then considered as void strings.\n" + " \n" + "The result is a list of records. In general the first one is the most accurate but\n" + "it is the responsibility of the client to decide which one best fits the user needs.\n", + (error?stderr:stdout) + ); + return; } typedef struct { - int line; + int line; int column; int page; - unsigned int offset; - char * input; - char * output; - char * directory; - char * viewer; - char * before; - char * middle; - char * after; + unsigned int offset; + char * input; + char * output; + char * directory; + char * viewer; + char * before; + char * middle; + char * after; } synctex_view_params_t; int synctex_view_proceed(synctex_view_params_t * paramsRef); /* "usage: synctex view -i line:column:input -o output [-d directory] [-x viewer-command] [-h before/offset:middle/after]\n" */ int synctex_view(int argc, char *argv[]) { - int arg_index = 0; - char * start = NULL; - char * end = NULL; - synctex_view_params_t Ps = {-1,0,0,-1,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; - - /* required */ - if((arg_index>=argc) || strcmp("-i",argv[arg_index]) || (++arg_index>=argc)) { - synctex_help_view("Missing -i required argument"); - return -1; - } - start = argv[arg_index]; - Ps.line = (int)strtol(start,&end,10); - if(end>start && strlen(end)>0 && *end==':') { - start = end+1; - Ps.column = (int)strtol(start,&end,10); - if(end == start || Ps.column < 0) { - Ps.column = 0; - } - if(strlen(end)>1 && *end==':') { - Ps.input = end+1; - goto scan_output; - } - } - synctex_help_view("Bad -i argument"); - return -1; + int arg_index = 0; + char * start = NULL; + char * end = NULL; + synctex_view_params_t Ps = {-1,0,0,-1,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; + + /* required */ + if((arg_index>=argc) || strcmp("-i",argv[arg_index]) || (++arg_index>=argc)) { + synctex_help_view("Missing -i required argument"); + return -1; + } + start = argv[arg_index]; + Ps.line = (int)strtol(start,&end,10); + if(end>start && strlen(end)>0 && *end==':') { + start = end+1; + Ps.column = (int)strtol(start,&end,10); + if(end == start || Ps.column < 0) { + Ps.column = 0; + } + if(strlen(end)>1 && *end==':') { + Ps.input = end+1; + goto scan_output; + } + } + synctex_help_view("Bad -i argument"); + return -1; scan_output: - if((++arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { - synctex_help_view("Missing -o required argument"); - return -1; - } - Ps.output = argv[arg_index]; - /* now scan the optional arguments */ - if(++arg_index<argc) { - if(0 == strcmp("-d",argv[arg_index])) { - if(++arg_index<argc) { - Ps.directory = argv[arg_index]; - if(++arg_index<argc) { - goto option_command; - } else { - return synctex_view_proceed(&Ps); - } - } else { - Ps.directory = getenv("SYNCTEX_BUILD_DIRECTORY"); - return synctex_view_proceed(&Ps); - } - } + if((++arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { + synctex_help_view("Missing -o required argument"); + return -1; + } + Ps.output = argv[arg_index]; + /* now scan the optional arguments */ + if(++arg_index<argc) { + if(0 == strcmp("-d",argv[arg_index])) { + if(++arg_index<argc) { + Ps.directory = argv[arg_index]; + if(++arg_index<argc) { + goto option_command; + } else { + return synctex_view_proceed(&Ps); + } + } else { + Ps.directory = getenv("SYNCTEX_BUILD_DIRECTORY"); + return synctex_view_proceed(&Ps); + } + } option_command: - if(0 == strcmp("-x",argv[arg_index])) { - if(++arg_index<argc) { - if(strcmp("-",argv[arg_index])) { - /* next option does not start with '-', this is a command */ - Ps.viewer = argv[arg_index]; - if(++arg_index<argc) { - goto option_hint; - } else { - return synctex_view_proceed(&Ps); - } - } else { - /* retrieve the environment variable */ - Ps.viewer = getenv("SYNCTEX_VIEWER"); - goto option_hint; - } - } else { - Ps.viewer = getenv("SYNCTEX_VIEWER"); - return synctex_view_proceed(&Ps); - } - } + if(0 == strcmp("-x",argv[arg_index])) { + if(++arg_index<argc) { + if(strcmp("-",argv[arg_index])) { + /* next option does not start with '-', this is a command */ + Ps.viewer = argv[arg_index]; + if(++arg_index<argc) { + goto option_hint; + } else { + return synctex_view_proceed(&Ps); + } + } else { + /* retrieve the environment variable */ + Ps.viewer = getenv("SYNCTEX_VIEWER"); + goto option_hint; + } + } else { + Ps.viewer = getenv("SYNCTEX_VIEWER"); + return synctex_view_proceed(&Ps); + } + } option_hint: - if(0 == strcmp("-h",argv[arg_index]) && ++arg_index<argc) { - /* modify the argument */; - Ps.after = strstr(argv[arg_index],"/"); - if(NULL != Ps.after) { - Ps.before = argv[arg_index]; - *Ps.after = '\0'; - ++Ps.after; - Ps.offset = (int)strtoul(Ps.after,&Ps.middle,10); - if(Ps.middle>Ps.after && strlen(Ps.middle)>2) { - Ps.after = strstr(++Ps.middle,"/"); - if(NULL != Ps.after) { - *Ps.after = '\0'; - if(Ps.offset<strlen(Ps.middle)) { - ++Ps.after; - return synctex_view_proceed(&Ps); - } - } - } - } - synctex_help_view("Bad hint"); - return -1; - } - } - return synctex_view_proceed(&Ps); + if(0 == strcmp("-h",argv[arg_index]) && ++arg_index<argc) { + /* modify the argument */; + Ps.after = strstr(argv[arg_index],"/"); + if(NULL != Ps.after) { + Ps.before = argv[arg_index]; + *Ps.after = '\0'; + ++Ps.after; + Ps.offset = (int)strtoul(Ps.after,&Ps.middle,10); + if(Ps.middle>Ps.after && strlen(Ps.middle)>2) { + Ps.after = strstr(++Ps.middle,"/"); + if(NULL != Ps.after) { + *Ps.after = '\0'; + if(Ps.offset<strlen(Ps.middle)) { + ++Ps.after; + return synctex_view_proceed(&Ps); + } + } + } + } + synctex_help_view("Bad hint"); + return -1; + } + } + return synctex_view_proceed(&Ps); } int synctex_view_proceed(synctex_view_params_t * Ps) { - synctex_scanner_p scanner = NULL; - size_t size = 0; + synctex_scanner_p scanner = NULL; + size_t size = 0; #if SYNCTEX_DEBUG - printf("line:%i\n",Ps->line); + printf("line:%i\n",Ps->line); printf("column:%i\n",Ps->column); printf("page:%i\n",Ps->page); - printf("input:%s\n",Ps->input); - printf("viewer:%s\n",Ps->viewer); - printf("before:%s\n",Ps->before); - printf("offset:%i\n",Ps->offset); - printf("middle:%s\n",Ps->middle); - printf("after:%s\n",Ps->after); - printf("output:%s\n",Ps->output); - printf("cwd:%s\n",getcwd(NULL,0)); + printf("input:%s\n",Ps->input); + printf("viewer:%s\n",Ps->viewer); + printf("before:%s\n",Ps->before); + printf("offset:%i\n",Ps->offset); + printf("middle:%s\n",Ps->middle); + printf("after:%s\n",Ps->after); + printf("output:%s\n",Ps->output); + printf("cwd:%s\n",getcwd(NULL,0)); #endif - /* We assume that viewer is not so big: */ + /* We assume that viewer is not so big: */ # define SYNCTEX_STR_SIZE 65536 - if(Ps->viewer && strlen(Ps->viewer)>=SYNCTEX_STR_SIZE) { - synctex_help_view("Viewer command is too long"); - return -1; - } - scanner = synctex_scanner_new_with_output_file(Ps->output,Ps->directory,1); - if(scanner && synctex_display_query(scanner,Ps->input,Ps->line,Ps->column,Ps->page)) { - synctex_node_p node = NULL; - if((node = synctex_scanner_next_result(scanner)) != NULL) { - /* filtering the command */ - if(Ps->viewer && strlen(Ps->viewer)) { - char * viewer = Ps->viewer; - char * where = NULL; - char * buffer = NULL; - char * buffer_cur = NULL; - int status = 0; - /* Preparing the buffer where everything will be printed */ - size = strlen(viewer)+3*sizeof(int)+6*sizeof(float)+4*(SYNCTEX_STR_SIZE); - buffer = malloc(size+1); - if(NULL == buffer) { - synctex_help_view("No memory available"); - return -1; - } - /* Properly terminate the buffer, no bad access for string related functions. */ - buffer[size] = '\0'; - /* Replace %{ by &{, then remove all unescaped '%'*/ - while((where = strstr(viewer,"%{")) != NULL) { - *where = '&'; - } - /* find all the unescaped '%', change to a safe character */ - where = viewer; - while(where && (where = strstr(where,"%"))) { - /* Find the next occurrence of a "%", - * if it is not followed by another "%", - * replace it by a "&" */ - if(strlen(++where)) { - if(*where == '%') { - ++where; - } else { - *(where-1)='&'; - } - } - } - buffer_cur = buffer; - /* find the next occurrence of a format key */ - where = viewer; - while(viewer && (where = strstr(viewer,"&{"))) { - #define TEST(KEY,FORMAT,WHAT)\ - if(!strncmp(where,KEY,strlen(KEY))) {\ - size_t printed = where-viewer;\ - if(buffer_cur != memcpy(buffer_cur,viewer,(size_t)printed)) {\ - synctex_help_view("Memory copy problem");\ - free(buffer);\ - return -1;\ - }\ - buffer_cur += printed;size-=printed;\ - printed = snprintf(buffer_cur,size,FORMAT,WHAT);\ - if((unsigned)printed >= (unsigned)size) {\ - synctex_help_view("Snprintf problem");\ - free(buffer);\ - return -1;\ - }\ - buffer_cur += printed;size-=printed;\ - *buffer_cur='\0';\ - viewer = where+strlen(KEY);\ - continue;\ - } - TEST("&{output}","%s",synctex_scanner_get_output(scanner)); - TEST("&{page}", "%i",synctex_node_page(node)-1); - TEST("&{page+1}","%i",synctex_node_page(node)); - TEST("&{x}", "%f",synctex_node_visible_h(node)); - TEST("&{y}", "%f",synctex_node_visible_v(node)); - TEST("&{h}", "%f",synctex_node_box_visible_h(node)); - TEST("&{v}", "%f",synctex_node_box_visible_v(node)+synctex_node_box_visible_depth(node)); - TEST("&{width}", "%f",fabs(synctex_node_box_visible_width(node))); - TEST("&{height}","%f",fmax(synctex_node_box_visible_height(node)+synctex_node_box_visible_depth(node),1)); - TEST("&{before}","%s",(Ps->before && strlen(Ps->before)<SYNCTEX_STR_SIZE?Ps->before:"")); - TEST("&{offset}","%i",Ps->offset); - TEST("&{middle}","%s",(Ps->middle && strlen(Ps->middle)<SYNCTEX_STR_SIZE?Ps->middle:"")); - TEST("&{after}", "%s",(Ps->after && strlen(Ps->after)<SYNCTEX_STR_SIZE?Ps->after:"")); - #undef TEST - break; - } - /* copy the rest of viewer into the buffer */ - if(buffer_cur != strncpy(buffer_cur,viewer,size + 1)) { - synctex_help_view("Memory copy problem"); - free(buffer); - return -1; - } - buffer_cur[size] = '\0'; - printf("SyncTeX: Executing\n%s\n",buffer); - status = system(buffer); - free(buffer); - buffer = NULL; - return status; - } else { - /* just print out the results */ - puts("SyncTeX result begin"); - do { - printf( "Output:%s\n" - "Page:%i\n" - "x:%f\n" - "y:%f\n" - "h:%f\n" - "v:%f\n" - "W:%f\n" - "H:%f\n" - "before:%s\n" - "offset:%i\n" - "middle:%s\n" - "after:%s\n", - Ps->output, - synctex_node_page(node), - synctex_node_visible_h(node), - synctex_node_visible_v(node), - synctex_node_box_visible_h(node), - synctex_node_box_visible_v(node)+synctex_node_box_visible_depth(node), - synctex_node_box_visible_width(node), - synctex_node_box_visible_height(node)+synctex_node_box_visible_depth(node), - (Ps->before?Ps->before:""), - Ps->offset, - (Ps->middle?Ps->middle:""), - (Ps->after?Ps->after:"")); - } while((node = synctex_scanner_next_result(scanner)) != NULL); - puts("SyncTeX result end"); - } - } - } - return 0; + if(Ps->viewer && strlen(Ps->viewer)>=SYNCTEX_STR_SIZE) { + synctex_help_view("Viewer command is too long"); + return -1; + } + scanner = synctex_scanner_new_with_output_file(Ps->output,Ps->directory,1); + if(scanner && synctex_display_query(scanner,Ps->input,Ps->line,Ps->column,Ps->page)) { + synctex_node_p node = NULL; + if((node = synctex_scanner_next_result(scanner)) != NULL) { + /* filtering the command */ + if(Ps->viewer && strlen(Ps->viewer)) { + char * viewer = Ps->viewer; + char * where = NULL; + char * buffer = NULL; + char * buffer_cur = NULL; + int status = 0; + /* Preparing the buffer where everything will be printed */ + size = strlen(viewer)+3*sizeof(int)+6*sizeof(float)+4*(SYNCTEX_STR_SIZE); + buffer = malloc(size+1); + if(NULL == buffer) { + synctex_help_view("No memory available"); + return -1; + } + /* Properly terminate the buffer, no bad access for string related functions. */ + buffer[size] = '\0'; + /* Replace %{ by &{, then remove all unescaped '%'*/ + while((where = strstr(viewer,"%{")) != NULL) { + *where = '&'; + } + /* find all the unescaped '%', change to a safe character */ + where = viewer; + while(where && (where = strstr(where,"%"))) { + /* Find the next occurrence of a "%", + * if it is not followed by another "%", + * replace it by a "&" */ + if(strlen(++where)) { + if(*where == '%') { + ++where; + } else { + *(where-1)='&'; + } + } + } + buffer_cur = buffer; + /* find the next occurrence of a format key */ + where = viewer; + while(viewer && (where = strstr(viewer,"&{"))) { +# define TEST(KEY,FORMAT,WHAT)\ + if(!strncmp(where,KEY,strlen(KEY))) {\ + size_t printed = where-viewer;\ + if(buffer_cur != memcpy(buffer_cur,viewer,(size_t)printed)) {\ + synctex_help_view("Memory copy problem");\ + free(buffer);\ + return -1;\ + }\ + buffer_cur += printed;size-=printed;\ + printed = snprintf(buffer_cur,size,FORMAT,WHAT);\ + if((unsigned)printed >= (unsigned)size) {\ + synctex_help_view("Snprintf problem");\ + free(buffer);\ + return -1;\ + }\ + buffer_cur += printed;size-=printed;\ + *buffer_cur='\0';\ + viewer = where+strlen(KEY);\ + continue;\ + } + TEST("&{output}","%s",synctex_scanner_get_output(scanner)); + TEST("&{page}", "%i",synctex_node_page(node)-1); + TEST("&{page+1}","%i",synctex_node_page(node)); + TEST("&{x}", "%f",synctex_node_visible_h(node)); + TEST("&{y}", "%f",synctex_node_visible_v(node)); + TEST("&{h}", "%f",synctex_node_box_visible_h(node)); + TEST("&{v}", "%f",synctex_node_box_visible_v(node)+synctex_node_box_visible_depth(node)); + TEST("&{width}", "%f",fabs(synctex_node_box_visible_width(node))); + TEST("&{height}","%f",fmax(synctex_node_box_visible_height(node)+synctex_node_box_visible_depth(node),1)); + TEST("&{before}","%s",(Ps->before && strlen(Ps->before)<SYNCTEX_STR_SIZE?Ps->before:"")); + TEST("&{offset}","%i",Ps->offset); + TEST("&{middle}","%s",(Ps->middle && strlen(Ps->middle)<SYNCTEX_STR_SIZE?Ps->middle:"")); + TEST("&{after}", "%s",(Ps->after && strlen(Ps->after)<SYNCTEX_STR_SIZE?Ps->after:"")); +# undef TEST + break; + } + /* copy the rest of viewer into the buffer */ + if(buffer_cur != strncpy(buffer_cur,viewer,size + 1)) { + synctex_help_view("Memory copy problem"); + free(buffer); + return -1; + } + buffer_cur[size] = '\0'; + printf("SyncTeX: Executing\n%s\n",buffer); + status = system(buffer); + free(buffer); + buffer = NULL; + return status; + } else { + /* just print out the results */ + puts("SyncTeX result begin"); + do { + printf("Output:%s\n" + "Page:%i\n" + "x:%f\n" + "y:%f\n" + "h:%f\n" + "v:%f\n" + "W:%f\n" + "H:%f\n" + "before:%s\n" + "offset:%i\n" + "middle:%s\n" + "after:%s\n", + Ps->output, + synctex_node_page(node), + synctex_node_visible_h(node), + synctex_node_visible_v(node), + synctex_node_box_visible_h(node), + synctex_node_box_visible_v(node)+synctex_node_box_visible_depth(node), + synctex_node_box_visible_width(node), + synctex_node_box_visible_height(node)+synctex_node_box_visible_depth(node), + (Ps->before?Ps->before:""), + Ps->offset, + (Ps->middle?Ps->middle:""), + (Ps->after?Ps->after:"")); + } while((node = synctex_scanner_next_result(scanner)) != NULL); + puts("SyncTeX result end"); + } + } + } + return 0; } void synctex_help_edit(const char * error,...) { - va_list v; - va_start(v, error); - synctex_usage(error, v); - va_end(v); - fputs( - "synctex edit: backwards or reverse synchronization,\n" - "command sent by the viewer to edit the source corresponding to the position under the mouse\n\n" - "\n" - "usage: synctex edit -o page:x:y:file [-d directory] [-x editor-command] [-h offset:context]\n" - "\n" - "-o page:x:y:file\n" - " specify the page and coordinates of the point under the mouse.\n" - " page is 1 based.\n" - " Coordinates x and y are counted from the top left corner of the page.\n" - " Their unit is the big point (72 dpi).\n" - " \n" - " file is in general the path of a pdf or dvi file.\n" - " It can be either absolute or relative to the current directory.\n" - " This named file must always exist.\n" - " \n" - "-d directory\n" - " is the directory containing the synctex file, in case it is different from the directory of the output.\n" - " This directory must exist.\n" - " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" - " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" - " The other ones are simply removed, if the authorization is granted\n" - " \n" - "-x editor-command\n" - " Normally the synctex tool outputs its result to the stdout.\n" - " It is possible to execute an external tool with the result of the query.\n" - " The editor-command is a printf like format string with following specifiers.\n" - " They will be replaced by their value before the command is executed.\n" - " %{output} is the full path specifier of the output document, with no extension.\n" - " %{input} is the name specifier of the input document.\n" - " %{line} is the 0 based line number specifier. %{line+1} is the 1 based line number specifier.\n" - " %{column} is the 0 based column number specifier or -1. %{column+1} is the 1 based column number or -1.\n" - " %{offset} is the 0 based offset specifier and %{context} is the context specifier of the hint.\n" - " \n" - " If no editor-command is provided, the content of the SYNCTEX_EDITOR environment variable is used instead.\n" - " \n" - "-h offset:context\n" - " This hint allows a backwards or reverse synchronization by contents.\n" - " You give a context including the character at the mouse location, and\n" - " the offset of this character relative to the beginning of this bunch of text.\n" - " \n", - (error?stderr:stdout) - ); - return; + va_list v; + va_start(v, error); + synctex_usage(error, v); + va_end(v); + fputs( + "synctex edit: backwards or reverse synchronization,\n" + "command sent by the viewer to edit the source corresponding to the position under the mouse\n\n" + "\n" + "usage: synctex edit -o page:x:y:file [-d directory] [-x editor-command] [-h offset:context]\n" + "\n" + "-o page:x:y:file\n" + " specify the page and coordinates of the point under the mouse.\n" + " page is 1 based.\n" + " Coordinates x and y are counted from the top left corner of the page.\n" + " Their unit is the big point (72 dpi).\n" + " \n" + " file is in general the path of a pdf or dvi file.\n" + " It can be either absolute or relative to the current directory.\n" + " This named file must always exist.\n" + " \n" + "-d directory\n" + " is the directory containing the synctex file, in case it is different from the directory of the output.\n" + " This directory must exist.\n" + " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" + " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" + " The other ones are simply removed, if the authorization is granted\n" + " \n" + "-x editor-command\n" + " Normally the synctex tool outputs its result to the stdout.\n" + " It is possible to execute an external tool with the result of the query.\n" + " The editor-command is a printf like format string with following specifiers.\n" + " They will be replaced by their value before the command is executed.\n" + " %{output} is the full path specifier of the output document, with no extension.\n" + " %{input} is the name specifier of the input document.\n" + " %{line} is the 0 based line number specifier. %{line+1} is the 1 based line number specifier.\n" + " %{column} is the 0 based column number specifier or -1. %{column+1} is the 1 based column number or -1.\n" + " %{offset} is the 0 based offset specifier and %{context} is the context specifier of the hint.\n" + " \n" + " If no editor-command is provided, the content of the SYNCTEX_EDITOR environment variable is used instead.\n" + " \n" + "-h offset:context\n" + " This hint allows a backwards or reverse synchronization by contents.\n" + " You give a context including the character at the mouse location, and\n" + " the offset of this character relative to the beginning of this bunch of text.\n" + " \n", + (error?stderr:stdout) + ); + return; } typedef struct { - int page; - float x; - float y; - unsigned int offset; - char * output; - char * directory; - char * editor; - char * context; + int page; + float x; + float y; + unsigned int offset; + char * output; + char * directory; + char * editor; + char * context; } synctex_edit_params_t; int synctex_edit_proceed(synctex_edit_params_t * Ps); -/* "usage: synctex edit -o page:x:y:output [-d directory] [-x editor-command] [-h offset:context]\n" */ +/* "usage: synctex edit -o page:x:y:output [-d directory] [-x editor-command] [-h offset:context]\n" */ int synctex_edit(int argc, char *argv[]) { - int arg_index = 0; - char * start = NULL; - char * end = NULL; - synctex_edit_params_t Ps = {0,0,0,0,NULL,NULL,NULL,NULL}; - /* required */ - if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { - synctex_help_edit("Missing -o required argument"); - return -1; - } - start = argv[arg_index]; - Ps.page = (int)strtol(start,&end,10); - if(end>start && strlen(end)>1 && *end==':') { - start = end+1; - Ps.x = strtod(start,&end); - if(end>start && strlen(end)>1 && *end==':') { - start = end+1; - Ps.y = strtod(start,&end); - if(end>start && strlen(end)>1 && *end==':') { - Ps.output = ++end; - goto scan_execute; - } - } - } - synctex_help_edit("Bad -o argument"); - return -1; + int arg_index = 0; + char * start = NULL; + char * end = NULL; + synctex_edit_params_t Ps = {0,0,0,0,NULL,NULL,NULL,NULL}; + /* required */ + if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { + synctex_help_edit("Missing -o required argument"); + return -1; + } + start = argv[arg_index]; + Ps.page = (int)strtol(start,&end,10); + if(end>start && strlen(end)>1 && *end==':') { + start = end+1; + Ps.x = strtod(start,&end); + if(end>start && strlen(end)>1 && *end==':') { + start = end+1; + Ps.y = strtod(start,&end); + if(end>start && strlen(end)>1 && *end==':') { + Ps.output = ++end; + goto scan_execute; + } + } + } + synctex_help_edit("Bad -o argument"); + return -1; scan_execute: - /* now scan the optional arguments */ - if(++arg_index<argc) { - if(0 == strcmp("-d",argv[arg_index])) { - if(++arg_index<argc) { - Ps.directory = argv[arg_index]; - if(++arg_index<argc) { - goto option_command; - } else { - return synctex_edit_proceed(&Ps); - } - } else { - Ps.directory = getenv("SYNCTEX_BUILD_DIRECTORY"); - return synctex_edit_proceed(&Ps); - } - } + /* now scan the optional arguments */ + if(++arg_index<argc) { + if(0 == strcmp("-d",argv[arg_index])) { + if(++arg_index<argc) { + Ps.directory = argv[arg_index]; + if(++arg_index<argc) { + goto option_command; + } else { + return synctex_edit_proceed(&Ps); + } + } else { + Ps.directory = getenv("SYNCTEX_BUILD_DIRECTORY"); + return synctex_edit_proceed(&Ps); + } + } option_command: - if(0 == strcmp("-x",argv[arg_index])) { - if(++arg_index<argc) { - if(strcmp("-",argv[arg_index])) { - /* next option does not start with '-', this is a command */ - Ps.editor = argv[arg_index]; - if(++arg_index<argc) { - goto option_hint; - } else { - return synctex_edit_proceed(&Ps); - } - } else { - /* retrieve the environment variable */ - Ps.editor = getenv("SYNCTEX_EDITOR"); - goto option_hint; - } - } else { - Ps.editor = getenv("SYNCTEX_EDITOR"); - return synctex_edit_proceed(&Ps); - } - } -option_hint: - if(0 == strcmp("-h",argv[arg_index]) && ++arg_index<argc) { - - start = argv[arg_index]; - end = NULL; - Ps.offset = (int)strtol(start,&end,10); - if(end>start && strlen(end)>1 && *end==':') { - Ps.context = end+1; - return synctex_edit_proceed(&Ps); - } - synctex_help_edit("Bad -h argument"); - return -1; - } - } - return synctex_edit_proceed(&Ps); + if(0 == strcmp("-x",argv[arg_index])) { + if(++arg_index<argc) { + if(strcmp("-",argv[arg_index])) { + /* next option does not start with '-', this is a command */ + Ps.editor = argv[arg_index]; + if(++arg_index<argc) { + goto option_hint; + } else { + return synctex_edit_proceed(&Ps); + } + } else { + /* retrieve the environment variable */ + Ps.editor = getenv("SYNCTEX_EDITOR"); + goto option_hint; + } + } else { + Ps.editor = getenv("SYNCTEX_EDITOR"); + return synctex_edit_proceed(&Ps); + } + } + option_hint: + if(0 == strcmp("-h",argv[arg_index]) && ++arg_index<argc) { + + start = argv[arg_index]; + end = NULL; + Ps.offset = (int)strtol(start,&end,10); + if(end>start && strlen(end)>1 && *end==':') { + Ps.context = end+1; + return synctex_edit_proceed(&Ps); + } + synctex_help_edit("Bad -h argument"); + return -1; + } + } + return synctex_edit_proceed(&Ps); } int synctex_edit_proceed(synctex_edit_params_t * Ps) { - synctex_scanner_p scanner = NULL; + synctex_scanner_p scanner = NULL; #if SYNCTEX_DEBUG - printf("page:%i\n",Ps->page); - printf("x:%f\n",Ps->x); - printf("y:%f\n",Ps->y); - printf("almost output:%s\n",Ps->output); - printf("editor:%s\n",Ps->editor); - printf("offset:%i\n",Ps->offset); - printf("context:%s\n",Ps->context); - printf("cwd:%s\n",getcwd(NULL,0)); + printf("page:%i\n",Ps->page); + printf("x:%f\n",Ps->x); + printf("y:%f\n",Ps->y); + printf("almost output:%s\n",Ps->output); + printf("editor:%s\n",Ps->editor); + printf("offset:%i\n",Ps->offset); + printf("context:%s\n",Ps->context); + printf("cwd:%s\n",getcwd(NULL,0)); #endif - scanner = synctex_scanner_new_with_output_file(Ps->output,Ps->directory,1); - if(NULL == scanner) { - synctex_help_edit("No SyncTeX available for %s",Ps->output); - return -1; - } - if(synctex_edit_query(scanner,Ps->page,Ps->x,Ps->y)) { - synctex_node_p node = NULL; - const char * input = NULL; - if(NULL != (node = synctex_scanner_next_result(scanner)) - && NULL != (input = synctex_scanner_get_name(scanner,synctex_node_tag(node)))) { - /* filtering the command */ - if(Ps->editor && strlen(Ps->editor)) { - size_t size = 0; - char * where = NULL; - char * buffer = NULL; - char * buffer_cur = NULL; - int status; - size = strlen(Ps->editor)+3*sizeof(int)+3*SYNCTEX_STR_SIZE; - buffer = malloc(size+1); - if(NULL == buffer) { - printf("SyncTeX ERROR: No memory available\n"); - return -1; - } - buffer[size]='\0'; - /* Replace %{ by &{, then remove all unescaped '%'*/ - while((where = strstr(Ps->editor,"%{")) != NULL) { - *where = '&'; - } - where = Ps->editor; - while(where &&(where = strstr(where,"%"))) { - if(strlen(++where)) { - if(*where == '%') { - ++where; - } else { - *(where-1)='&'; - } - } - } - buffer_cur = buffer; - /* find the next occurrence of a format key */ - where = Ps->editor; - while(Ps->editor && (where = strstr(Ps->editor,"&{"))) { - #define TEST(KEY,FORMAT,WHAT)\ - if(!strncmp(where,KEY,strlen(KEY))) {\ - size_t printed = where-Ps->editor;\ - if(buffer_cur != memcpy(buffer_cur,Ps->editor,(size_t)printed)) {\ - synctex_help_edit("Memory copy problem");\ - free(buffer);\ - return -1;\ - }\ - buffer_cur += printed;size-=printed;\ - printed = snprintf(buffer_cur,size,FORMAT,WHAT);\ - if((unsigned)printed >= (unsigned)size) {\ - synctex_help_edit("Snprintf problem");\ - free(buffer);\ - return -1;\ - }\ - buffer_cur += printed;size-=printed;\ - *buffer_cur='\0';\ - Ps->editor = where+strlen(KEY);\ - continue;\ - } - TEST("&{output}", "%s",Ps->output); - TEST("&{input}", "%s",input); - TEST("&{line}", "%i",synctex_node_line(node)); - TEST("&{column}", "%i",-1); - TEST("&{offset}", "%i",Ps->offset); - TEST("&{context}","%s",Ps->context); - #undef TEST - break; - } - /* copy the rest of editor into the buffer */ - if(buffer_cur != memcpy(buffer_cur,Ps->editor,strlen(Ps->editor))) { - fputs("! synctex_edit: Memory copy problem",stderr); - free(buffer); - return -1; - }\ - printf("SyncTeX: Executing\n%s\n",buffer); - status = system(buffer); - free(buffer); - buffer = NULL; - return status; - } else { - /* just print out the results */ - puts("SyncTeX result begin"); - do { - printf( "Output:%s\n" - "Input:%s\n" - "Line:%i\n" - "Column:%i\n" - "Offset:%i\n" - "Context:%s\n", - Ps->output, - input, - synctex_node_line(node), - synctex_node_column(node), - Ps->offset, - (Ps->context?Ps->context:"")); - } while((node = synctex_scanner_next_result(scanner)) != NULL); - puts("SyncTeX result end"); - } - } - } - return 0; + scanner = synctex_scanner_new_with_output_file(Ps->output,Ps->directory,1); + if(NULL == scanner) { + synctex_help_edit("No SyncTeX available for %s",Ps->output); + return -1; + } + if(synctex_edit_query(scanner,Ps->page,Ps->x,Ps->y)) { + synctex_node_p node = NULL; + const char * input = NULL; + if(NULL != (node = synctex_scanner_next_result(scanner)) + && NULL != (input = synctex_scanner_get_name(scanner,synctex_node_tag(node)))) { + /* filtering the command */ + if(Ps->editor && strlen(Ps->editor)) { + size_t size = 0; + char * where = NULL; + char * buffer = NULL; + char * buffer_cur = NULL; + int status; + size = strlen(Ps->editor)+3*sizeof(int)+3*SYNCTEX_STR_SIZE; + buffer = malloc(size+1); + if(NULL == buffer) { + printf("SyncTeX ERROR: No memory available\n"); + return -1; + } + buffer[size]='\0'; + /* Replace %{ by &{, then remove all unescaped '%'*/ + while((where = strstr(Ps->editor,"%{")) != NULL) { + *where = '&'; + } + where = Ps->editor; + while(where &&(where = strstr(where,"%"))) { + if(strlen(++where)) { + if(*where == '%') { + ++where; + } else { + *(where-1)='&'; + } + } + } + buffer_cur = buffer; + /* find the next occurrence of a format key */ + where = Ps->editor; + while(Ps->editor && (where = strstr(Ps->editor,"&{"))) { +# define TEST(KEY,FORMAT,WHAT)\ + if(!strncmp(where,KEY,strlen(KEY))) {\ + size_t printed = where-Ps->editor;\ + if(buffer_cur != memcpy(buffer_cur,Ps->editor,(size_t)printed)) {\ + synctex_help_edit("Memory copy problem");\ + free(buffer);\ + return -1;\ + }\ + buffer_cur += printed;size-=printed;\ + printed = snprintf(buffer_cur,size,FORMAT,WHAT);\ + if((unsigned)printed >= (unsigned)size) {\ + synctex_help_edit("Snprintf problem");\ + free(buffer);\ + return -1;\ + }\ + buffer_cur += printed;size-=printed;\ + *buffer_cur='\0';\ + Ps->editor = where+strlen(KEY);\ + continue;\ + } + TEST("&{output}", "%s",Ps->output); + TEST("&{input}", "%s",input); + TEST("&{line}", "%i",synctex_node_line(node)); + TEST("&{column}", "%i",-1); + TEST("&{offset}", "%i",Ps->offset); + TEST("&{context}","%s",Ps->context); +# undef TEST + break; + } + /* copy the rest of editor into the buffer */ + if(buffer_cur != memcpy(buffer_cur,Ps->editor,strlen(Ps->editor))) { + fputs("! synctex_edit: Memory copy problem",stderr); + free(buffer); + return -1; + }\ + printf("SyncTeX: Executing\n%s\n",buffer); + status = system(buffer); + free(buffer); + buffer = NULL; + return status; + } else { + /* just print out the results */ + puts("SyncTeX result begin"); + do { + printf( "Output:%s\n" + "Input:%s\n" + "Line:%i\n" + "Column:%i\n" + "Offset:%i\n" + "Context:%s\n", + Ps->output, + input, + synctex_node_line(node), + synctex_node_column(node), + Ps->offset, + (Ps->context?Ps->context:"")); + } while((node = synctex_scanner_next_result(scanner)) != NULL); + puts("SyncTeX result end"); + } + } + } + return 0; } void synctex_help_update(const char * error,...) { - va_list v; - va_start(v, error); - synctex_usage(error, v); - va_end(v); - fputs( - "synctex update: up to date synctex file,\n" - "Use this command to update the synctex file once a dvi/xdv to pdf filter is applied.\n\n" - "\n" - "usage: synctex update -o output [-d directory] [-m number] [-x dimension] [-y dimension]\n" - "\n" - "-o output is the full or relative path of an existing file,\n" - " either the real synctex file you wish to update\n" - " or a related file: foo.tex, foo.pdf, foo.dvi...\n" - "-d directory is the directory containing the synctex file, in case it is different from the directory of the output.\n" - " This directory must exist.\n" - " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" - " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" - " The other ones are simply removed, if the authorization is granted\n" - " \n" - "-m number Set additional magnification\n" - "-x dimension Set horizontal offset\n" - "-y dimension Set vertical offset\n" - "In general, these are exactly the same options provided to the dvi/xdv to pdf filter.\n", - (error?stderr:stdout) - ); - return; + va_list v; + va_start(v, error); + synctex_usage(error, v); + va_end(v); + fputs( + "synctex update: up to date synctex file,\n" + "Use this command to update the synctex file once a dvi/xdv to pdf filter is applied.\n\n" + "\n" + "usage: synctex update -o output [-d directory] [-m number] [-x dimension] [-y dimension]\n" + "\n" + "-o output is the full or relative path of an existing file,\n" + " either the real synctex file you wish to update\n" + " or a related file: foo.tex, foo.pdf, foo.dvi...\n" + "-d directory is the directory containing the synctex file, in case it is different from the directory of the output.\n" + " This directory must exist.\n" + " An example will explain how things work: for synctex -o ...:bar.tex -d foo,\n" + " the chosen synctex file is the most recent among bar.synctex, bar.synctex.gz, foo/bar.synctex and foo/bar.synctex.gz.\n" + " The other ones are simply removed, if the authorization is granted\n" + " \n" + "-m number Set additional magnification\n" + "-x dimension Set horizontal offset\n" + "-y dimension Set vertical offset\n" + "In general, these are exactly the same options provided to the dvi/xdv to pdf filter.\n", + (error?stderr:stdout) + ); + return; } /* "usage: synctex update -o output [-d directory] [-m number] [-x dimension] [-y dimension]\n" */ int synctex_update(int argc, char *argv[]) { - int arg_index = 0; - synctex_updater_p updater = NULL; - char * magnification = NULL; - char * x = NULL; - char * y = NULL; - char * output = NULL; - char * directory = NULL; - #define SYNCTEX_fprintf (*synctex_fprintf) - if(arg_index>=argc) { - synctex_help_update("Bad update command"); - return -1; - } - /* required */ - if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { - synctex_help_update("Missing -o required argument"); - return -1; - } - output = argv[arg_index]; - if(++arg_index>=argc) { - return 0; - } + int arg_index = 0; + synctex_updater_p updater = NULL; + char * magnification = NULL; + char * x = NULL; + char * y = NULL; + char * output = NULL; + char * directory = NULL; +#define SYNCTEX_fprintf (*synctex_fprintf) + if(arg_index>=argc) { + synctex_help_update("Bad update command"); + return -1; + } + /* required */ + if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { + synctex_help_update("Missing -o required argument"); + return -1; + } + output = argv[arg_index]; + if(++arg_index>=argc) { + return 0; + } next_argument: - if(0 == strcmp("-m",argv[arg_index])) { - if(++arg_index>=argc) { - synctex_help_update("Missing magnification"); - return -1; - } - magnification = argv[arg_index]; -prepare_next_argument: - if(++arg_index<argc) { - goto next_argument; - } - } else if(0 == strcmp("-x",argv[arg_index])) { - if(++arg_index>=argc) { - synctex_help_update("Missing x offset"); - return -1; - } - x = argv[arg_index]; - goto prepare_next_argument; - } else if(0 == strcmp("-y",argv[arg_index])) { - if(++arg_index>=argc) { - synctex_help_update("Missing y offset"); - return -1; - } - y = argv[arg_index]; - goto prepare_next_argument; - } else if(0 == strcmp("-d",argv[arg_index])) { - if(++arg_index<argc) { - directory = argv[arg_index]; - } else { - directory = getenv("SYNCTEX_BUILD_DIRECTORY"); - } - goto prepare_next_argument; - } - - /* Arguments parsed */ - updater = synctex_updater_new_with_output_file(output,directory); - synctex_updater_append_magnification(updater,magnification); - synctex_updater_append_x_offset(updater,x); - synctex_updater_append_y_offset(updater,y); - synctex_updater_free(updater); - return 0; + if(0 == strcmp("-m",argv[arg_index])) { + if(++arg_index>=argc) { + synctex_help_update("Missing magnification"); + return -1; + } + magnification = argv[arg_index]; + prepare_next_argument: + if(++arg_index<argc) { + goto next_argument; + } + } else if(0 == strcmp("-x",argv[arg_index])) { + if(++arg_index>=argc) { + synctex_help_update("Missing x offset"); + return -1; + } + x = argv[arg_index]; + goto prepare_next_argument; + } else if(0 == strcmp("-y",argv[arg_index])) { + if(++arg_index>=argc) { + synctex_help_update("Missing y offset"); + return -1; + } + y = argv[arg_index]; + goto prepare_next_argument; + } else if(0 == strcmp("-d",argv[arg_index])) { + if(++arg_index<argc) { + directory = argv[arg_index]; + } else { + directory = getenv("SYNCTEX_BUILD_DIRECTORY"); + } + goto prepare_next_argument; + } + + /* Arguments parsed */ + updater = synctex_updater_new_with_output_file(output,directory); + synctex_updater_append_magnification(updater,magnification); + synctex_updater_append_x_offset(updater,x); + synctex_updater_append_y_offset(updater,y); + synctex_updater_free(updater); + return 0; } int synctex_test_file (int argc, char *argv[]); /* "usage: synctex test subcommand options\n" */ int synctex_test(int argc, char *argv[]) { - if(argc) { - if(0==strcmp("file",argv[0])) { - return synctex_test_file(argc-1,argv+1); - } - } - return 0; + if(argc) { + if(0==strcmp("file",argv[0])) { + return synctex_test_file(argc-1,argv+1); + } + } + return 0; } int synctex_test_file (int argc, char *argv[]) { - int arg_index = 0; - char * output = NULL; - char * directory = NULL; - char * synctex_name = NULL; - synctex_compress_mode_t mode = synctex_compress_mode_none; - if(arg_index>=argc) { - _synctex_error("! usage: synctex test file -o output [-d directory]\n"); - return -1; - } - /* required */ - if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { - _synctex_error("! usage: synctex test file -o output [-d directory]\n"); - return -1; - } - output = argv[arg_index]; - /* optional */ - if(++arg_index<argc) { - if(0 == strcmp("-d",argv[arg_index])) { - if(++arg_index<argc) { - directory = argv[arg_index]; - } else { - directory = getenv("SYNCTEX_BUILD_DIRECTORY"); - } - } - } - /* Arguments parsed */ - if(_synctex_get_name(output, directory, &synctex_name, &mode)) { - _synctex_error("! TEST FAILED\n"); - } else { - printf("output:%s\n" - "directory:%s\n" - "file name:%s\n" - "compression mode:%s\n", - output, - directory, - synctex_name, - (mode?"gz":"none")); - } - return 0; + int arg_index = 0; + char * output = NULL; + char * directory = NULL; + char * synctex_name = NULL; + synctex_compress_mode_t mode = synctex_compress_mode_none; + if(arg_index>=argc) { + _synctex_error("! usage: synctex test file -o output [-d directory]\n"); + return -1; + } + /* required */ + if((arg_index>=argc) || strcmp("-o",argv[arg_index]) || (++arg_index>=argc)) { + _synctex_error("! usage: synctex test file -o output [-d directory]\n"); + return -1; + } + output = argv[arg_index]; + /* optional */ + if(++arg_index<argc) { + if(0 == strcmp("-d",argv[arg_index])) { + if(++arg_index<argc) { + directory = argv[arg_index]; + } else { + directory = getenv("SYNCTEX_BUILD_DIRECTORY"); + } + } + } + /* Arguments parsed */ + if(_synctex_get_name(output, directory, &synctex_name, &mode)) { + _synctex_error("! TEST FAILED\n"); + } else { + printf("output:%s\n" + "directory:%s\n" + "file name:%s\n" + "compression mode:%s\n", + output, + directory, + synctex_name, + (mode?"gz":"none")); + } + return 0; } diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser.c b/Build/source/texk/web2c/synctexdir/synctex_parser.c index edca5ce8c7c..f4f7d848e43 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser.c @@ -3,8 +3,8 @@ This file is part of the __SyncTeX__ package. - [//]: # (Latest Revision: Wed Oct 11 19:19:08 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Latest Revision: Sun Oct 15 15:09:55 UTC 2017) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details @@ -59,8 +59,8 @@ * \file synctex_parser.c * \brief SyncTeX file parser and controller. * - author: Jérôme LAURENS - * \version 1.20 - * \date Mon Apr 24 07:08:56 UTC 2017 + * \version 1.21 + * \date Sun Oct 15 15:09:55 UTC 2017 * * Reads and parse *.synctex[.gz] files, * performs edit and display queries. @@ -106,6 +106,14 @@ #include <locale.h> #endif +/* Mark unused parameters, so that there will be no compile warnings. */ +#ifdef __DARWIN_UNIX03 +# define SYNCTEX_UNUSED(x) SYNCTEX_PRAGMA(unused(x)) +# define SYNCTEX_PRAGMA(x) _Pragma ( #x ) +#else +# define SYNCTEX_UNUSED(x) (void)(x); +#endif + #include "synctex_parser_advanced.h" SYNCTEX_INLINE static int _synctex_abs(int x) { @@ -168,26 +176,6 @@ typedef struct synctex_data_model_t { int size; } synctex_data_model_s; -static const synctex_data_model_s synctex_data_model_none = { - -1, /* tag */ - -1, /* line */ - -1, /* column */ - -1, /* h */ - -1, /* v */ - -1, /* width */ - -1, /* height */ - -1, /* depth */ - -1, /* mean_line */ - -1, /* weight */ - -1, /* h_V */ - -1, /* v_V */ - -1, /* width_V */ - -1, /* height_V */ - -1, /* depth_V */ - -1, /* name */ - -1, /* page */ - 0 /* size */ -}; typedef const synctex_data_model_s * synctex_data_model_p; typedef int (*synctex_int_getter_f)(synctex_node_p); @@ -198,9 +186,7 @@ typedef struct synctex_tlcpector_t { } synctex_tlcpector_s; typedef const synctex_tlcpector_s * synctex_tlcpector_p; static int _synctex_int_none(synctex_node_p node) { -# ifdef __DARWIN_UNIX03 -# pragma unused(node) -# endif + SYNCTEX_UNUSED(node) return 0; } static const synctex_tlcpector_s synctex_tlcpector_none = { @@ -234,9 +220,7 @@ typedef struct synctex_vispector_t { synctex_float_getter_f depth; } synctex_vispector_s; static float _synctex_float_none(synctex_node_p node) { -# ifdef __DARWIN_UNIX03 -# pragma unused(node) -# endif + SYNCTEX_UNUSED(node) return 0; } static const synctex_vispector_s synctex_vispector_none = { @@ -282,12 +266,12 @@ typedef synctex_node_p synctex_noxy_p; * \def SYNCTEX_MSG_SEND * \brief Takes care of sending the given message if possible. * - parameter NODE: of type synctex_node_p - * - parameter SELECTOR: one of the class pointer properties + * - parameter SELECTOR: one of the class_ pointer properties */ # define SYNCTEX_MSG_SEND(NODE,SELECTOR) do {\ synctex_node_p N__ = NODE;\ - if (N__ && N__->class->SELECTOR) {\ - (*(N__->class->SELECTOR))(N__);\ + if (N__ && N__->class_->SELECTOR) {\ + (*(N__->class_->SELECTOR))(N__);\ }\ } while (synctex_NO) @@ -376,7 +360,7 @@ __synctex_scanner_register_handle_to(NODE) #define DEFINE_SYNCTEX_TREE_HAS(WHAT)\ static synctex_bool_t _synctex_tree_has_##WHAT(synctex_node_p node) {\ if (node) {\ - if (node->class->navigator->WHAT>=0) {\ + if (node->class_->navigator->WHAT>=0) {\ return synctex_YES; \ } else {\ printf("WARNING: NO tree %s for %s\n", #WHAT, synctex_node_isa(node));\ @@ -388,13 +372,13 @@ static synctex_bool_t _synctex_tree_has_##WHAT(synctex_node_p node) {\ #define SYNCTEX_PARAMETER_ASSERT(WHAT) #define DEFINE_SYNCTEX_TREE_HAS(WHAT) \ static synctex_bool_t _synctex_tree_has_##WHAT(synctex_node_p node) {\ - return (node && (node->class->navigator->WHAT>=0));\ + return (node && (node->class_->navigator->WHAT>=0));\ } #endif # define DEFINE_SYNCTEX_TREE__GET(WHAT) \ SYNCTEX_INLINE static synctex_node_p __synctex_tree_##WHAT(synctex_non_null_node_p node) {\ - return node->data[node->class->navigator->WHAT].as_node;\ + return node->data[node->class_->navigator->WHAT].as_node;\ } # define DEFINE_SYNCTEX_TREE_GET(WHAT) \ DEFINE_SYNCTEX_TREE__GET(WHAT) \ @@ -406,8 +390,8 @@ static synctex_node_p _synctex_tree_##WHAT(synctex_node_p node) {\ } # define DEFINE_SYNCTEX_TREE__RESET(WHAT) \ SYNCTEX_INLINE static synctex_node_p __synctex_tree_reset_##WHAT(synctex_non_null_node_p node) {\ - synctex_node_p old = node->data[node->class->navigator->WHAT].as_node;\ - node->data[node->class->navigator->WHAT].as_node=NULL;\ + synctex_node_p old = node->data[node->class_->navigator->WHAT].as_node;\ + node->data[node->class_->navigator->WHAT].as_node=NULL;\ return old;\ } # define DEFINE_SYNCTEX_TREE_RESET(WHAT) \ @@ -419,7 +403,7 @@ SYNCTEX_INLINE static synctex_node_p _synctex_tree_reset_##WHAT(synctex_node_p n # define DEFINE_SYNCTEX_TREE__SET(WHAT) \ SYNCTEX_INLINE static synctex_node_p __synctex_tree_set_##WHAT(synctex_non_null_node_p node, synctex_node_p new_value) {\ synctex_node_p old = __synctex_tree_##WHAT(node);\ - node->data[node->class->navigator->WHAT].as_node=new_value;\ + node->data[node->class_->navigator->WHAT].as_node=new_value;\ return old;\ } # define DEFINE_SYNCTEX_TREE_SET(WHAT) \ @@ -533,8 +517,8 @@ typedef struct synctex_reader_t { char * current; /* current location in the buffer */ char * start; /* start of the buffer */ char * end; /* end of the buffer */ - int min_size; - int size; + size_t min_size; + size_t size; int lastv; int line_number; SYNCTEX_DECLARE_CHAR_OFFSET @@ -824,7 +808,7 @@ struct synctex_scanner_t { synctex_node_p ref_in_form; /* The first form ref node, its friends are the other form ref nodes in sheet */ int number_of_lists; /* The number of friend lists */ synctex_node_r lists_of_friends;/* The friend lists */ - synctex_class_s class[synctex_node_number_of_types]; /* The classes of the nodes of the scanner */ + synctex_class_s class_[synctex_node_number_of_types]; /* The classes of the nodes of the scanner */ int display_switcher; char * display_prompt; }; @@ -836,7 +820,7 @@ struct synctex_scanner_t { * to ask for an acceptable type. */ synctex_node_p synctex_node_new(synctex_scanner_p scanner, synctex_node_type_t type) { - return scanner? scanner->class[type].new(scanner):NULL; + return scanner? scanner->class_[type].new(scanner):NULL; } # if defined(SYNCTEX_USE_HANDLE) SYNCTEX_INLINE static void __synctex_scanner_free_handle(synctex_scanner_p scanner) { @@ -844,7 +828,7 @@ SYNCTEX_INLINE static void __synctex_scanner_free_handle(synctex_scanner_p scann } SYNCTEX_INLINE static void __synctex_scanner_remove_handle_to(synctex_node_p node) { synctex_node_p arg_sibling = NULL; - synctex_node_p handle = node->class->scanner->handle; + synctex_node_p handle = node->class_->scanner->handle; while (handle) { synctex_node_p sibling; if (node == _synctex_tree_target(handle)) { @@ -852,7 +836,7 @@ SYNCTEX_INLINE static void __synctex_scanner_remove_handle_to(synctex_node_p nod if (arg_sibling) { __synctex_tree_set_sibling(arg_sibling, sibling); } else { - node->class->scanner->handle = sibling; + node->class_->scanner->handle = sibling; } synctex_node_free(handle); break; @@ -865,20 +849,20 @@ SYNCTEX_INLINE static void __synctex_scanner_remove_handle_to(synctex_node_p nod } SYNCTEX_INLINE static void __synctex_scanner_register_handle_to(synctex_node_p node) { synctex_node_p NNN = _synctex_new_handle_with_target(node); - __synctex_tree_set_sibling(NNN,node->class->scanner->handle); - node->class->scanner->handle = NNN; + __synctex_tree_set_sibling(NNN,node->class_->scanner->handle); + node->class_->scanner->handle = NNN; } #endif #if SYNCTEX_USE_NODE_COUNT>10 SYNCTEX_INLINE static void _synctex_did_new(synctex_node_p node) { printf("NODE CREATED # %i, %s, %p\n", - (node->class->scanner->node_count)++, + (node->class_->scanner->node_count)++, synctex_node_isa(node), node); } SYNCTEX_INLINE static void _synctex_will_free(synctex_node_p node) { printf("NODE DELETED # %i, %s, %p\n", - --(node->class->scanner->node_count), + --(node->class_->scanner->node_count), synctex_node_isa(node), node); } @@ -989,14 +973,14 @@ static synctex_ss_s _synctex_decode_string(synctex_scanner_p scanner); * through the class modelator integer fields. * - parameter NODE: of type synctex_node_p */ -# define SYNCTEX_DATA(NODE) ((*((((NODE)->class))->info))(NODE)) +# define SYNCTEX_DATA(NODE) ((*((((NODE)->class_))->info))(NODE)) #if defined SYNCTEX_DEBUG > 1000 # define DEFINE_SYNCTEX_DATA_HAS(WHAT) \ SYNCTEX_INLINE static synctex_bool_t __synctex_data_has_##WHAT(synctex_node_p node) {\ - return (node && (node->class->modelator->WHAT>=0));\ + return (node && (node->class_->modelator->WHAT>=0));\ }\ SYNCTEX_INLINE static synctex_bool_t _synctex_data_has_##WHAT(synctex_node_p node) {\ - if (node && (node->class->modelator->WHAT<0)) {\ + if (node && (node->class_->modelator->WHAT<0)) {\ printf("WARNING: NO %s for %s\n", #WHAT, synctex_node_isa(node));\ }\ return __synctex_data_has_##WHAT(node);\ @@ -1004,7 +988,7 @@ SYNCTEX_INLINE static synctex_bool_t _synctex_data_has_##WHAT(synctex_node_p nod #else # define DEFINE_SYNCTEX_DATA_HAS(WHAT) \ SYNCTEX_INLINE static synctex_bool_t __synctex_data_has_##WHAT(synctex_node_p node) {\ - return (node && (node->class->modelator->WHAT>=0));\ + return (node && (node->class_->modelator->WHAT>=0));\ }\ SYNCTEX_INLINE static synctex_bool_t _synctex_data_has_##WHAT(synctex_node_p node) {\ return __synctex_data_has_##WHAT(node);\ @@ -1012,28 +996,28 @@ SYNCTEX_INLINE static synctex_bool_t _synctex_data_has_##WHAT(synctex_node_p nod #endif SYNCTEX_INLINE static synctex_data_p __synctex_data(synctex_node_p node) { - return node->data+node->class->navigator->size; + return node->data+node->class_->navigator->size; } # define DEFINE_SYNCTEX_DATA_INT_GETSET(WHAT) \ DEFINE_SYNCTEX_DATA_HAS(WHAT)\ static int _synctex_data_##WHAT(synctex_node_p node) {\ if (_synctex_data_has_##WHAT(node)) {\ - return __synctex_data(node)[node->class->modelator->WHAT].as_integer;\ + return __synctex_data(node)[node->class_->modelator->WHAT].as_integer;\ }\ return 0;\ }\ static int _synctex_data_set_##WHAT(synctex_node_p node, int new_value) {\ int old = 0;\ if (_synctex_data_has_##WHAT(node)) {\ - old = __synctex_data(node)[node->class->modelator->WHAT].as_integer;\ - __synctex_data(node)[node->class->modelator->WHAT].as_integer=new_value;\ + old = __synctex_data(node)[node->class_->modelator->WHAT].as_integer;\ + __synctex_data(node)[node->class_->modelator->WHAT].as_integer=new_value;\ }\ return old;\ } #define DEFINE_SYNCTEX_DATA_INT_DECODE(WHAT) \ static synctex_status_t _synctex_data_decode_##WHAT(synctex_node_p node) {\ if (_synctex_data_has_##WHAT(node)) {\ - synctex_is_s is = _synctex_decode_int(node->class->scanner);\ + synctex_is_s is = _synctex_decode_int(node->class_->scanner);\ if (is.status == SYNCTEX_STATUS_OK) {\ _synctex_data_set_##WHAT(node,is.integer);\ } \ @@ -1044,7 +1028,7 @@ static synctex_status_t _synctex_data_decode_##WHAT(synctex_node_p node) {\ # define DEFINE_SYNCTEX_DATA_INT_DECODE_v(WHAT) \ static synctex_status_t _synctex_data_decode_##WHAT##_v(synctex_node_p node) {\ if (_synctex_data_has_##WHAT(node)) {\ - synctex_is_s is = _synctex_decode_int_v(node->class->scanner);\ + synctex_is_s is = _synctex_decode_int_v(node->class_->scanner);\ if (is.status == SYNCTEX_STATUS_OK) {\ _synctex_data_set_##WHAT(node,is.integer);\ } \ @@ -1056,22 +1040,22 @@ static synctex_status_t _synctex_data_decode_##WHAT##_v(synctex_node_p node) {\ DEFINE_SYNCTEX_DATA_HAS(WHAT)\ static char * _synctex_data_##WHAT(synctex_node_p node) {\ if (_synctex_data_has_##WHAT(node)) {\ - return node->data[node->class->navigator->size+node->class->modelator->WHAT].as_string;\ + return node->data[node->class_->navigator->size+node->class_->modelator->WHAT].as_string;\ }\ return NULL;\ }\ static char * _synctex_data_set_##WHAT(synctex_node_p node, char * new_value) {\ char * old = "";\ if (_synctex_data_has_##WHAT(node)) {\ - old = node->data[node->class->navigator->size+node->class->modelator->WHAT].as_string;\ - node->data[node->class->navigator->size+node->class->modelator->WHAT].as_string =new_value;\ + old = node->data[node->class_->navigator->size+node->class_->modelator->WHAT].as_string;\ + node->data[node->class_->navigator->size+node->class_->modelator->WHAT].as_string =new_value;\ }\ return old;\ } #define DEFINE_SYNCTEX_DATA_STR_DECODE(WHAT) \ static synctex_status_t _synctex_data_decode_##WHAT(synctex_node_p node) {\ if (_synctex_data_has_##WHAT(node)) {\ - synctex_ss_s ss = _synctex_decode_string(node->class->scanner);\ + synctex_ss_s ss = _synctex_decode_string(node->class_->scanner);\ if (ss.status == SYNCTEX_STATUS_OK) {\ _synctex_data_set_##WHAT(node,ss.string);\ } \ @@ -1172,7 +1156,7 @@ static synctex_class_s synctex_class_input = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_s_input_max+synctex_data_input_tln_max]; } synctex_input_s; @@ -1180,7 +1164,7 @@ static synctex_node_p _synctex_new_input(synctex_scanner_p scanner) { if (scanner) { synctex_node_p node = _synctex_malloc(sizeof(synctex_input_s)); if (node) { - node->class = scanner->class+synctex_node_type_input; + node->class_ = scanner->class_+synctex_node_type_input; SYNCTEX_DID_NEW(node); SYNCTEX_IMPLEMENT_CHARINDEX(node,0); SYNCTEX_REGISTER_HANDLE_TO(node); @@ -1219,7 +1203,7 @@ DEFINE_SYNCTEX_DATA_INT_GETSET_DECODE(page) typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_scn_sheet_max+synctex_data_p_sheet_max]; } synctex_node_sheet_s; @@ -1231,7 +1215,7 @@ static synctex_node_p _synctex_new_##NAME(synctex_scanner_p scanner) {\ ++SYNCTEX_CUR;\ synctex_node_p node = _synctex_malloc(sizeof(synctex_node_##NAME##_s));\ if (node) {\ - node->class = scanner->class+synctex_node_type_##NAME;\ + node->class_ = scanner->class_+synctex_node_type_##NAME;\ SYNCTEX_DID_NEW(node); \ SYNCTEX_IMPLEMENT_CHARINDEX(node,-1);\ SYNCTEX_REGISTER_HANDLE_TO(node); \ @@ -1302,7 +1286,7 @@ static synctex_class_s synctex_class_sheet = { */ typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_sct_form_max+synctex_data_t_form_max]; } synctex_node_form_s; @@ -1368,7 +1352,7 @@ static synctex_class_s synctex_class_form = { */ typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spcfl_vbox_max+synctex_data_box_max]; } synctex_node_vbox_s; @@ -1396,7 +1380,7 @@ static const synctex_tree_model_s synctex_tree_model_vbox = { DEFINE_SYNCTEX_DATA_INT_GETSET(column) static synctex_status_t _synctex_data_decode_column(synctex_node_p node) { if (_synctex_data_has_column(node)) { - synctex_is_s is = _synctex_decode_int_opt(node->class->scanner, + synctex_is_s is = _synctex_decode_int_opt(node->class_->scanner, SYNCTEX_DFLT_COLUMN); if (is.status == SYNCTEX_STATUS_OK) { _synctex_data_set_column(node,is.integer); @@ -1544,7 +1528,7 @@ static const synctex_data_model_s synctex_data_model_hbox = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spcfln_hbox_max+synctex_data_hbox_max]; } synctex_node_hbox_s; @@ -1590,7 +1574,7 @@ static const synctex_tree_model_s synctex_tree_model_spf = { }; typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spf_max+synctex_data_box_max]; } synctex_node_void_vbox_s; @@ -1650,7 +1634,7 @@ static synctex_class_s synctex_class_void_hbox = { /* The form ref node. */ typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spfa_max+synctex_data_ref_thv_max]; } synctex_node_ref_s; @@ -1734,7 +1718,7 @@ static const synctex_data_model_s synctex_data_model_tlchv = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spf_max+synctex_data_tlchv_max]; } synctex_node_tlchv_s; @@ -1807,7 +1791,7 @@ static const synctex_data_model_s synctex_data_model_tlchvw = { }; typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spf_max+synctex_data_tlchvw_max]; } synctex_node_kern_s; @@ -1884,7 +1868,7 @@ static synctex_class_s synctex_class_glue = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spf_max+synctex_data_box_max]; } synctex_node_rule_s; @@ -1954,7 +1938,7 @@ static synctex_class_s synctex_class_boundary = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spfa_max+synctex_data_tlchv_max]; } synctex_node_box_bdry_s; @@ -1963,7 +1947,7 @@ SYNCTEX_INLINE static synctex_node_p _synctex_new_##NAME(synctex_scanner_p scann if (scanner) {\ synctex_node_p node = _synctex_malloc(sizeof(synctex_node_##NAME##_s));\ if (node) {\ - node->class = scanner->class+synctex_node_type_##NAME;\ + node->class_ = scanner->class_+synctex_node_type_##NAME;\ SYNCTEX_DID_NEW(node); \ }\ return node;\ @@ -2099,7 +2083,7 @@ static const synctex_data_model_s synctex_data_model_proxy = { }; typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spcflnt_proxy_hbox_max+synctex_data_proxy_hv_max]; } synctex_node_proxy_hbox_s; @@ -2181,7 +2165,7 @@ static const synctex_tree_model_s synctex_tree_model_proxy_vbox = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spcflt_proxy_vbox_max+synctex_data_proxy_hv_max]; } synctex_node_proxy_vbox_s; @@ -2203,7 +2187,7 @@ static synctex_class_s synctex_class_proxy_vbox = { &synctex_tree_model_proxy_vbox, /* tree model */ &synctex_data_model_proxy, /* data model */ &synctex_tlcpector_proxy, /* tlcpector */ - &synctex_inspector_proxy_box, /* inspector */ + &synctex_inspector_proxy_box, /* inspector */ &synctex_vispector_proxy_box, /* vispector */ }; @@ -2229,7 +2213,7 @@ static const synctex_tree_model_s synctex_tree_model_proxy = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spft_proxy_max+synctex_data_proxy_hv_max]; } synctex_node_proxy_s; @@ -2285,7 +2269,7 @@ static const synctex_tree_model_s synctex_tree_model_proxy_last = { typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; synctex_data_u data[synctex_tree_spfat_proxy_last_max+synctex_data_proxy_hv_max]; } synctex_node_proxy_last_s; @@ -2336,10 +2320,31 @@ static const synctex_tree_model_s synctex_tree_model_handle = { synctex_tree_spct_handle_max }; +static const synctex_data_model_s synctex_data_model_handle = { + -1, /* tag */ + -1, /* line */ + -1, /* column */ + -1, /* h */ + -1, /* v */ + -1, /* width */ + -1, /* height */ + -1, /* depth */ + -1, /* mean_line */ + synctex_data_handle_w_idx, /* weight */ + -1, /* h_V */ + -1, /* v_V */ + -1, /* width_V */ + -1, /* height_V */ + -1, /* depth_V */ + -1, /* name */ + -1, /* page */ + synctex_data_handle_w_max +}; + typedef struct { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; - synctex_data_u data[synctex_tree_spct_handle_max+0]; + synctex_class_p class_; + synctex_data_u data[synctex_tree_spct_handle_max+synctex_data_handle_w_max]; } synctex_node_handle_s; /* handle node creator */ @@ -2358,7 +2363,7 @@ static synctex_class_s synctex_class_handle = { &_synctex_display_handle, /* display */ &_synctex_abstract_handle, /* abstract */ &synctex_tree_model_handle, /* tree model */ - &synctex_data_model_none, /* data model */ + &synctex_data_model_handle, /* data model */ &synctex_tlcpector_proxy, /* tlcpector */ &synctex_inspector_proxy_box, /* inspector */ &synctex_vispector_proxy_box, /* vispector */ @@ -2366,7 +2371,7 @@ static synctex_class_s synctex_class_handle = { SYNCTEX_INLINE static synctex_node_p _synctex_new_handle_with_target(synctex_node_p target) { if (target) { - synctex_node_p result = _synctex_new_handle(target->class->scanner); + synctex_node_p result = _synctex_new_handle(target->class_->scanner); if (result) { _synctex_tree_set_target(result,target); return result; @@ -2376,7 +2381,7 @@ SYNCTEX_INLINE static synctex_node_p _synctex_new_handle_with_target(synctex_nod } SYNCTEX_INLINE static synctex_node_p _synctex_new_handle_with_child(synctex_node_p child) { if (child) { - synctex_node_p result = _synctex_new_handle(child->class->scanner); + synctex_node_p result = _synctex_new_handle(child->class_->scanner); if (result) { _synctex_tree_set_child(result,child); return result; @@ -2423,10 +2428,10 @@ SYNCTEX_INLINE static synctex_node_p __synctex_new_proxy_from_ref_to(synctex_nod } switch(synctex_node_type(to_node)) { case synctex_node_type_vbox: - proxy = _synctex_new_proxy_vbox(ref->class->scanner); + proxy = _synctex_new_proxy_vbox(ref->class_->scanner); break; case synctex_node_type_hbox: - proxy = _synctex_new_proxy_hbox(ref->class->scanner); + proxy = _synctex_new_proxy_hbox(ref->class_->scanner); break; default: _synctex_error("! __synctex_new_proxy_from_ref_to. Unexpected form child (%s). Please report.", synctex_node_isa(to_node)); @@ -2462,7 +2467,7 @@ SYNCTEX_INLINE static synctex_node_p __synctex_new_child_proxy_to(synctex_node_p } switch(synctex_node_type(target)) { case synctex_node_type_vbox: - if ((proxy = _synctex_new_proxy_vbox(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy_vbox(owner->class_->scanner))) { exit_standard: _synctex_data_set_h(proxy, _synctex_data_h(owner)); _synctex_data_set_v(proxy, _synctex_data_v(owner)); @@ -2476,7 +2481,7 @@ SYNCTEX_INLINE static synctex_node_p __synctex_new_child_proxy_to(synctex_node_p }; break; case synctex_node_type_proxy_vbox: - if ((proxy = _synctex_new_proxy_vbox(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy_vbox(owner->class_->scanner))) { exit_proxy: target = _synctex_tree_target(to_node); _synctex_data_set_h(proxy, _synctex_data_h(owner)+_synctex_data_h(to_node)); @@ -2485,23 +2490,23 @@ SYNCTEX_INLINE static synctex_node_p __synctex_new_child_proxy_to(synctex_node_p }; break; case synctex_node_type_hbox: - if ((proxy = _synctex_new_proxy_hbox(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy_hbox(owner->class_->scanner))) { goto exit_standard; }; break; case synctex_node_type_proxy_hbox: - if ((proxy = _synctex_new_proxy_hbox(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy_hbox(owner->class_->scanner))) { goto exit_proxy; }; break; case synctex_node_type_proxy: case synctex_node_type_proxy_last: - if ((proxy = _synctex_new_proxy(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy(owner->class_->scanner))) { goto exit_proxy; }; break; default: - if ((proxy = _synctex_new_proxy(owner->class->scanner))) { + if ((proxy = _synctex_new_proxy(owner->class_->scanner))) { goto exit_standard; }; break; @@ -2543,7 +2548,7 @@ SYNCTEX_INLINE static synctex_nns_s _synctex_new_child_proxies_to(synctex_node_p "Please report."); nns.status = SYNCTEX_STATUS_ERROR; } - } else if((sibling = _synctex_new_proxy_last(owner->class->scanner))) { + } else if((sibling = _synctex_new_proxy_last(owner->class_->scanner))) { _synctex_tree_set_sibling(nns.last,sibling); nns.last = sibling; _synctex_data_set_h(nns.last, _synctex_data_h(nns.first)); @@ -2592,9 +2597,9 @@ SYNCTEX_INLINE static synctex_node_p synctex_tree_set_friend(synctex_node_p node SYNCTEX_INLINE static synctex_node_p __synctex_node_make_friend(synctex_node_p node, int i) { synctex_node_p old = NULL; if (i>=0) { - i = i%(node->class->scanner->number_of_lists); - old = synctex_tree_set_friend(node,(node->class->scanner->lists_of_friends)[i]); - (node->class->scanner->lists_of_friends)[i] = node; + i = i%(node->class_->scanner->number_of_lists); + old = synctex_tree_set_friend(node,(node->class_->scanner->lists_of_friends)[i]); + (node->class_->scanner->lists_of_friends)[i] = node; #if SYNCTEX_DEBUG>500 printf("tl(%i)=>",i); synctex_node_log(node); @@ -2866,16 +2871,16 @@ synctex_node_p synctex_node_arg_sibling(synctex_node_p node) { /* Public node accessor: the type */ synctex_node_type_t synctex_node_type(synctex_node_p node) { - return node? node->class->type: synctex_node_type_none; + return node? node->class_->type: synctex_node_type_none; } /* Public node accessor: the type */ synctex_node_type_t synctex_node_target_type(synctex_node_p node) { synctex_node_p target = _synctex_tree_target(node); if (target) { - return (((target)->class))->type; + return (((target)->class_))->type; } else if (node) { - return (((node)->class))->type; + return (((node)->class_))->type; } return synctex_node_type_none; } @@ -3142,14 +3147,14 @@ static char * _synctex_scanner_display_prompt_up(synctex_scanner_p scanR) { void synctex_node_display(synctex_node_p node) { if (node) { - synctex_scanner_p scanR = node->class->scanner; + synctex_scanner_p scanR = node->class_->scanner; if (scanR) { if (scanR->display_switcher<0) { SYNCTEX_MSG_SEND(node, display); } else if (scanR->display_switcher>0 && --scanR->display_switcher>0) { SYNCTEX_MSG_SEND(node, display); } else if (scanR->display_switcher-->=0) { - printf("%s Next display skipped. Reset display switcher.\n",node->class->scanner->display_prompt); + printf("%s Next display skipped. Reset display switcher.\n",node->class_->scanner->display_prompt); } } else { SYNCTEX_MSG_SEND(node, display); @@ -3157,16 +3162,16 @@ void synctex_node_display(synctex_node_p node) { } } static char * _synctex_node_abstract(synctex_node_p node) { - SYNCTEX_PARAMETER_ASSERT(node || node->class); - return (node && node->class->abstract)? node->class->abstract(node):"none"; + SYNCTEX_PARAMETER_ASSERT(node || node->class_); + return (node && node->class_->abstract)? node->class_->abstract(node):"none"; } SYNCTEX_INLINE static void _synctex_display_child(synctex_node_p node) { synctex_node_p N = _synctex_tree_child(node); if (N) { - _synctex_scanner_display_prompt_down(N->class->scanner); + _synctex_scanner_display_prompt_down(N->class_->scanner); synctex_node_display(N); - _synctex_scanner_display_prompt_up(N->class->scanner); + _synctex_scanner_display_prompt_up(N->class_->scanner); } } @@ -3214,11 +3219,11 @@ static void _synctex_display_sheet(synctex_node_p node) { printf("%s{%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_page(node) SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); - printf("%s}\n",node->class->scanner->display_prompt); + printf("%s}\n",node->class_->scanner->display_prompt); _synctex_display_sibling(node); } } @@ -3239,11 +3244,11 @@ static void _synctex_display_form(synctex_node_p node) { printf("%s<%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node) SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); - printf("%s>\n",node->class->scanner->display_prompt); + printf("%s>\n",node->class_->scanner->display_prompt); _synctex_display_sibling(node); } } @@ -3270,7 +3275,7 @@ static void _synctex_display_vbox(synctex_node_p node) { printf("%s[%i,%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3281,8 +3286,8 @@ static void _synctex_display_vbox(synctex_node_p node) { SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); printf("%s]\n%slast:%s\n", - node->class->scanner->display_prompt, - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_node_abstract(_synctex_tree_last(node))); _synctex_display_sibling(node); } @@ -3312,7 +3317,7 @@ static void _synctex_display_hbox(synctex_node_p node) { printf("%s(%i,%i~%i*%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_mean_line(node), @@ -3325,8 +3330,8 @@ static void _synctex_display_hbox(synctex_node_p node) { SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); printf("%s)\n%slast:%s\n", - node->class->scanner->display_prompt, - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_node_abstract(_synctex_tree_last(node))); _synctex_display_sibling(node); } @@ -3355,7 +3360,7 @@ static void _synctex_display_void_vbox(synctex_node_p node) { printf("%sv%i,%i;%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3390,7 +3395,7 @@ static void _synctex_display_void_hbox(synctex_node_p node) { printf("%sh%i,%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3422,7 +3427,7 @@ static void _synctex_display_glue(synctex_node_p node) { printf("%sglue:%i,%i:%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3454,7 +3459,7 @@ static void _synctex_display_rule(synctex_node_p node) { printf("%srule:%i,%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3486,7 +3491,7 @@ static void _synctex_display_math(synctex_node_p node) { printf("%smath:%i,%i:%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3516,7 +3521,7 @@ static void _synctex_display_kern(synctex_node_p node) { printf("%skern:%i,%i:%i,%i:%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3546,7 +3551,7 @@ static void _synctex_display_boundary(synctex_node_p node) { printf("%sboundary:%i,%i:%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3572,7 +3577,7 @@ static char * _synctex_abstract_box_bdry(synctex_node_p node) { static void _synctex_display_box_bdry(synctex_node_p node) { if (node) { printf("%sbox bdry:%i,%i:%i,%i", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_line(node), _synctex_data_h(node), @@ -3597,7 +3602,7 @@ static char * _synctex_abstract_ref(synctex_node_p node) { static void _synctex_display_ref(synctex_node_p node) { if (node) { printf("%sform ref:%i:%i,%i", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_data_tag(node), _synctex_data_h(node), _synctex_data_v(node)); @@ -3624,7 +3629,7 @@ static void _synctex_display_proxy(synctex_node_p node) { if (node) { synctex_node_p N = _synctex_tree_target(node); printf("%s%s:%i,%i:%i,%i", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, synctex_node_isa(node), synctex_node_tag(node), synctex_node_line(node), @@ -3667,7 +3672,7 @@ static void _synctex_display_proxy_vbox(synctex_node_p node) { printf("%s[*%i,%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, synctex_node_tag(node), synctex_node_line(node), synctex_node_h(node), @@ -3678,8 +3683,8 @@ static void _synctex_display_proxy_vbox(synctex_node_p node) { SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); printf("%s*]\n%slast:%s\n", - node->class->scanner->display_prompt, - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_node_abstract(_synctex_tree_last(node))); _synctex_display_sibling(node); } @@ -3710,7 +3715,7 @@ static void _synctex_display_proxy_hbox(synctex_node_p node) { printf("%s(*%i,%i~%i*%i:%i,%i:%i,%i,%i" SYNCTEX_PRINT_CHARINDEX_FMT "\n", - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, synctex_node_tag(node), synctex_node_line(node), synctex_node_mean_line(node), @@ -3723,8 +3728,8 @@ static void _synctex_display_proxy_hbox(synctex_node_p node) { SYNCTEX_PRINT_CHARINDEX_WHAT); _synctex_display_child(node); printf("%s*)\n%slast:%s\n", - node->class->scanner->display_prompt, - node->class->scanner->display_prompt, + node->class_->scanner->display_prompt, + node->class_->scanner->display_prompt, _synctex_node_abstract(_synctex_tree_last(node))); _synctex_display_sibling(node); } @@ -3734,7 +3739,7 @@ static char * _synctex_abstract_handle(synctex_node_p node) { static char abstract[SYNCTEX_ABSTRACT_MAX] = "none"; if (node) { synctex_node_p N = _synctex_tree_target(node); - if (N && !N->class) { + if (N && !N->class_) { exit(1); } snprintf(abstract,SYNCTEX_ABSTRACT_MAX,"%s:%s", @@ -3746,9 +3751,10 @@ static char * _synctex_abstract_handle(synctex_node_p node) { static void _synctex_display_handle(synctex_node_p node) { if (node) { synctex_node_p N = _synctex_tree_target(node); - printf("%s%s:->%s\n", - node->class->scanner->display_prompt, + printf("%s%s(%i):->%s\n", + node->class_->scanner->display_prompt, synctex_node_isa(node), + _synctex_data_weight(N), _synctex_node_abstract(N)); _synctex_display_child(node); _synctex_display_sibling(node); @@ -4974,7 +4980,7 @@ SYNCTEX_INLINE static synctex_box_s _synctex_data_box_V(synctex_node_p node); SYNCTEX_INLINE static synctex_node_p _synctex_input_register_line(synctex_node_p input,synctex_node_p node) { if (node && _synctex_data_tag(input) != _synctex_data_tag(node)) { - input = synctex_scanner_input_with_tag(node->class->scanner,_synctex_data_tag(node)); + input = synctex_scanner_input_with_tag(node->class_->scanner,_synctex_data_tag(node)); } if (_synctex_data_line(node)>_synctex_data_line(input)) { _synctex_data_set_line(input,_synctex_data_line(node)); @@ -5699,7 +5705,7 @@ SYNCTEX_INLINE static synctex_ns_s __synctex_replace_ref(synctex_node_p ref) { synctex_node_p arg_sibling = synctex_node_arg_sibling(ref); /* arg_sibling != NULL because the child of a box * is always a box boundary, not a ref. */ - synctex_node_p target = synctex_form_content(ref->class->scanner, _synctex_data_tag(ref)); + synctex_node_p target = synctex_form_content(ref->class_->scanner, _synctex_data_tag(ref)); /* The target is a single node (box) * with children and no siblings. */ if ((ns.node = __synctex_new_proxy_from_ref_to(ref, target))) { @@ -5783,8 +5789,8 @@ SYNCTEX_INLINE static synctex_status_t _synctex_post_process_proxy(synctex_node_ printf("POST PROCESSING %s\n",_synctex_node_abstract(proxy)); { int i,j = 0; - for (i=0;i<proxy->class->scanner->number_of_lists;++i) { - synctex_node_p N = proxy->class->scanner->lists_of_friends[i]; + for (i=0;i<proxy->class_->scanner->number_of_lists;++i) { + synctex_node_p N = proxy->class_->scanner->lists_of_friends[i]; do { if (N==proxy) { ++j; @@ -5801,8 +5807,8 @@ SYNCTEX_INLINE static synctex_status_t _synctex_post_process_proxy(synctex_node_ #if SYNCTEX_DEBUG>500 { int i,j = 0; - for (i=0;i<proxy->class->scanner->number_of_lists;++i) { - synctex_node_p N = proxy->class->scanner->lists_of_friends[i]; + for (i=0;i<proxy->class_->scanner->number_of_lists;++i) { + synctex_node_p N = proxy->class_->scanner->lists_of_friends[i]; do { if (N==proxy) { ++j; @@ -5820,8 +5826,8 @@ SYNCTEX_INLINE static synctex_status_t _synctex_post_process_proxy(synctex_node_ #if SYNCTEX_DEBUG>500 if (proxy) { int i,j = 0; - for (i=0;i<proxy->class->scanner->number_of_lists;++i) { - synctex_node_p N = proxy->class->scanner->lists_of_friends[i]; + for (i=0;i<proxy->class_->scanner->number_of_lists;++i) { + synctex_node_p N = proxy->class_->scanner->lists_of_friends[i]; do { if (N==proxy) { ++j; @@ -5973,8 +5979,8 @@ synctex_scanner_p synctex_scanner_new() { # pragma mark - # endif # define DEFINE_synctex_scanner_class(NAME)\ - scanner->class[synctex_node_type_##NAME] = synctex_class_##NAME;\ -(scanner->class[synctex_node_type_##NAME]).scanner = scanner + scanner->class_[synctex_node_type_##NAME] = synctex_class_##NAME;\ +(scanner->class_[synctex_node_type_##NAME]).scanner = scanner DEFINE_synctex_scanner_class(input); DEFINE_synctex_scanner_class(sheet); DEFINE_synctex_scanner_class(form); @@ -6205,7 +6211,7 @@ const char * synctex_scanner_get_name(synctex_scanner_p scanner,int tag) { } const char * synctex_node_get_name(synctex_node_p node) { if (node) { - return synctex_scanner_get_name(node->class->scanner,_synctex_data_tag(node)); + return synctex_scanner_get_name(node->class_->scanner,_synctex_data_tag(node)); } return NULL; } @@ -6320,8 +6326,8 @@ const char * synctex_scanner_get_synctex(synctex_scanner_p scanner) { # define SYNCTEX_DEFINE_NODE_HVWHD(WHAT) \ int synctex_node_##WHAT(synctex_node_p node) { \ - return (node && node->class->inspector->WHAT)? \ - node->class->inspector->WHAT(node): 0; \ + return (node && node->class_->inspector->WHAT)? \ + node->class_->inspector->WHAT(node): 0; \ } # define SYNCTEX_DEFINE_PROXY_HV(WHAT) \ static int _synctex_proxy_##WHAT(synctex_proxy_p proxy) { \ @@ -6372,10 +6378,10 @@ SYNCTEX_DEFINE_PROXY_TLCWVD(depth) SYNCTEX_INLINE static synctex_bool_t _synctex_node_is_box(synctex_node_p node) { return node && - (node->class->type == synctex_node_type_hbox - || node->class->type == synctex_node_type_void_hbox - || node->class->type == synctex_node_type_vbox - || node->class->type == synctex_node_type_void_vbox + (node->class_->type == synctex_node_type_hbox + || node->class_->type == synctex_node_type_void_hbox + || node->class_->type == synctex_node_type_vbox + || node->class_->type == synctex_node_type_void_vbox || _synctex_node_is_box(_synctex_tree_target(node))); } @@ -6389,7 +6395,7 @@ SYNCTEX_INLINE static synctex_bool_t _synctex_node_is_box(synctex_node_p node) { SYNCTEX_INLINE static synctex_bool_t _synctex_node_is_handle(synctex_node_p node) { return node && - (node->class->type == synctex_node_type_handle); + (node->class_->type == synctex_node_type_handle); } /** @@ -6412,8 +6418,8 @@ SYNCTEX_INLINE static synctex_node_p _synctex_node_or_handle_target(synctex_node SYNCTEX_INLINE static synctex_bool_t _synctex_node_is_hbox(synctex_node_p node) { return node && - (node->class->type == synctex_node_type_hbox - || node->class->type == synctex_node_type_void_hbox + (node->class_->type == synctex_node_type_hbox + || node->class_->type == synctex_node_type_void_hbox || _synctex_node_is_hbox(_synctex_tree_target(node))); } @@ -6560,11 +6566,11 @@ int synctex_node_hbox_depth(synctex_node_p node) { # endif #define SYNCTEX_VISIBLE_SIZE(node,s) \ -(s)*node->class->scanner->unit +(s)*node->class_->scanner->unit #define SYNCTEX_VISIBLE_DISTANCE_h(node,d) \ -((d)*node->class->scanner->unit+node->class->scanner->x_offset) +((d)*node->class_->scanner->unit+node->class_->scanner->x_offset) #define SYNCTEX_VISIBLE_DISTANCE_v(node,d) \ -((d)*node->class->scanner->unit+node->class->scanner->y_offset) +((d)*node->class_->scanner->unit+node->class_->scanner->y_offset) static float __synctex_node_visible_h(synctex_node_p node) { return SYNCTEX_VISIBLE_DISTANCE_h(node,synctex_node_h(node)); } @@ -6633,7 +6639,7 @@ static float __synctex_rule_visible_depth(synctex_noxy_p noxy) { * - author: JL */ float synctex_node_visible_h(synctex_node_p node){ - return node? node->class->vispector->h(node): 0; + return node? node->class_->vispector->h(node): 0; } /** * The vertical location of node, in page coordinates. @@ -6642,7 +6648,7 @@ float synctex_node_visible_h(synctex_node_p node){ * - author: JL */ float synctex_node_visible_v(synctex_node_p node){ - return node? node->class->vispector->v(node): 0; + return node? node->class_->vispector->v(node): 0; } /** * The width of node, in page coordinates. @@ -6651,7 +6657,7 @@ float synctex_node_visible_v(synctex_node_p node){ * - author: JL */ float synctex_node_visible_width(synctex_node_p node){ - return node? node->class->vispector->width(node): 0; + return node? node->class_->vispector->width(node): 0; } /** * The height of node, in page coordinates. @@ -6660,7 +6666,7 @@ float synctex_node_visible_width(synctex_node_p node){ * - author: JL */ float synctex_node_visible_height(synctex_node_p node){ - return node? node->class->vispector->height(node): 0; + return node? node->class_->vispector->height(node): 0; } /** * The depth of node, in page coordinates. @@ -6669,7 +6675,7 @@ float synctex_node_visible_height(synctex_node_p node){ * - author: JL */ float synctex_node_visible_depth(synctex_node_p node){ - return node? node->class->vispector->depth(node): 0; + return node? node->class_->vispector->depth(node): 0; } /** @@ -6773,7 +6779,7 @@ SYNCTEX_INLINE static synctex_box_s _synctex_data_box_V(synctex_node_p node) { static synctex_node_p _synctex_node_box_visible(synctex_node_p node) { if ((node = _synctex_node_or_handle_target(node))) { int mean = 0; - int bound = 1500000/(node->class->scanner->pre_magnification/1000.0); + int bound = 1500000/(node->class_->scanner->pre_magnification/1000.0); synctex_node_p parent = NULL; /* get the first enclosing parent * then get the highest enclosing parent with the same mean line ±1 */ @@ -6900,7 +6906,7 @@ synctex_charindex_t synctex_node_charindex(synctex_node_p node) { * - author: JL */ int synctex_node_tag(synctex_node_p node) { - return node? node->class->tlcpector->tag(node): -1; + return node? node->class_->tlcpector->tag(node): -1; } /** * The line of the node. @@ -6909,7 +6915,7 @@ int synctex_node_tag(synctex_node_p node) { * - author: JL */ int synctex_node_line(synctex_node_p node) { - return node? node->class->tlcpector->line(node): -1; + return node? node->class_->tlcpector->line(node): -1; } /** * The column of the node. @@ -6918,7 +6924,7 @@ int synctex_node_line(synctex_node_p node) { * - author: JL */ int synctex_node_column(synctex_node_p node) { - return node? node->class->tlcpector->column(node): -1; + return node? node->class_->tlcpector->column(node): -1; } /** * The mean line number of the node. @@ -7057,41 +7063,93 @@ SYNCTEX_INLINE static synctex_node_p _synctex_scanner_friend(synctex_scanner_p s SYNCTEX_INLINE static synctex_bool_t _synctex_nodes_are_friend(synctex_node_p left, synctex_node_p right) { return synctex_node_tag(left) == synctex_node_tag(right) && synctex_node_line(left) == synctex_node_line(right); } -SYNCTEX_INLINE static synctex_node_p _synctex_vertically_sorted_v2(synctex_node_p sibling) { - synctex_node_p child = NULL; - synctex_node_p best_child = sibling; - synctex_node_p next_child = _synctex_tree_reset_child(best_child); - synctex_node_p target = _synctex_tree_target(best_child); - synctex_node_p parent = _synctex_tree_parent(target); - unsigned int best_count = 0; - unsigned int count = 0; - synctex_node_p N = _synctex_tree_child(parent); +/** + * The sibling argument is a parent/child list of nodes of the same page. + */ +typedef struct { + int count; + synctex_node_p node; +} synctex_counted_node_s; + +SYNCTEX_INLINE static synctex_counted_node_s _synctex_vertically_sorted_v2(synctex_node_p sibling) { + /* Clean the weights of the parents */ + synctex_counted_node_s result = {0, NULL}; + synctex_node_p h = NULL; + synctex_node_p next_h = NULL; + synctex_node_p parent = NULL; + int weight = 0; + synctex_node_p N = NULL; + h = sibling; do { - if (_synctex_nodes_are_friend(N,best_child)) { - ++best_count; - } - } while ((N = __synctex_tree_sibling(N))); - /* Navigate through the other children */ - while ((child = next_child)) { - next_child = _synctex_tree_reset_child(child); - target = _synctex_tree_target(child); - parent = _synctex_tree_parent(target); - count = 0; - N = _synctex_tree_child(parent); - do { - if (_synctex_nodes_are_friend(N,best_child)) { - ++count; - } - } while ((N = __synctex_tree_sibling(N))); - if (count>best_count) { - best_count = count; - synctex_node_free(best_child); - best_child = child; + N = _synctex_tree_target(h); + parent = _synctex_tree_parent(N); + _synctex_data_set_weight(parent, 0); + } while((h = _synctex_tree_child(h))); + /* Compute the weights of the nodes */ + h = sibling; + do { + N = _synctex_tree_target(h); + parent = _synctex_tree_parent(N); + weight = _synctex_data_weight(parent); + if (weight==0) { + N = _synctex_tree_child(parent); + do { + if (_synctex_nodes_are_friend(N,sibling)) { + ++ weight; + } + } while ((N = __synctex_tree_sibling(N))); + _synctex_data_set_weight(h,weight); + _synctex_data_set_weight(parent,weight); + } + } while((h = _synctex_tree_child(h))); + /* Order handle nodes according to the weight */ + h = _synctex_tree_reset_child(sibling); + result.node = sibling; + weight = 0; + while((h)) { + N = result.node; + if (_synctex_data_weight(h)>_synctex_data_weight(N)) { + next_h = _synctex_tree_set_child(h,N); + result.node = h; + } else if (_synctex_data_weight(h) == 0) { + ++ weight; + next_h = _synctex_tree_reset_child(h); + synctex_node_free(h); } else { - synctex_node_free(child); + synctex_node_p next_N = NULL; + while((next_N = _synctex_tree_child(N))) { + N = next_N; + if (_synctex_data_weight(h)<_synctex_data_weight(next_N)) { + continue; + } + break; + } + next_h = _synctex_tree_set_child(h,_synctex_tree_set_child(N,h)); } + h = next_h; + }; + h = result.node; + weight = 0; + do { + ++weight; + } while((h = _synctex_tree_child(h))); + result.count = 1; + h = result.node; + while((next_h = _synctex_tree_child(h))) { + if (_synctex_data_weight(next_h)==0) { + _synctex_tree_reset_child(h); + weight = 1; + h = next_h; + while((h = _synctex_tree_child(h))) { + ++weight; + } + synctex_node_free(next_h); + break; + } + ++result.count; + h = next_h; } - return best_child; + return result; } SYNCTEX_INLINE static synctex_bool_t _synctex_point_in_box_v2(synctex_point_p hitP, synctex_node_p node); @@ -7145,8 +7203,12 @@ static synctex_nd_s _synctex_eq_closest_child_v2(synctex_point_p hitP, synctex_n # pragma mark Queries # endif +/** + * iterator for a deep first tree traversal. + */ struct synctex_iterator_t { synctex_node_p seed; + synctex_node_p top; synctex_node_p next; int count0; int count; @@ -7155,7 +7217,7 @@ struct synctex_iterator_t { SYNCTEX_INLINE static synctex_iterator_p _synctex_iterator_new(synctex_node_p result, int count) { synctex_iterator_p iterator; if ((iterator = _synctex_malloc(sizeof(synctex_iterator_s)))) { - iterator->seed = iterator->next = result; + iterator->seed = iterator->top = iterator->next = result; iterator->count0 = iterator->count = count; } return iterator; @@ -7183,7 +7245,9 @@ int synctex_iterator_count(synctex_iterator_p iterator) { synctex_node_p synctex_iterator_next_result(synctex_iterator_p iterator) { if (iterator && iterator->count>0) { synctex_node_p N = iterator->next; - iterator->next = __synctex_tree_sibling(N); + if(!(iterator->next = _synctex_tree_child(N))) { + iterator->next = iterator->top = __synctex_tree_sibling(iterator->top); + } --iterator->count; return _synctex_tree_target(N); } @@ -7191,7 +7255,7 @@ synctex_node_p synctex_iterator_next_result(synctex_iterator_p iterator) { } int synctex_iterator_reset(synctex_iterator_p iterator) { if (iterator) { - iterator->next = iterator->seed; + iterator->next = iterator->top = iterator->seed; return iterator->count = iterator->count0; } return 0; @@ -7376,6 +7440,7 @@ static synctex_node_p _synctex_display_query_v2(synctex_node_p target, int tag, /* Find a result with the same page number */; do { if (_synctex_node_target_page(same_page_node) == page) { + /* Insert result between same_page_node and its child */ _synctex_tree_set_child(result,_synctex_tree_set_child(same_page_node,result)); } else if ((same_page_node = __synctex_tree_sibling(same_page_node))) { continue; @@ -7394,9 +7459,7 @@ static synctex_node_p _synctex_display_query_v2(synctex_node_p target, int tag, return first_handle; } synctex_iterator_p synctex_iterator_new_display(synctex_scanner_p scanner,const char * name,int line,int column, int page_hint) { -# ifdef __DARWIN_UNIX03 -# pragma unused(column) -# endif + SYNCTEX_UNUSED(column) if (scanner) { int tag = synctex_scanner_get_tag(scanner,name);/* parse if necessary */ int max_line = 0; @@ -7434,34 +7497,34 @@ synctex_iterator_p synctex_iterator_new_display(synctex_scanner_p scanner,const * Then reorder the nodes to put first the one which fits best. * The idea is to count the number of nodes * with the same tag and line number in the parents - * and choose the one with the biggest count. + * and choose the ones with the biggest count. */ if (result) { - /* navigate through siblings, - then children */ - int count = 1; + /* navigate through siblings, then children */ synctex_node_p next_sibling = __synctex_tree_reset_sibling(result); int best_match = abs(page_hint-_synctex_node_target_page(result)); synctex_node_p sibling; int match; - result = _synctex_vertically_sorted_v2(result); + synctex_counted_node_s cn = _synctex_vertically_sorted_v2(result); + int count = cn.count; + result = cn.node; while((sibling = next_sibling)) { /* What is next? Do not miss that step! */ next_sibling = __synctex_tree_reset_sibling(sibling); - sibling = _synctex_vertically_sorted_v2(sibling); + cn = _synctex_vertically_sorted_v2(sibling); + count += cn.count; + sibling = cn.node; match = abs(page_hint-_synctex_node_target_page(sibling)); if (match<best_match) { /* Order this node first */ __synctex_tree_set_sibling(sibling,result); result = sibling; best_match = match; - } else /*if (match>best_match)*/ { + } else /*if (match>=best_match)*/ { __synctex_tree_set_sibling(sibling,__synctex_tree_sibling(result)); __synctex_tree_set_sibling(result,sibling); } - ++count; } - /* Now order first the result closest to the page hint */ return _synctex_iterator_new(result,count); } } @@ -8168,6 +8231,7 @@ SYNCTEX_INLINE static synctex_nd_lr_s __synctex_eq_get_closest_children_in_hbox_ } #endif SYNCTEX_INLINE static synctex_nd_lr_s __synctex_eq_get_closest_children_in_vbox_v2(synctex_point_p hitP, synctex_node_p nodeP) { + SYNCTEX_UNUSED(nodeP) synctex_nd_lr_s nds = {SYNCTEX_ND_0,SYNCTEX_ND_0}; synctex_nd_s nd = SYNCTEX_ND_0; if ((nd.node = synctex_node_child(nd.node))) { @@ -8304,8 +8368,8 @@ static synctex_nd_s _synctex_eq_closest_child_v2(synctex_point_p hitP, synctex_n SYNCTEX_INLINE static synctex_nd_lr_s _synctex_eq_get_closest_children_in_box_v2(synctex_point_p hitP, synctex_node_p node) { synctex_nd_lr_s nds = {SYNCTEX_ND_0,SYNCTEX_ND_0}; if(_synctex_tree_has_child(node)) { /* node != NULL */ - if (node->class->type==synctex_node_type_hbox || - node->class->type==synctex_node_type_proxy_hbox) { + if (node->class_->type==synctex_node_type_hbox || + node->class_->type==synctex_node_type_proxy_hbox) { return __synctex_eq_get_closest_children_in_hbox_v2(hitP,node); } else { return __synctex_eq_get_closest_children_in_vbox_v2(hitP,node); diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser.h b/Build/source/texk/web2c/synctexdir/synctex_parser.h index 7375ebd4d60..e54a0176a15 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser.h @@ -4,7 +4,7 @@ This file is part of the __SyncTeX__ package. [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h b/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h index dd7172937a1..867fbf7ed00 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h @@ -3,8 +3,8 @@ This file is part of the __SyncTeX__ package. - [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Latest Revision: Sun Oct 15 15:09:55 UTC 2017) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details @@ -245,6 +245,9 @@ extern "C" { synctex_data_proxy_h_idx = 0, synctex_data_proxy_v_idx = 1, synctex_data_proxy_hv_max = 2, + /* handle */ + synctex_data_handle_w_idx = 0, + synctex_data_handle_w_max = 1, }; /* each synctex node has a class */ @@ -287,7 +290,7 @@ extern "C" { # endif struct synctex_node_t { SYNCTEX_DECLARE_CHARINDEX - synctex_class_p class; + synctex_class_p class_; #ifdef DEBUG synctex_data_u data[22]; #else @@ -388,7 +391,7 @@ extern "C" { int synctex_node_hbox_height(synctex_node_p node); int synctex_node_hbox_depth(synctex_node_p node); - synctex_scanner_p synctex_scanner_new(); + synctex_scanner_p synctex_scanner_new(void); synctex_node_p synctex_node_new(synctex_scanner_p scanner,synctex_node_type_t type); /** diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_local.h b/Build/source/texk/web2c/synctexdir/synctex_parser_local.h index 89fd1369659..032b25687b3 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_local.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_local.h @@ -1,43 +1,43 @@ /* -Copyright (c) 2008, 2009, 2010 , 2011 jerome DOT laurens AT u-bourgogne DOT fr - -This file is part of the SyncTeX package. - -Latest Revision: Tue Jun 14 08:23:30 UTC 2011 - -Version: 1.18 - -See synctex_parser_readme.txt for more details - -License: --------- -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE - -Except as contained in this notice, the name of the copyright holder -shall not be used in advertising or otherwise to promote the sale, -use or other dealings in this Software without prior written -authorization from the copyright holder. - -*/ + Copyright (c) 2008, 2009, 2010 , 2011 jerome DOT laurens AT u-bourgogne DOT fr + + This file is part of the SyncTeX package. + + Latest Revision: Sun Oct 15 15:09:55 UTC 2017 + + Version: 1.21 + + See synctex_parser_readme.txt for more details + + License: + -------- + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE + + Except as contained in this notice, the name of the copyright holder + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization from the copyright holder. + + */ /* This local header file is for TEXLIVE, use your own header to fit your system */ # include <w2c/c-auto.h> /* for inline && HAVE_xxx */ diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_readme.md b/Build/source/texk/web2c/synctexdir/synctex_parser_readme.md index 29db9695e75..d47a89f5705 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_readme.md +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_readme.md @@ -2,14 +2,23 @@ This file is part of the __SyncTeX__ package. -[//]: # (Version: 1.20) -[//]: # (Date: Fri Jul 14 16:20:41 UTC 2017) +[//]: # (Version: 1.21) +[//]: # (Date: Sun Oct 15 15:09:55 UTC 2017) ## Important +* Changes in version `1.21` + + * Display query returns more results (as much as `1.18`) + * Remove a `\` character from the name of 2 test files. + * Change variable name `class` to `class_` because the former is a reserved keyword in C++. + * Adding a more portable unused variable management. + * Various cosmetic changes in the source code, including explicit declaration of `void` in forward function declaration. + + * Changes in version `1.20` - One bug fixed in some initialization and different syntax to make some compilers happy. + One bug fixed in some initialization and different syntax to make some compilers happy. * Changes in version `1.19` diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c index 59c47bbb301..c4f200d8754 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c @@ -4,7 +4,7 @@ This file is part of the __SyncTeX__ package. [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h index 7c4966888b3..4dd4e17e649 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h @@ -4,7 +4,7 @@ This file is part of the __SyncTeX__ package. [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) - [//]: # (Version: 1.20) + [//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_version.txt b/Build/source/texk/web2c/synctexdir/synctex_parser_version.txt index 5fb5a6b4f54..d2ab029d32c 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_version.txt +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_version.txt @@ -1 +1 @@ -1.20 +1.21 diff --git a/Build/source/texk/web2c/synctexdir/synctex_version.h b/Build/source/texk/web2c/synctexdir/synctex_version.h index 2f460558df6..5665ccb9604 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_version.h +++ b/Build/source/texk/web2c/synctexdir/synctex_version.h @@ -4,7 +4,7 @@ Copyright (c) 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr This file is part of the __SyncTeX__ package. [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017) -[//]: # (Version: 1.20) +[//]: # (Version: 1.21) See `synctex_parser_readme.md` for more details @@ -52,7 +52,7 @@ I would appreciate to be listed as contributor and see "__SyncTeX__" highlighted # define SYNCTEX_VERSION_MAJOR 1 -# define SYNCTEX_VERSION_STRING "1.20" +# define SYNCTEX_VERSION_STRING "1.21" # define SYNCTEX_CLI_VERSION_STRING "1.5" |