summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoyu Bai <divinekid@gmail.com>2009-01-28 16:10:16 +0000
committerHaoyu Bai <divinekid@gmail.com>2009-01-28 16:10:16 +0000
commit320f2f065f4926e72232c5ae7e735e30aac97a31 (patch)
treedc5e8ff8755b586af8c672a383b477aa685581a4
parentafed10e1b5a8456ec8c448072a6d165218df1057 (diff)
downloadswig-320f2f065f4926e72232c5ae7e735e30aac97a31.tar.gz
Change the return type of Char(x) from 'char *' to 'const char *'. Also corrected the const-ness of (nearly) all the variables used to store the return value of Char(x). (And propagated const-correctness for more functions and variables.)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0@11091 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Source/CParse/cparse.h2
-rw-r--r--Source/CParse/cscanner.c8
-rw-r--r--Source/CParse/parser.y84
-rw-r--r--Source/CParse/templ.c4
-rw-r--r--Source/DOH/base.c2
-rw-r--r--Source/DOH/doh.h8
-rw-r--r--Source/DOH/dohint.h2
-rw-r--r--Source/DOH/file.c8
-rw-r--r--Source/DOH/fio.c10
-rw-r--r--Source/DOH/string.c18
-rw-r--r--Source/Modules/allegrocl.cxx39
-rw-r--r--Source/Modules/cffi.cxx18
-rw-r--r--Source/Modules/chicken.cxx2
-rw-r--r--Source/Modules/clisp.cxx5
-rw-r--r--Source/Modules/emit.cxx2
-rw-r--r--Source/Modules/guile.cxx2
-rw-r--r--Source/Modules/lang.cxx23
-rw-r--r--Source/Modules/lua.cxx2
-rw-r--r--Source/Modules/main.cxx8
-rw-r--r--Source/Modules/modula3.cxx4
-rw-r--r--Source/Modules/mzscheme.cxx2
-rw-r--r--Source/Modules/ocaml.cxx6
-rw-r--r--Source/Modules/octave.cxx2
-rw-r--r--Source/Modules/perl5.cxx14
-rw-r--r--Source/Modules/pike.cxx2
-rw-r--r--Source/Modules/python.cxx14
-rw-r--r--Source/Modules/r.cxx21
-rw-r--r--Source/Modules/ruby.cxx31
-rw-r--r--Source/Modules/tcl8.cxx4
-rw-r--r--Source/Modules/uffi.cxx7
-rw-r--r--Source/Preprocessor/cpp.c21
-rw-r--r--Source/Preprocessor/expr.c2
-rw-r--r--Source/Swig/cwrap.c2
-rw-r--r--Source/Swig/error.c13
-rw-r--r--Source/Swig/fragment.c19
-rw-r--r--Source/Swig/include.c12
-rw-r--r--Source/Swig/misc.c42
-rw-r--r--Source/Swig/naming.c31
-rw-r--r--Source/Swig/scanner.c2
-rw-r--r--Source/Swig/stype.c22
-rw-r--r--Source/Swig/swig.h8
-rw-r--r--Source/Swig/swigfile.h2
-rw-r--r--Source/Swig/swigwrap.h4
-rw-r--r--Source/Swig/symbol.c16
-rw-r--r--Source/Swig/typemap.c18
-rw-r--r--Source/Swig/typeobj.c88
-rw-r--r--Source/Swig/typesys.c12
-rw-r--r--Source/Swig/wrapfunc.c8
48 files changed, 358 insertions, 318 deletions
diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
index 664449fef..13a0c2baa 100644
--- a/Source/CParse/cparse.h
+++ b/Source/CParse/cparse.h
@@ -38,7 +38,7 @@ extern "C" {
extern void scanner_set_main_input_file(String *file);
extern String *scanner_get_main_input_file();
extern void Swig_cparse_follow_locators(int);
- extern void start_inline(char *, int);
+ extern void start_inline(const char *, int);
extern String *scanner_ccode;
extern int yylex(void);
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index 76ea73f57..18bcdf46b 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -178,7 +178,7 @@ void scanner_file(DOHFile * f) {
* by the %inline directive.
* ------------------------------------------------------------------------- */
-void start_inline(char *text, int line) {
+void start_inline(const char *text, int line) {
String *stext = NewString(text);
Seek(stext,0,SEEK_SET);
@@ -423,7 +423,7 @@ int yylook(void) {
case SWIG_TOKEN_COMMENT:
{
String *cmt = Scanner_text(scan);
- char *loc = Char(cmt);
+ const char *loc = Char(cmt);
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
scanner_locator(cmt);
}
@@ -485,7 +485,7 @@ String *scanner_get_main_input_file() {
int yylex(void) {
int l;
- char *yytext;
+ const char *yytext;
if (!scan_init) {
scanner_init();
@@ -724,7 +724,7 @@ int yylex(void) {
yylval.str = s;
if (!rename_active) {
String *cs;
- char *t = Char(s) + 9;
+ const char *t = Char(s) + 9;
if (!((strcmp(t, "new") == 0)
|| (strcmp(t, "delete") == 0)
|| (strcmp(t, "new[]") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 3f4256718..5c202de73 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -43,7 +43,7 @@ static Node *module_node = 0;
static String *Classprefix = 0;
static String *Namespaceprefix = 0;
static int inclass = 0;
-static char *last_cpptype = 0;
+static const char *last_cpptype = 0;
static int inherit_list = 0;
static Parm *template_parameters = 0;
static int extendmode = 0;
@@ -86,7 +86,7 @@ static Node *copy_node(Node *n) {
for (k = First(n); k.key; k = Next(k)) {
String *ci;
String *key = k.key;
- char *ckey = Char(key);
+ const char *ckey = Char(key);
if ((strcmp(ckey,"nextSibling") == 0) ||
(strcmp(ckey,"previousSibling") == 0) ||
(strcmp(ckey,"parentNode") == 0) ||
@@ -209,7 +209,7 @@ Hash *Swig_cparse_features(void) {
return features_hash;
}
-static String *feature_identifier_fix(String *s) {
+static String *feature_identifier_fix(const_String_or_char_ptr s) {
if (SwigType_istemplate(s)) {
String *tp, *ts, *ta, *tq;
tp = SwigType_templateprefix(s);
@@ -433,7 +433,7 @@ static void add_symbols(Node *n) {
/* Only add to C symbol table and continue */
Swig_symbol_add(0, n);
} else if (strncmp(Char(symname),"$ignore",7) == 0) {
- char *c = Char(symname)+7;
+ const char *c = Char(symname)+7;
SetFlag(n,"feature:ignore");
if (strlen(c)) {
SWIG_WARN_NODE_BEGIN(n);
@@ -518,7 +518,7 @@ static void add_symbols_copy(Node *n) {
String *name;
int emode = 0;
while (n) {
- char *cnodeType = Char(nodeType(n));
+ const char *cnodeType = Char(nodeType(n));
if (strcmp(cnodeType,"access") == 0) {
String *kind = Getattr(n,"kind");
@@ -832,7 +832,7 @@ static String *remove_block(Node *kw, const String *inputcode) {
while (kw) {
String *name = Getattr(kw,"name");
if (name && (Cmp(name,"noblock") == 0)) {
- char *cstr = Char(inputcode);
+ const char *cstr = Char(inputcode);
size_t len = Len(inputcode);
if (len && cstr[0] == '{') {
--len; ++cstr;
@@ -980,7 +980,7 @@ typedef struct Nested {
String *code; /* Associated code fragment */
int line; /* line number where it starts */
char *name; /* Name associated with this nested class */
- char *kind; /* Kind of class */
+ const char *kind; /* Kind of class */
int unnamed; /* unnamed class */
SwigType *type; /* Datatype associated with the name */
struct Nested *next; /* Next code fragment in list */
@@ -1115,27 +1115,32 @@ static Node *dump_nested(const char *parent) {
ret = retx;
*/
+ /* TODO(bhy) Futher clean up. */
+
+ /* allocate a new temp char* string, so the following code can work on this writable string. */
+ char *tmp_code = (char *) malloc(Len(n->code)+1);
+ strncpy(tmp_code, Char(n->code), Len(n->code)+1);
/* Strip comments - further code may break in presence of comments. */
- strip_comments(Char(n->code));
+ strip_comments(tmp_code);
- /* Make all SWIG created typedef structs/unions/classes unnamed else
+ /* Make all SWIG created typedef structs/unions/classes unnamed else
redefinition errors occur - nasty hack alert.*/
{
const char* types_array[3] = {"struct", "union", "class"};
int i;
for (i=0; i<3; i++) {
- char* code_ptr = Char(n->code);
+ char* code_ptr = tmp_code; //Char(n->code);
while (code_ptr) {
/* Replace struct name (as in 'struct name {...}' ) with whitespace
name will be between struct and opening brace */
-
+
code_ptr = strstr(code_ptr, types_array[i]);
if (code_ptr) {
char *open_bracket_pos;
code_ptr += strlen(types_array[i]);
open_bracket_pos = strchr(code_ptr, '{');
- if (open_bracket_pos) {
+ if (open_bracket_pos) {
/* Make sure we don't have something like struct A a; */
char* semi_colon_pos = strchr(code_ptr, ';');
if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos)))
@@ -1146,15 +1151,15 @@ static Node *dump_nested(const char *parent) {
}
}
}
-
+
{
/* Remove SWIG directive %constant which may be left in the SWIG created typedefs */
- char* code_ptr = Char(n->code);
+ char* code_ptr = tmp_code; //Char(n->code);
while (code_ptr) {
code_ptr = strstr(code_ptr, "%constant");
if (code_ptr) {
char* directive_end_pos = strchr(code_ptr, ';');
- if (directive_end_pos) {
+ if (directive_end_pos) {
while (code_ptr <= directive_end_pos)
*code_ptr++ = ' ';
}
@@ -1162,15 +1167,21 @@ static Node *dump_nested(const char *parent) {
}
}
{
+ /* Put tmp_code back to n->code */
+ Delete(n->code);
+ n->code = NewString(tmp_code);
+ free(tmp_code);
+ }
+ {
Node *head = new_node("insert");
String *code = NewStringf("\n%s\n",n->code);
Setattr(head,"code", code);
Delete(code);
set_nextSibling(head,ret);
- Delete(ret);
+ Delete(ret);
ret = head;
}
-
+
/* Dump the code to the scanner */
start_inline(Char(n->code),n->line);
@@ -1190,7 +1201,7 @@ Node *Swig_cparse(File *f) {
return top;
}
-static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {
+static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, const char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {
String *fname;
String *name;
String *fixname;
@@ -1240,7 +1251,7 @@ static void single_new_feature(const char *featurename, String *val, Hash *featu
/* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms)
* and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter,
* simulating the equivalent overloaded method. */
-static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {
+static void new_feature(const char *featurename, String *val, Hash *featureattribs, const char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {
ParmList *declparms = declaratorparms;
@@ -1339,7 +1350,7 @@ static void default_arguments(Node *n) {
/* Create new function and add to symbol table */
{
SwigType *ntype = Copy(nodeType(function));
- char *cntype = Char(ntype);
+ const char *cntype = Char(ntype);
Node *new_function = new_node(ntype);
SwigType *decl = Copy(Getattr(function,"decl"));
int constqualifier = SwigType_isconst(decl);
@@ -1436,7 +1447,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%}
%union {
- char *id;
+ const char *id;
List *bases;
struct Define {
String *val;
@@ -1453,7 +1464,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
int line;
} loc;
struct {
- char *id;
+ const char *id;
SwigType *type;
String *defarg;
ParmList *parms;
@@ -2316,11 +2327,13 @@ rename_directive : rename_namewarn declarator idstring SEMI {
scanner_clear_rename();
}
| rename_namewarn LPAREN kwargs RPAREN string SEMI {
+ String *tmp_str = NewString($5);
if ($1) {
- Swig_name_rename_add(Namespaceprefix,$5,0,$3,0);
+ Swig_name_rename_add(Namespaceprefix,tmp_str,0,$3,0);
} else {
- Swig_name_namewarn_add(Namespaceprefix,$5,0,$3);
+ Swig_name_namewarn_add(Namespaceprefix,tmp_str,0,$3);
}
+ Delete(tmp_str);
$$ = 0;
scanner_clear_rename();
}
@@ -2759,7 +2772,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
String *symname = Swig_name_make(templnode,0,$3,0,0);
*/
- String *symname = $3;
+ String *symname = NewString($3);
Swig_cparse_template_expand(templnode,symname,temparms,tscope);
Setattr(templnode,"sym:name",symname);
} else {
@@ -3528,7 +3541,7 @@ cpp_class_decl :
Delete(n);
{
/* If a proper typedef name was given, we'll use it to set the scope name */
- String *name = 0;
+ const char *name = 0;
if ($1 && (strcmp($1,"typedef") == 0)) {
if (!Len($7.type)) {
String *scpname = 0;
@@ -3884,13 +3897,13 @@ template_parms : templateparameters {
String *name = Getattr(p,"name");
if (!name) {
/* Hmmm. Maybe it's a 'class T' parameter */
- char *type = Char(Getattr(p,"type"));
+ const char *type = Char(Getattr(p,"type"));
/* Template template parameter */
if (strncmp(type,"template<class> ",16) == 0) {
type += 16;
}
if ((strncmp(type,"class ",6) == 0) || (strncmp(type,"typename ", 9) == 0)) {
- char *t = strchr(type,' ');
+ const char *t = strchr(type,' ');
Setattr(p,"name", t+1);
} else {
/*
@@ -5819,13 +5832,13 @@ mem_initializer : idcolon LPAREN {
}
;
-template_decl : LESSTHAN valparms GREATERTHAN {
+template_decl : LESSTHAN valparms GREATERTHAN {
String *s = NewStringEmpty();
SwigType_add_template(s,$2);
$$ = Char(s);
scanner_last_id(1);
}
- | empty { $$ = (char*)""; }
+ | empty { $$ = ""; }
;
idstring : ID { $$ = $1; }
@@ -5928,9 +5941,10 @@ idcolontailnt : DCOLON ID idcolontailnt {
/* Concatenated strings */
string : string STRING {
- $$ = (char *) malloc(strlen($1)+strlen($2)+1);
- strcpy($$,$1);
- strcat($$,$2);
+ char *tmp = (char *) malloc(strlen($1)+strlen($2)+1);
+ strcpy(tmp,$1);
+ strcat(tmp,$2);
+ $$ = tmp;
}
| STRING { $$ = $1;}
;
@@ -6036,12 +6050,12 @@ Parm *Swig_cparse_parm(String *s) {
ParmList *Swig_cparse_parms(String *s) {
String *ns;
- char *cs = Char(s);
+ const char *cs = Char(s);
if (cs && cs[0] != '(') {
ns = NewStringf("(%s);",s);
} else {
ns = NewStringf("%s;",s);
- }
+ }
Seek(ns,0,SEEK_SET);
scanner_file(ns);
top = 0;
diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c
index 14886605f..152116511 100644
--- a/Source/CParse/templ.c
+++ b/Source/CParse/templ.c
@@ -215,8 +215,8 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String
static
String *partial_arg(String *s, String *p) {
- char *c;
- char *cp = Char(p);
+ const char *c;
+ const char *cp = Char(p);
String *prefix;
String *newarg;
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index 15827f328..27a6b5dfa 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -631,7 +631,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
* DohWrite()
* ----------------------------------------------------------------------------- */
-int DohWrite(DOH *obj, void *buffer, int length) {
+int DohWrite(DOH *obj, const void *buffer, int length) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo;
if (DohCheck(obj)) {
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 766e12a34..bf1e50f4d 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
/* File methods */
-extern int DohWrite(DOHFile * obj, void *buffer, int length);
+extern int DohWrite(DOHFile * obj, const void *buffer, int length);
extern int DohRead(DOHFile * obj, void *buffer, int length);
extern int DohSeek(DOHFile * obj, long offset, int whence);
extern long DohTell(DOHFile * obj);
@@ -300,10 +300,10 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
* Files
* ----------------------------------------------------------------------------- */
-extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
+extern DOHFile *DohNewFile(const DOH *filename, const char *mode, DOHList *outfiles);
extern DOHFile *DohNewFileFromFile(FILE *f);
extern DOHFile *DohNewFileFromFd(int fd);
-extern void DohFileErrorDisplay(DOHString * filename);
+extern void DohFileErrorDisplay(const DOHString * filename);
extern int DohClose(DOH *file);
extern int DohCopyto(DOHFile * input, DOHFile * output);
@@ -355,7 +355,7 @@ extern void DohMemoryDebug(void);
#define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
#define Len DohLen
#define Data DohData
-#define Char (char *) Data
+#define Char (const char *) Data
#define Cmp DohCmp
#define Equal DohEqual
#define Setline DohSetline
diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h
index 1fc5eb7c9..446555ab3 100644
--- a/Source/DOH/dohint.h
+++ b/Source/DOH/dohint.h
@@ -44,7 +44,7 @@ typedef struct {
/* File methods */
typedef struct {
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
- int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
+ int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
int (*doh_putc) (DOH *obj, int ch); /* Put character */
int (*doh_getc) (DOH *obj); /* Get character */
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index 65c2336a4..eb438b0be 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -65,7 +65,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
* File_write()
* ----------------------------------------------------------------------------- */
-static int File_write(DOH *fo, void *buffer, int len) {
+static int File_write(DOH *fo, const void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
int ret = (int) fwrite(buffer, 1, len, f->filep);
@@ -231,10 +231,10 @@ static DohObjInfo DohFileType = {
* If newfiles is non-zero, the filename is added to the list of new files.
* ----------------------------------------------------------------------------- */
-DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) {
+DOH *DohNewFile(const DOH *filename, const char *mode, DOHList *newfiles) {
DohFile *f;
FILE *file;
- char *filen;
+ const char *filen;
filen = Char(filename);
file = fopen(filen, mode);
@@ -294,6 +294,6 @@ DOH *DohNewFileFromFd(int fd) {
* Display cause of one of the NewFile functions failing.
* ----------------------------------------------------------------------------- */
-void DohFileErrorDisplay(DOHString * filename) {
+void DohFileErrorDisplay(const DOHString * filename) {
Printf(stderr, "Unable to open file %s: %s\n", filename, strerror(errno));
}
diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c
index f544cee64..8271cbb18 100644
--- a/Source/DOH/fio.c
+++ b/Source/DOH/fio.c
@@ -328,19 +328,21 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
DohFree(stemp);
}
} else {
+ const char *enc_str = (const char*) doh;
if (!doh)
- doh = (char *) "";
+ enc_str = "";
if (strlen(encoder)) {
DOH *s = NewString(doh);
Seek(s, 0, SEEK_SET);
enc = encode(encoder, s);
Delete(s);
- doh = Char(enc);
+ enc_str = Char(enc);
} else {
enc = 0;
+ //enc_str = (const char*) doh;
}
- maxwidth = maxwidth + strlen(newformat) + strlen((char *) doh);
+ maxwidth = maxwidth + strlen(newformat) + strlen(enc_str);
*(fmt++) = 's';
*fmt = 0;
if ((maxwidth + 1) < OBUFLEN) {
@@ -348,7 +350,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
} else {
stemp = (char *) DohMalloc(maxwidth + 1);
}
- nbytes += sprintf(stemp, newformat, doh);
+ nbytes += sprintf(stemp, newformat, enc_str);
if (Writen(so, stemp, strlen(stemp)) < 0)
return -1;
if (stemp != obuffer) {
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 141cd58e8..9f0251f35 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -417,7 +417,7 @@ static int String_read(DOH *so, void *buffer, int len) {
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
-static int String_write(DOH *so, void *buffer, int len) {
+static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
String *s = (String *) ObjData(so);
s->hashkey = -1;
@@ -603,13 +603,13 @@ static char *end_quote(char *s) {
}
}
-static char *match_simple(char *base, char *s, char *token, int tokenlen) {
+static char *match_simple(char *base, char *s, const char *token, int tokenlen) {
(void) base;
(void) tokenlen;
return strstr(s, token);
}
-static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier(char *base, char *s, const char *token, int tokenlen) {
while (s) {
s = strstr(s, token);
if (!s)
@@ -628,7 +628,7 @@ static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
}
-static char *match_identifier_begin(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier_begin(char *base, char *s, const char *token, int tokenlen) {
while (s) {
s = strstr(s, token);
if (!s)
@@ -642,7 +642,7 @@ static char *match_identifier_begin(char *base, char *s, char *token, int tokenl
return 0;
}
-static char *match_identifier_end(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier_end(char *base, char *s, const char *token, int tokenlen) {
(void) base;
while (s) {
s = strstr(s, token);
@@ -657,7 +657,7 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
return 0;
}
-static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
+static int replace_simple(String *str, const char *token, const char *rep, int flags, int count, char *(*match) (char *, char *, const char *, int)) {
int tokenlen; /* Length of the token */
int replen; /* Length of the replacement */
int delta, expand = 0;
@@ -1148,9 +1148,9 @@ int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n)
}
char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2) {
- char *p1 = Char(s1);
- char *p2 = Char(s2);
- return p1 == 0 || p2 == 0 || *p2 == '\0' ? p1 : strstr(p1, p2);
+ const char *p1 = Char(s1);
+ const char *p2 = Char(s2);
+ return (char*) (p1 == 0 || p2 == 0 || *p2 == '\0' ? p1 : strstr(p1, p2));
}
char *DohStrchr(const DOHString_or_char *s1, int ch) {
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index d21be9364..467e862d5 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -82,7 +82,7 @@ private:
static ALLEGROCL *allegrocl = 0;
static String *trim(String *str) {
- char *c = Char(str);
+ const char *c = Char(str);
while (*c != '\0' && isspace((int) *c))
++c;
String *result = NewString(c);
@@ -91,7 +91,7 @@ static String *trim(String *str) {
}
int is_integer(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
if (c[0] == '#' && (c[1] == 'x' || c[1] == 'o'))
c += 2;
@@ -142,16 +142,16 @@ String *namespaced_name(Node *n, String *ns = current_namespace) {
// "Namespace::Nested::Class2::Baz" -> "Baz"
static String *strip_namespaces(String *str) {
- char *result = Char(str);
+ const char *result = Char(str);
String *stripped_one;
while ((stripped_one = Strstr(result, "::")))
result = Char(stripped_one) + 2;
return NewString(result);
}
-static String *namespace_of(String *str) {
- char *p = Char(str);
- char *start = Char(str);
+static char *namespace_of(String *str) {
+ const char *p = Char(str);
+ const char *start = Char(str);
char *result = 0;
String *stripped_one;
@@ -164,7 +164,7 @@ static String *namespace_of(String *str) {
strncpy(result, start, len - 1);
result[len - 1] = 0;
}
- return Char(result);
+ return result;
}
void add_linked_type(Node *n) {
@@ -621,7 +621,7 @@ void note_implicit_template_instantiation(SwigType *t) {
#ifdef ALLEGROCL_CLASS_DEBUG
Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t));
#endif
- String *implicit_ns = namespace_of(SwigType_templateprefix(t));
+ char *implicit_ns = namespace_of(SwigType_templateprefix(t));
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
}
@@ -845,8 +845,8 @@ static String *mangle_name(Node *n, char const *prefix = "ACL", String *ns = cur
(* :char) ==> :char
(* (:array :int 30)) ==> (:array :int 30) */
String *dereference_ffitype(String *ffitype) {
- char *start;
- char *temp = Char(ffitype);
+ const char *start;
+ const char *temp = Char(ffitype);
String *reduced_type = 0;
if(temp && temp[0] == '(' && temp[1] == '*') {
@@ -855,12 +855,10 @@ String *dereference_ffitype(String *ffitype) {
// walk past start of pointer references
while(*temp == ' ') temp++;
start = temp;
- // temp = Char(reduced_type);
- reduced_type = NewString(start);
- temp = Char(reduced_type);
// walk to end of string. remove closing paren
while(*temp != '\0') temp++;
- *(--temp) = '\0';
+ reduced_type = NewStringWithSize(start, temp-start-1);
+ //*(--temp) = '\0';
}
return reduced_type ? reduced_type : Copy(ffitype);
@@ -879,7 +877,7 @@ int ALLEGROCL::validIdentifier(String *s) {
Printf(stderr, "validIdentifier %s\n", s);
#endif
- char *c = Char(s);
+ const char *c = Char(s);
bool got_dot = false;
bool only_dots = true;
@@ -949,7 +947,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
String *num_param = Copy(literal);
String *trimmed = trim(num_param);
String *num = strip_parens(trimmed), *res = 0;
- char *s = Char(num);
+ const char *s = Char(num);
String *ns = listify_namespace(current_namespace);
@@ -977,8 +975,8 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
String *oldnum = Copy(num);
// careful. may be a float identifier or float constant.
- char *num_start = Char(num);
- char *num_end = num_start + strlen(num_start) - 1;
+ const char *num_start = Char(num);
+ const char *num_end = num_start + strlen(num_start) - 1;
bool is_literal = isdigit(*num_start) || (*num_start == '.');
@@ -991,7 +989,8 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
}
if (*num_end == 'l' || *num_end == 'L' || *num_end == 'f' || *num_end == 'F') {
- *num_end = '\0';
+ //*num_end = '\0';
+ Delitem(num, DOH_END);
num_end--;
}
@@ -2196,7 +2195,7 @@ IDargs *id_converter_arguments(Node *n) {
Replaceall(Getattr(n, "allegrocl:kind"), "function", "operator");
if (Strstr(Getattr(n, "allegrocl:kind"), "variable")) {
int name_end = Len(Getattr(n, "sym:name")) - 4;
- char *str = Char(Getattr(n, "sym:name"));
+ const char *str = Char(Getattr(n, "sym:name"));
String *get_set = NewString(str + name_end + 1);
result->type = Copy(Getattr(n, "allegrocl:kind"));
Replaceall(result->type, "variable", "");
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index 38c9c574f..607dc5108 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -54,7 +54,7 @@ private:
void emit_struct_union(Node *n, bool un);
void emit_export(Node *n, String *name);
void emit_inline(Node *n, String *name);
- String *lispy_name(char *name);
+ String *lispy_name(const char *name);
String *lispify_name(Node *n, String *ty, const char *flag, bool kw = false);
String *convert_literal(String *num_param, String *type, bool try_to_split = true);
String *infix_to_prefix(String *val, char split_op, const String *op, String *type);
@@ -872,7 +872,8 @@ String *CFFI::lispify_name(Node *n, String *ty, const char *flag, bool kw) {
/* utilities */
/* returns new string w/ parens stripped */
String *CFFI::strip_parens(String *string) {
- char *s = Char(string), *p;
+ const char *s = Char(string);
+ char *p;
int len = Len(string);
String *res;
@@ -896,7 +897,7 @@ String *CFFI::strip_parens(String *string) {
}
String *CFFI::trim(String *str) {
- char *c = Char(str);
+ const char *c = Char(str);
while (*c != '\0' && isspace((int) *c))
++c;
String *result = NewString(c);
@@ -952,7 +953,7 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
String *trimmed = trim(num_param);
String *num = strip_parens(trimmed), *res = 0;
Delete(trimmed);
- char *s = Char(num);
+ const char *s = Char(num);
// very basic parsing of infix expressions.
if (try_to_split) {
@@ -976,8 +977,8 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
// Use CL syntax for float literals
// careful. may be a float identifier or float constant.
- char *num_start = Char(num);
- char *num_end = num_start + strlen(num_start) - 1;
+ const char *num_start = Char(num);
+ const char *num_end = num_start + strlen(num_start) - 1;
bool is_literal = isdigit(*num_start) || (*num_start == '.') || (*num_start == '+') || (*num_start == '-');
@@ -990,7 +991,8 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
}
if (*num_end == 'l' || *num_end == 'L' || *num_end == 'f' || *num_end == 'F') {
- *num_end = '\0';
+ //*num_end = '\0';
+ Delitem(num, DOH_END);
num_end--;
}
@@ -1047,7 +1049,7 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
}
//less flexible as it does the conversion in C, the lispify name does the conversion in lisp
-String *CFFI::lispy_name(char *name) {
+String *CFFI::lispy_name(const char *name) {
bool helper = false;
String *new_name = NewString("");
for (unsigned int i = 0; i < strlen(name); i++) {
diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
index 84060e844..50bfc3223 100644
--- a/Source/Modules/chicken.cxx
+++ b/Source/Modules/chicken.cxx
@@ -1473,7 +1473,7 @@ String *CHICKEN::chickenPrimitiveName(String *name) {
}
int CHICKEN::validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
/* Check whether we have an R5RS identifier. */
/* <identifier> --> <initial> <subsequent>* | <peculiar identifier> */
/* <initial> --> <letter> | <special initial> */
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index 276919627..ce5074473 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -312,7 +312,8 @@ int CLISP::classDeclaration(Node *n) {
/* utilities */
/* returns new string w/ parens stripped */
String *CLISP::strip_parens(String *string) {
- char *s = Char(string), *p;
+ const char *s = Char(string);
+ char *p;
int len = Len(string);
String *res;
@@ -337,7 +338,7 @@ String *CLISP::strip_parens(String *string) {
String *CLISP::convert_literal(String *num_param, String *type) {
String *num = strip_parens(num_param), *res;
- char *s = Char(num);
+ const char *s = Char(num);
/* Make sure doubles use 'd' instead of 'e' */
if (!Strcmp(type, "double")) {
diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx
index a4cf8cebc..59e56af15 100644
--- a/Source/Modules/emit.cxx
+++ b/Source/Modules/emit.cxx
@@ -407,7 +407,7 @@ String *emit_action(Node *n) {
if (fragment) {
char *c, *tok;
String *t = Copy(fragment);
- c = Char(t);
+ c = (char *) Char(t);
tok = strtok(c, ",");
while (tok) {
String *fname = NewString(tok);
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index 51d4accdc..4965fc7d3 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -1684,7 +1684,7 @@ public:
* ------------------------------------------------------------ */
virtual int validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
/* Check whether we have an R5RS identifier. Guile supports a
superset of R5RS identifiers, but it's probably a bad idea to use
those. */
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index c868a094e..d31fc6fc5 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -84,7 +84,7 @@ int Dispatcher::emit_one(Node *n) {
String *wrn;
int ret = SWIG_OK;
- char *tag = Char(nodeType(n));
+ const char *tag = Char(nodeType(n));
if (!tag) {
/* Printf(stderr,"SWIG: Fatal internal error. Malformed parse tree
node!\n"); */
@@ -188,7 +188,7 @@ int Dispatcher::emit_one(Node *n) {
int Dispatcher::emit_children(Node *n) {
Node *c;
- char *eo = Char(Getattr(n, "feature:emitonlychildren"));
+ const char *eo = Char(Getattr(n, "feature:emitonlychildren"));
for (c = firstChild(n); c; c = nextSibling(c)) {
if (eo) {
const char *tag = Char(nodeType(c));
@@ -411,7 +411,7 @@ static Node *first_nontemplate(Node *n) {
* Handle swig pragma directives.
* -------------------------------------------------------------------------- */
-void swig_pragma(char *lang, char *name, char *value) {
+void swig_pragma(const char *lang, const char *name, const char *value) {
if (strcmp(lang, "swig") == 0) {
if ((strcmp(name, "make_default") == 0) || ((strcmp(name, "makedefault") == 0))) {
GenerateDefault = 1;
@@ -419,16 +419,15 @@ void swig_pragma(char *lang, char *name, char *value) {
Swig_warning(WARN_DEPRECATED_NODEFAULT, "SWIG", 1, "dangerous, use %%nodefaultctor, %%nodefaultdtor instead.\n");
GenerateDefault = 0;
} else if (strcmp(name, "attributefunction") == 0) {
- String *nvalue = NewString(value);
- char *s = strchr(Char(nvalue), ':');
+ const char *p = Char(value);
+ const char *s = strchr(p, ':');
if (!s) {
Swig_error(input_file, line_number, "Bad value for attributefunction. Expected \"fmtget:fmtset\".\n");
} else {
- *s = 0;
- AttributeFunctionGet = NewString(Char(nvalue));
+ //*s = 0;
+ AttributeFunctionGet = NewStringWithSize(p, s-p);
AttributeFunctionSet = NewString(s + 1);
}
- Delete(nvalue);
} else if (strcmp(name, "noattributefunction") == 0) {
AttributeFunctionGet = 0;
AttributeFunctionSet = 0;
@@ -2321,8 +2320,8 @@ int Language::classDeclaration(Node *n) {
String *tdname = Getattr(n, "tdname");
String *symname = Getattr(n, "sym:name");
- char *classname = tdname ? Char(tdname) : Char(name);
- char *iname = Char(symname);
+ const char *classname = tdname ? Char(tdname) : Char(name);
+ const char *iname = Char(symname);
int strip = (tdname || CPlusPlus) ? 1 : 0;
@@ -2740,7 +2739,7 @@ int Language::destructorHandler(Node *n) {
String *symname = Getattr(n, "sym:name");
String *mrename;
- char *csymname = Char(symname);
+ const char *csymname = Char(symname);
if (csymname && (*csymname == '~'))
csymname += 1;
@@ -2784,7 +2783,7 @@ int Language::namespaceDeclaration(Node *n) {
}
int Language::validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (!(isalnum(*c) || (*c == '_')))
return 0;
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index c615bfa9a..81df19110 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -794,7 +794,7 @@ public:
if (SwigType_type(type) == T_MPOINTER) {
String *wname = Swig_name_wrapper(iname);
Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value);
- value = Char(wname);
+ value = wname;
}
if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 27625bd08..18bb7bc2d 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -211,7 +211,7 @@ static int check_suffix(String *filename) {
static void install_opts(int argc, char *argv[]) {
int i;
int noopt = 0;
- char *c;
+ const char *c;
for (i = 1; i < (argc - 1); i++) {
if (argv[i]) {
if ((*argv[i] == '-') && (!isupper(*(argv[i] + 1)))) {
@@ -837,7 +837,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
- char *token = strtok(Char(package_version), ".");
+ const char *token = strtok((char *)Char(package_version), ".");
String *vers = NewString("SWIG_VERSION 0x");
int count = 0;
while (token) {
@@ -943,7 +943,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// If the user has requested to check out a file, handle that
if (checkout) {
DOH *s;
- char *outfile = Char(input_file);
+ const char *outfile = Char(input_file);
if (outfile_name)
outfile = outfile_name;
@@ -983,7 +983,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (!df) {
df = Swig_include_open(input_file);
if (!df) {
- char *cfile = Char(input_file);
+ const char *cfile = Char(input_file);
if (cfile && cfile[0] == '-') {
Printf(stderr, "Unable to find option or file '%s', ", input_file);
Printf(stderr, "use 'swig -help' for more information.\n");
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index 982d6224d..1d1c4aad7 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -458,7 +458,7 @@ MODULA3():
* ----------------------------------------------------------------------------- */
String *nameToModula3(const String *sym, bool leadingCap) {
int len_sym = Len(sym);
- char *csym = Char(sym);
+ const char *csym = Char(sym);
char *m3sym = new char[len_sym + 1];
int i, j;
bool cap = leadingCap;
@@ -508,7 +508,7 @@ MODULA3():
String *oldPrefix = Getattr(n, "feature:modula3:oldprefix");
String *newPrefix = Getattr(n, "feature:modula3:newprefix");
String *result = NewString("");
- char *short_sym = Char(sym);
+ const char *short_sym = Char(sym);
// if at least one prefix feature is present
// the replacement takes place
if ((oldPrefix != NIL) || (newPrefix != NIL)) {
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 99f1024ff..71b956626 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -774,7 +774,7 @@ public:
* ------------------------------------------------------------ */
virtual int validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
/* Check whether we have an R5RS identifier. */
/* <identifier> --> <initial> <subsequent>* | <peculiar identifier> */
/* <initial> --> <letter> | <special initial> */
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 022611502..8386f339a 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -374,7 +374,7 @@ public:
*/
void oc_SwigType_del_reference(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
if (strncmp(c, "q(", 2) == 0) {
Delete(SwigType_pop(t));
c = Char(t);
@@ -387,7 +387,7 @@ public:
}
void oc_SwigType_del_array(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
if (strncmp(c, "q(", 2) == 0) {
Delete(SwigType_pop(t));
c = Char(t);
@@ -1005,7 +1005,7 @@ public:
}
bool isSimpleType(String *name) {
- char *ch = Char(name);
+ const char *ch = Char(name);
return !(strchr(ch, '(') || strchr(ch, '<') || strchr(ch, ')') || strchr(ch, '>'));
}
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index c9febcbba..f13ef191d 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -305,7 +305,7 @@ public:
if (str && Len(str) > 0) {
// strip off {} if necessary
- char *t = Char(str);
+ const char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index e454f5050..391defe72 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -305,7 +305,7 @@ public:
f_pm = NewString(0);
} else {
if (pmfile == NULL) {
- char *m = Char(module) + Len(module);
+ const char *m = Char(module) + Len(module);
while (m != Char(module)) {
if (*m == ':') {
m++;
@@ -977,7 +977,7 @@ public:
if (SwigType_type(type) == T_MPOINTER) {
String *wname = Swig_name_wrapper(iname);
Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value);
- value = Char(wname);
+ value = wname;
}
if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
@@ -1031,7 +1031,7 @@ public:
/* ------------------------------------------------------------
* usage_func()
* ------------------------------------------------------------ */
- char *usage_func(char *iname, SwigType *, ParmList *l) {
+ const char *usage_func(const char *iname, SwigType *, ParmList *l) {
static String *temp = 0;
Parm *p;
int i;
@@ -1227,7 +1227,7 @@ public:
Printf(pm, "use overload\n");
Iterator ki;
for (ki = First(operators); ki.key; ki = Next(ki)) {
- char *name = Char(ki.key);
+ const char *name = Char(ki.key);
// fprintf(stderr,"found name: <%s>\n", name);
if (strstr(name, "__eq__")) {
Printv(pm, tab4, "\"==\" => sub { $_[0]->__eq__($_[1])},\n",NIL);
@@ -1649,7 +1649,7 @@ public:
String *perlcode(String *code, const String *indent) {
String *out = NewString("");
String *temp;
- char *t;
+ const char *t;
if (!indent)
indent = "";
@@ -1672,7 +1672,7 @@ public:
for (si = First(clist); si.item; si = Next(si)) {
s = si.item;
if (Len(s)) {
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (!isspace(*c))
break;
@@ -1689,7 +1689,7 @@ public:
while (si.item) {
s = si.item;
if (Len(s) > initial) {
- char *c = Char(s);
+ const char *c = Char(s);
c += initial;
Printv(out, indent, c, "\n", NIL);
} else {
diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx
index 800c8f74c..6419255ca 100644
--- a/Source/Modules/pike.cxx
+++ b/Source/Modules/pike.cxx
@@ -185,7 +185,7 @@ public:
* ------------------------------------------------------------ */
virtual int validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
const char *c0 = c;
const char *c1 = c0 + 1;
while (*c) {
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index fd4e9be8b..8f549f663 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -961,7 +961,7 @@ public:
String *pythoncode(String *code, const String *indent) {
String *out = NewString("");
String *temp;
- char *t;
+ const char *t;
if (!indent)
indent = "";
@@ -984,7 +984,7 @@ public:
for (si = First(clist); si.item; si = Next(si)) {
s = si.item;
if (Len(s)) {
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (!isspace(*c))
break;
@@ -1001,7 +1001,7 @@ public:
while (si.item) {
s = si.item;
if (Len(s) > initial) {
- char *c = Char(s);
+ const char *c = Char(s);
c += initial;
Printv(out, indent, c, "\n", NIL);
} else {
@@ -1031,7 +1031,7 @@ public:
autodoc_l autodoc_level(String *autodoc) {
autodoc_l dlevel = NO_AUTODOC;
if (autodoc) {
- char *c = Char(autodoc);
+ const char *c = Char(autodoc);
if (c && isdigit(c[0])) {
dlevel = (autodoc_l) atoi(c);
} else {
@@ -1073,7 +1073,7 @@ public:
String *doc = NULL;
if (have_ds) {
- char *t = Char(str);
+ const char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
@@ -1548,7 +1548,7 @@ public:
String *pythonprepend(Node *n) {
String *str = Getattr(n, "feature:pythonprepend");
- char *t = Char(str);
+ const char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
@@ -1578,7 +1578,7 @@ public:
if (!str)
str = Getattr(n, "feature:addtofunc");
- char *t = Char(str);
+ const char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index ae905a806..4561977c8 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -53,7 +53,7 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
*outCount = count;
String *tmp = NewString("");
- char *retName = Char(SwigType_manglestr(t));
+ const char *retName = Char(SwigType_manglestr(t));
Insert(tmp, 0, retName);
return tmp;
@@ -109,7 +109,7 @@ static String * getRType(Node *n) {
static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
String *tmp = NewString("");
SwigType *resolved = SwigType_typedef_resolve_all(retType);
- char *retName = Char(SwigType_manglestr(resolved));
+ const char *retName = Char(SwigType_manglestr(resolved));
if (upRef) {
Printf(tmp, "_p%s", retName);
} else{
@@ -187,7 +187,7 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
String *el = Getitem(l, n-1);
- char *ptr = Char(el);
+ const char *ptr = Char(el);
if(strncmp(ptr, "struct ", 7) == 0)
ptr += 7;
@@ -1019,7 +1019,7 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
el = Getattr(tb, key);
String *className = Getitem(el, 0);
- char *ptr = Char(key);
+ const char *ptr = Char(key);
ptr = &ptr[Len(key) - 3];
int isSet = strcmp(ptr, "set") == 0;
@@ -1075,7 +1075,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
if (!Strcmp(item, "__str__")) has_str = 1;
String *dup = Getitem(el, j + 1);
- char *ptr = Char(dup);
+ const char *ptr = Char(dup);
ptr = &ptr[Len(dup) - 3];
if (!strcmp(ptr, "get"))
@@ -1108,7 +1108,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
for(j = 0; j < numMems; j+=3) {
String *item = Getitem(el, j);
String *dup = Getitem(el, j + 1);
- char *ptr = Char(dup);
+ const char *ptr = Char(dup);
ptr = &ptr[Len(dup) - 3];
if (!strcmp(ptr, "get")) {
@@ -1311,7 +1311,7 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
int isSet) {
if(isSet < 0) {
int n = Len(name);
- char *ptr = Char(name);
+ const char *ptr = Char(name);
isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0;
}
@@ -1748,7 +1748,7 @@ int R::functionWrapper(Node *n) {
We will dump all these at the end. */
int n = Len(iname);
- char *ptr = Char(iname);
+ const char *ptr = Char(iname);
bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0);
@@ -2483,7 +2483,8 @@ int R::generateCopyRoutines(Node *n) {
String *m = NewStringf("%sCopyToR", name);
addNamespaceMethod(m);
- char *tt = Char(m); tt[Len(m)-1] = 'C';
+ //char *tt = Char(m); tt[Len(m)-1] = 'C';
+ Delitem(m, DOH_END); Append(m, "C");
addNamespaceMethod(m);
Delete(m);
Delete(rclassName);
@@ -2513,7 +2514,7 @@ int R::typedefHandler(Node *n) {
if(Strncmp(type, "struct ", 7) == 0) {
String *name = Getattr(n, "name");
- char *trueName = Char(type);
+ const char *trueName = Char(type);
trueName += 7;
if (debugMode)
Printf(stderr, "<typedefHandler> Defining S class %s\n", trueName);
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index dcc778225..519feaafc 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -110,7 +110,8 @@ public:
if (Strncmp(s, prefix, Len(prefix)) == 0) {
Replaceall(temp, prefix, "");
}
- return Char(temp);
+ //TODO(bhy) fix it later
+ return (char *)Char(temp);
}
};
@@ -202,7 +203,7 @@ private:
autodoc_l autodoc_level(String *autodoc) {
autodoc_l dlevel = NO_AUTODOC;
if (autodoc) {
- char *c = Char(autodoc);
+ const char *c = Char(autodoc);
if (c && isdigit(c[0])) {
dlevel = (autodoc_l) atoi(c);
} else {
@@ -245,7 +246,7 @@ private:
String *doc = NULL;
if (have_ds) {
- char *t = Char(str);
+ const char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
@@ -448,7 +449,9 @@ private:
parent_name = Copy( Getattr(mod, "name") );
if ( parent_name )
{
- (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]);
+ Seek(parent_name, 0, SEEK_SET);
+ Putc(toupper((Char(parent_name))[0]), parent_name);
+ //(Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]);
}
}
if ( parent_name )
@@ -1196,7 +1199,9 @@ public:
while (m.item) {
if (Len(m.item) > 0) {
String *cap = NewString(m.item);
- (Char(cap))[0] = (char)toupper((Char(cap))[0]);
+ Seek(cap, 0, SEEK_SET);
+ Putc(toupper((Char(cap))[0]), cap);
+ //(Char(cap))[0] = (char)toupper((Char(cap))[0]);
if (last != 0) {
Append(module, "::");
}
@@ -1208,7 +1213,9 @@ public:
if (feature == 0) {
feature = Copy(last);
}
- (Char(last))[0] = (char)toupper((Char(last))[0]);
+ Seek(last, 0, SEEK_SET);
+ Putc(toupper((Char(last))[0]), last);
+ //(Char(last))[0] = (char)toupper((Char(last))[0]);
modvar = NewStringf("m%s", last);
Delete(modules);
}
@@ -1573,7 +1580,7 @@ public:
* --------------------------------------------------------------------- */
virtual int validIdentifier(String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (!(isalnum(*c) || (*c == '_') || (*c == '?') || (*c == '!') || (*c == '=')))
return 0;
@@ -2253,7 +2260,7 @@ public:
if (SwigType_type(type) == T_MPOINTER) {
String *wname = Swig_name_wrapper(iname);
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
- value = Char(wname);
+ value = wname;
}
String *tm = Swig_typemap_lookup("constant", n, value, 0);
if (!tm)
@@ -2305,7 +2312,8 @@ public:
if (!klass) {
klass = new RClass();
String *valid_name = NewString(symname ? symname : namestr);
- validate_const_name(Char(valid_name), "class");
+ //TODO(bhy) fix it later
+ validate_const_name((char *)Char(valid_name), "class");
klass->set_name(namestr, symname, valid_name);
SET_RCLASS(classes, Char(namestr), klass);
Delete(valid_name);
@@ -2443,7 +2451,8 @@ public:
assert(klass != 0);
Delete(namestr);
String *valid_name = NewString(symname);
- validate_const_name(Char(valid_name), "class");
+ //TODO: fix it later
+ validate_const_name((char*)Char(valid_name), "class");
Clear(klass->type);
Printv(klass->type, Getattr(n, "classtype"), NIL);
@@ -2545,7 +2554,7 @@ public:
Node *pn = Swig_methodclass(n);
String *symname = Getattr(pn, "sym:name");
String *name = Copy(symname);
- char *cname = Char(name);
+ char *cname = (char*)Char(name); //TODO: fix later
if (cname)
cname[0] = (char)toupper(cname[0]);
Printv(director_prot_ctor_code,
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 24f3739c8..03801cea1 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -674,7 +674,7 @@ public:
if (SwigType_type(type) == T_MPOINTER) {
String *wname = Swig_name_wrapper(iname);
Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value);
- value = Char(wname);
+ value = wname;
}
if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
@@ -1216,7 +1216,7 @@ public:
* usage_string()
* ------------------------------------------------------------ */
- char *usage_string(char *iname, SwigType *, ParmList *l) {
+ const char *usage_string(const char *iname, SwigType *, ParmList *l) {
static String *temp = 0;
Parm *p;
int i, numopt, pcount;
diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx
index 5fdc6101d..6c6be4209 100644
--- a/Source/Modules/uffi.cxx
+++ b/Source/Modules/uffi.cxx
@@ -49,7 +49,8 @@ static int any_varargs(ParmList *pl) {
/* utilities */
/* returns new string w/ parens stripped */
static String *strip_parens(String *string) {
- char *s = Char(string), *p;
+ const char *s = Char(string);
+ char *p;
int len = Len(string);
String *res;
@@ -75,7 +76,7 @@ static String *strip_parens(String *string) {
static String *convert_literal(String *num_param, String *type) {
String *num = strip_parens(num_param), *res;
- char *s = Char(num);
+ const char *s = Char(num);
/* Make sure doubles use 'd' instead of 'e' */
if (!Strcmp(type, "double")) {
@@ -138,7 +139,7 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
return NewString(typespec);
} else {
SwigType *tr = SwigType_typedef_resolve_all(ty);
- char *type_reduced = Char(tr);
+ const char *type_reduced = Char(tr);
int i;
//Printf(stdout,"convert_type %s\n", ty);
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index d93afc09a..bb4e53b2d 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -265,7 +265,7 @@ void Preprocessor_error_as_warning(int a) {
String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) {
String *argname;
String *varargname;
- char *s, *dots;
+ const char *s, *dots;
argname = Copy(str);
s = Char(argname);
@@ -283,8 +283,8 @@ String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr
if (dots == s) {
varargname = NewString("__VA_ARGS__");
} else {
- *dots = '\0';
- varargname = NewString(s);
+ //*dots = '\0';
+ varargname = NewStringWithSize(s, dots-s);
}
Delete(argname);
return varargname;
@@ -407,7 +407,8 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
{
int state = 0;
- char *cc = Char(macrovalue);
+ //TODO(bhy): fix later
+ char *cc = (char *) Char(macrovalue);
while (*cc) {
switch (state) {
case 0:
@@ -812,7 +813,7 @@ static String *expand_macro(String *name, List *args) {
if (strchr(Char(ns), '`')) {
String *rep;
- char *c;
+ const char *c;
Clear(temp);
Printf(temp, "`%s`", aname);
c = Char(arg);
@@ -847,11 +848,13 @@ static String *expand_macro(String *name, List *args) {
if (isvarargs && i == l - 1 && Len(arg) == 0) {
/* Zero length varargs macro argument. We search for commas that might appear before and nuke them */
- char *a, *s, *t, *name;
- int namelen;
+ const char *s, *name;
+ char *a, *t;
+ int namelen;
s = Char(ns);
name = Char(aname);
namelen = Len(aname);
+ //TODO(bhy) fix later
a = strstr(s, name);
while (a) {
char ca = a[namelen + 1];
@@ -1170,7 +1173,7 @@ static void addline(DOH *s1, DOH *s2, int allow) {
if (allow) {
Append(s1, s2);
} else {
- char *c = Char(s2);
+ const char *c = Char(s2);
while (*c) {
if (*c == '\n')
Putc('\n', s1);
@@ -1623,7 +1626,7 @@ String *Preprocessor_parse(String *s) {
}
} else if (Equal(id, kpp_pragma)) {
if (Strncmp(value, "SWIG ", 5) == 0) {
- char *c = Char(value) + 5;
+ const char *c = Char(value) + 5;
while (*c && (isspace((int) *c)))
c++;
if (*c) {
diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c
index 4da24a774..87f2e3471 100644
--- a/Source/Preprocessor/expr.c
+++ b/Source/Preprocessor/expr.c
@@ -281,7 +281,7 @@ int Preprocessor_expr(DOH *s, int *error) {
}
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
- char *c = Char(Scanner_text(scan));
+ const char *c = Char(Scanner_text(scan));
stack[sp].value = (long) strtol(c, 0, 0);
stack[sp].svalue = 0;
/* stack[sp].value = (long) atol(Char(Scanner_text(scan))); */
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 49d2c1e9b..0f99cef64 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -285,7 +285,7 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or
/* A sick hack */
{
- char *c = Char(decl) + Len(decl) - 1;
+ const char *c = Char(decl) + Len(decl) - 1;
if (!((*c == ';') || (*c == '}')))
Append(fcall, ";");
}
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index 156fe06a7..f9bbd1ae5 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -60,7 +60,7 @@ static String *format_filename(const_String_or_char_ptr filename);
void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) {
String *out;
- char *msg;
+ const char *msg;
int wrn = 1;
va_list ap;
if (silence)
@@ -75,7 +75,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c
msg = Char(out);
if (isdigit((unsigned char) *msg)) {
- unsigned long result = strtoul(msg, &msg, 10);
+ unsigned long result = strtoul(msg, (char **)&msg, 10);
if (msg != Char(out)) {
msg++;
wnum = result;
@@ -86,7 +86,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c
if (filter) {
char temp[32];
char *c;
- char *f = Char(filter);
+ const char *f = Char(filter);
sprintf(temp, "%d", wnum);
while (*f != '\0' && (c = strstr(f, temp))) {
if (*(c - 1) == '-') {
@@ -171,8 +171,8 @@ void Swig_error_silent(int s) {
* ----------------------------------------------------------------------------- */
void Swig_warnfilter(const_String_or_char_ptr wlist, int add) {
- char *c;
- char *cw;
+ const char *c;
+ const char *cw;
String *s;
if (!filter)
filter = NewStringEmpty();
@@ -187,7 +187,8 @@ void Swig_warnfilter(const_String_or_char_ptr wlist, int add) {
++cw;
}
c = Char(s);
- c = strtok(c, ", ");
+ //TODO(bhy) fix later
+ c = strtok((char*)c, ", ");
while (c) {
if (isdigit((int) *c) || (*c == '+') || (*c == '-')) {
/* Even if c is a digit, the rest of the string might not be, eg in the case of typemap
diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c
index 510a01875..a6a4358f4 100644
--- a/Source/Swig/fragment.c
+++ b/Source/Swig/fragment.c
@@ -73,7 +73,7 @@ void Swig_fragment_register(Node *fragment) {
* ----------------------------------------------------------------------------- */
static
-char *char_index(char *str, char c) {
+const char *char_index(const char *str, char c) {
while (*str && (c != *str))
++str;
return (c == *str) ? str : 0;
@@ -81,7 +81,8 @@ char *char_index(char *str, char c) {
void Swig_fragment_emit(Node *n) {
String *code;
- char *pc, *tok;
+ const char *pc;
+ const char *tok;
String *t;
String *mangle = 0;
String *name = 0;
@@ -107,10 +108,14 @@ void Swig_fragment_emit(Node *n) {
t = Copy(name);
tok = Char(t);
pc = char_index(tok, ',');
- if (pc)
- *pc = 0;
+ /*if (pc)
+ *pc = 0;*/
while (tok) {
- String *name = NewString(tok);
+ String *name;
+ if (pc)
+ name = NewStringWithSize(tok, pc-tok);
+ else
+ name = NewString(tok);
if (mangle)
Append(name, mangle);
if (looking_fragments && Getattr(looking_fragments, name)) {
@@ -172,8 +177,8 @@ void Swig_fragment_emit(Node *n) {
tok = pc ? pc + 1 : 0;
if (tok) {
pc = char_index(tok, ',');
- if (pc)
- *pc = 0;
+ /*if (pc)
+ *pc = 0;*/
}
Delete(name);
}
diff --git a/Source/Swig/include.c b/Source/Swig/include.c
index f42eb5d45..9cec72fa9 100644
--- a/Source/Swig/include.c
+++ b/Source/Swig/include.c
@@ -159,7 +159,7 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
FILE *f;
String *filename;
List *spath = 0;
- char *cname;
+ const char *cname;
int i, ilen;
if (!directories)
@@ -219,7 +219,7 @@ String *Swig_read_file(FILE *f) {
}
len = Len(str);
if (len) {
- char *cstr = Char(str);
+ const char *cstr = Char(str);
if (cstr[len - 1] != '\n') {
Append(str, "\n");
}
@@ -313,9 +313,9 @@ File *Swig_filebyname(const_String_or_char_ptr filename) {
* Returns the suffix of a file
* ----------------------------------------------------------------------------- */
-char *Swig_file_suffix(const_String_or_char_ptr filename) {
- char *d;
- char *c = Char(filename);
+const char *Swig_file_suffix(const_String_or_char_ptr filename) {
+ const char *d;
+ const char *c = Char(filename);
int len = Len(filename);
if (strlen(c)) {
d = c + len - 1;
@@ -339,7 +339,7 @@ char *Swig_file_basename(const_String_or_char_ptr filename) {
static char tmp[1024];
char *c;
strcpy(tmp, Char(filename));
- c = Swig_file_suffix(tmp);
+ c = (char*) Swig_file_suffix(tmp);
*c = 0;
return tmp;
}
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index e97e93abb..758f99601 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -384,7 +384,7 @@ String *Swig_string_ucase(String *s) {
String *Swig_string_first_upper(String *s) {
String *ns = NewStringEmpty();
- char *cs = Char(s);
+ const char *cs = Char(s);
if (cs && cs[0] != 0) {
Putc(toupper((int)cs[0]), ns);
Append(ns, cs + 1);
@@ -405,7 +405,7 @@ String *Swig_string_first_upper(String *s) {
String *Swig_string_first_lower(String *s) {
String *ns = NewStringEmpty();
- char *cs = Char(s);
+ const char *cs = Char(s);
if (cs && cs[0] != 0) {
Putc(tolower((int)cs[0]), ns);
Append(ns, cs + 1);
@@ -506,7 +506,7 @@ String *Swig_string_mangle(const String *s) {
#if 0
/* old mangling, not suitable for using in macros */
String *t = Copy(s);
- char *c = Char(t);
+ const char *c = Char(t);
while (*c) {
if (!isalnum(*c))
*c = '_';
@@ -517,7 +517,7 @@ String *Swig_string_mangle(const String *s) {
String *result = NewStringEmpty();
int space = 0;
int state = 0;
- char *pc, *cb;
+ const char *pc, *cb;
String *b = Copy(s);
if (SwigType_istemplate(b)) {
String *st = Swig_symbol_template_deftype(b, 0);
@@ -652,9 +652,9 @@ String *Swig_string_emangle(String *s) {
* ----------------------------------------------------------------------------- */
void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
- char *tmp = Char(s);
- char *c = tmp;
- char *cc = c;
+ const char *tmp = Char(s);
+ const char *c = tmp;
+ const char *cc = c;
char *co = 0;
if (!strstr(c, "::")) {
*rprefix = 0;
@@ -706,9 +706,9 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
String *Swig_scopename_prefix(const String *s) {
- char *tmp = Char(s);
- char *c = tmp;
- char *cc = c;
+ const char *tmp = Char(s);
+ const char *c = tmp;
+ const char *cc = c;
char *co = 0;
if (!strstr(c, "::"))
return 0;
@@ -758,9 +758,9 @@ String *Swig_scopename_prefix(const String *s) {
* ----------------------------------------------------------------------------- */
String *Swig_scopename_last(const String *s) {
- char *tmp = Char(s);
- char *c = tmp;
- char *cc = c;
+ const char *tmp = Char(s);
+ const char *c = tmp;
+ const char *cc = c;
char *co = 0;
if (!strstr(c, "::"))
return NewString(s);
@@ -802,9 +802,9 @@ String *Swig_scopename_last(const String *s) {
* ----------------------------------------------------------------------------- */
String *Swig_scopename_first(const String *s) {
- char *tmp = Char(s);
- char *c = tmp;
- char *co = 0;
+ const char *tmp = Char(s);
+ const char *c = tmp;
+ const char *co = 0;
if (!strstr(c, "::"))
return 0;
@@ -852,8 +852,8 @@ String *Swig_scopename_first(const String *s) {
* ----------------------------------------------------------------------------- */
String *Swig_scopename_suffix(const String *s) {
- char *tmp = Char(s);
- char *c = tmp;
+ const char *tmp = Char(s);
+ const char *c = tmp;
char *co = 0;
if (!strstr(c, "::"))
return 0;
@@ -896,7 +896,7 @@ String *Swig_scopename_suffix(const String *s) {
* ----------------------------------------------------------------------------- */
int Swig_scopename_check(const String *s) {
- char *c = Char(s);
+ const char *c = Char(s);
char *co = strstr(c, "operator ");
if (co) {
@@ -955,7 +955,7 @@ String *Swig_string_command(String *s) {
String *res = NewStringEmpty();
#if defined(HAVE_POPEN)
if (Len(s)) {
- char *command = Char(s);
+ const char *command = Char(s);
FILE *fp = popen(command, "r");
if (fp) {
char buffer[1025];
@@ -1042,7 +1042,7 @@ const char *skip_delim(char pb, char pe, const char *ce) {
String *Swig_string_rxspencer(String *s) {
String *res = 0;
if (Len(s)) {
- const char *cs = Char(s);
+ const const char *cs = Char(s);
const char *cb;
const char *ce;
if (*cs == '[') {
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 3e1f46bb1..044bbd524 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -44,7 +44,8 @@ static int name_mangle(String *r) {
int special;
special = 0;
Replaceall(r, "::", "_");
- c = Char(r);
+ //TODO(bhy) fix later
+ c = (char*) Char(r);
while (*c) {
if (!isalnum((int) *c) && (*c != '_')) {
special = 1;
@@ -172,7 +173,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
String *r;
String *f;
String *rclassname;
- char *cname;
+ const char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
@@ -257,7 +258,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
- char *cname;
+ const char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
@@ -290,7 +291,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
- char *cname;
+ const char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
@@ -323,7 +324,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
- char *cname;
+ const char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
if (!naming_hash)
@@ -355,7 +356,7 @@ String *Swig_name_disown(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
- char *cname;
+ const char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
if (!naming_hash)
@@ -538,7 +539,7 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
Iterator ki;
String *bprefix;
String *dprefix;
- char *cbprefix;
+ const char *cbprefix;
int plen;
if (!namehash)
@@ -549,7 +550,7 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
cbprefix = Char(bprefix);
plen = strlen(cbprefix);
for (ki = First(namehash); ki.key; ki = Next(ki)) {
- char *k = Char(ki.key);
+ const char *k = Char(ki.key);
if (strncmp(k, cbprefix, plen) == 0) {
Iterator oi;
String *nkey = NewStringf("%s%s", dprefix, k + plen);
@@ -1028,7 +1029,7 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
while (kw) {
Node *next = nextSibling(kw);
String *kname = Getattr(kw, "name");
- char *ckey = kname ? Char(kname) : 0;
+ const char *ckey = kname ? Char(kname) : 0;
if (ckey) {
const char **rkey;
int isnotmatch = 0;
@@ -1135,8 +1136,8 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
#if defined(USE_RXSPENCER)
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
int match = 0;
- char *cvalue = Char(value);
- char *cmvalue = Char(mvalue);
+ const char *cvalue = Char(value);
+ const char *cmvalue = Char(mvalue);
regex_t compiled;
int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
if (retval != 0)
@@ -1160,8 +1161,8 @@ int Swig_name_rxsmatch_value(String *mvalue, String *value) {
int Swig_name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
int match = 0;
- char *cvalue = Char(value);
- char *cmvalue = Char(mvalue);
+ const char *cvalue = Char(value);
+ const char *cmvalue = Char(mvalue);
char *sep = strchr(cmvalue, '|');
while (sep && !match) {
match = strncmp(cvalue, cmvalue, sep - cmvalue) == 0;
@@ -1405,7 +1406,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin
if (Strcmp(newname, "$ignore") == 0) {
result = Copy(newname);
} else {
- char *cnewname = Char(newname);
+ const char *cnewname = Char(newname);
if (cnewname) {
int destructor = name && (*(Char(name)) == '~');
String *fmt = newname;
@@ -1506,7 +1507,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
}
if (result && !Equal(result, name)) {
/* operators in C++ allow aliases, we look for them */
- char *cresult = Char(result);
+ const char *cresult = Char(result);
if (cresult && (strncmp(cresult, "operator ", 9) == 0)) {
String *nresult = Swig_name_make(n, prefix, result, decl, oldname);
if (!Equal(nresult, result)) {
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 53f1ad4a0..dbd8847fb 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -252,7 +252,7 @@ Scanner_freeze_line(Scanner *s, int val) {
* ----------------------------------------------------------------------------- */
static void retract(Scanner * s, int n) {
int i, l;
- char *str;
+ const char *str;
str = Char(s->text);
l = Len(s->text);
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index 8a7700bec..07064577d 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -160,7 +160,7 @@ void SwigType_push(SwigType *t, String *cons) {
return;
if (Len(t)) {
- char *c = Char(cons);
+ const char *c = Char(cons);
if (c[strlen(c) - 1] != '.')
Insert(t, 0, ".");
}
@@ -174,7 +174,7 @@ void SwigType_push(SwigType *t, String *cons) {
* ----------------------------------------------------------------------------- */
int SwigType_ispointer_return(SwigType *t) {
- char *c;
+ const char *c;
int idx;
if (!t)
return 0;
@@ -187,7 +187,7 @@ int SwigType_ispointer_return(SwigType *t) {
}
int SwigType_isreference_return(SwigType *t) {
- char *c;
+ const char *c;
int idx;
if (!t)
return 0;
@@ -200,7 +200,7 @@ int SwigType_isreference_return(SwigType *t) {
}
int SwigType_isconst(SwigType *t) {
- char *c;
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -237,7 +237,7 @@ int SwigType_ismutable(SwigType *t) {
}
int SwigType_isenum(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
if (!t)
return 0;
if (strncmp(c, "enum ", 5) == 0) {
@@ -247,7 +247,7 @@ int SwigType_isenum(SwigType *t) {
}
int SwigType_issimple(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
if (!t)
return 0;
while (*c) {
@@ -358,7 +358,7 @@ void SwigType_add_default(String *def, SwigType *nr) {
SwigType *SwigType_default(SwigType *t) {
String *r1, *def;
String *r = 0;
- char *cr;
+ const char *cr;
#ifdef SWIG_DEFAULT_CACHE
if (!default_cache)
@@ -429,7 +429,7 @@ SwigType *SwigType_default(SwigType *t) {
for (i = 0; i < ndim; i++) {
String *dim = SwigType_array_getdim(r, i);
if (!Len(dim)) {
- char *c = Char(nr);
+ const char *c = Char(nr);
empty = strstr(c, "a(ANY).") != c;
}
Delete(dim);
@@ -499,7 +499,7 @@ String *SwigType_namestr(const SwigType *t) {
String *suffix;
List *p;
int i, sz;
- char *d = Char(t);
+ const char *d = Char(t);
char *c = strstr(d, "<(");
if (!c || !strstr(c + 2, ")>"))
@@ -942,7 +942,7 @@ String *SwigType_manglestr_default(SwigType *s) {
result = SwigType_prefix(lt);
base = SwigType_base(lt);
- c = Char(result);
+ c = (char *) Char(result);
while (*c) {
if (!isalnum((int) *c))
*c = '_';
@@ -959,7 +959,7 @@ String *SwigType_manglestr_default(SwigType *s) {
Replace(base, "union ", "", DOH_REPLACE_ANY);
Replace(base, "enum ", "", DOH_REPLACE_ANY);
- c = Char(base);
+ c = (char *) Char(base);
while (*c) {
if (*c == '<')
*c = 'T';
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 10c33a319..7ca8181f5 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -135,13 +135,13 @@ extern "C" {
extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
- extern int SwigType_ispointer(SwigType *t);
+ extern int SwigType_ispointer(const SwigType *t);
extern int SwigType_ispointer_return(SwigType *t);
extern int SwigType_isfunctionpointer(SwigType *t);
extern int SwigType_ismemberpointer(SwigType *t);
extern int SwigType_isreference(SwigType *t);
extern int SwigType_isreference_return(SwigType *t);
- extern int SwigType_isarray(SwigType *t);
+ extern int SwigType_isarray(const SwigType *t);
extern int SwigType_prefix_is_simple_1D_array(SwigType *t);
extern int SwigType_isfunction(SwigType *t);
extern int SwigType_isqualifier(SwigType *t);
@@ -188,7 +188,7 @@ extern "C" {
extern SwigType *SwigType_typedef_resolve(const SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
- extern int SwigType_istypedef(SwigType *t);
+ extern int SwigType_istypedef(const SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
@@ -196,7 +196,7 @@ extern "C" {
extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
- extern int SwigType_type(SwigType *t);
+ extern int SwigType_type(const SwigType *t);
/* --- Symbol table module --- */
diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h
index 92c7945e6..2713b1ace 100644
--- a/Source/Swig/swigfile.h
+++ b/Source/Swig/swigfile.h
@@ -24,7 +24,7 @@ extern void Swig_set_push_dir(int dopush);
extern int Swig_get_push_dir(void);
extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile);
extern File *Swig_filebyname(const_String_or_char_ptr filename);
-extern char *Swig_file_suffix(const_String_or_char_ptr filename);
+extern const char *Swig_file_suffix(const_String_or_char_ptr filename);
extern char *Swig_file_basename(const_String_or_char_ptr filename);
extern char *Swig_file_filename(const_String_or_char_ptr filename);
extern char *Swig_file_dirname(const_String_or_char_ptr filename);
diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h
index 0dcf88059..bbc7f0a32 100644
--- a/Source/Swig/swigwrap.h
+++ b/Source/Swig/swigwrap.h
@@ -25,5 +25,5 @@ extern void Wrapper_print(Wrapper *w, File *f);
extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...);
extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name);
-extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
-extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...);
+extern const char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
+extern const char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...);
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index 055af854f..24764e29d 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -993,7 +993,7 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
}
if (Swig_scopename_check(name)) {
- char *cname = Char(name);
+ const char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
@@ -1065,7 +1065,7 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
}
if (Swig_scopename_check(name)) {
- char *cname = Char(name);
+ const char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
@@ -1129,7 +1129,7 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
}
if (Swig_scopename_check(name)) {
- char *cname = Char(name);
+ const char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
@@ -1177,7 +1177,7 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
}
if (Swig_scopename_check(name)) {
- char *cname = Char(name);
+ const char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
@@ -1212,7 +1212,7 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) {
- char *cname = Char(name);
+ const char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0)
return symbol_lookup_qualified(0, global_scope, name, 0, 0);
return symbol_lookup_qualified(0, symtab, name, 0, 0);
@@ -1409,7 +1409,7 @@ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
List *elements;
String *result = NewStringEmpty();
int i, len;
- char *c = Char(t);
+ const char *c = Char(t);
if (strncmp(c, "::", 2) == 0) {
Append(result, t);
return result;
@@ -1599,7 +1599,7 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
{
const char *dclass[3] = { "struct ", "union ", "class " };
int i;
- char *c = Char(nt);
+ const char *c = Char(nt);
for (i = 0; i < 3; i++) {
if (strstr(c, dclass[i]) == c) {
Replace(nt, dclass[i], "", DOH_REPLACE_FIRST);
@@ -1650,7 +1650,7 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
int have_id = 0;
String *id = NewStringEmpty();
String *r = NewStringEmpty();
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (isalpha((int) *c) || (*c == '_') || (*c == ':')) {
Putc(*c, id);
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 401a99801..9f757e52a 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -389,7 +389,7 @@ static
int count_args(String *s) {
/* Count up number of arguments */
int na = 0;
- char *c = Char(s);
+ const char *c = Char(s);
while (*c) {
if (*c == '+')
na++;
@@ -553,9 +553,9 @@ void Swig_typemap_clear_apply(Parm *parms) {
if (tm) {
/* Clear typemaps that match our signature */
Iterator ki, ki2;
- char *ctsig = Char(tsig);
+ const char *ctsig = Char(tsig);
for (ki = First(tm); ki.key; ki = Next(ki)) {
- char *ckey = Char(ki.key);
+ const char *ckey = Char(ki.key);
if (strncmp(ckey, "tmap:", 5) == 0) {
int na = count_args(ki.key);
if ((na == narg) && strstr(ckey, ctsig)) {
@@ -877,7 +877,7 @@ int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
String *descriptor, *star_descriptor, *amp_descriptor;
String *ts;
- char *sc;
+ const char *sc;
sc = Char(s);
@@ -1101,7 +1101,7 @@ int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *
static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
Parm *p;
- char *new_name;
+ const char *new_name;
p = l;
while (p) {
@@ -1186,7 +1186,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
String *symname;
String *cname = 0;
String *clname = 0;
- char *cop = Char(op);
+ const char *cop = Char(op);
int optimal_attribute = 0;
int optimal_substitution = 0;
int num_substitutions = 0;
@@ -1245,7 +1245,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
while (kw) {
String *value = Copy(Getattr(kw, "value"));
String *type = Getattr(kw, "type");
- char *ckwname = Char(Getattr(kw, "name"));
+ const char *ckwname = Char(Getattr(kw, "name"));
if (type) {
String *mangle = Swig_string_mangle(type);
Append(value, mangle);
@@ -1488,7 +1488,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
ParmList *locals;
int argnum = 0;
char temp[256];
- char *cop = Char(op);
+ const char *cop = Char(op);
String *kwmatch = 0;
p = parms;
@@ -1728,7 +1728,7 @@ static List *split_embedded(String *s) {
static void split_var(String *s, String **name, String **value) {
char *eq;
- char *c;
+ const char *c;
eq = strchr(Char(s), '=');
if (!eq) {
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 8ff31bc0b..230c91825 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -130,9 +130,9 @@ SwigType *NewSwigType(const_String_or_char_ptr initial) {
* substring, to chop the element off, or for other purposes).
* ----------------------------------------------------------------------------- */
-static int element_size(char *c) {
+static int element_size(const char *c) {
int nparen;
- char *s = c;
+ const char *s = c;
while (*c) {
if (*c == '.') {
c++;
@@ -177,7 +177,7 @@ SwigType *SwigType_del_element(SwigType *t) {
SwigType *SwigType_pop(SwigType *t) {
SwigType *result;
- char *c;
+ const char *c;
int sz;
c = Char(t);
@@ -201,7 +201,7 @@ SwigType *SwigType_pop(SwigType *t) {
* ----------------------------------------------------------------------------- */
String *SwigType_parm(SwigType *t) {
- char *start, *c;
+ const char *start, *c;
int nparens = 0;
c = Char(t);
@@ -233,7 +233,7 @@ String *SwigType_parm(SwigType *t) {
List *SwigType_split(const SwigType *t) {
String *item;
List *list;
- char *c;
+ const char *c;
int len;
c = Char(t);
@@ -269,8 +269,8 @@ List *SwigType_split(const SwigType *t) {
List *SwigType_parmlist(const String *p) {
String *item = 0;
List *list;
- char *c;
- char *itemstart;
+ const char *c;
+ const char *itemstart;
int size;
assert(p);
@@ -335,7 +335,7 @@ SwigType *SwigType_add_pointer(SwigType *t) {
}
SwigType *SwigType_del_pointer(SwigType *t) {
- char *c, *s;
+ const char *c, *s;
c = Char(t);
s = c;
/* Skip qualifiers, if any */
@@ -352,8 +352,8 @@ SwigType *SwigType_del_pointer(SwigType *t) {
return t;
}
-int SwigType_ispointer(SwigType *t) {
- char *c;
+int SwigType_ispointer(const SwigType *t) {
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -387,7 +387,7 @@ SwigType *SwigType_add_reference(SwigType *t) {
}
SwigType *SwigType_del_reference(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
int check = strncmp(c, "r.", 2);
assert(check == 0);
Delslice(t, 0, 2);
@@ -395,7 +395,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
}
int SwigType_isreference(SwigType *t) {
- char *c;
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -422,9 +422,9 @@ int SwigType_isreference(SwigType *t) {
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
char temp[256], newq[256];
int sz, added = 0;
- char *q, *cqual;
-
- char *c = Char(t);
+ char *q;
+ const char *cqual;
+ const char *c = Char(t);
cqual = Char(qual);
if (!(strncmp(c, "q(", 2) == 0)) {
@@ -477,7 +477,7 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
}
SwigType *SwigType_del_qualifier(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
int check = strncmp(c, "q(", 2);
assert(check == 0);
Delslice(t, 0, element_size(c));
@@ -485,7 +485,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
}
int SwigType_isqualifier(SwigType *t) {
- char *c;
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -500,7 +500,7 @@ int SwigType_isqualifier(SwigType *t) {
* ----------------------------------------------------------------------------- */
int SwigType_isfunctionpointer(SwigType *t) {
- char *c;
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -545,7 +545,7 @@ SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name)
}
SwigType *SwigType_del_memberpointer(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
int check = strncmp(c, "m(", 2);
assert(check == 0);
Delslice(t, 0, element_size(c));
@@ -553,7 +553,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
}
int SwigType_ismemberpointer(SwigType *t) {
- char *c;
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -589,15 +589,15 @@ SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
}
SwigType *SwigType_del_array(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
int check = strncmp(c, "a(", 2);
assert(check == 0);
Delslice(t, 0, element_size(c));
return t;
}
-int SwigType_isarray(SwigType *t) {
- char *c;
+int SwigType_isarray(const SwigType *t) {
+ const char *c;
if (!t)
return 0;
c = Char(t);
@@ -613,7 +613,7 @@ int SwigType_isarray(SwigType *t) {
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
*/
int SwigType_prefix_is_simple_1D_array(SwigType *t) {
- char *c = Char(t);
+ const char *c = Char(t);
if (c && (strncmp(c, "a(", 2) == 0)) {
c = strchr(c, '.');
@@ -640,7 +640,7 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
/* Return number of array dimensions */
int SwigType_array_ndim(SwigType *t) {
int ndim = 0;
- char *c = Char(t);
+ const char *c = Char(t);
while (c && (strncmp(c, "a(", 2) == 0)) {
c = strchr(c, '.');
@@ -652,14 +652,16 @@ int SwigType_array_ndim(SwigType *t) {
/* Get nth array dimension */
String *SwigType_array_getdim(SwigType *t, int n) {
- char *c = Char(t);
+ const char *c = Char(t);
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
c++;
n--;
}
if (n == 0) {
- String *dim = SwigType_parm(c);
+ String *tmp = NewString(c);
+ String *dim = SwigType_parm(tmp);
+ Delete(tmp);
if (SwigType_istemplate(dim)) {
String *ndim = SwigType_namestr(dim);
Delete(dim);
@@ -676,8 +678,8 @@ String *SwigType_array_getdim(SwigType *t, int n) {
void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
String *result = 0;
char temp;
- char *start;
- char *c = Char(t);
+ const char *start;
+ const char *c = Char(t);
start = c;
if (strncmp(c, "a(", 2))
@@ -689,11 +691,11 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
n--;
}
if (n == 0) {
- temp = *c;
- *c = 0;
- result = NewString(start);
+ //temp = *c;
+ //*c = 0;
+ result = NewStringWithSize(start, c-start);
Printf(result, "a(%s)", rep);
- *c = temp;
+ //*c = temp;
c = strchr(c, '.');
Append(result, c);
}
@@ -745,7 +747,7 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
SwigType *SwigType_pop_function(SwigType *t) {
SwigType *f = 0;
SwigType *g = 0;
- char *c = Char(t);
+ const char *c = Char(t);
if (strncmp(c, "q(", 2) == 0) {
f = SwigType_pop(t);
c = Char(t);
@@ -762,7 +764,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
}
int SwigType_isfunction(SwigType *t) {
- char *c;
+ const char *c;
if (!t) {
return 0;
}
@@ -936,7 +938,7 @@ String *SwigType_templateargs(const SwigType *t) {
* ----------------------------------------------------------------------------- */
int SwigType_istemplate(const SwigType *t) {
- char *ct = Char(t);
+ const char *ct = Char(t);
ct = strstr(ct, "<(");
if (ct && (strstr(ct + 2, ")>")))
return 1;
@@ -951,8 +953,8 @@ int SwigType_istemplate(const SwigType *t) {
* ----------------------------------------------------------------------------- */
SwigType *SwigType_base(const SwigType *t) {
- char *c;
- char *lastop = 0;
+ const char *c;
+ const char *lastop = 0;
c = Char(t);
lastop = c;
@@ -1009,7 +1011,7 @@ SwigType *SwigType_base(const SwigType *t) {
* ----------------------------------------------------------------------------- */
String *SwigType_prefix(const SwigType *t) {
- char *c, *d;
+ const char *c, *d;
String *r = 0;
c = Char(t);
@@ -1046,10 +1048,10 @@ String *SwigType_prefix(const SwigType *t) {
}
if (*d == '.') {
- char t = *(d + 1);
- *(d + 1) = 0;
- r = NewString(c);
- *(d + 1) = t;
+ //char t = *(d + 1);
+ //*(d + 1) = 0;
+ r = NewStringWithSize(c, d+1-c);
+ //*(d + 1) = t;
return r;
}
}
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index 5c6d236d1..2bb0fef09 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -755,7 +755,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
r = SwigType_prefix(t);
if (!type) {
if (r && Len(r)) {
- char *cr = Char(r);
+ const char *cr = Char(r);
if ((strstr(cr, "f(") || (strstr(cr, "m(")))) {
SwigType *rt = SwigType_typedef_resolve(r);
if (rt) {
@@ -953,7 +953,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
break;
lastnode = n;
if (n) {
- char *ntype = Char(nodeType(n));
+ const char *ntype = Char(nodeType(n));
if (strcmp(ntype, "enumitem") == 0) {
/* An enum item. Generate a fully qualified name */
String *qn = Swig_symbol_qualified(n);
@@ -1051,7 +1051,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
* Checks a typename to see if it is a typedef.
* ----------------------------------------------------------------------------- */
-int SwigType_istypedef(SwigType *t) {
+int SwigType_istypedef(const SwigType *t) {
String *type;
type = SwigType_typedef_resolve(t);
@@ -1186,8 +1186,8 @@ int SwigType_isclass(SwigType *t) {
* everything is based on typemaps.
* ----------------------------------------------------------------------------- */
-int SwigType_type(SwigType *t) {
- char *c;
+int SwigType_type(const SwigType *t) {
+ const char *c;
/* Check for the obvious stuff */
c = Char(t);
@@ -1486,7 +1486,7 @@ void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientda
Printf(stdout,"fr= '%s'\n\n", fr); */
if (t) {
- char *ct = Char(t);
+ const char *ct = Char(t);
if (strchr(ct, '<') && !(strstr(ct, "<("))) {
Printf(stdout, "Bad template type passed to SwigType_remember: %s\n", t);
assert(0);
diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c
index 11518bfc2..f57c442e8 100644
--- a/Source/Swig/wrapfunc.c
+++ b/Source/Swig/wrapfunc.c
@@ -465,11 +465,11 @@ int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) {
* used. Returns the name that was actually selected.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
+const char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
int i;
String *nname = NewString(name);
String *ndecl = NewString(decl);
- char *ret;
+ const char *ret;
i = 0;
@@ -496,9 +496,9 @@ char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
+const char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
va_list ap;
- char *ret;
+ const char *ret;
String *decl;
DOH *obj;
decl = NewStringEmpty();