Added strcasestr
This commit is contained in:
parent
e215fc40c9
commit
2f82ecd85d
2 changed files with 14 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue