diff options
Diffstat (limited to 'Build/source/texk/web2c/synctexdir/synctex_parser.c')
-rw-r--r-- | Build/source/texk/web2c/synctexdir/synctex_parser.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser.c b/Build/source/texk/web2c/synctexdir/synctex_parser.c index fb06768eefb..d6957009e88 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser.c @@ -93,6 +93,12 @@ Thu Jun 19 09:39:21 UTC 2008 #include "synctex_parser.h" #include <synctex_parser_utils.h> +/* These are the possible extensions of the synctex file */ +const char * synctex_suffix = ".synctex"; +const char * synctex_suffix_gz = ".gz"; + +static const char * synctex_io_modes[synctex_io_mode_append+2] = {"r","rb","a","ab"}; + /* each synctex node has a class */ typedef struct __synctex_class_t _synctex_class_t; typedef _synctex_class_t * synctex_class_t; @@ -260,9 +266,9 @@ void _synctex_free_leaf(synctex_node_t node) { */ struct __synctex_scanner_t { gzFile file; /* The (possibly compressed) file */ - unsigned char * buffer_cur; /* current location in the buffer */ - unsigned char * buffer_start; /* start of the buffer */ - unsigned char * buffer_end; /* end of the buffer */ + char * buffer_cur; /* current location in the buffer */ + char * buffer_start; /* start of the buffer */ + char * buffer_end; /* end of the buffer */ char * output_fmt; /* dvi or pdf, not yet used */ char * output; /* the output name used to create the scanner */ char * synctex; /* the .synctex or .synctex.gz name used to create the scanner */ @@ -344,7 +350,7 @@ synctex_node_t _synctex_new_sheet(synctex_scanner_t scanner); void _synctex_display_sheet(synctex_node_t sheet); void _synctex_log_sheet(synctex_node_t sheet); -static const _synctex_class_t synctex_class_sheet = { +static _synctex_class_t synctex_class_sheet = { NULL, /* No scanner yet */ synctex_node_type_sheet, /* Node type */ &_synctex_new_sheet, /* creator */ @@ -406,7 +412,7 @@ void _synctex_display_vbox(synctex_node_t node); /* These are static class objects, each scanner will make a copy of them and setup the scanner field. */ -static const _synctex_class_t synctex_class_vbox = { +static _synctex_class_t synctex_class_vbox = { NULL, /* No scanner yet */ synctex_node_type_vbox, /* Node type */ &_synctex_new_vbox, /* creator */ @@ -459,7 +465,7 @@ void _synctex_display_hbox(synctex_node_t node); void _synctex_log_horiz_box(synctex_node_t sheet); -static const _synctex_class_t synctex_class_hbox = { +static _synctex_class_t synctex_class_hbox = { NULL, /* No scanner yet */ synctex_node_type_hbox, /* Node type */ &_synctex_new_hbox, /* creator */ @@ -497,7 +503,7 @@ synctex_node_t _synctex_new_void_vbox(synctex_scanner_t scanner); void _synctex_log_void_box(synctex_node_t sheet); void _synctex_display_void_vbox(synctex_node_t node); -static const _synctex_class_t synctex_class_void_vbox = { +static _synctex_class_t synctex_class_void_vbox = { NULL, /* No scanner yet */ synctex_node_type_void_vbox,/* Node type */ &_synctex_new_void_vbox, /* creator */ @@ -524,7 +530,7 @@ synctex_node_t _synctex_new_void_vbox(synctex_scanner_t scanner) { synctex_node_t _synctex_new_void_hbox(synctex_scanner_t scanner); void _synctex_display_void_hbox(synctex_node_t node); -static const _synctex_class_t synctex_class_void_hbox = { +static _synctex_class_t synctex_class_void_hbox = { NULL, /* No scanner yet */ synctex_node_type_void_hbox,/* Node type */ &_synctex_new_void_hbox, /* creator */ @@ -570,7 +576,7 @@ void _synctex_log_medium_node(synctex_node_t node); synctex_node_t _synctex_new_math(synctex_scanner_t scanner); void _synctex_display_math(synctex_node_t node); -static const _synctex_class_t synctex_class_math = { +static _synctex_class_t synctex_class_math = { NULL, /* No scanner yet */ synctex_node_type_math, /* Node type */ &_synctex_new_math, /* creator */ @@ -597,7 +603,7 @@ synctex_node_t _synctex_new_math(synctex_scanner_t scanner) { synctex_node_t _synctex_new_kern(synctex_scanner_t scanner); void _synctex_display_kern(synctex_node_t node); -static const _synctex_class_t synctex_class_kern = { +static _synctex_class_t synctex_class_kern = { NULL, /* No scanner yet */ synctex_node_type_kern, /* Node type */ &_synctex_new_kern, /* creator */ @@ -633,7 +639,7 @@ void _synctex_log_small_node(synctex_node_t node); synctex_node_t _synctex_new_glue(synctex_scanner_t scanner); void _synctex_display_glue(synctex_node_t node); -static const _synctex_class_t synctex_class_glue = { +static _synctex_class_t synctex_class_glue = { NULL, /* No scanner yet */ synctex_node_type_glue, /* Node type */ &_synctex_new_glue, /* creator */ @@ -659,7 +665,7 @@ synctex_node_t _synctex_new_glue(synctex_scanner_t scanner) { synctex_node_t _synctex_new_boundary(synctex_scanner_t scanner); void _synctex_display_boundary(synctex_node_t node); -static const _synctex_class_t synctex_class_boundary = { +static _synctex_class_t synctex_class_boundary = { NULL, /* No scanner yet */ synctex_node_type_boundary, /* Node type */ &_synctex_new_boundary, /* creator */ @@ -698,7 +704,7 @@ void _synctex_free_input(synctex_node_t node); void _synctex_display_input(synctex_node_t node); void _synctex_log_input(synctex_node_t sheet); -static const _synctex_class_t synctex_class_input = { +static _synctex_class_t synctex_class_input = { NULL, /* No scanner yet */ synctex_node_type_input, /* Node type */ &_synctex_new_input, /* creator */ @@ -1319,8 +1325,8 @@ return_NOT_OK: * The given scanner argument must not be NULL, on the contrary, value_ref may be NULL. */ synctex_status_t _synctex_decode_int(synctex_scanner_t scanner, int* value_ref) { - unsigned char * ptr = NULL; - unsigned char * end = NULL; + char * ptr = NULL; + char * end = NULL; int result = 0; size_t available = 0; synctex_status_t status = 0; @@ -1343,7 +1349,7 @@ synctex_status_t _synctex_decode_int(synctex_scanner_t scanner, int* value_ref) return SYNCTEX_STATUS_NOT_OK;/* It is not possible to scan an int */ } } - result = (int)strtol((char *)ptr, (char **)&end, 10); + result = (int)strtol(ptr, &end, 10); if(end>ptr) { SYNCTEX_CUR = end; if(value_ref) { @@ -1372,7 +1378,7 @@ synctex_status_t _synctex_decode_int(synctex_scanner_t scanner, int* value_ref) * SYNCTEX_STATUS_BAD_ARGUMENT is returned. */ synctex_status_t _synctex_decode_string(synctex_scanner_t scanner, char ** value_ref) { - unsigned char * end = NULL; + char * end = NULL; size_t current_size = 0; size_t new_size = 0; size_t len = 0;/* The number of bytes to copy */ @@ -1510,7 +1516,7 @@ synctex_status_t _synctex_scan_input(synctex_scanner_t scanner) { typedef synctex_status_t (*synctex_decoder_t)(synctex_scanner_t,void *); -synctex_status_t _synctex_scan_named(synctex_scanner_t scanner,char * name,void * value_ref,synctex_decoder_t decoder); +synctex_status_t _synctex_scan_named(synctex_scanner_t scanner,const char * name,void * value_ref,synctex_decoder_t decoder); /* Used when parsing the synctex file. * Read one of the settings. @@ -1520,7 +1526,7 @@ synctex_status_t _synctex_scan_named(synctex_scanner_t scanner,char * name,void * On return, the scanner points to the next character after the decoded object whatever it is. * It is the responsibility of the caller to prepare the scanner for the next line. */ -synctex_status_t _synctex_scan_named(synctex_scanner_t scanner,char * name,void * value_ref,synctex_decoder_t decoder) { +synctex_status_t _synctex_scan_named(synctex_scanner_t scanner,const char * name,void * value_ref,synctex_decoder_t decoder) { synctex_status_t status = 0; if(NULL == scanner || NULL == name || NULL == value_ref || NULL == decoder) { return SYNCTEX_STATUS_BAD_ARGUMENT; @@ -1607,7 +1613,7 @@ synctex_status_t _synctex_scan_preamble(synctex_scanner_t scanner) { /* parse a float with a dimension */ synctex_status_t _synctex_scan_float_and_dimension(synctex_scanner_t scanner, float * value_ref) { synctex_status_t status = 0; - unsigned char * endptr = NULL; + char * endptr = NULL; float f = 0; #ifdef HAVE_SETLOCALE char * loc = setlocale(LC_NUMERIC, NULL); @@ -1625,7 +1631,7 @@ synctex_status_t _synctex_scan_float_and_dimension(synctex_scanner_t scanner, fl #ifdef HAVE_SETLOCALE setlocale(LC_NUMERIC, "C"); #endif - f = strtod((char *)SYNCTEX_CUR,(char **)&endptr); + f = strtod(SYNCTEX_CUR,&endptr); #ifdef HAVE_SETLOCALE setlocale(LC_NUMERIC, loc); #endif @@ -1690,7 +1696,7 @@ report_unit_error: * a negative error is returned otherwise */ synctex_status_t _synctex_scan_post_scriptum(synctex_scanner_t scanner) { synctex_status_t status = 0; - unsigned char * endptr = NULL; + char * endptr = NULL; #ifdef HAVE_SETLOCALE char * loc = setlocale(LC_NUMERIC, NULL); #endif @@ -1726,7 +1732,7 @@ next_line: #ifdef HAVE_SETLOCALE setlocale(LC_NUMERIC, "C"); #endif - scanner->unit = strtod((char *)SYNCTEX_CUR,(char **)&endptr); + scanner->unit = strtod(SYNCTEX_CUR,&endptr); #ifdef HAVE_SETLOCALE setlocale(LC_NUMERIC, loc); #endif @@ -2659,7 +2665,8 @@ int _synctex_open(const char * output, const char * build_directory, char ** syn # define the_file (*file_ref) int result = __synctex_open(output,synctex_name_ref,file_ref,add_quotes,io_modeRef); if((result || !*file_ref) && build_directory && strlen(build_directory)) { - char * build_output, *lpc; + char * build_output; + const char * lpc; size_t size; synctex_bool_t is_absolute; build_output = NULL; @@ -2676,7 +2683,7 @@ int _synctex_open(const char * output, const char * build_directory, char ** syn if(build_output != strcpy(build_output,output)) { return -4; } - *(lpc+(build_output-output))='\0'; + build_output[lpc-output]='\0'; } if(build_output == strcat(build_output,build_directory)) { /* Append a path separator if necessary. */ @@ -2752,7 +2759,7 @@ synctex_scanner_t synctex_scanner_parse(synctex_scanner_t scanner) { (scanner->class[synctex_node_type_math]).scanner = scanner; scanner->class[synctex_node_type_boundary] = synctex_class_boundary; (scanner->class[synctex_node_type_boundary]).scanner = scanner; - SYNCTEX_START = (unsigned char *)malloc(SYNCTEX_BUFFER_SIZE+1); /* one more character for null termination */ + SYNCTEX_START = (char *)malloc(SYNCTEX_BUFFER_SIZE+1); /* one more character for null termination */ if(NULL == SYNCTEX_START) { _synctex_error("SyncTeX: malloc error"); synctex_scanner_free(scanner); @@ -3310,7 +3317,7 @@ int synctex_display_query(synctex_scanner_t scanner,const char * name,int line,i goto next_end; } start_ref += 1; - SYNCTEX_END = (unsigned char *)start_ref; + SYNCTEX_END = (char *)start_ref; } SYNCTEX_CUR = NULL; return (SYNCTEX_END-SYNCTEX_START)/sizeof(synctex_node_t); |