Bug 1103 - Useless assignment in omnet-data-output.cc
authorMitch Watrous <watrous@u.washington.edu>
Fri, 13 May 2011 13:43:00 -0700
changeset 7200 4e1d562d5029
parent 7199 eae56a101979
child 7201 61140caa6f71
Bug 1103 - Useless assignment in omnet-data-output.cc
src/stats/model/omnet-data-output.cc
--- a/src/stats/model/omnet-data-output.cc	Fri May 13 13:07:57 2011 -0700
+++ b/src/stats/model/omnet-data-output.cc	Fri May 13 13:43:00 2011 -0700
@@ -57,10 +57,29 @@
 //----------------------------------------------
 
 inline bool isNumeric(const std::string& s) {
-  char *endp;
-  double unused = strtod(s.c_str(), &endp); // declared with warn_unused_result
-  unused = unused; // quiet compiler
-  return endp == s.c_str() + s.size();
+  bool decimalPtSeen = false;
+  bool exponentSeen = false;
+  char last = '\0';
+
+  for (std::string::const_iterator it = s.begin (); it != s.end (); it++)
+    {
+      if ((*it == '.') && (decimalPtSeen))
+        return false;
+      else if (*it == '.')
+        decimalPtSeen = true;
+      else if ((*it == 'e') && exponentSeen)
+        return false;
+      else if (*it == 'e')
+        {
+          exponentSeen = true;
+          decimalPtSeen = false;
+        }
+      else if (*it == '-' && it != s.begin () && last != 'e')
+        return false;
+
+      last = *it;
+    }
+  return true;
 }
 
 void