[Kst] extragear/graphics/kst/kst/datasources/ascii

George Staikos staikos at kde.org
Fri Jun 24 21:03:22 CEST 2005


SVN commit 428636 by staikos:

- preincrement
- don't atof() if we know it's wrong


 M  +9 -7      ascii.cpp  


--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #428635:428636
@@ -308,7 +308,7 @@
         is_comment = true;
       } else if (tmpbuf[i] == '\n' || tmpbuf[i] == '\r') {
         if (has_dat) {
-          _numFrames++;
+          ++_numFrames;
           if (_numFrames >= _numLinesAlloc) {
             _numLinesAlloc += 32768;
             _rowIndex = (int *)realloc(_rowIndex, _numLinesAlloc*sizeof(int));
@@ -413,10 +413,11 @@
         } else {
           if (!incol) {
             incol = true;
-            i_col++;
+            ++i_col;
             if (i_col == col) {
-              v[i] = atof(_tmpBuf + ch);
-              if (v[i] == 0.0 && !isdigit(_tmpBuf[ch])) {
+              if (isdigit(_tmpBuf[ch])) {
+                v[i] = atof(_tmpBuf + ch);
+              } else {
                 v[i] = NAN;
               }
               break;
@@ -443,10 +444,11 @@
         } else {
           if (!incol) {
             incol = true;
-            i_col++;
+            ++i_col;
             if (i_col == col) {
-              v[i] = atof(_tmpBuf + ch);
-              if (v[i] == 0.0 && !isdigit(_tmpBuf[ch])) {
+              if (isdigit(_tmpBuf[ch])) {
+                v[i] = atof(_tmpBuf + ch);
+              } else {
                 v[i] = NAN;
               }
               break;


More information about the Kst mailing list