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

character.


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

View file

@ -697,7 +697,7 @@ static void check_extensions() {
if (!extendhash) return;
for (ki = First(extendhash); ki.key; ki = Next(ki)) {
if (!Strstr(ki.key,"<")) {
if (!Strchr(ki.key,'<')) {
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_WARN_NODE_END(ki.item);
@ -1042,10 +1042,10 @@ static Node *dump_nested(const char *parent) {
if (code_ptr) {
char *open_bracket_pos;
code_ptr += strlen(types_array[i]);
open_bracket_pos = strstr(code_ptr, "{");
open_bracket_pos = strchr(code_ptr, '{');
if (open_bracket_pos) {
/* 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)))
while (code_ptr < open_bracket_pos)
*code_ptr++ = ' ';
@ -1061,7 +1061,7 @@ static Node *dump_nested(const char *parent) {
while (code_ptr) {
code_ptr = strstr(code_ptr, "%constant");
if (code_ptr) {
char* directive_end_pos = strstr(code_ptr, ";");
char* directive_end_pos = strchr(code_ptr, ';');
if (directive_end_pos) {
while (code_ptr <= directive_end_pos)
*code_ptr++ = ' ';
@ -2780,8 +2780,8 @@ c_declaration : c_decl {
}
| c_enum_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 {
if (Strcmp($2,"C") == 0) {
@ -3496,7 +3496,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
if ($$) tname = Getattr($$,k_name);
/* 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. */
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
and the constructor is missing the template part, we
add it */
if (Classprefix && (c = strstr(Char(Classprefix),"<"))) {
if (!Strstr($3,"<")) {
if (Classprefix && (c = strchr(Char(Classprefix),'<'))) {
if (!Strchr($3,'<')) {
$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);
}
if (strstr(Char(name),"<")) {
if (strchr(Char(name),'<')) {
Append(patchlist,Getattr(n,k_name));
} else {
Append(name,templateargs);
}
name = Getattr(n,k_symname);
if (name) {
if (strstr(Char(name),"<")) {
if (strchr(Char(name),'<')) {
Clear(name);
Append(name,rname);
Append(name,rname);
} else {
String *tmp = Copy(name);
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);
} else if (StringEqual(nodeType,k_destructor)) {
String *name = Getattr(n,k_name);
if (name && strstr(Char(name),"<")) {
if (name && strchr(Char(name),'<')) {
Append(patchlist,Getattr(n,k_name));
} else {
Append(name,templateargs);
}
name = Getattr(n,k_symname);
if (name && strstr(Char(name),"<")) {
if (name && strchr(Char(name),'<')) {
String *sn = Copy(tname);
Setattr(n,k_symname, sn);
Delete(sn);
@ -184,7 +184,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
Append(cpatchlist,Getattr(n,k_code));
} else if (StringEqual(nodeType,k_using)) {
String *uname = Getattr(n,k_uname);
if (uname && strstr(Char(uname),"<")) {
if (uname && strchr(Char(uname),'<')) {
Append(patchlist, uname);
}
if (Getattr(n,k_namespace)) {
@ -218,8 +218,8 @@ String *partial_arg(String *s, String *p) {
String *newarg;
/* Find the prefix on the partial argument */
c = strstr(cp,"$");
c = strchr(cp,'$');
if (!c) {
return Copy(s);
}

View file

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

View file

@ -327,7 +327,7 @@ class Allocate : public Dispatcher {
if (!name) continue;
String *base_decl = Getattr(nn,"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)) {
search_decl = SwigType_pop_function(base_decl);

View file

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

View file

@ -321,7 +321,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
if (c == '(') {
argstr = NewStringEmpty();
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) {
if (c == ')') break;
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
nothing happens */
if (strstr(StringChar(ns),"`")) {
if (strchr(StringChar(ns),'`')) {
String *rep;
char *c;
Clear(temp);
@ -884,7 +884,7 @@ expand_macro(String *name, List *args)
Printf(f,"/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g);
#else
/* 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);
} else {
StringAppend(f,g);

View file

@ -892,7 +892,7 @@ String *Swig_string_rxspencer(String *s) {
if (retval != REG_NOMATCH) {
char *spos = 0;
res = NewStringWithSize(cb, ce - cb);
spos = Strstr(res,"@");
spos = Strchr(res,'@');
while (spos) {
char cd = *(++spos);
if (isdigit(cd)) {
@ -908,9 +908,9 @@ String *Swig_string_rxspencer(String *s) {
} else {
Replaceall(res,arg,"");
}
spos = Strstr(res,"@");
spos = Strchr(res,'@');
} 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) {
List *list = NewList();
const char *cattr = strstr(ckey,"$");
const char *cattr = strchr(ckey,'$');
if (cattr) {
String *nattr;
const char *rattr = strstr(++cattr,"$");
const char *rattr = strchr(++cattr,'$');
while (rattr) {
nattr = NewStringWithSize(cattr, rattr-cattr);
Append(list,nattr);
Delete(nattr);
cattr = rattr + 1;
rattr = strstr(cattr,"$");
rattr = strchr(cattr,'$');
}
nattr = NewString(cattr);
Append(list,nattr);
@ -1158,14 +1158,14 @@ int Swig_name_match_value(String *mvalue, String *value)
int match = 0;
char *cvalue = Char(value);
char *cmvalue = Char(mvalue);
char *sep = strstr(cmvalue,"|");
char *sep = strchr(cmvalue,'|');
while (sep && !match) {
match = strncmp(cvalue,cmvalue, sep - cmvalue) == 0;
#ifdef SWIG_DEBUG
Printf(stderr,"match_value: %s %s %d\n",cvalue,cmvalue, match);
#endif
cmvalue = sep + 1;
sep = strstr(cmvalue,"|");
sep = strchr(cmvalue,'|');
}
if (!match) {
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)) == '~');
String *fmt = newname;
/* 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) {
result = NewStringf(fmt,prefix,name);
} else {

View file

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

View file

@ -1437,7 +1437,7 @@ void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata)
if (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);
assert(0);
}

View file

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