瀏覽代碼

allowed '-' in double

Wolfgang Ortmann 9 年之前
父節點
當前提交
f6116b6645
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/stringtools.cpp

+ 3 - 3
src/stringtools.cpp

@@ -126,10 +126,10 @@ long int getLongInt(const string& s, unsigned int& i)
 
 double getDouble(const string& s, unsigned int& i)
 {
-  if (!isdigit(s[i]))
-    throw Exception("getLongInt", "digit expected");
+  if (!isdigit(s[i])||s[i]=='-')
+    throw Exception("getDouble", "digit expected");
   string is;
-  while (i < s.size() && (isdigit(s[i]) || s[i]=='.' || s[i]=='e' || s[i]=='E'))
+  while (i < s.size() && (isdigit(s[i]) || s[i]=='-' || s[i]=='.' || s[i]=='e' || s[i]=='E'))
     {
       is += s[i];
       ++i;