Added strcasestr
fluxgen fluxgen
2 files changed,
14 insertions(+),
0 deletions(-)
M
src/StringUtil.cc
→
src/StringUtil.cc
@@ -35,6 +35,19 @@ strncpy(n, s, l);
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
M
src/StringUtil.hh
→
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); };