# HG changeset patch
# User Santeri Piippo <crimsondusk64@gmail.com>
# Date 1369435451 -10800
# Node ID 9f7e6e2889537a5a7090fd93d3ac83a9319c20c2
# Parent  67d4aedf10416c3150517fc80433423fb332f6cb
rewrote isNumber using range-for

diff -r 67d4aedf1041 -r 9f7e6e288953 src/misc.cpp
--- a/src/misc.cpp	Fri May 24 20:38:55 2013 +0300
+++ b/src/misc.cpp	Sat May 25 01:44:11 2013 +0300
@@ -137,43 +137,40 @@
 	// turn into anything weird (like commas)
 	setlocale (LC_NUMERIC, "C");
 	
-	str zRep = fmt ("%f", num);
+	str rep = fmt ("%f", num);
 	
 	// Remove trailing zeroes
-	while (zRep[~zRep - 1] == '0')
-		zRep -= 1;
+	while (rep[~rep - 1] == '0')
+		rep -= 1;
 	
 	// If there was only zeroes in the decimal place, remove
 	// the decimal point now.
-	if (zRep[~zRep - 1] == '.')
-		zRep -= 1;
+	if (rep[~rep - 1] == '.')
+		rep -= 1;
 	
-	return zRep;
+	return rep;
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-bool isNumber (str& tok) {
-	char* cpPointer = &tok[0];
-	bool bGotDot = false;
+bool isNumber (const str& tok) {
+	char* ptr = &tok[0];
+	bool gotDot = false;
 	
-	// Allow leading hyphen for negatives
-	if (*cpPointer == '-')
-		cpPointer++;
-	
-	while (*cpPointer != '\0') {
-		if (*cpPointer == '.' && !bGotDot) {
-			// Decimal point
-			bGotDot = true;
-			cpPointer++;
+	for (const char& c : tok) {
+		// Allow leading hyphen for negatives
+		if (&c == &tok[0] && c == '-')
+			continue;
+		
+		// Check for decimal point
+		if (!gotDot && c == '.') {
+			gotDot = true;
 			continue;
 		}
 		
-		if (*cpPointer >= '0' && *cpPointer <= '9') {
-			cpPointer++;
+		if (c >= '0' && c <= '9')
 			continue; // Digit
-		}
 		
 		// If the above cases didn't catch this character, it was
 		// illegal and this is therefore not a number.
diff -r 67d4aedf1041 -r 9f7e6e288953 src/misc.h
--- a/src/misc.h	Fri May 24 20:38:55 2013 +0300
+++ b/src/misc.h	Sat May 25 01:44:11 2013 +0300
@@ -31,7 +31,7 @@
 extern const ushort g_primes[NUM_PRIMES];
 
 // Returns whether a given string represents a floating point number.
-bool isNumber (str& tok);
+bool isNumber (const str& tok);
 
 // Converts a float value to a string value.
 str ftoa (double num);