From e9a83f0653a06b8ff6f90dd3bf6c4e206a3750ca Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 20 Jul 2007 16:11:14 +0200 Subject: [PATCH] string constants are of type const char * (not char *) Recent gcc's complain about this typing problem. --- src/basesuif/scripts/ver_create_ver_cc | 6 +++--- src/basesuif/suif1/cmdparse.cc | 8 ++++---- src/basesuif/suif1/cmdparse.h | 4 ++-- src/basesuif/suif1/initsuif.cc | 2 +- src/basesuif/suif1/initsuif.h | 12 ++++++------ src/basesuif/suif1/misc.cc | 4 ++-- src/basesuif/suif1/misc.h | 4 ++-- src/suifbuilder/builder/builder.cc | 4 ++-- src/suifbuilder/builder/builder_internals.h | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/basesuif/scripts/ver_create_ver_cc b/src/basesuif/scripts/ver_create_ver_cc index 7eff445..3eba09f 100755 --- a/src/basesuif/scripts/ver_create_ver_cc +++ b/src/basesuif/scripts/ver_create_ver_cc @@ -46,7 +46,7 @@ rm -f ${1} touch ${1} echo "/* Generated automatically by the SUIF makefiles. */" >> ${1} echo >> ${1} -echo "char *"${2}"_ver_string = \""${prog_version}"\";" >> ${1} -echo "char *"${2}"_who_string = \"compiled "`date`" by "`whoami`" on" \ +echo "const char *"${2}"_ver_string = \""${prog_version}"\";" >> ${1} +echo "const char *"${2}"_who_string = \"compiled "`date`" by "`whoami`" on" \ `hostname`"\";" >> ${1} -echo "char *"${2}"_suif_string = \""${suif_system_version}"\";" >> ${1} +echo "const char *"${2}"_suif_string = \""${suif_system_version}"\";" >> ${1} diff --git a/src/basesuif/suif1/cmdparse.cc b/src/basesuif/suif1/cmdparse.cc index 51dee79..e0cf65a 100644 --- a/src/basesuif/suif1/cmdparse.cc +++ b/src/basesuif/suif1/cmdparse.cc @@ -26,7 +26,7 @@ RCS_BASE( */ static int -parse_cmd_line_int(char *s) +parse_cmd_line_int(const char *s) { int ret_int; @@ -59,11 +59,11 @@ parse_cmd_line (int &argc, char *argv[], cmd_line_option clos[], int nclos) *(double*)clos[i].data = atof(clos[i].deflt); break; case CLO_STRING: - *(char**)clos[i].data = clos[i].deflt; + *(const char**)clos[i].data = clos[i].deflt; break; case CLO_MULTI_STRING: elem_num[i] = 0; - (*(char ***)clos[i].data)[0] = clos[i].deflt; + (*(const char ***)clos[i].data)[0] = clos[i].deflt; break; default: assert_msg(FALSE, ("parse_cmd_line - unknown argument kind %d", @@ -110,7 +110,7 @@ parse_cmd_line (int &argc, char *argv[], cmd_line_option clos[], int nclos) (*(const char ***)(clos[i].data))[elem_num[i]] = const_string(argv[ap+1]); ++(elem_num[i]); - (*(char ***)(clos[i].data))[elem_num[i]] = clos[i].deflt; + (*(const char ***)(clos[i].data))[elem_num[i]] = clos[i].deflt; break; } int ap2 = ap; diff --git a/src/basesuif/suif1/cmdparse.h b/src/basesuif/suif1/cmdparse.h index e01126d..5c678c0 100644 --- a/src/basesuif/suif1/cmdparse.h +++ b/src/basesuif/suif1/cmdparse.h @@ -26,8 +26,8 @@ enum cmd_line_option_kind { struct cmd_line_option { cmd_line_option_kind knd; - char *name; - char *deflt; + const char *name; + const char *deflt; void *data; }; diff --git a/src/basesuif/suif1/initsuif.cc b/src/basesuif/suif1/initsuif.cc index 78cfec7..c2f7acf 100644 --- a/src/basesuif/suif1/initsuif.cc +++ b/src/basesuif/suif1/initsuif.cc @@ -76,7 +76,7 @@ static void exit_suif_internal(); */ void -register_library (char *nm, char *ver, char *info, +register_library (const char *nm, const char *ver, const char *info, lib_init_f init_f, lib_exit_f exit_f) { if ((suif_libraries != NULL) && initializations_done) { diff --git a/src/basesuif/suif1/initsuif.h b/src/basesuif/suif1/initsuif.h index 03259aa..073ca01 100644 --- a/src/basesuif/suif1/initsuif.h +++ b/src/basesuif/suif1/initsuif.h @@ -32,9 +32,9 @@ typedef void (*lib_init_f)(int& argc, char *argv[]); typedef void (*lib_exit_f)(); struct suif_library { - char *name; /* name of the library (e.g. "suif") */ - char *version; /* the library version */ - char *compile_info; /* who/when/where was it compiled */ + const char *name; /* name of the library (e.g. "suif") */ + const char *version; /* the library version */ + const char *compile_info; /* who/when/where was it compiled */ lib_init_f initializer; /* function to initialize it */ lib_exit_f finalizer; /* function to deallocate storage */ }; @@ -42,7 +42,7 @@ struct suif_library { DECLARE_DLIST_CLASS(library_list, suif_library*); EXPORTED_BY_SUIF library_list *suif_libraries; /* list of registered libraries */ -void register_library(char *nm, char *ver, char *info, +void register_library(const char *nm, const char *ver, const char *info, lib_init_f init_f=NULL, lib_exit_f exit_f=NULL); void start_suif(int& argc, char *argv[]); @@ -51,8 +51,8 @@ void init_suif(int& argc, char *argv[]); extern "C" void exit_suif1(void); #define LIBRARY(name, init_f, exit_f) \ - EXPORTED_BY_SUIF char *lib ## name ## _ver_string; \ - EXPORTED_BY_SUIF char *lib ## name ## _who_string; \ + EXPORTED_BY_SUIF const char *lib ## name ## _ver_string; \ + EXPORTED_BY_SUIF const char *lib ## name ## _who_string; \ EXPORTED_BY_SUIF void init_f(int& argc, char *argv[]); \ EXPORTED_BY_SUIF void exit_f(); \ register_library(#name, lib ## name ## _ver_string, \ diff --git a/src/basesuif/suif1/misc.cc b/src/basesuif/suif1/misc.cc index ab8e2b0..c671e0c 100644 --- a/src/basesuif/suif1/misc.cc +++ b/src/basesuif/suif1/misc.cc @@ -170,9 +170,9 @@ within_expr (instruction *dst, instruction *src) /*****************************************************************************/ -char *__suif_assert_file = NULL; +const char *__suif_assert_file = NULL; int __suif_assert_line = -1; -char *__suif_assert_module = NULL; +const char *__suif_assert_module = NULL; jmp_buf * _suif_longjmp_env = NULL; diff --git a/src/basesuif/suif1/misc.h b/src/basesuif/suif1/misc.h index 95ee42b..b31ee8b 100644 --- a/src/basesuif/suif1/misc.h +++ b/src/basesuif/suif1/misc.h @@ -194,8 +194,8 @@ extern void pop_clue(annote *the_annote); } \ } -EXPORTED_BY_SUIF char *__suif_assert_file; -EXPORTED_BY_SUIF char *__suif_assert_module; +EXPORTED_BY_SUIF const char *__suif_assert_file; +EXPORTED_BY_SUIF const char *__suif_assert_module; EXPORTED_BY_SUIF int __suif_assert_line; extern void __suif_assert_msg(const char* ...); diff --git a/src/suifbuilder/builder/builder.cc b/src/suifbuilder/builder/builder.cc index 103f771..6eee02b 100644 --- a/src/suifbuilder/builder/builder.cc +++ b/src/suifbuilder/builder/builder.cc @@ -1231,7 +1231,7 @@ type_node * block::parse_type(base_symtab * st, const char * c, * Error handler * ***************************************************************************/ -void builder_base::error_internal(char *fmt, va_list args) +void builder_base::error_internal(const char *fmt, va_list args) { char * out; @@ -1267,7 +1267,7 @@ void builder_base::error_internal(char *fmt, va_list args) error_file = NULL; } -void builder_base::error(error_type et, char *fmt, ...) +void builder_base::error(error_type et, const char *fmt, ...) { va_list args; diff --git a/src/suifbuilder/builder/builder_internals.h b/src/suifbuilder/builder/builder_internals.h index 53d3564..a8d7324 100644 --- a/src/suifbuilder/builder/builder_internals.h +++ b/src/suifbuilder/builder/builder_internals.h @@ -76,9 +76,9 @@ protected: static tree_proc * proc; static block_symtab * BlockSymTab; - static void error_internal(char *fmt, va_list args); + static void error_internal(const char *fmt, va_list args); public: - static void error(error_type, char *fmt,...); + static void error(error_type, const char *fmt,...); static void _error(char *fmt,...); static void _error_set(error_type t, char * f, int l) { error_level = t; error_file = f; -- 2.11.4.GIT