diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-01-08 15:39:16 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-01-08 15:39:16 -0800 |
commit | 3e42921c657bc93094f0c7d96855aae9b0be5a7e (patch) | |
tree | fe74fd1c1f8b370084091f1e26aef94ad427e7b0 /src/common/extract.hpp | |
parent | 8b0d596d0bfce7666e59952a6949572ab826b43c (diff) | |
download | tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.gz tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.bz2 tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.xz tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.zip |
Improve warnings; fix const_db.txt bug.
Diffstat (limited to 'src/common/extract.hpp')
-rw-r--r-- | src/common/extract.hpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/common/extract.hpp b/src/common/extract.hpp index 52df9df..24456be 100644 --- a/src/common/extract.hpp +++ b/src/common/extract.hpp @@ -29,14 +29,9 @@ bool extract(const_string str, T *iv) { if (!str || str.size() > 20) return false; - switch (str.front()) - { - case '-': - case '0' ... '9': - break; - default: - return false; - } + if (!((str.front() == '-' && std::is_signed<T>::value) + || ('0' <= str.front() && str.front() <= '9'))) + return false; char buf[20 + 1]; std::copy(str.begin(), str.end(), buf); buf[str.size()] = '\0'; @@ -53,8 +48,6 @@ bool extract(const_string str, T *iv) } else { - if (str.front() == '-') - return false; unsigned long long v = strtoull(buf, &end, 10); if (errno || *end) return false; |