From c4707bd5bdd25bf9fc751a66917a009b4ff15d02 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Fri, 22 Jan 2010 18:00:20 +0000 Subject: texk/web2c/synctex: compiler warnings git-svn-id: svn://tug.org/texlive/trunk@16800 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/Makefile.in | 2 +- Build/source/texk/web2c/synctexdir/ChangeLog | 18 +++++++ Build/source/texk/web2c/synctexdir/am/synctex.am | 4 +- Build/source/texk/web2c/synctexdir/synctex_main.c | 4 ++ .../source/texk/web2c/synctexdir/synctex_parser.c | 61 ++++++++++++---------- .../texk/web2c/synctexdir/synctex_parser_utils.c | 24 ++++----- .../texk/web2c/synctexdir/synctex_parser_utils.h | 8 ++- 7 files changed, 74 insertions(+), 47 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index f6375aa09ec..bc97eee3388 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -2173,7 +2173,7 @@ synctex_SOURCES = \ synctexdir/synctex_parser_utils.c synctex_CPPFLAGS = -I$(srcdir)/synctexdir $(ZLIB_INCLUDES) -DSYNCTEX_USE_LOCAL_HEADER -synctex_CFLAGS = # $(WARNING_CFLAGS) +synctex_CFLAGS = $(WARNING_CFLAGS) synctex_LDADD = $(ZLIB_LIBS) @TEX_SYNCTEX_TRUE@tex_ch_synctex = \ @TEX_SYNCTEX_TRUE@ synctexdir/synctex-mem.ch0 \ diff --git a/Build/source/texk/web2c/synctexdir/ChangeLog b/Build/source/texk/web2c/synctexdir/ChangeLog index 838aa043b6f..6f3dbc92d62 100644 --- a/Build/source/texk/web2c/synctexdir/ChangeLog +++ b/Build/source/texk/web2c/synctexdir/ChangeLog @@ -1,3 +1,21 @@ +2010-01-22 Peter Breitenlohner + + * am/synctex.am: Enable compiler warnings. + Avoid compiler warnings: + * synctex_main.c: Define _ISOC99_SOURCE to get fmax() prototype + FIXME: Linux only? + * synctex_parser_utils.h: Move declaration of synctex_io_modes ... + * synctex_parser.c: ... to here. + * synctex_parser_utils.h: Declare synctex_suffix{,_gz} extern ... + * synctex_parser.c: ... and instantiate here. + * synctex_parser_utils.[ch]: Constify _synctex_last_path_component() + return type. + * synctex_parser.c (__synctex_scanner_t): Change type of struct + members buffer_{cur,start,end} from 'unsigned char *' to 'char *' + and remove the casts. + (_synctex_class_t synctex_class_*): Declare as non-const. + (_synctex_scan_named): Constify string param `name'. + 2010-01-10 Jérôme Laurens * synctex_parser.c: in the _synctex_smallest_container() function, diff --git a/Build/source/texk/web2c/synctexdir/am/synctex.am b/Build/source/texk/web2c/synctexdir/am/synctex.am index 730f4b27edd..0b1c06f9dfd 100644 --- a/Build/source/texk/web2c/synctexdir/am/synctex.am +++ b/Build/source/texk/web2c/synctexdir/am/synctex.am @@ -1,6 +1,6 @@ ## texk/web2c/synctexdir/am/synctex.am: Makefile fragment for SyncTeX. ## -## Copyright (C) 2009 Peter Breitenlohner +## Copyright (C) 2009, 2010 Peter Breitenlohner ## You may freely use, modify and/or distribute this file. ## The SyncTeX tool @@ -16,7 +16,7 @@ synctex_SOURCES = \ synctexdir/synctex_parser_utils.c synctex_CPPFLAGS = -I$(srcdir)/synctexdir $(ZLIB_INCLUDES) -DSYNCTEX_USE_LOCAL_HEADER -synctex_CFLAGS = # $(WARNING_CFLAGS) +synctex_CFLAGS = $(WARNING_CFLAGS) synctex_LDADD = $(ZLIB_LIBS) diff --git a/Build/source/texk/web2c/synctexdir/synctex_main.c b/Build/source/texk/web2c/synctexdir/synctex_main.c index e8436943b1d..489c621afa8 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_main.c +++ b/Build/source/texk/web2c/synctexdir/synctex_main.c @@ -57,6 +57,10 @@ 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 + # include "web2c/c-auto.h" /* for inline && HAVE_xxx */ # include 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 +/* 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); diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c index e344beab1d7..0aef5777dbb 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.c @@ -185,24 +185,24 @@ synctex_bool_t _synctex_path_is_absolute(const char * name) { } /* We do not take care of UTF-8 */ -char * _synctex_last_path_component(const char * name) { +const char * _synctex_last_path_component(const char * name) { const char * c = name+strlen(name); if(c>name) { if(!SYNCTEX_IS_PATH_SEPARATOR(*c)) { do { --c; if(SYNCTEX_IS_PATH_SEPARATOR(*c)) { - return (char *)c+1; + return c+1; } } while(c>name); } - return (char *)c;/* the last path component is the void string*/ + return c;/* the last path component is the void string*/ } - return (char *)c; + return c; } int _synctex_copy_with_quoting_last_path_component(const char * src, char ** dest_ref, size_t size) { - char * lpc; + const char * lpc; if(src && dest_ref) { # define dest (*dest_ref) dest = NULL; /* Default behavior: no change and sucess. */ @@ -215,17 +215,17 @@ int _synctex_copy_with_quoting_last_path_component(const char * src, char ** des * or equivalently: strlen(dest)+20) { /* Yes, we do. */ - char * temp = NULL; + const char * temp = NULL; char * corename = NULL; /* base name of output without path extension. */ char * dirname = NULL; /* dir name of output */ char * quoted_corename = NULL; @@ -385,7 +385,7 @@ int _synctex_get_name(const char * output, const char * build_directory, char ** } } if(!_synctex_path_is_absolute(output) && build_directory && (size = strlen(build_directory))) { - temp = (char *)build_directory + size - 1; + temp = build_directory + size - 1; if(_synctex_path_is_absolute(temp)) { build = _synctex_merge_strings(build_directory,none,NULL); if(quoted_corename && strlen(quoted_corename)>0) { diff --git a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h index 5999f72d6e3..e28ff58ade0 100644 --- a/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h +++ b/Build/source/texk/web2c/synctexdir/synctex_parser_utils.h @@ -86,7 +86,7 @@ synctex_bool_t _synctex_is_equivalent_file_name(const char *lhs, const char *rhs synctex_bool_t _synctex_path_is_absolute(const char * name); /* Description forthcoming...*/ -char * _synctex_last_path_component(const char * name); +const char * _synctex_last_path_component(const char * name); /* If the core of the last path component of src is not already enclosed with double quotes ('"') * and contains a space character (' '), then a new buffer is created, the src is copied and quotes are added. @@ -100,8 +100,8 @@ char * _synctex_last_path_component(const char * name); int _synctex_copy_with_quoting_last_path_component(const char * src, char ** dest_ref, size_t size); /* These are the possible extensions of the synctex file */ -static const char * synctex_suffix = ".synctex"; -static const char * synctex_suffix_gz = ".gz"; +extern const char * synctex_suffix; +extern const char * synctex_suffix_gz; typedef enum { synctex_io_mode_read = 0, @@ -113,8 +113,6 @@ typedef enum { synctex_compress_mode_gz = 1 } synctex_compress_mode_t; -static const char * synctex_io_modes[synctex_io_mode_append+2] = {"r","rb","a","ab"}; - int _synctex_get_name(const char * output, const char * build_directory, char ** synctex_name_ref, synctex_compress_mode_t * compress_mode_ref); -- cgit v1.2.3