Added strcasestr

This commit is contained in:
fluxgen 2002-01-06 13:35:28 +00:00
parent e215fc40c9
commit 2f82ecd85d
2 changed files with 14 additions and 0 deletions

View file

@ -35,6 +35,19 @@ char *StringUtil::strdup(const char *s) {
return n; return n;
} }
//------- strcasestr --------------
// TODO: comment this
//---------------------------------
const char * StringUtil::strcasestr(const char *str, const char *ptn) {
const char *s2, *p2;
for( ; *str; str++) {
for(s2=str,p2=ptn; ; s2++,p2++) {
if (!*p2) return str;
if (toupper(*s2) != toupper(*p2)) break;
}
}
return 0;
}
//------------- expandFilename ---------------------- //------------- expandFilename ----------------------
// if ~ then expand it to home of user // if ~ then expand it to home of user

View file

@ -24,6 +24,7 @@
struct StringUtil struct StringUtil
{ {
static char *strdup(const char *); static char *strdup(const char *);
static const char *strcasestr(const char *str, const char *ptn);
static char *expandFilename(const char *filename); static char *expandFilename(const char *filename);
}; };