[Kst] kdeextragear-2/kst/kst/datasources/ascii

Andrew Walker arwalker at sumusltd.com
Sat Feb 7 01:18:22 CET 2004


CVS commit by arwalker: 

Modified code to recognize that a call to isspace( ... ) returns true for the \n character.


  M +13 -7     ascii.cpp   1.10


--- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp  #1.9:1.10
@@ -113,5 +113,6 @@ KstObject::UpdateType AsciiSource::updat
           has_dat = true;
         }
-      } else if (tmpbuf[i] == '\n') {
+      } else if (tmpbuf[i] == '\n' ||
+                 tmpbuf[i] == '\r') {
         if (has_dat) {
           _numFrames++;
@@ -170,19 +171,24 @@ int AsciiSource::readField(double *v, co
   file.readBlock(tmpbuf, bufread);
 
+  memset( v, 0, n * sizeof( double ) );
+  
   for (int i = 0; i < n; i++, s++) {
     bool done = false;
     bool incol = false;
     int i_col = 0;
-    for (int ch = _rowIndex[s] - bufstart; !done; ch++) {
+    for (int ch = _rowIndex[s] - bufstart; !done && ch < bufread; ch++) {
       if (isspace(tmpbuf[ch])) {
-        incol = false;
-      } else if (tmpbuf[ch] == '\n') {
+        if (tmpbuf[ch] == '\n' ||
+            tmpbuf[ch] == '\r' ) {
         done = true;
-        v[i] = 0;
+        }
+        else
+        {
+          incol = false;
+        }
       } else if (tmpbuf[ch] == '#' || tmpbuf[ch] == '!' ||
           tmpbuf[ch] == '/' || tmpbuf[ch] == ';' ||
           tmpbuf[ch] == 'c') {
         done = true;
-        v[i] = 0;
       } else {
         if (!incol) {





More information about the Kst mailing list