summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/convto.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/convto.h b/include/convto.h
index 9ace83261..1fc684829 100644
--- a/include/convto.h
+++ b/include/convto.h
@@ -104,14 +104,14 @@ template<> inline char ConvToNum<char>(const std::string& in)
{
// We specialise ConvToNum for char to avoid istringstream treating
// the input as a character literal.
- uint16_t num = ConvToNum<uint16_t>(in);
- return num <= UINT8_MAX ? num : 0;
+ int16_t num = ConvToNum<int16_t>(in);
+ return num >= INT8_MIN && num <= INT8_MAX ? num : 0;
}
template<> inline unsigned char ConvToNum<unsigned char>(const std::string& in)
{
// We specialise ConvToNum for unsigned char to avoid istringstream
// treating the input as a character literal.
- int16_t num = ConvToNum<int16_t>(in);
- return num >= INT8_MIN && num <= INT8_MAX ? num : 0;
+ uint16_t num = ConvToNum<uint16_t>(in);
+ return num <= UINT8_MAX ? num : 0;
}