[haiku-commits] r35244 - haiku/trunk/src/kits/shared

Author: stippi
Date: 2010-01-22 22:02:04 +0100 (Fri, 22 Jan 2010)
New Revision: 35244
Changeset: http://dev.haiku-os.org/changeset/35244/haiku

Modified:
   haiku/trunk/src/kits/shared/ExpressionParser.cpp
Log:
Fix parsing scientific notation in the form of 1E+6 or 1E-6.


Modified: haiku/trunk/src/kits/shared/ExpressionParser.cpp
===================================================================
--- haiku/trunk/src/kits/shared/ExpressionParser.cpp    2010-01-22 20:54:33 UTC 
(rev 35243)
+++ haiku/trunk/src/kits/shared/ExpressionParser.cpp    2010-01-22 21:02:04 UTC 
(rev 35244)
@@ -137,11 +137,22 @@
                        BString temp;
 
                        const char* begin = fCurrentChar;
+                       bool expectE = true;
+                       bool expectPlusOfMinus = false;
                        while (*fCurrentChar != 0) {
                                if (!isdigit(*fCurrentChar)) {
-                                       if (!(*fCurrentChar == '.' || 
*fCurrentChar == ','
-                                               || *fCurrentChar == 'e' || 
*fCurrentChar == 'E'))
+                                       if (*fCurrentChar == 'e' || 
*fCurrentChar == 'E') {
+                                               if (!expectE)
+                                                       break;
+                                               expectE = false;
+                                               expectPlusOfMinus = true;
+                                       } else if (*fCurrentChar == '+' || 
*fCurrentChar == '-') {
+                                               if (!expectPlusOfMinus)
+                                                       break;
+                                       } else if (!(*fCurrentChar == '.' || 
*fCurrentChar == ','))
                                                break;
+                                       else
+                                               expectPlusOfMinus = false;
                                }
                                if (*fCurrentChar == ',')
                                        temp << '.';


Other related posts:

  • » [haiku-commits] r35244 - haiku/trunk/src/kits/shared - superstippi