From 51d8f1fc9cc8ed4280b9c53b135ccb0521e84889 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 30 Jul 2008 09:22:02 +0000 Subject: Removed use of nonstandard strcasestr. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6731 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spl-util.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/spl-util.cc') diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 9b6f978ebd..f86cc634c9 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -142,24 +142,29 @@ spschool_flag_type school_by_name(std::string name) short_match = long_match = SPTYP_NONE; short_matches = long_matches = 0; + lowercase(name); + for (int i = 0; i <= SPTYP_RANDOM; i++) { spschool_flag_type type = (spschool_flag_type) (1 << i); - const char* short_name = spelltype_short_name(type); - const char* long_name = spelltype_long_name(type); + std::string short_name = spelltype_short_name(type); + std::string long_name = spelltype_long_name(type); + + lowercase(short_name); + lowercase(long_name); - if (strcasecmp(short_name, name.c_str()) == 0) + if (name == short_name) return type; - if (strcasecmp(long_name, name.c_str()) == 0) + if (name == long_name) return type; - if (strcasestr(short_name, name.c_str())) + if (short_name.find(name) != std::string::npos) { short_match = type; short_matches++; } - if (strcasestr(long_name, name.c_str())) + if (long_name.find(name) != std::string::npos) { long_match = type; long_matches++; -- cgit v1.2.3-54-g00ecf