summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/synctex/synctex_parser.c
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2008-05-08 13:16:56 +0000
committerJonathan Kew <jfkthame@googlemail.com>2008-05-08 13:16:56 +0000
commita10711ec4f3a0ce10ece61a929101038b83e19f2 (patch)
treed96b31bbbd70c63e6bde6853ecba897efbe9f39c /Build/source/texk/web2c/synctex/synctex_parser.c
parent012963a39269c51a7c94afabeb2bda2ac20f84aa (diff)
updated synctex code from xetex svn r.670
git-svn-id: svn://tug.org/texlive/trunk@7936 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/synctex/synctex_parser.c')
-rw-r--r--Build/source/texk/web2c/synctex/synctex_parser.c624
1 files changed, 329 insertions, 295 deletions
diff --git a/Build/source/texk/web2c/synctex/synctex_parser.c b/Build/source/texk/web2c/synctex/synctex_parser.c
index f68e32d99d7..6e0fb7f02ef 100644
--- a/Build/source/texk/web2c/synctex/synctex_parser.c
+++ b/Build/source/texk/web2c/synctex/synctex_parser.c
@@ -46,7 +46,7 @@ authorization from the copyright holder.
void *_synctex_malloc(size_t size) {
void * ptr = malloc(size);
if(ptr) {
- memset(ptr,0,size);
+ bzero(ptr,size);
}
return (void *)ptr;
}
@@ -202,11 +202,14 @@ void _synctex_free_leaf(synctex_node_t node) {
return;
}
+#include <zlib.h>
+
/* The synctex scanner is the root object.
* Is is initiated with the contents of a text file.
* The buffer_? are first used to parse the text.
*/
struct __synctex_scanner_t {
+ gzFile file; /* The (compressed) file */
unsigned char * buffer_ptr; /* current location in the buffer */
unsigned char * buffer_start; /* start of the buffer */
unsigned char * buffer_end; /* end of the buffer */
@@ -602,7 +605,7 @@ sibling:
return SIBLING(node);
}
if(node = PARENT(node)) {
- if(node->class->type == synctex_node_type_sheet) {// EXC_BAD_ACCESS?
+ if(node->class->type == synctex_node_type_sheet) {/* EXC_BAD_ACCESS? */
return NULL;
}
goto sibling;
@@ -833,6 +836,56 @@ void _synctex_display_input(synctex_node_t node) {
#define SYNCTEX_NOERR 0
+#define F scanner->file
+#define SYNCTEX_BUF_SIZE 32768
+
+/* Ensures that the buffer contains at least size bytes.
+ * Passing a negative size argument means the whole buffer length.
+ * The return value is the number of bytes now available in the buffer.
+ * -1 is returned in case of error. */
+int _synctex_fill_buffer_up_to_size(synctex_scanner_t scanner, int size) {
+ int count = END - PTR; /* count is the number of unparsed chars in the buffer */
+ if(size<0) {
+ size = SYNCTEX_BUF_SIZE;
+ }
+ if(size<=count) {
+ return count;
+ }
+ if(F) {
+ /* Copy the remaining part of the buffer to the beginning,
+ * then read the next part of the file */
+ int read = 0;
+ if(count) {
+ memmove(START, PTR, count);
+ }
+ PTR = START + count; /* the next character after the move, will change. */
+ /* Fill the buffer up to its end */
+ read = gzread(F,(void *)PTR,SYNCTEX_BUF_SIZE - count);
+ if(read>0) {
+ END = PTR + read;
+ PTR = START;
+ if(SYNCTEX_BUF_SIZE==size || size<=END-PTR) {
+ return END - PTR;
+ }
+ return -1;
+ } else if(read<0) {
+ /*This is an error */
+ printf("SyncTeX Error: gzread error (1)");
+ return -1;
+ } else {
+ gzclose(F);
+ F = NULL;
+ END = PTR;
+ PTR = START;
+ return END - PTR; /* there might be a bit of text left */
+ }
+ }
+ if(END-PTR > 0)
+ return END - PTR;
+ /* There was nothing left in the file */
+ return -1;
+}
+
/* Used when parsing the synctex file.
* Advance to the next character starting a line.
* Actually, only \n is recognized as end of line marker. */
@@ -840,13 +893,15 @@ int _synctex_next_line(synctex_scanner_t scanner) {
if(NULL == scanner) {
return -1;
}
- while(PTR<END) {
- if(*PTR == '\n') {
+ do {
+ while(PTR<END) {
+ if(*PTR == '\n') {
+ ++PTR;
+ return 0;
+ }
++PTR;
- return 0;
}
- ++PTR;
- }
+ } while(_synctex_fill_buffer_up_to_size(scanner, -1)>0);
return 1;
}
@@ -855,14 +910,19 @@ int _synctex_next_line(synctex_scanner_t scanner) {
* First file separators are skipped
*/
int _synctex_decode_int(synctex_scanner_t scanner, int* valueRef) {
+ unsigned char * ptr;
+ unsigned char * end = NULL;
+ int result = 0;
if(NULL == scanner) return -1;
+ if(END-PTR<=15) {
+ _synctex_fill_buffer_up_to_size(scanner, -1);
+ }
+ ptr = PTR;
if(PTR>=END) return -1;
- unsigned char * ptr = PTR;
if(*ptr==':' || *ptr==',') {
++ptr;
}
- unsigned char * end;
- int result = (int)strtol((char *)ptr, (char **)&end, 10);
+ result = (int)strtol((char *)ptr, (char **)&end, 10);
if(end>ptr) {
PTR = end;
if(valueRef) {
@@ -874,23 +934,58 @@ int _synctex_decode_int(synctex_scanner_t scanner, int* valueRef) {
}
int _synctex_decode_string(synctex_scanner_t scanner, char ** valueRef) {
+ unsigned char * end = PTR;
+ size_t current_size = 0;
+ size_t len = 0;/* The number of bytes to copy */
if(NULL == scanner || NULL == valueRef) return -1;
if(PTR>=END) return -1;
- char * end = (char *)PTR;
- while(end<(char *)END && *end != '\n') {
- ++end;
- }
- size_t len = end - (char *)PTR;
- if(* valueRef = malloc(len+1)) {
- if(memcpy((*valueRef),(synctex_node_t)PTR,len)) {
- (* valueRef)[len]='\0';
+ /* We scan all the characters up to the next '\n'
+ * There is a problem with the buffer. */
+next_character:
+ if(end<END) {
+ if(*end == '\n') {
+ /* OK, we found where to stop */
+ len = end - PTR;
+ if(* valueRef = realloc(* valueRef,current_size+len+1)) {
+ if(memcpy((*valueRef)+current_size,PTR,len)) {
+ current_size += len;/* update the current_size to the new value */
+ (* valueRef)[current_size]='\0'; /* Terminate the string */
+ PTR += len;
+ return SYNCTEX_NOERR;
+ }
+ free(* valueRef);
+ * valueRef = NULL;
+ return -1;
+ }
+ /* Huge memory problem */
PTR += len;
- return 0;
+ return -1;
+ } else {
+ ++end;
+ goto next_character;
}
- free(* valueRef);
- * valueRef = NULL;
+ } else {
+ len = end - PTR;
+ if(* valueRef = realloc(* valueRef,current_size+len+1)) {
+ if(memcpy((*valueRef)+current_size,PTR,len)) {
+ current_size += len;/* update the current_size to the new value */
+ (* valueRef)[current_size]='\0'; /* Terminate the string */
+ PTR += len;
+ if(_synctex_fill_buffer_up_to_size(scanner,-1)>0) {
+ end = PTR;
+ goto next_character;
+ } else {
+ return 0;
+ }
+ }
+ free(* valueRef);
+ * valueRef = NULL;
+ return -1;
+ }
+ /* Huge memory problem */
+ PTR += len;
+ return -1;
}
- return -1;
}
/* Used when parsing the synctex file.
@@ -900,8 +995,7 @@ int _synctex_scan_input(synctex_scanner_t scanner) {
if(NULL == scanner) {
return -1;
}
- if(0 == strncmp((char *)PTR,"Input:",6)) {
- PTR += 6;
+ if(0 == _synctex_scan_string(scanner,"Input:")) {
synctex_node_t input = _synctex_new_input(scanner);
if(_synctex_decode_int(scanner,INFO(input)+TAG)
|| (++PTR,_synctex_decode_string(scanner,(char **)(INFO(input)+NAME)))
@@ -923,52 +1017,47 @@ int _synctex_scan_settings(synctex_scanner_t scanner) {
if(NULL == scanner) {
return -1;
}
- while(strncmp((char *)PTR,"Output:",7)) {
+ while(_synctex_scan_string(scanner,"Output:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 7;
if(_synctex_decode_string(scanner,&(scanner->output))
|| _synctex_next_line(scanner)) {
return -1;
}
- while(strncmp((char *)PTR,"Magnification:",14)) {
+ while(_synctex_scan_string(scanner,"Magnification:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 14;
if(_synctex_decode_int(scanner,(int *)&(scanner->pre_magnification))
|| _synctex_next_line(scanner)) {
return -1;
}
- while(strncmp((char *)PTR,"Unit:",5)) {
+ while(_synctex_scan_string(scanner,"Unit:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 5;
if(_synctex_decode_int(scanner,(int *)&(scanner->pre_unit))
|| _synctex_next_line(scanner)) {
return -1;
}
- while(strncmp((char *)PTR,"X Offset:",9)) {
+ while(_synctex_scan_string(scanner,"X Offset:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 9;
if(_synctex_decode_int(scanner,&(scanner->pre_x_offset))
|| _synctex_next_line(scanner)) {
return -1;
}
- while(strncmp((char *)PTR,"Y Offset:",9)) {
+ while(_synctex_scan_string(scanner,"Y Offset:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 9;
if(_synctex_decode_int(scanner,&(scanner->pre_y_offset))
|| _synctex_next_line(scanner)) {
return -1;
@@ -976,16 +1065,42 @@ int _synctex_scan_settings(synctex_scanner_t scanner) {
return 0;
}
+/* Scan the given string. No 0 length string as argument.
+ */
+int _synctex_scan_string(synctex_scanner_t scanner, const char * the_string) {
+ size_t len = 0;
+ if(NULL == scanner) {
+ return -1;
+ }
+ len = strlen(the_string);
+ if(0 == len) {
+ printf("SyncTeX Error: No string given\n");
+ return -1;
+ }
+ if(_synctex_fill_buffer_up_to_size(scanner,len)<0) {
+ return -1;
+ }
+ if(len>END-PTR) {
+ return -1;
+ }
+ if(strncmp((char *)PTR,the_string,len)) {
+ return -1;
+ }
+ PTR += len;
+ return 0;
+}
+
/* Used when parsing the synctex file.
- * Read the preamplesss.
+ * Read the preamble.
*/
int _synctex_scan_preamble(synctex_scanner_t scanner) {
if(NULL == scanner) {
return -1;
}
- if(strncmp((char *)PTR,"SyncTeX Version:",1)
- || ((PTR+=16),_synctex_decode_int(scanner,&(scanner->version)))
+ if(_synctex_scan_string(scanner,"SyncTeX Version:")
+ || _synctex_decode_int(scanner,&(scanner->version))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Missing version\n");
return -1;
}
while(SYNCTEX_NOERR == _synctex_scan_input(scanner)) {
@@ -996,76 +1111,69 @@ int _synctex_scan_preamble(synctex_scanner_t scanner) {
/* parse the post scriptum */
#include "xlocale.h"
int _synctex_scan_post_scriptum(synctex_scanner_t scanner) {
- while(strncmp((char *)PTR,"Post scriptum:",14)) {
+ int status = 0;
+ while(_synctex_scan_string(scanner,"Post scriptum:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 14;
/* Scanning the information */
/* initialize the offset with a fake value */
scanner->x_offset = 6.027e23;
scanner->y_offset = scanner->x_offset;
- /* By default, C programs start in the "C" locale
- * But we are in a library, so we cannot assume that. */
- locale_t locale = newlocale(LC_ALL_MASK, NULL, NULL);
- int status = 0;
+ /* By default, all "*_l" functions are used with a C locale. */
next_record:
- if(0 == strncmp((char *)PTR,"Magnification:",14)) {
- PTR += 14;
+ if(0 == _synctex_scan_string(scanner,"Magnification:")) {
if(PTR<END) {
- scanner->unit = strtof_l((char *)PTR,(char **)&PTR,locale);
+ scanner->unit = strtof_l((char *)PTR,(char **)&PTR,NULL);
next_line:
status = _synctex_next_line(scanner);
if(status<0) {
- freelocale(locale);
return -1;
} else if(0 == status) {
goto next_record;
}
}
- freelocale(locale);
return 0;
- } else if(0 == strncmp((char *)PTR,"X Offset:",9)) {
- PTR += 9;
+ } else if(0 == _synctex_scan_string(scanner,"X Offset:")) {
if(PTR<END) {
unsigned char * end = NULL;
- float f = strtof_l((char *)PTR,(char **)&end,locale);
+ float f = strtof_l((char *)PTR,(char **)&end,NULL);
if(end>PTR) {
/* scan the x offset */
- //72/72.27/65536*16384+0.5;
+ /* 72/72.27/65536*16384+0.5; */
PTR = end;
- if(strncmp((char *)PTR,"in",2) == 0) {
+ if(_synctex_scan_string(scanner,"in") == 0) {
f *= 72.27*65536;
}
- else if(strncmp((char *)PTR,"cm",2) == 0) {
+ else if(_synctex_scan_string(scanner,"cm") == 0) {
f *= 72.27*65536/2.54;
}
- else if(strncmp((char *)PTR,"mm",2) == 0) {
+ else if(_synctex_scan_string(scanner,"mm") == 0) {
f *= 72.27*65536/25.4;
}
- else if(strncmp((char *)PTR,"pt",2) == 0) {
+ else if(_synctex_scan_string(scanner,"pt") == 0) {
f *= 65536.0;
}
- else if(strncmp((char *)PTR,"bp",2) == 0) {
+ else if(_synctex_scan_string(scanner,"bp") == 0) {
f *= 72.27/72*65536;
}
- else if(strncmp((char *)PTR,"pc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"pc") == 0) {
f *= 12.0*65536;
}
- else if(strncmp((char *)PTR,"sp",2) == 0) {
+ else if(_synctex_scan_string(scanner,"sp") == 0) {
f *= 1.0;
}
- else if(strncmp((char *)PTR,"dd",2) == 0) {
+ else if(_synctex_scan_string(scanner,"dd") == 0) {
f *= 1238.0/1157*65536;
}
- else if(strncmp((char *)PTR,"cc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"cc") == 0) {
f *= 14856.0/1157*65536;
}
- else if(strncmp((char *)PTR,"nd",2) == 0) {
+ else if(_synctex_scan_string(scanner,"nd") == 0) {
f *= 685.0/642*65536;
}
- else if(strncmp((char *)PTR,"nc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"nc") == 0) {
f *= 1370.0/107*65536;
}
else {
@@ -1076,48 +1184,46 @@ next_line:
}
goto next_line;
}
- freelocale(locale);
return 0;
- } else if(0 == strncmp((char *)PTR,"Y Offset:",9)) {
- PTR += 9;
+ } else if(0 == _synctex_scan_string(scanner,"Y Offset:")) {
if(PTR<END) {
unsigned char * end = NULL;
- float f = strtof_l((char *)PTR,(char **)&end,locale);
+ float f = strtof_l((char *)PTR,(char **)&end,NULL);
if(end>PTR) {
/* scan the x offset */
- //72/72.27/65536*16384+0.5;
+ /* 72/72.27/65536*16384+0.5; */
PTR = end;
- if(strncmp((char *)PTR,"in",2) == 0) {
+ if(_synctex_scan_string(scanner,"in") == 0) {
f *= 72.27*65536;
}
- else if(strncmp((char *)PTR,"cm",2) == 0) {
+ else if(_synctex_scan_string(scanner,"cm") == 0) {
f *= 72.27*65536/2.54;
}
- else if(strncmp((char *)PTR,"mm",2) == 0) {
+ else if(_synctex_scan_string(scanner,"mm") == 0) {
f *= 72.27*65536/25.4;
}
- else if(strncmp((char *)PTR,"pt",2) == 0) {
+ else if(_synctex_scan_string(scanner,"pt") == 0) {
f *= 65536.0;
}
- else if(strncmp((char *)PTR,"bp",2) == 0) {
+ else if(_synctex_scan_string(scanner,"bp") == 0) {
f *= 72.27/72*65536;
}
- else if(strncmp((char *)PTR,"pc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"pc") == 0) {
f *= 12.0*65536;
}
- else if(strncmp((char *)PTR,"sp",2) == 0) {
+ else if(_synctex_scan_string(scanner,"sp") == 0) {
f *= 1.0;
}
- else if(strncmp((char *)PTR,"dd",2) == 0) {
+ else if(_synctex_scan_string(scanner,"dd") == 0) {
f *= 1238.0/1157*65536;
}
- else if(strncmp((char *)PTR,"cc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"cc") == 0) {
f *= 14856.0/1157*65536;
}
- else if(strncmp((char *)PTR,"nd",2) == 0) {
+ else if(_synctex_scan_string(scanner,"nd") == 0) {
f *= 685.0/642*65536;
}
- else if(strncmp((char *)PTR,"nc",2) == 0) {
+ else if(_synctex_scan_string(scanner,"nc") == 0) {
f *= 1370.0/107*65536;
}
else {
@@ -1128,7 +1234,6 @@ next_line:
}
goto next_line;
}
- freelocale(locale);
return 0;
}
goto next_line;
@@ -1138,12 +1243,11 @@ int _synctex_scan_postamble(synctex_scanner_t scanner) {
if(NULL == scanner) {
return -1;
}
- if(strncmp((char *)PTR,"Postamble:",10)
- || ((PTR += 10),_synctex_next_line(scanner))) {
+ if(_synctex_scan_string(scanner,"Postamble:")
+ || _synctex_next_line(scanner)) {
return -1;
}
- if(!strncmp((char *)PTR,"Count:",6)) {
- PTR += 6;
+ if(!_synctex_scan_string(scanner,"Count:")) {
if(_synctex_decode_int(scanner,&(scanner->count))
|| _synctex_next_line(scanner)) {
return -1;
@@ -1163,10 +1267,11 @@ int _synctex_scan_postamble(synctex_scanner_t scanner) {
* At creation time, the visible size is set to the values of the real size.
*/
int _synctex_setup_visible_box(synctex_node_t box) {
+ int * info = NULL;
if(NULL == box || box->class->type != synctex_node_type_hbox) {
return -1;
}
- int * info = INFO(box);
+ info = INFO(box);
if(info) {
info[HORIZ_V] = info[HORIZ];
info[VERT_V] = info[VERT];
@@ -1183,11 +1288,12 @@ int _synctex_setup_visible_box(synctex_node_t box) {
* With this method, one can enlarge the box to contain the given point (h,v).
*/
int _synctex_horiz_box_setup_visible(synctex_node_t node,int h, int v) {
+ int * itsINFO = NULL;
+ int itsBtm, itsTop;
if(NULL == node || node->class->type != synctex_node_type_hbox) {
return -1;
}
- int * itsINFO = INFO(node);
- int itsBtm, itsTop;
+ itsINFO = INFO(node);
if(itsINFO[WIDTH_V]<0) {
itsBtm = itsINFO[HORIZ_V]+itsINFO[WIDTH_V];
itsTop = itsINFO[HORIZ_V];
@@ -1216,18 +1322,21 @@ int _synctex_horiz_box_setup_visible(synctex_node_t node,int h, int v) {
return 0;
}
+int synctex_bail(void);
+
/* Used when parsing the synctex file.
* The parent is a newly created sheet node that will hold the contents.
* Something is returned in case of error.
*/
int _synctex_scan_sheet(synctex_scanner_t scanner, synctex_node_t parent) {
- if((NULL == scanner) || (NULL == parent))return -1;
synctex_node_t child = NULL;
synctex_node_t sibling = NULL;
int friend_index = 0;
int * info = NULL;
int curh, curv;
+ if((NULL == scanner) || (NULL == parent))return -1;
vertical_loop:
+// printf("H loop:%i\n",++loop);
if(PTR<END) {
if(*PTR == '[') {
++PTR;
@@ -1240,6 +1349,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad vbox record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1247,6 +1357,7 @@ vertical_loop:
child = NULL;
goto vertical_loop;
} else {
+ printf("SyncTeX Error: Can't create vbox record.\n");
return -1;
}
} else if(*PTR == ']') {
@@ -1263,9 +1374,10 @@ vertical_loop:
child = parent;
parent = PARENT(child);
} else {
- printf("Unexpected ]\n");
+ printf("SyncTeX Error: Unexpected ']', ignored.\n");
}
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Uncomplete sheet.\n");
return -1;
}
goto horizontal_loop;
@@ -1281,6 +1393,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_setup_visible_box(child)
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad hbox record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1288,6 +1401,7 @@ vertical_loop:
child = NULL;
goto vertical_loop;
} else {
+ printf("SyncTeX Error: Can't create hbox record.\n");
return -1;
}
} else if(*PTR == ')') {
@@ -1299,9 +1413,10 @@ vertical_loop:
child = parent;
parent = PARENT(child);
} else {
- printf("Unexpected )\n");
+ printf("SyncTeX Error: Unexpected ')', ignored.\n");
}
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Uncomplete sheet.\n");
return -1;
}
goto horizontal_loop;
@@ -1316,6 +1431,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad void vbox record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1326,6 +1442,7 @@ vertical_loop:
UPDATE_FRIEND(child);
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create vbox record.\n");
return -1;
}
} else if(*PTR == 'h') {
@@ -1339,6 +1456,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad void hbox record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1347,6 +1465,7 @@ vertical_loop:
_synctex_horiz_box_setup_visible(parent,synctex_node_h(child)+synctex_node_width(child),synctex_node_v(child));
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create void hbox record.\n");
return -1;
}
} else if(*PTR == 'k') {
@@ -1358,6 +1477,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_decode_int(scanner,(int*)(info+WIDTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad kern record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1370,6 +1490,7 @@ vertical_loop:
}
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create kern record.\n");
return -1;
}
} else if(*PTR == 'x') {
@@ -1379,6 +1500,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,&curh)
|| _synctex_decode_int(scanner,&curv)
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad x record.\n");
return -1;
}
_synctex_horiz_box_setup_visible(parent,curh,curv);
@@ -1391,6 +1513,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+HORIZ))
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad glue record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1398,6 +1521,7 @@ vertical_loop:
UPDATE_FRIEND(child);
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create glue record.\n");
return -1;
}
} else if(*PTR == '$') {
@@ -1408,6 +1532,7 @@ vertical_loop:
|| _synctex_decode_int(scanner,(int*)(info+HORIZ))
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad math record.\n");
return -1;
}
SET_CHILD(parent,child);
@@ -1415,34 +1540,42 @@ vertical_loop:
UPDATE_FRIEND(child);
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create math record.\n");
return -1;
}
} else if(*PTR == '}') {
++PTR;
if(!parent || parent->class->type != synctex_node_type_sheet
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Unexpected end of sheet.\n");
return -1;
}
return 0;
} else if(*PTR == '!') {
++PTR;
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Missing anchor.\n");
return -1;
}
goto vertical_loop;
} else {
- printf("Ignored:<%c>\n",*PTR);
+ printf("SyncTeX Error: Ignored record %c\n",*PTR);
++PTR;
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Unexpected end.\n");
return -1;
}
goto vertical_loop;
}
+ } else if(_synctex_fill_buffer_up_to_size(scanner,-1)>0){
+ goto vertical_loop;
} else {
+ printf("SyncTeX Error: Uncomplete sheet(0)\n");
return -1;
}
synctex_bail();
horizontal_loop:
+// printf("V loop:%i\n",++loop);
if(PTR<END) {
if(*PTR == '[') {
++PTR;
@@ -1455,6 +1588,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad vbox record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1462,6 +1596,7 @@ horizontal_loop:
child = NULL;
goto vertical_loop;
} else {
+ printf("SyncTeX Error: Can't create vbox record (2).\n");
return -1;
}
} else if(*PTR == ']') {
@@ -1473,9 +1608,10 @@ horizontal_loop:
child = parent;
parent = PARENT(child);
} else {
- printf("Unexpected ]\n");
+ printf("SyncTeX Error: Unexpected end of vbox record (2), ignored.\n");
}
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Unexpected end of file (2).\n");
return -1;
}
goto horizontal_loop;
@@ -1491,6 +1627,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_setup_visible_box(sibling)
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad hbox record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1498,6 +1635,7 @@ horizontal_loop:
child = NULL;
goto vertical_loop;
} else {
+ printf("SyncTeX Error: Can't create hbox record (2).\n");
return -1;
}
} else if(*PTR == ')') {
@@ -1509,10 +1647,10 @@ horizontal_loop:
child = parent;
parent = PARENT(child);
} else {
- printf("Unexpected )\n");
+ printf("SyncTeX Error: Unexpected end of hbox record (2).\n");
}
if(_synctex_next_line(scanner)) {
- LOG(child);
+ printf("SyncTeX Error: Unexpected end of file (2,')').\n");
return -1;
}
goto horizontal_loop;
@@ -1527,6 +1665,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad void vbox record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1534,6 +1673,7 @@ horizontal_loop:
child = sibling;
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: can't create void vbox record (2).\n");
return -1;
}
} else if(*PTR == 'h') {
@@ -1547,6 +1687,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+HEIGHT))
|| _synctex_decode_int(scanner,(int*)(info+DEPTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad void hbox record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1556,6 +1697,7 @@ horizontal_loop:
_synctex_horiz_box_setup_visible(parent,synctex_node_h(child)+synctex_node_width(child),synctex_node_v(child));
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: can't create void hbox record (2).\n");
return -1;
}
} else if(*PTR == 'x') {
@@ -1565,6 +1707,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,&curh)
|| _synctex_decode_int(scanner,&curv)
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad x record (2).\n");
return -1;
}
_synctex_horiz_box_setup_visible(parent,curh,curv);
@@ -1578,6 +1721,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_decode_int(scanner,(int*)(info+WIDTH))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad kern record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1586,6 +1730,7 @@ horizontal_loop:
_synctex_horiz_box_setup_visible(parent,synctex_node_h(child),synctex_node_v(child));
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create kern record (2).\n");
return -1;
}
} else if(*PTR == 'g') {
@@ -1596,6 +1741,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+HORIZ))
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad glue record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1604,6 +1750,7 @@ horizontal_loop:
_synctex_horiz_box_setup_visible(parent,synctex_node_h(child),synctex_node_v(child));
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create glue record (2).\n");
return -1;
}
} else if(*PTR == '$') {
@@ -1614,6 +1761,7 @@ horizontal_loop:
|| _synctex_decode_int(scanner,(int*)(info+HORIZ))
|| _synctex_decode_int(scanner,(int*)(info+VERT))
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Bad math record (2).\n");
return -1;
}
SET_SIBLING(child,sibling);
@@ -1622,29 +1770,35 @@ horizontal_loop:
child = sibling;
goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Can't create math record (2).\n");
return -1;
}
} else if(*PTR == '}') {
++PTR;
if(!parent || parent->class->type != synctex_node_type_sheet
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Unexpected end of vbox (2).\n");
return -1;
}
return 0;
} else if(*PTR == '!') {
++PTR;
if(_synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Missing anchor (2).\n");
return -1;
}
goto horizontal_loop;
} else {
- printf("SyncTeX: Ignored record %c\n",*PTR);
+ printf("SyncTeX Error: Ignored record %c(2)\n",*PTR);
if(_synctex_next_line(scanner)) {
return -1;
}
goto horizontal_loop;
}
+ } else if(_synctex_fill_buffer_up_to_size(scanner,-1)>0){
+ goto horizontal_loop;
} else {
+ printf("SyncTeX Error: Uncomplete sheet(2)\n");
return -1;
}
}
@@ -1652,6 +1806,7 @@ horizontal_loop:
/* Used when parsing the synctex file
*/
int _synctex_scan_content(synctex_scanner_t scanner) {
+ synctex_node_t sheet = NULL;
if(NULL == scanner) {
return -1;
}
@@ -1660,24 +1815,25 @@ int _synctex_scan_content(synctex_scanner_t scanner) {
scanner->number_of_lists = 1024;
scanner->lists_of_friends = (synctex_node_t *)_synctex_malloc(scanner->number_of_lists*sizeof(synctex_node_t));
if(NULL == scanner->lists_of_friends) {
- printf("malloc:2\n");
+ printf("SyncTeX Error: malloc:2\n");
return -1;
}
}
/* Find where this section starts */
- while(strncmp((char *)PTR,"Content:",8)) {
+ while(_synctex_scan_string(scanner,"Content:")) {
if(_synctex_next_line(scanner)) {
return -1;
}
}
- PTR += 8;
if(_synctex_next_line(scanner)) {
+printf("SyncTeX Error: Uncomplete file.\n");
return -1;
}
next_sheet:
if(*PTR != '{') {
if(_synctex_scan_postamble(scanner)) {
if(_synctex_next_line(scanner)) {
+printf("SyncTeX Error: Uncomplete sheet.\n");
return -1;
}
goto next_sheet;
@@ -1686,14 +1842,16 @@ next_sheet:
}
++PTR;
/* Create a new sheet node */
- synctex_node_t sheet = _synctex_new_sheet(scanner);
+ sheet = _synctex_new_sheet(scanner);
if(_synctex_decode_int(scanner,INFO(sheet)+PAGE)
|| _synctex_next_line(scanner)) {
+ printf("SyncTeX Error: Missing sheet number.\n");
bail:
FREE(sheet);
return -1;
}
if(_synctex_scan_sheet(scanner,sheet)) {
+ printf("SyncTeX Error: Bad sheet content.\n");
goto bail;
}
SET_SIBLING(sheet,scanner->sheet);
@@ -1704,9 +1862,10 @@ bail:
}
/* Where the synctex scanner is created.
- * name is the full path of the synctex file. */
+ * name is the full path of the uncompressed synctex file. */
synctex_scanner_t synctex_scanner_new_with_contents_of_file(const char * name) {
synctex_scanner_t scanner = (synctex_scanner_t)_synctex_malloc(sizeof(_synctex_scanner_t));
+ int size = 0;
if(NULL == scanner) {
return NULL;
}
@@ -1731,42 +1890,41 @@ synctex_scanner_t synctex_scanner_new_with_contents_of_file(const char * name) {
(scanner->class[synctex_node_type_math]).scanner = scanner;
scanner->class[synctex_node_type_input] = synctex_class_input;
(scanner->class[synctex_node_type_input]).scanner = scanner;
-
- FILE * F = fopen(name,"r");
+ F = gzopen(name,"r");
if(NULL == F) {
printf("SyncTeX: could not open %s, error %i\n",name,errno);
bail:
synctex_scanner_free(scanner);
return NULL;
}
- if(fseek(F, 0, SEEK_END)) {
- close(F);
- goto bail;
- }
- size_t size = ftell(F);
- rewind(F);
- START = (unsigned char *)malloc(size+1);
+ START = (unsigned char *)malloc(SYNCTEX_BUF_SIZE+1);
if(NULL == START) {
- printf("malloc error\n");
- close(F);
+ printf("SyncTeX: malloc error\n");
+ gzclose(F);
goto bail;
}
- if(size != fread((void *)START, 1, size, F)) {
+ START[SYNCTEX_BUF_SIZE] = '\0';
+ PTR = START;
+ END = START+SYNCTEX_BUF_SIZE;
+ size = gzread(F,(void *)START, SYNCTEX_BUF_SIZE);
+ if(!size) {
+ printf("SyncTeX: No gzread content\n");
bailey:
- close(F);
+ gzclose(F);
goto bail;
}
- close(F);
- START[size] = '\0'; /* ensure null termination */
- /* first read the beginning */
- END = START + size;
- PTR = START;
- if(_synctex_scan_preamble(scanner)
- || _synctex_scan_content(scanner)) {
+ if(_synctex_scan_preamble(scanner)) {
+ printf("SyncTeX: Bad preamble\n");
+ goto bailey;
+ }
+ if(_synctex_scan_content(scanner)) {
+ printf("SyncTeX: Bad content\n");
goto bailey;
}
free((void *)START);
START = PTR = END = NULL;
+ gzclose(F);
+ F = NULL;
/* Everything is finished, final tuning */
/* 1 pre_unit = (scanner->pre_unit)/65536 pt = (scanner->pre_unit)/65781.76 bp
* 1 pt = 65536 sp */
@@ -1794,6 +1952,7 @@ bailey:
scanner->y_offset /= 65781.76;
}
return scanner;
+ #undef F
}
/* The scanner destructor
@@ -1863,22 +2022,24 @@ void synctex_scanner_display(synctex_scanner_t scanner) {
}
/* Public*/
const char * synctex_scanner_get_name(synctex_scanner_t scanner,int tag) {
+ synctex_node_t input = NULL;
if(NULL == scanner) {
return "";
}
- synctex_node_t input = scanner->input;
+ input = scanner->input;
do {
if(tag == INFO(input)[TAG]) {
return (char *)(INFO(input)[NAME]);
}
} while(input = SIBLING(input));
- return 0;
+ return NULL;
}
int synctex_scanner_get_tag(synctex_scanner_t scanner,const char * name) {
+ synctex_node_t input = NULL;
if(NULL == scanner) {
return 0;
}
- synctex_node_t input = scanner->input;
+ input = scanner->input;
do {
if((strlen(name) == strlen((char *)(INFO(input)[NAME]))) &&
(0 == strncmp(name,(char *)(INFO(input)[NAME]),strlen(name)))) {
@@ -2107,10 +2268,11 @@ result:
#pragma mark -
#pragma mark Other public node attributes
int synctex_node_page(synctex_node_t node){
+ synctex_node_t parent = NULL;
if(!node) {
return -1;
}
- synctex_node_t parent = PARENT(node);
+ parent = PARENT(node);
while(parent) {
node = parent;
parent = PARENT(node);
@@ -2147,15 +2309,17 @@ synctex_node_t synctex_sheet_content(synctex_scanner_t scanner,int page) {
int synctex_display_query(synctex_scanner_t scanner,const char * name,int line,int column) {
int tag = synctex_scanner_get_tag(scanner,name);
+ size_t size = 0;
+ int friend_index = 0;
+ synctex_node_t node = NULL;
if(tag == 0) {
printf("No tag for %s\n",name);
return -1;
}
free(START);
PTR = END = START = NULL;
- size_t size = 0;
- int friend_index = (tag+line)%(scanner->number_of_lists);
- synctex_node_t node = (scanner->lists_of_friends)[friend_index];
+ friend_index = (tag+line)%(scanner->number_of_lists);
+ node = (scanner->lists_of_friends)[friend_index];
while(node) {
if((tag == INFO(node)[TAG]) && (line == INFO(node)[LINE])) {
if(PTR == END) {
@@ -2204,12 +2368,19 @@ int _synctex_point_in_visible_box(float h, float v, synctex_node_t node) {
}
int synctex_edit_query(synctex_scanner_t scanner,int page,float h,float v) {
+ synctex_node_t sheet = NULL;
+ synctex_node_t * start = NULL;
+ synctex_node_t * end = NULL;
+ synctex_node_t * ptr = NULL;
+ size_t size = 0;
+ synctex_node_t node = NULL;
+ synctex_node_t next = NULL;
if(NULL == scanner) {
return 0;
}
free(START);
START = END = PTR = NULL;
- synctex_node_t sheet = scanner->sheet;
+ sheet = scanner->sheet;
while(INFO(sheet)[PAGE] != page) {
sheet = SIBLING(sheet);
}
@@ -2218,12 +2389,7 @@ int synctex_edit_query(synctex_scanner_t scanner,int page,float h,float v) {
}
/* Now sheet points to the sheet node with proper page number */
/* Declare memory storage, a buffer to hold found nodes */
- synctex_node_t * start = NULL;
- synctex_node_t * end = NULL;
- synctex_node_t * ptr = NULL;
- size_t size = 0;
- synctex_node_t node = CHILD(sheet); /* start with the child of the sheet */
- synctex_node_t next;
+ node = CHILD(sheet); /* start with the child of the sheet */
has_node_any_child:
if(next = CHILD(node)) {
/* node is a non void box */
@@ -2278,14 +2444,17 @@ next_sibling:
}
/* This is the last node at this level
* The next step is the parent's sibling */
- next = PARENT(node);
- if(ptr && *ptr == next) {
- /* No included box does contain the point
- * next was already tagged to contain the hit point
- * but was not fully registered at that time, now we can increment ptr */
- ++ptr;
- *ptr = NULL;
- } else if(next == sheet) {
+ next = PARENT(node);
+ if(ptr && *ptr == next) {
+ /* No included box does contain the point
+ * next was already tagged to contain the hit point
+ * but was not fully registered at that time, now we can increment ptr */
+ ++ptr;
+ *ptr = NULL;
+ } else if(next == sheet) {
+ float best;
+ float candidate;
+ synctex_node_t * best_node_ref = NULL;
we_are_done:
end = ptr;
ptr = NULL;
@@ -2298,9 +2467,7 @@ we_are_done:
* This is in general the expected box in LaTeX picture environment. */
ptr = start;
node = *ptr;
- float best = synctex_node_box_visible_width(node);
- float candidate;
- synctex_node_t * best_node_ref = NULL;
+ best = synctex_node_box_visible_width(node);
while(node = *(++ptr)) {
candidate = synctex_node_box_visible_width(node);
if(candidate<best) {
@@ -2317,8 +2484,8 @@ we_are_done:
* Working with boxes is not very accurate because in general boxes are created asynchronously.
* The glue, kern, math are more appropriate for synchronization. */
if(node = CHILD(*start)) {
- best = INFINITY;
synctex_node_t best_node = NULL;
+ best = INFINITY;
do {
switch((node->class)->type) {
default:
@@ -2375,9 +2542,25 @@ int synctex_bail(void) {
#pragma mark -
#pragma mark TESTS
/* This is not public, it is not up to date */
+int _synctex_scan_next_line_header(synctex_scanner_t scanner, unsigned char * valueRef) {
+ if(NULL == scanner || NULL == valueRef) return -1;
+ /* read until the next '\0' byte, return the following one */
+ while(PTR<END) {
+ if(*PTR=='\0') {
+ if(++PTR<END) {
+ *valueRef = *(PTR++);
+ return 0;
+ }
+ } else {
+ ++PTR;
+ }
+ }
+ return -1;
+}
synctex_scanner_t synctex_scanner_new_with_data(const void * bytes, unsigned int length) {
synctex_scanner_t scanner = (synctex_scanner_t)_synctex_malloc(sizeof(_synctex_scanner_t));
if(NULL != scanner) {
+ unsigned char the_char;
START = (void *)bytes;
if(UINT_MAX-length<(int)(START)) {
bail:
@@ -2387,7 +2570,6 @@ bail:
END = START+length;
scanner->pre_unit = 8192;
scanner->pre_x_offset = scanner->pre_y_offset = 578;
- unsigned char the_char;
if(_synctex_scan_preamble(scanner)) {
goto bail;
}
@@ -2403,21 +2585,6 @@ bail:
return scanner;
}
-int _synctex_scan_next_line_header(synctex_scanner_t scanner, unsigned char * valueRef) {
- if(NULL == scanner || NULL == valueRef) return -1;
- /* read until the next '\0' byte, return the following one */
- while(PTR<END) {
- if(*PTR=='\0') {
- if(++PTR<END) {
- *valueRef = *(PTR++);
- return 0;
- }
- } else {
- ++PTR;
- }
- }
- return -1;
-}
int synctex_jump(synctex_scanner_t scanner)
{
unsigned char the_char;
@@ -2467,136 +2634,3 @@ next:
}
return 0;
}
-int synctex_test(void) {
- printf("sizeof(synctex_sheet_t):%i\n",sizeof(synctex_sheet_t));
- printf("sizeof(synctex_vert_box_node_t):%i\n",sizeof(synctex_vert_box_node_t));
- printf("sizeof(synctex_horiz_box_node_t):%i\n",sizeof(synctex_horiz_box_node_t));
- printf("sizeof(synctex_void_box_node_t):%i\n",sizeof(synctex_void_box_node_t));
- printf("sizeof(synctex_medium_node_t):%i\n",sizeof(synctex_medium_node_t));
- /* TESTING */
- synctex_node_t node;
- synctex_node_t child;
- synctex_node_t next;
- #define TEST(LABEL,constructor)\
- printf("TESTING constructor:%s\n",LABEL);\
- node = constructor(NULL);\
- LOG(node);\
- FREE(node);
- TEST(("_synctex_new_sheet"),_synctex_new_sheet);
- TEST(("_synctex_new_vbox"),_synctex_new_vbox);
- TEST(("_synctex_new_hbox"),_synctex_new_hbox);
- TEST(("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST(("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST(("_synctex_new_math"),_synctex_new_math);
- TEST(("_synctex_new_kern"),_synctex_new_kern);
- TEST(("_synctex_new_glue"),_synctex_new_glue);
- printf("...... ALL constructor tested\n\n\n\n");
- #undef TEST
- #define TEST(PARENT_LABEL,PARENT_CONSTRUCTOR,CHILD_LABEL,CHILD_CONSTRUCTOR)\
- printf("TESTING parent:%s -> child:%s\n",PARENT_LABEL,CHILD_LABEL);\
- node = PARENT_CONSTRUCTOR(NULL);\
- child = CHILD_CONSTRUCTOR(NULL);\
- DISPLAY(node);\
- DISPLAY(child);\
- SET_CHILD(node,child);\
- DISPLAY(node);\
- DISPLAY(child);\
- if((CHILD(node) != child) || (node != PARENT(child))) {\
- return synctex_bail();\
- }\
- FREE(node);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_sheet",_synctex_new_sheet,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_glue"),_synctex_new_glue);
-// TEST("_synctex_new_sheet","",_synctex_new_sheet,);
-// TEST("","",,);
- #undef TEST
- #define TEST(CHILD_LABEL,CHILD_CONSTRUCTOR,SIBLING_LABEL,SIBLING_CONSTRUCTOR)\
- printf("TESTING child:%s -> next:%s\n",CHILD_LABEL,SIBLING_LABEL);\
- node = _synctex_new_sheet(NULL);\
- child = CHILD_CONSTRUCTOR(NULL);\
- next = SIBLING_CONSTRUCTOR(NULL);\
- DISPLAY(node);\
- DISPLAY(child);\
- DISPLAY(next);\
- SET_CHILD(node,child);\
- SET_SIBLING(child,next);\
- DISPLAY(node);\
- DISPLAY(child);\
- DISPLAY(next);\
- if((SIBLING(child) != next) || (node != PARENT(next))) {\
- return synctex_bail();\
- }\
- FREE(node);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_vbox",_synctex_new_vbox,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_hbox",_synctex_new_hbox,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_void_vbox",_synctex_new_void_vbox,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_void_hbox",_synctex_new_void_hbox,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_math",_synctex_new_math,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_kern",_synctex_new_kern,("_synctex_new_glue"),_synctex_new_glue);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_vbox"),_synctex_new_vbox);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_hbox"),_synctex_new_hbox);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_void_vbox"),_synctex_new_void_vbox);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_void_hbox"),_synctex_new_void_hbox);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_math"),_synctex_new_math);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_kern"),_synctex_new_kern);
- TEST("_synctex_new_glue",_synctex_new_glue,("_synctex_new_glue"),_synctex_new_glue);
-
- return 0;
-
-}
-