Use Strchr/strchr instead of Strstr/strstr when searching for a single

character.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9334 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-23 22:36:23 +00:00
commit b17fcc97f7
11 changed files with 38 additions and 38 deletions

View file

@ -697,7 +697,7 @@ static void check_extensions() {
if (!extendhash) return; if (!extendhash) return;
for (ki = First(extendhash); ki.key; ki = Next(ki)) { for (ki = First(extendhash); ki.key; ki = Next(ki)) {
if (!Strstr(ki.key,"<")) { if (!Strchr(ki.key,'<')) {
SWIG_WARN_NODE_BEGIN(ki.item); SWIG_WARN_NODE_BEGIN(ki.item);
Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", ki.key); Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", ki.key);
SWIG_WARN_NODE_END(ki.item); SWIG_WARN_NODE_END(ki.item);
@ -1042,10 +1042,10 @@ static Node *dump_nested(const char *parent) {
if (code_ptr) { if (code_ptr) {
char *open_bracket_pos; char *open_bracket_pos;
code_ptr += strlen(types_array[i]); code_ptr += strlen(types_array[i]);
open_bracket_pos = strstr(code_ptr, "{"); 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; */ /* Make sure we don't have something like struct A a; */
char* semi_colon_pos = strstr(code_ptr, ";"); char* semi_colon_pos = strchr(code_ptr, ';');
if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos))) if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos)))
while (code_ptr < open_bracket_pos) while (code_ptr < open_bracket_pos)
*code_ptr++ = ' '; *code_ptr++ = ' ';
@ -1061,7 +1061,7 @@ static Node *dump_nested(const char *parent) {
while (code_ptr) { while (code_ptr) {
code_ptr = strstr(code_ptr, "%constant"); code_ptr = strstr(code_ptr, "%constant");
if (code_ptr) { if (code_ptr) {
char* directive_end_pos = strstr(code_ptr, ";"); char* directive_end_pos = strchr(code_ptr, ';');
if (directive_end_pos) { if (directive_end_pos) {
while (code_ptr <= directive_end_pos) while (code_ptr <= directive_end_pos)
*code_ptr++ = ' '; *code_ptr++ = ' ';
@ -2780,8 +2780,8 @@ c_declaration : c_decl {
} }
| c_enum_decl { $$ = $1; } | c_enum_decl { $$ = $1; }
| c_enum_forward_decl { $$ = $1; } | c_enum_forward_decl { $$ = $1; }
/* A an extern C type declaration, disable cparse_cplusplus if needed. */ /* An extern C type declaration, disable cparse_cplusplus if needed. */
| EXTERN string LBRACE { | EXTERN string LBRACE {
if (Strcmp($2,"C") == 0) { if (Strcmp($2,"C") == 0) {
@ -3496,7 +3496,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
if ($$) tname = Getattr($$,k_name); if ($$) tname = Getattr($$,k_name);
/* Check if the class is a template specialization */ /* Check if the class is a template specialization */
if (($$) && (Strstr(tname,"<")) && (!is_operator(tname))) { if (($$) && (Strchr(tname,'<')) && (!is_operator(tname))) {
/* If a specialization. Check if defined. */ /* If a specialization. Check if defined. */
Node *tempn = 0; Node *tempn = 0;
{ {
@ -4022,8 +4022,8 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
/* Check for template names. If the class is a template /* Check for template names. If the class is a template
and the constructor is missing the template part, we and the constructor is missing the template part, we
add it */ add it */
if (Classprefix && (c = strstr(Char(Classprefix),"<"))) { if (Classprefix && (c = strchr(Char(Classprefix),'<'))) {
if (!Strstr($3,"<")) { if (!Strchr($3,'<')) {
$3 = NewStringf("%s%s",$3,c); $3 = NewStringf("%s%s",$3,c);
} }
} }

View file

@ -141,16 +141,16 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
} }
Delete(stripped_name); Delete(stripped_name);
} }
if (strstr(Char(name),"<")) { if (strchr(Char(name),'<')) {
Append(patchlist,Getattr(n,k_name)); Append(patchlist,Getattr(n,k_name));
} else { } else {
Append(name,templateargs); Append(name,templateargs);
} }
name = Getattr(n,k_symname); name = Getattr(n,k_symname);
if (name) { if (name) {
if (strstr(Char(name),"<")) { if (strchr(Char(name),'<')) {
Clear(name); Clear(name);
Append(name,rname); Append(name,rname);
} else { } else {
String *tmp = Copy(name); String *tmp = Copy(name);
Replace(tmp,tname,rname, DOH_REPLACE_ANY); Replace(tmp,tname,rname, DOH_REPLACE_ANY);
@ -167,13 +167,13 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
add_parms(Getattr(n,k_throws), cpatchlist, typelist); add_parms(Getattr(n,k_throws), cpatchlist, typelist);
} else if (StringEqual(nodeType,k_destructor)) { } else if (StringEqual(nodeType,k_destructor)) {
String *name = Getattr(n,k_name); String *name = Getattr(n,k_name);
if (name && strstr(Char(name),"<")) { if (name && strchr(Char(name),'<')) {
Append(patchlist,Getattr(n,k_name)); Append(patchlist,Getattr(n,k_name));
} else { } else {
Append(name,templateargs); Append(name,templateargs);
} }
name = Getattr(n,k_symname); name = Getattr(n,k_symname);
if (name && strstr(Char(name),"<")) { if (name && strchr(Char(name),'<')) {
String *sn = Copy(tname); String *sn = Copy(tname);
Setattr(n,k_symname, sn); Setattr(n,k_symname, sn);
Delete(sn); Delete(sn);
@ -184,7 +184,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
Append(cpatchlist,Getattr(n,k_code)); Append(cpatchlist,Getattr(n,k_code));
} else if (StringEqual(nodeType,k_using)) { } else if (StringEqual(nodeType,k_using)) {
String *uname = Getattr(n,k_uname); String *uname = Getattr(n,k_uname);
if (uname && strstr(Char(uname),"<")) { if (uname && strchr(Char(uname),'<')) {
Append(patchlist, uname); Append(patchlist, uname);
} }
if (Getattr(n,k_namespace)) { if (Getattr(n,k_namespace)) {
@ -218,8 +218,8 @@ String *partial_arg(String *s, String *p) {
String *newarg; String *newarg;
/* Find the prefix on the partial argument */ /* Find the prefix on the partial argument */
c = strstr(cp,"$"); c = strchr(cp,'$');
if (!c) { if (!c) {
return Copy(s); return Copy(s);
} }

View file

@ -55,7 +55,7 @@ static DOH *encode(char *name, DOH *s) {
DOH *handle, *ns; DOH *handle, *ns;
DOH *(*fn)(DOH *); DOH *(*fn)(DOH *);
long pos; long pos;
char *cfmt = strstr(name,":"); char *cfmt = strchr(name,':');
DOH *tmp = 0; DOH *tmp = 0;
if (cfmt) { if (cfmt) {
tmp = NewString(cfmt + 1); tmp = NewString(cfmt + 1);

View file

@ -327,7 +327,7 @@ class Allocate : public Dispatcher {
if (!name) continue; if (!name) continue;
String *base_decl = Getattr(nn,"decl"); String *base_decl = Getattr(nn,"decl");
if (base_decl) base_decl = SwigType_typedef_resolve_all(base_decl); if (base_decl) base_decl = SwigType_typedef_resolve_all(base_decl);
if (Strstr(name,"~")) continue; /* Don't care about destructors */ if (Strchr(name,'~')) continue; /* Don't care about destructors */
if (SwigType_isfunction(base_decl)) { if (SwigType_isfunction(base_decl)) {
search_decl = SwigType_pop_function(base_decl); search_decl = SwigType_pop_function(base_decl);

View file

@ -89,15 +89,15 @@ Hash *Contracts::ContractSplit(Node *n) {
Iterator i; Iterator i;
for (i = First(l); i.item; i = Next(i)) { for (i = First(l); i.item; i = Next(i)) {
int found = 0; int found = 0;
if (Strstr(i.item,"{")) continue; if (Strchr(i.item,'{')) continue;
if (Strstr(i.item,"}")) continue; if (Strchr(i.item,'}')) continue;
for (int j = 0; Rules[j].section; j++) { for (int j = 0; Rules[j].section; j++) {
if (Strstr(i.item,Rules[j].section)) { if (Strstr(i.item,Rules[j].section)) {
if (Len(current_section)) { if (Len(current_section)) {
Setattr(result,current_section_name,current_section); Setattr(result,current_section_name,current_section);
current_section = Getattr(result,Rules[j].section); current_section = Getattr(result,Rules[j].section);
if (!current_section) current_section = NewString(""); if (!current_section) current_section = NewString("");
} }
current_section_name = Rules[j].section; current_section_name = Rules[j].section;
found = 1; found = 1;
break; break;

View file

@ -321,7 +321,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
if (c == '(') { if (c == '(') {
argstr = NewStringEmpty(); argstr = NewStringEmpty();
copy_location(str,argstr); copy_location(str,argstr);
/* It is a macro. Go extract it's argument string */ /* It is a macro. Go extract its argument string */
while ((c = StringGetc(str)) != EOF) { while ((c = StringGetc(str)) != EOF) {
if (c == ')') break; if (c == ')') break;
else StringPutc(c,argstr); else StringPutc(c,argstr);
@ -793,7 +793,7 @@ expand_macro(String *name, List *args)
version of the argument except that if the argument is already quoted version of the argument except that if the argument is already quoted
nothing happens */ nothing happens */
if (strstr(StringChar(ns),"`")) { if (strchr(StringChar(ns),'`')) {
String *rep; String *rep;
char *c; char *c;
Clear(temp); Clear(temp);
@ -884,7 +884,7 @@ expand_macro(String *name, List *args)
Printf(f,"/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g); Printf(f,"/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g);
#else #else
/* Use simplified around markers to properly count lines in cscanner.c */ /* Use simplified around markers to properly count lines in cscanner.c */
if (strstr(Char(g),"\n")) { if (strchr(Char(g),'\n')) {
Printf(f,"/*@SWIG:%s@*/%s/*@SWIG@*/", name, g); Printf(f,"/*@SWIG:%s@*/%s/*@SWIG@*/", name, g);
} else { } else {
StringAppend(f,g); StringAppend(f,g);

View file

@ -892,7 +892,7 @@ String *Swig_string_rxspencer(String *s) {
if (retval != REG_NOMATCH) { if (retval != REG_NOMATCH) {
char *spos = 0; char *spos = 0;
res = NewStringWithSize(cb, ce - cb); res = NewStringWithSize(cb, ce - cb);
spos = Strstr(res,"@"); spos = Strchr(res,'@');
while (spos) { while (spos) {
char cd = *(++spos); char cd = *(++spos);
if (isdigit(cd)) { if (isdigit(cd)) {
@ -908,9 +908,9 @@ String *Swig_string_rxspencer(String *s) {
} else { } else {
Replaceall(res,arg,""); Replaceall(res,arg,"");
} }
spos = Strstr(res,"@"); spos = Strchr(res,'@');
} else if (cd == '@') { } else if (cd == '@') {
spos = strstr(spos + 1,"@"); spos = strchr(spos + 1,'@');
} }
} }
} }

View file

@ -997,16 +997,16 @@ int Swig_need_protected(Node* n)
static List *Swig_make_attrlist(const char *ckey) { static List *Swig_make_attrlist(const char *ckey) {
List *list = NewList(); List *list = NewList();
const char *cattr = strstr(ckey,"$"); const char *cattr = strchr(ckey,'$');
if (cattr) { if (cattr) {
String *nattr; String *nattr;
const char *rattr = strstr(++cattr,"$"); const char *rattr = strchr(++cattr,'$');
while (rattr) { while (rattr) {
nattr = NewStringWithSize(cattr, rattr-cattr); nattr = NewStringWithSize(cattr, rattr-cattr);
Append(list,nattr); Append(list,nattr);
Delete(nattr); Delete(nattr);
cattr = rattr + 1; cattr = rattr + 1;
rattr = strstr(cattr,"$"); rattr = strchr(cattr,'$');
} }
nattr = NewString(cattr); nattr = NewString(cattr);
Append(list,nattr); Append(list,nattr);
@ -1158,14 +1158,14 @@ int Swig_name_match_value(String *mvalue, String *value)
int match = 0; int match = 0;
char *cvalue = Char(value); char *cvalue = Char(value);
char *cmvalue = Char(mvalue); char *cmvalue = Char(mvalue);
char *sep = strstr(cmvalue,"|"); char *sep = strchr(cmvalue,'|');
while (sep && !match) { while (sep && !match) {
match = strncmp(cvalue,cmvalue, sep - cmvalue) == 0; match = strncmp(cvalue,cmvalue, sep - cmvalue) == 0;
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stderr,"match_value: %s %s %d\n",cvalue,cmvalue, match); Printf(stderr,"match_value: %s %s %d\n",cvalue,cmvalue, match);
#endif #endif
cmvalue = sep + 1; cmvalue = sep + 1;
sep = strstr(cmvalue,"|"); sep = strchr(cmvalue,'|');
} }
if (!match) { if (!match) {
match = strcmp(cvalue,cmvalue) == 0; match = strcmp(cvalue,cmvalue) == 0;
@ -1414,7 +1414,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin
int destructor = name && (*(Char(name)) == '~'); int destructor = name && (*(Char(name)) == '~');
String *fmt = newname; String *fmt = newname;
/* use name as a fmt, but avoid C++ "%" and "%=" operators */ /* use name as a fmt, but avoid C++ "%" and "%=" operators */
if (Len(newname) > 1 && strstr(cnewname,"%") && !(strcmp(cnewname,"%=") == 0)) { if (Len(newname) > 1 && strchr(cnewname,'%') && !(strcmp(cnewname,"%=") == 0)) {
if (fullname && prefix) { if (fullname && prefix) {
result = NewStringf(fmt,prefix,name); result = NewStringf(fmt,prefix,name);
} else { } else {

View file

@ -1664,7 +1664,7 @@ static List *split_embedded(String *s) {
int leading = 1; int leading = 1;
args = NewList(); args = NewList();
c = strstr(Char(s),"("); c = strchr(Char(s),'(');
c++; c++;
start = c; start = c;
@ -1703,7 +1703,7 @@ static void split_var(String *s, String **name, String **value) {
char *eq; char *eq;
char *c; char *c;
eq = strstr(Char(s),"="); eq = strchr(Char(s),'=');
if (!eq) { if (!eq) {
*name = 0; *name = 0;
*value = 0; *value = 0;

View file

@ -1437,7 +1437,7 @@ void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata)
if (t) { if (t) {
char *ct = Char(t); char *ct = Char(t);
if (strstr(ct,"<") && !(strstr(ct,"<("))) { if (strchr(ct,'<') && !(strstr(ct,"<("))) {
Printf(stdout,"Bad template type passed to SwigType_remember: %s\n", t); Printf(stdout,"Bad template type passed to SwigType_remember: %s\n", t);
assert(0); assert(0);
} }

View file

@ -104,7 +104,7 @@ Wrapper_pretty_print(String *str, File *f) {
} else if (c == ':') { } else if (c == ':') {
Putc(c,ts); Putc(c,ts);
if ((c = Getc(str)) == '\n') { if ((c = Getc(str)) == '\n') {
if (!empty && !strstr(Char(ts),"?")) label = 1; if (!empty && !strchr(Char(ts),'?')) label = 1;
} }
Ungetc(c,str); Ungetc(c,str);
} else if (c == '(') { } else if (c == '(') {