From 2f82ecd85d70d022bedab2d0844198a14cb40f2d Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 6 Jan 2002 13:35:28 +0000 Subject: Added strcasestr --- src/StringUtil.cc | 13 +++++++++++++ src/StringUtil.hh | 1 + 2 files changed, 14 insertions(+) diff --git a/src/StringUtil.cc b/src/StringUtil.cc index dabc02e..6d4a582 100644 --- a/src/StringUtil.cc +++ b/src/StringUtil.cc @@ -35,6 +35,19 @@ char *StringUtil::strdup(const char *s) { 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 ---------------------- // if ~ then expand it to home of user diff --git a/src/StringUtil.hh b/src/StringUtil.hh index e48b4dd..d9fda35 100644 --- a/src/StringUtil.hh +++ b/src/StringUtil.hh @@ -24,6 +24,7 @@ struct StringUtil { static char *strdup(const char *); + static const char *strcasestr(const char *str, const char *ptn); static char *expandFilename(const char *filename); }; -- cgit v0.11.2