summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/cxxstdio.hpp2
-rw-r--r--src/common/extract.hpp13
2 files changed, 4 insertions, 11 deletions
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<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;