83
83
* First level objects are sheets and forms, containing boxes, glues, kerns...
84
84
* The third tree allows to browse leaves according to tag and line.
86
/* Declare _GNU_SOURCE for accessing vasprintf. For MSC compiler, vasprintf is
87
* defined in this file
86
91
# if defined(SYNCTEX_USE_LOCAL_HEADER)
87
92
# include "synctex_parser_local.h"
369
374
return synctex_NO;\
372
#define SYNCTEX_PARAMETER_ASSERT(WHAT)
373
#define DEFINE_SYNCTEX_TREE_HAS(WHAT) \
374
static synctex_bool_t _synctex_tree_has_##WHAT(synctex_node_p node) {\
377
# define SYNCTEX_PARAMETER_ASSERT(WHAT)
378
# define DEFINE_SYNCTEX_TREE_HAS(WHAT) \
379
SYNCTEX_INLINE static synctex_bool_t _synctex_tree_has_##WHAT(synctex_node_p node) {\
375
380
return (node && (node->class_->navigator->WHAT>=0));\
383
388
# define DEFINE_SYNCTEX_TREE_GET(WHAT) \
384
389
DEFINE_SYNCTEX_TREE__GET(WHAT) \
385
static synctex_node_p _synctex_tree_##WHAT(synctex_node_p node) {\
390
SYNCTEX_INLINE static synctex_node_p _synctex_tree_##WHAT(synctex_node_p node) {\
386
391
if (_synctex_tree_has_##WHAT(node)) {\
387
392
return __synctex_tree_##WHAT(node);\
438
443
* The return value of _synctex_tree_set_child and
439
444
* _synctex_tree_set_sibling must be released somehow.
446
/* The next macro call creates:
447
SYNCTEX_INLINE static synctex_node_p __synctex_tree_sibling(synctex_node_p node)
448
SYNCTEX_INLINE static synctex_node_p __synctex_tree_set_sibling(synctex_node_p node, synctex_node_p new_value)
449
SYNCTEX_INLINE static synctex_node_p __synctex_tree_reset_sibling(synctex_node_p node)
441
451
DEFINE_SYNCTEX_TREE__GETSETRESET(sibling)
452
/* The next macro call creates:
453
SYNCTEX_INLINE static synctex_bool_t _synctex_tree_has_parent(synctex_node_p node);
454
SYNCTEX_INLINE static synctex_node_p __synctex_tree_parent(synctex_non_null_node_p node);
455
SYNCTEX_INLINE static synctex_node_p _synctex_tree_parent(synctex_node_p node);
456
SYNCTEX_INLINE static synctex_node_p __synctex_tree_set_parent(synctex_node_p node, synctex_node_p new_value);
457
SYNCTEX_INLINE static synctex_node_p _synctex_tree_set_parent(synctex_node_p node, synctex_node_p new_value);
458
SYNCTEX_INLINE static synctex_node_p __synctex_tree_reset_parent(synctex_node_p node);
459
SYNCTEX_INLINE static synctex_node_p _synctex_tree_reset_parent(synctex_node_p node);
442
461
DEFINE_SYNCTEX_TREE_GETSETRESET(parent)
443
462
DEFINE_SYNCTEX_TREE_GETSETRESET(child)
444
463
DEFINE_SYNCTEX_TREE_GETSETRESET(friend)
464
/* The next macro call creates:
465
SYNCTEX_INLINE static synctex_bool_t _synctex_tree_has_last(synctex_node_p node);
466
SYNCTEX_INLINE static synctex_node_p __synctex_tree_last(synctex_non_null_node_p node);
467
SYNCTEX_INLINE static synctex_node_p _synctex_tree_last(synctex_node_p node);
468
SYNCTEX_INLINE static synctex_node_p __synctex_tree_set_last(synctex_node_p node, synctex_node_p new_value);
469
SYNCTEX_INLINE static synctex_node_p _synctex_tree_set_last(synctex_node_p node, synctex_node_p new_value);
445
471
DEFINE_SYNCTEX_TREE_GETSET(last)
446
472
DEFINE_SYNCTEX_TREE_GETSET(next_hbox)
447
473
DEFINE_SYNCTEX_TREE_GETSET(arg_sibling)
892
918
* It is not owned by its parent, unless it is its first child.
893
919
* This destructor is for all handles.
921
static void _synctex_free_handle_old(synctex_node_p handle) {
923
_synctex_free_handle_old(__synctex_tree_sibling(handle));
924
_synctex_free_handle_old(_synctex_tree_child(handle));
925
_synctex_free(handle);
895
929
static void _synctex_free_handle(synctex_node_p handle) {
897
_synctex_free_handle(__synctex_tree_sibling(handle));
898
_synctex_free_handle(_synctex_tree_child(handle));
899
_synctex_free(handle);
931
synctex_node_p n = handle;
933
__synctex_tree_set_parent(n, NULL);
935
while ((nn = _synctex_tree_child(n))) {
936
__synctex_tree_set_parent(nn, n);
940
nn = __synctex_tree_sibling(n);
946
nn = __synctex_tree_parent(n);
4510
4562
_synctex_error("Problem with Y offset in the Post Scriptum.");
4511
4563
return fs.status;
4513
scanner->x_offset = fs.value;
4565
scanner->y_offset = fs.value;
4514
4566
goto next_line;
4515
4567
} else if (status<SYNCTEX_STATUS_EOF){
4516
4568
goto report_record_problem;
6006
6058
_synctex_error("malloc problem");
6009
if ((scanner->reader = synctex_reader_init_with_output_file(scanner->reader, output, build_directory))) {
6061
if (synctex_reader_init_with_output_file(scanner->reader, output, build_directory)) {
6010
6062
return parse? synctex_scanner_parse(scanner):scanner;
6012
6064
// don't warn to terminal if no file is present, this is a library.
6013
6065
// _synctex_error("No file?");
6066
synctex_scanner_free(scanner);
6054
6103
scanner->x_offset = scanner->y_offset = 6.027e23f;
6055
6104
scanner->reader->line_number = 1;
6057
SYNCTEX_START = (char *)malloc(SYNCTEX_BUFFER_SIZE+1); /* one more character for null termination */
6058
if (NULL == SYNCTEX_START) {
6059
_synctex_error("! malloc error in synctex_scanner_parse.");
6061
#ifdef SYNCTEX_DEBUG
6064
synctex_scanner_free(scanner);
6068
6106
synctex_scanner_set_display_switcher(scanner, 1000);
6069
6107
SYNCTEX_END = SYNCTEX_START+SYNCTEX_BUFFER_SIZE;
6070
6108
/* SYNCTEX_END always points to a null terminating character.
6078
6116
status = _synctex_scan_preamble(scanner);
6079
6117
if (status<SYNCTEX_STATUS_OK) {
6080
6118
_synctex_error("Bad preamble\n");
6120
#ifdef SYNCTEX_DEBUG
6123
synctex_scanner_free(scanner);
6083
6127
status = _synctex_scan_content(scanner);
6084
6128
if (status<SYNCTEX_STATUS_OK) {
8390
8434
int length; /* the number of chars appended */
8437
__attribute__((__format__ (__printf__, 2, 3)))
8393
8438
static int _synctex_updater_print(synctex_updater_p updater, const char * format, ...) {
8394
8439
int result = 0;
8427
8472
* gzvprintf is not available until OSX 10.10
8474
__attribute__((__format__ (__printf__, 2, 3)))
8429
8475
static int _synctex_updater_print_gz(synctex_updater_p updater, const char * format, ...) {
8430
8476
int result = 0;