From dac89e16d479366c5e79da4de29898af97262d23 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Nov 2012 20:30:37 +0000 Subject: [PATCH] const char * correctness fixes (in C code) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13939 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/doh.h | 2 +- Source/DOH/dohint.h | 2 +- Source/DOH/fio.c | 4 ++-- Source/Preprocessor/cpp.c | 4 ++-- Source/Preprocessor/expr.c | 4 ++-- Source/Preprocessor/preprocessor.h | 2 +- Source/Swig/tree.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index a0bd1817c..8071edd4d 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -254,7 +254,7 @@ extern int DohDelmeta(DOH *, const DOH *); /* Utility functions */ -extern void DohEncoding(char *name, DOH *(*fn) (DOH *s)); +extern void DohEncoding(const char *name, DOH *(*fn) (DOH *s)); extern int DohPrintf(DOHFile * obj, const char *format, ...); extern int DohvPrintf(DOHFile * obj, const char *format, va_list ap); extern int DohPrintv(DOHFile * obj, ...); diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h index 9f5c06272..c073bd95b 100644 --- a/Source/DOH/dohint.h +++ b/Source/DOH/dohint.h @@ -63,7 +63,7 @@ typedef struct { * ----------------------------------------------------------------------------- */ typedef struct DohObjInfo { - char *objname; /* Object name */ + const char *objname; /* Object name */ /* Basic object methods */ void (*doh_del) (DOH *obj); /* Delete object */ diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index 3557b3c37..c4fbb1e8f 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -47,7 +47,7 @@ static int Writen(DOH *out, void *buffer, int len) { * two file-like objects and operate as a filter. * ----------------------------------------------------------------------------- */ -void DohEncoding(char *name, DOH *(*fn) (DOH *s)) { +void DohEncoding(const char *name, DOH *(*fn) (DOH *s)) { if (!encodings) encodings = NewHash(); Setattr(encodings, (void *) name, NewVoid((void *) fn, 0)); @@ -102,7 +102,7 @@ static DOH *encode(char *name, DOH *s) { * ----------------------------------------------------------------------------- */ int DohvPrintf(DOH *so, const char *format, va_list ap) { - static char *fmt_codes = "dioxXucsSfeEgGpn"; + static const char *fmt_codes = "dioxXucsSfeEgGpn"; int state = 0; const char *p = format; char newformat[256]; diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 7e45c5bd4..c16fbe7e5 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1637,7 +1637,7 @@ String *Preprocessor_parse(String *s) { if (Len(sval) > 0) { val = Preprocessor_expr(sval, &e); if (e) { - char *msg = Preprocessor_expr_error(); + const char *msg = Preprocessor_expr_error(); Seek(value, 0, SEEK_SET); Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value); if (msg) @@ -1671,7 +1671,7 @@ String *Preprocessor_parse(String *s) { if (Len(sval) > 0) { val = Preprocessor_expr(sval, &e); if (e) { - char *msg = Preprocessor_expr_error(); + const char *msg = Preprocessor_expr_error(); Seek(value, 0, SEEK_SET); Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value); if (msg) diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index e7470378d..b32665d4a 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -35,7 +35,7 @@ static exprval stack[256]; /* Parsing stack */ static int sp = 0; /* Stack pointer */ static int prec[256]; /* Precedence rules */ static int expr_init = 0; /* Initialization flag */ -static char *errmsg = 0; /* Parsing error */ +static const char *errmsg = 0; /* Parsing error */ /* Initialize the precedence table for various operators. Low values have higher precedence */ static void init_precedence() { @@ -435,6 +435,6 @@ extra_rparen: * Return error message set by the evaluator (if any) * ----------------------------------------------------------------------------- */ -char *Preprocessor_expr_error() { +const char *Preprocessor_expr_error() { return errmsg; } diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index b08ff31b9..4c24f48d0 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -20,7 +20,7 @@ extern "C" { #endif extern int Preprocessor_expr(String *s, int *error); - extern char *Preprocessor_expr_error(void); + extern const char *Preprocessor_expr_error(void); extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro); extern void Preprocessor_undef(const_String_or_char_ptr name); extern void Preprocessor_init(void); diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index af22da156..b5c9d26dc 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -82,7 +82,7 @@ void Swig_print_node(Node *obj) { Printf(stdout, "%-12s - %s\n", k, ParmList_str_defaultargs(Getattr(obj, k))); } else { DOH *o; - char *trunc = ""; + const char *trunc = ""; print_indent(2); if (DohIsString(Getattr(obj, k))) { o = Str(Getattr(obj, k));