From 3e42921c657bc93094f0c7d96855aae9b0be5a7e Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 8 Jan 2013 15:39:16 -0800 Subject: Improve warnings; fix const_db.txt bug. --- src/common/cxxstdio.hpp | 2 +- src/common/extract.hpp | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'src/common') diff --git a/src/common/cxxstdio.hpp b/src/common/cxxstdio.hpp index 6f5072e..d7c0634 100644 --- a/src/common/cxxstdio.hpp +++ b/src/common/cxxstdio.hpp @@ -67,7 +67,7 @@ namespace cxxstdio return vsscanf(in, fmt, ap); } #else - int do_vscan(const char *in, const char *fmt, va_list ap) = delete; + int do_vscan(const char *, const char *, va_list) = delete; #endif inline __attribute__((format(scanf, 2, 0))) 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::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; -- cgit v1.2.3-70-g09d2