mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 21:40:03 +00:00
fix config::valid_id()
previously config::valid_id() had the following issues: 1) It passed its parameter by copy. 2) It used isalnum, which depends on the current locale, this means that its reults might be different on different machines and it also means that its slow becasue it must check the current locale.
This commit is contained in:
parent
84ff8f4d96
commit
c55faadecc
@ -480,13 +480,16 @@ config &config::operator=(config &&cfg)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool config::valid_id(const std::string id)
|
||||
bool config::valid_id(const std::string& id)
|
||||
{
|
||||
if (id.empty()) {
|
||||
return false;
|
||||
}
|
||||
BOOST_FOREACH(char c, id) {
|
||||
if (!isalnum(c) && c != '_') {
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
|
||||
//valid character.
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
~config();
|
||||
|
||||
// Verifies that the string can be used as an attribute or tag name
|
||||
static bool valid_id(std::string);
|
||||
static bool valid_id(const std::string& id);
|
||||
|
||||
#ifdef HAVE_CXX11
|
||||
explicit operator bool() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user