summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dbg-util.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-09-07 16:09:04 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-09-07 16:09:04 +0200
commit218de6a8af4f7b4165112c6fd55d95e184b9f565 (patch)
tree7092dc584f96f5c3857c33b7dcb8948c4c3435f2 /crawl-ref/source/dbg-util.cc
parent5a1df532ff9e1c4ed2f1000392621789dc6dfafa (diff)
downloadcrawl-ref-218de6a8af4f7b4165112c6fd55d95e184b9f565.tar.gz
crawl-ref-218de6a8af4f7b4165112c6fd55d95e184b9f565.zip
Get rid of strlwr().
Besides being non-standard and present only on some platforms, it cannot be extended to Unicode as some characters expand or contract while being upper/lowercased.
Diffstat (limited to 'crawl-ref/source/dbg-util.cc')
-rw-r--r--crawl-ref/source/dbg-util.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/crawl-ref/source/dbg-util.cc b/crawl-ref/source/dbg-util.cc
index c1f7ff593c..b9f6056777 100644
--- a/crawl-ref/source/dbg-util.cc
+++ b/crawl-ref/source/dbg-util.cc
@@ -326,6 +326,7 @@ skill_type debug_prompt_for_skill(const char *prompt)
if (specs[0] == '\0')
return (SK_NONE);
+ std::string spec = lowercase_string(specs);
skill_type skill = SK_NONE;
@@ -336,20 +337,15 @@ skill_type debug_prompt_for_skill(const char *prompt)
if (is_invalid_skill(sk))
continue;
- char sk_name[80];
- strncpy(sk_name, skill_name(sk), sizeof(sk_name));
+ std::string sk_name = lowercase_string(skill_name(sk));
- char *ptr = strstr(strlwr(sk_name), strlwr(specs));
- if (ptr != NULL)
+ size_t pos = sk_name.find(spec);
+ if (pos != std::string::npos)
{
- if (ptr == sk_name && strlen(specs) > 0)
- {
- // We prefer prefixes over partial matches.
- skill = sk;
+ skill = sk;
+ // We prefer prefixes over partial matches.
+ if (!pos)
break;
- }
- else
- skill = sk;
}
}