src/misc.cpp

changeset 508
7ace3537a560
parent 507
fc76d38c3530
child 538
2f85d4d286e5
--- a/src/misc.cpp	Wed Oct 16 23:07:59 2013 +0300
+++ b/src/misc.cpp	Wed Oct 16 23:20:35 2013 +0300
@@ -128,33 +128,8 @@
 }
 
 // =============================================================================
-// Float to string. Removes trailing zeroes and is locale-independant.
-// TODO: Replace with QString::number()
 // -----------------------------------------------------------------------------
-str ftoa (double num)
-{	// Disable the locale first so that the decimal point will not
-	// turn into anything weird (like commas)
-	setlocale (LC_NUMERIC, "C");
-
-	str rep;
-	rep.sprintf ("%f", num);
-
-	// Remove trailing zeroes
-	while (rep.right (1) == "0")
-		rep.chop (1);
-
-	// If there were only zeroes in the decimal place, remove
-	// the decimal point now.
-	if (rep.right (1) == ".")
-		rep.chop (1);
-
-	return rep;
-}
-
-// =============================================================================
-// TODO: I guess Qt must have something like this stashed somewhere?
-// -----------------------------------------------------------------------------
-bool isNumber (const str& tok)
+bool numeric (const str& tok)
 {	bool gotDot = false;
 
 	for (int i = 0; i < tok.length(); ++i)
@@ -283,28 +258,6 @@
 }
 
 // =============================================================================
-// TODO: I'm quite sure Qt has this covered as well.
-// -----------------------------------------------------------------------------
-double atof (str val)
-{	// Disable the locale while parsing the line or atof's behavior changes
-	// between locales (i.e. fails to read decimals properly). That is
-	// quite undesired...
-	setlocale (LC_NUMERIC, "C");
-
-	char* buf = new char[val.length()];
-	char* bufptr = &buf[0];
-
-	for (QChar& c : val)
-		*bufptr++ = c.toLatin1();
-
-	*bufptr = '\0';
-
-	double fval = atof (buf);
-	delete[] buf;
-	return fval;
-}
-
-// =============================================================================
 // This is the main algorithm of the ring finder. It tries to use math to find
 // the one ring between r0 and r1. If it fails (the ring number is non-integral),
 // it finds an intermediate radius (ceil of the ring number times scale) and

mercurial