From 996969c22f3cbfdc0a0aabe6e530a37f0e4b21b1 Mon Sep 17 00:00:00 2001 From: Jérôme Laurens Date: Mon, 11 May 2020 15:56:48 +0000 Subject: Synctex parser tool: Typos fixed, keyword added, added... git-svn-id: svn://tug.org/texlive/trunk@55094 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/synctexdir/README.txt | 177 +-------------------- Build/source/texk/web2c/synctexdir/synctex_main.c | 8 +- .../source/texk/web2c/synctexdir/synctex_parser.c | 82 +++++----- .../source/texk/web2c/synctexdir/synctex_parser.h | 10 +- .../web2c/synctexdir/synctex_parser_advanced.h | 2 +- .../texk/web2c/synctexdir/synctex_parser_utils.c | 9 +- 6 files changed, 57 insertions(+), 231 deletions(-) (limited to 'Build/source/texk/web2c/synctexdir') diff --git a/Build/source/texk/web2c/synctexdir/README.txt b/Build/source/texk/web2c/synctexdir/README.txt index f8008e3cd75..6c7df4a7544 100644 --- a/Build/source/texk/web2c/synctexdir/README.txt +++ b/Build/source/texk/web2c/synctexdir/README.txt @@ -1,176 +1 @@ -# Copyright (c) 2008, 2009, 2010, 2011 jerome DOT laurens AT u-bourgogne DOT fr -# -# This file is part of the SyncTeX package. -# -# 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 -# Thu Jun 19 09:39:21 UTC 2008 - - -This file gives the .synctex file specifications. - -SyncTeX output file specifications, Version 2, Lun 31 mar 2008 13:50:31 UTC -=========================================================================== -This is an EBNF file specification extended by ICU regex patterns -(enclosed between 2 '/'s) - -The whole synctex file is made of various records gathered into four different sections: - - ::= - -Each record is a sequence of text characters following an end of record mark or starting the file, -and ending with an end of record mark. -The first characters of a record will determine the type of the record. - - ::= /\n/ - ::= /[^\n]*/ - -The preamble: -------------- - - ::= * - - ::= /SyncTeX Version:/ - ::= - ::= /1/ - - ::= /Input:/ - ::= /:/ - ::= - ::= /[^]*/ -This is used to give a shortcut to filenames. - - ::= ? ? ? ? ? - - ::= /Output:/ - ::= /dvi|pdf|xdv|[0-9a-zA-Z]*/ - - ::= /Magnification:/ - ::= -This is the TeX magnification. - - ::= /Unit:/ - ::= -The SyncTeX unit is scaled point, 1 in general, 8192 when not given. - - ::= /X Offset:/ - ::= - ::= /Y Offset:/ - ::= -The offset or the origin of the system of coordinates from the top left point of the page. -This defaults to 1in for both the vertical and horizontal offsets. -Both offsets are given in this section in scaled point unit. - -: The preamble, like any other section may contain in the future any other kind of record, -except the one starting the next section. In order to ensure some forwards compatibility, -parsers should anticipate and parse unknown records: an unexpected record should be silently ignored by the parser. -This means that this format is somehow open an more types of records can be added without breaking existing software. - -The preamble ends when a record is found that fits the following section. - -The contents: -------------- - ::= **...* - -::=/Contents:// - ::= - ::= * - ::= /{//:// - ::= /}/ - - ::= ||| - ::= (*)|* - ::= ||| - ::= * - - ::= /v//://:/ - ::= /h//://:/ - ::= /,//,/ - ::= - ::= - ::= - ::= /,/(/,/)? - ::= - ::= - - ::= /x//:/ - ::= /k//://:/ - ::= /g//:/ - ::= /$//:/ - -The byte offset is an implicit anchor to navigate the synctex file from sheet to sheet. - -The postamble: --------------- -The postamble closes the file -If there is no postamble, it means that the typesetting process did not end correctly. - ::= - - ::= /Postamble:/ - ::= /Count:/ - -The post scriptum: ------------------- -The post scriptum contains material possibly added by 3rd parties. -It allows to append some transformation (shift and magnify). -Typically, one applies a dvi to pdf filter with offset options and magnification, -then he appends the same options to the synctex file, for example - - dvipdfmx -m 0.486 -x 9472573sp -y 13.3dd source.dvi - echo "X Offset:9472573" >> source.synctex - echo "Y Offset:13.3dd" >> source.synctex - echo "Magnification:0.486" >> source.synctex - - - ::= (||)* - ::= /Magnification:/ - ::= - ::= /X Offset:/ - ::= - ::= - ::= /(+|-)?/ - ::= /(in|cm|mm|pt|bp|pc|sp|dd|cc|nd|nc)?/ - ::= /[\n\r]*/ - ::= /Y Offset:/ - ::= - -This second information will override the offset and magnification previously available in the preamble section. -All the numbers are encoded using the decimal representation with "C" locale. - +The .synctex file specifications is now available as a man page with `man 5 synctex`. diff --git a/Build/source/texk/web2c/synctexdir/synctex_main.c b/Build/source/texk/web2c/synctexdir/synctex_main.c index 01f269673f5..ea676eacc1a 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_main.c +++ b/Build/source/texk/web2c/synctexdir/synctex_main.c @@ -382,7 +382,7 @@ int synctex_view_proceed(synctex_view_params_t * Ps) { 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("offset:%u\n",Ps->offset); printf("middle:%s\n",Ps->middle); printf("after:%s\n",Ps->after); printf("output:%s\n",Ps->output); @@ -466,7 +466,7 @@ int synctex_view_proceed(synctex_view_params_t * Ps) { 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)before:"")); - TEST("&{offset}","%i",Ps->offset); + TEST("&{offset}","%u",Ps->offset); TEST("&{middle}","%s",(Ps->middle && strlen(Ps->middle)middle:"")); TEST("&{after}", "%s",(Ps->after && strlen(Ps->after)after:"")); # undef TEST @@ -673,7 +673,7 @@ int synctex_edit_proceed(synctex_edit_params_t * Ps) { 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("offset:%u\n",Ps->offset); printf("context:%s\n",Ps->context); printf("cwd:%s\n",getcwd(NULL,0)); #endif @@ -743,7 +743,7 @@ int synctex_edit_proceed(synctex_edit_params_t * Ps) { TEST("&{input}", "%s",input); TEST("&{line}", "%i",synctex_node_line(node)); TEST("&{column}", "%i",-1); - TEST("&{offset}", "%i",Ps->offset); + TEST("&{offset}", "%u",Ps->offset); TEST("&{context}","%s",Ps->context); # undef TEST break; diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser.c b/Build/source/texk/web2c/synctexdir/synctex_parser.c index f4f7d848e43..7fcbe0ce3a9 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser.c @@ -279,7 +279,7 @@ typedef synctex_node_p synctex_noxy_p; * Free the given node by sending the free message. * - parameter NODE: of type synctex_node_p */ -void synctex_node_free(synctex_node_p node) { +static void synctex_node_free(synctex_node_p node) { SYNCTEX_MSG_SEND(node,free); } # if defined(SYNCTEX_TESTING) @@ -436,7 +436,7 @@ DEFINE_SYNCTEX_TREE_RESET(WHAT) /* * _synctex_tree_set_... methods return the old value. * The return value of _synctex_tree_set_child and - * _synctex_tree_set_sibling must be released somehown. + * _synctex_tree_set_sibling must be released somehow. */ DEFINE_SYNCTEX_TREE__GETSETRESET(sibling) DEFINE_SYNCTEX_TREE_GETSETRESET(parent) @@ -648,12 +648,12 @@ static synctex_open_s __synctex_open_v2(const char * output, synctex_io_mode_t i quoteless_synctex_name = NULL; } } - /* The operation is successfull, return the arguments by value. */ + /* The operation is successful, return the arguments by value. */ open.status = SYNCTEX_STATUS_OK; return open; } -/* Opens the ouput file, taking into account the eventual build_directory. +/* Opens the output file, taking into account the eventual build_directory. * - returns: an open structure which status is * SYNCTEX_STATUS_OK on success, * SYNCTEX_STATUS_ERROR on failure. @@ -707,7 +707,7 @@ static synctex_open_s _synctex_open_v2(const char * output, const char * build_d } /* if (build_directory...) */ return open; } -void synctex_reader_free(synctex_reader_p reader) { +static void synctex_reader_free(synctex_reader_p reader) { if (reader) { _synctex_free(reader->output); _synctex_free(reader->synctex); @@ -720,7 +720,7 @@ void synctex_reader_free(synctex_reader_p reader) { * Return reader on success. * Deallocate reader and return NULL on failure. */ -synctex_reader_p synctex_reader_init_with_output_file(synctex_reader_p reader, const char * output, const char * build_directory) { +static synctex_reader_p synctex_reader_init_with_output_file(synctex_reader_p reader, const char * output, const char * build_directory) { if (reader) { /* now open the synctex file */ synctex_open_s open = _synctex_open_v2(output,build_directory,0,synctex_ADD_QUOTES); @@ -2827,20 +2827,6 @@ synctex_node_p synctex_node_next(synctex_node_p node) { } return _synctex_node_sibling_or_parents(node); } -/** - * The next nodes corresponds to a deep first tree traversal. - * Does not create child proxies as side effect contrary to - * the synctex_node_next method above. - * May loop infinitely many times if the tree - * is not properly built (contains loops). - */ -synctex_node_p _synctex_node_next(synctex_node_p node) { - synctex_node_p N = _synctex_tree_child(node); - if (N) { - return N; - } - return _synctex_node_sibling_or_parents(node); -} /** * The node which argument is the sibling. * - return: NULL if the argument has no parent or @@ -5165,7 +5151,7 @@ main_loop: /* At least 1 more character */ zs = _synctex_buffer_get_available_size(scanner,1); if (zs.size == 0){ - _synctex_error("Uncomplete synctex file, postamble missing."); + _synctex_error("Incomplete synctex file, postamble missing."); SYNCTEX_RETURN(SYNCTEX_STATUS_ERROR); } goto main_loop; @@ -5182,13 +5168,13 @@ ignore_loop: --ignored_form_depth; } if (_synctex_next_line(scanner)reader->lastv = -1; - synctex_status_t status = 0; if (NULL == scanner) { return SYNCTEX_STATUS_BAD_ARGUMENT; } + scanner->reader->lastv = -1; + synctex_status_t status = 0; /* Find where this section starts */ content_not_found: status = _synctex_match_string(scanner,"Content:"); @@ -5956,7 +5942,7 @@ content_not_found: return status; } if (_synctex_next_line(scanner)pre_magnification = 1000; scanner->pre_unit = 8192; scanner->pre_x_offset = scanner->pre_y_offset = 578; - /* initialize the offset with a fake unprobable value, - * If there is a post scriptum section, this value will be overriden by the real life value */ + /* initialize the offset with a fake improbable value, + * If there is a post scriptum section, this value will be overridden by the real life value */ scanner->x_offset = scanner->y_offset = 6.027e23f; scanner->reader->line_number = 1; @@ -7613,7 +7599,7 @@ static synctex_nd_s _synctex_point_h_ordered_distance_v2 width = _synctex_data_width(node); min = _synctex_data_h(node); max = min + (width>0?width:-width); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->hh; /* regions 1+4+7, result is > 0 */ } else if (hit->h>max) { @@ -7627,7 +7613,7 @@ static synctex_nd_s _synctex_point_h_ordered_distance_v2 width = synctex_node_width(node); min = synctex_node_h(node); max = min + (width>0?width:-width); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->hh; /* regions 1+4+7, result is > 0 */ } else if (hit->h>max) { @@ -7642,7 +7628,7 @@ static synctex_nd_s _synctex_point_h_ordered_distance_v2 width = synctex_node_hbox_width(node); min = synctex_node_hbox_h(node); max = min + (width>0?width:-width); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->hh; /* regions 1+4+7, result is > 0 */ } else if (hit->h>max) { @@ -7754,7 +7740,7 @@ static synctex_nd_s _synctex_point_v_ordered_distance_v2 min = synctex_node_v(node); max = min + _synctex_abs(_synctex_data_depth(node)); min -= _synctex_abs(_synctex_data_height(node)); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->vv; /* regions 1+2+3, result is > 0 */ } else if (hit->v>max) { @@ -7768,7 +7754,7 @@ static synctex_nd_s _synctex_point_v_ordered_distance_v2 min = synctex_node_v(node); max = min + _synctex_abs(synctex_node_depth(node)); min -= _synctex_abs(synctex_node_height(node)); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->vv; /* regions 1+2+3, result is > 0 */ } else if (hit->v>max) { @@ -7785,7 +7771,7 @@ static synctex_nd_s _synctex_point_v_ordered_distance_v2 max = min + (depth>0?depth:-depth); height = synctex_node_hbox_height(node); min -= (height>0?height:-height); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->vv; /* regions 1+2+3, result is > 0 */ } else if (hit->v>max) { @@ -7801,7 +7787,7 @@ static synctex_nd_s _synctex_point_v_ordered_distance_v2 min = _synctex_data_v(node); max = min + _synctex_abs(_synctex_data_depth(_synctex_tree_parent(node))); min -= _synctex_abs(_synctex_data_height(_synctex_tree_parent(node))); - /* We allways have min <= max */ + /* We always have min <= max */ if (hit->vv; /* regions 1+2+3, result is > 0 */ } else if (hit->v>max) { @@ -8394,10 +8380,10 @@ typedef union { gzFile as_gzFile; FILE * as_FILE_p; void * as_ptr; -} syncex_file_u; +} synctex_file_u; struct synctex_updater_t { - syncex_file_u file; + synctex_file_u file; synctex_print_f print; synctex_close_f close; int length; /* the number of chars appended */ @@ -8560,6 +8546,20 @@ void synctex_updater_free(synctex_updater_p updater){ # pragma mark - # pragma mark Testers # endif +/** + * The next nodes corresponds to a deep first tree traversal. + * Does not create child proxies as side effect contrary to + * the synctex_node_next method above. + * May loop infinitely many times if the tree + * is not properly built (contains loops). + */ +static synctex_node_p _synctex_node_next(synctex_node_p node) { + synctex_node_p N = _synctex_tree_child(node); + if (N) { + return N; + } + return _synctex_node_sibling_or_parents(node); +} static int _synctex_input_copy_name(synctex_node_p input, char * name) { char * copy = _synctex_malloc(strlen(name)+1); memcpy(copy,name,strlen(name)+1); diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser.h b/Build/source/texk/web2c/synctexdir/synctex_parser.h index e54a0176a15..3a6a9018295 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser.h @@ -146,7 +146,7 @@ extern "C" { /* The main entry points. * Given the file name, a line and a column number, synctex_display_query returns the number of nodes - * satisfying the contrain. Use code like + * satisfying the constrain. Use code like * * if(synctex_display_query(scanner,name,line,column,page_hint)>0) { * synctex_node_p node; @@ -165,7 +165,7 @@ extern "C" { * - highlight just the character using that information * * Given the page and the position in the page, synctex_edit_query returns the number of nodes - * satisfying the contrain. Use code like + * satisfying the constrain. Use code like * * if(synctex_edit_query(scanner,page,h,v)>0) { * synctex_node_p node; @@ -230,7 +230,7 @@ extern "C" { * synctex_node_box_visible_depth(node) * ); * The visible dimensions are bigger than real ones - * to compensate 0 width boxes or nodes intentionnaly + * to compensate 0 width boxes or nodes intentionally * put outside the box (using \kern for example). * - parameter node: a node. * - returns: a float. @@ -248,7 +248,7 @@ extern "C" { * as opposite to TeX coordinates. * The origin is at the top left corner of the page. * The visible dimensions are bigger than real ones - * to compensate 0 width boxes or nodes intentionnaly + * to compensate 0 width boxes or nodes intentionally * put outside the box (using \kern for example). * All nodes have coordinates, but all nodes don't * have non null size. For example, math nodes @@ -389,7 +389,7 @@ extern "C" { * The scanner owns a list of sheet siblings and * a list of form siblings. * Sheets or forms have one child which is a box: - * theie contents. + * their contents. * - argument page: 1 based sheet page number. * - argument tag: 1 based form tag number. */ diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h b/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h index 867fbf7ed00..a7f04d80dab 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_advanced.h @@ -449,7 +449,7 @@ extern "C" { */ void synctex_iterator_free(synctex_iterator_p iterator); /** - * Wether the iterator actually points to an object. + * Whether the iterator actually points to an object. * - argument iterator: the object to iterate on... */ synctex_bool_t synctex_iterator_has_next(synctex_iterator_p iterator); diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c index c4f200d8754..4b4065dab64 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c @@ -48,7 +48,6 @@ #include #include -#include #include @@ -87,7 +86,7 @@ void _synctex_free(void * ptr) { # include #endif -int _synctex_log(int level, const char * prompt, const char * reason,va_list arg) { +static int _synctex_log(int level, const char * prompt, const char * reason,va_list arg) { int result; # ifdef SYNCTEX_RECENT_WINDOWS {/* This code is contributed by William Blum. @@ -301,7 +300,7 @@ int _synctex_copy_with_quoting_last_path_component(const char * src, char ** des if(src && dest_ref) { const char * lpc; # define dest (*dest_ref) - dest = NULL; /* Default behavior: no change and sucess. */ + dest = NULL; /* Default behavior: no change and success. */ lpc = _synctex_last_path_component(src); if(strlen(lpc)) { if(strchr(lpc,' ') && lpc[0]!='"' && lpc[strlen(lpc)-1]!='"') { @@ -351,6 +350,7 @@ char * _synctex_merge_strings(const char * first,...) { size_t len = strlen(temp); if(UINT_MAX-len