summaryrefslogtreecommitdiffstats
path: root/src/StringUtils.h
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-08-13 14:37:07 +0200
committerTycho <work.tycho+git@gmail.com>2014-08-13 14:37:07 +0200
commitf4d268636a02346acc46c993666fe02bbc1ff0b8 (patch)
tree22d2be3aaff407d02f94a28d09f1afd539a0e2e2 /src/StringUtils.h
parentAdded missing header (diff)
downloadcuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar.gz
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar.bz2
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar.lz
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar.xz
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.tar.zst
cuberite-f4d268636a02346acc46c993666fe02bbc1ff0b8.zip
Diffstat (limited to '')
-rw-r--r--src/StringUtils.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/StringUtils.h b/src/StringUtils.h
index 30a193845..a78f8b0bf 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -100,12 +100,12 @@ extern int GetBEInt(const char * a_Mem);
/// Writes four bytes to the specified memory location so that they interpret as BigEndian int
extern void SetBEInt(char * a_Mem, Int32 a_Value);
-/// Parses any integer type. Checks bounds and
+/// Parses any integer type. Checks bounds and returns errors out of band.
template<class T>
-bool StringToInteger(AString a_str, T& a_Num)
+bool StringToInteger(const AString& a_str, T& a_Num)
{
size_t i = 0;
- T positive = true;
+ bool positive = true;
T result = 0;
if (a_str[0] == '+')
{
@@ -118,7 +118,7 @@ bool StringToInteger(AString a_str, T& a_Num)
}
if (positive)
{
- for(; i <= a_str.size(); i++)
+ for(size_t size = a_str.size(); i < size; i++)
{
if ((a_str[i] <= '0') || (a_str[i] >= '9'))
{
@@ -139,7 +139,7 @@ bool StringToInteger(AString a_str, T& a_Num)
}
else
{
- for(; i <= a_str.size(); i++)
+ for(size_t size = a_str.size(); i < size; i++)
{
if ((a_str[i] <= '0') || (a_str[i] >= '9'))
{