[Kst] branches/work/kst/portto4/kst/src/datasources/ascii

Peter Kümmel syntheticpp at gmx.net
Sun Aug 29 17:09:16 CEST 2010


SVN commit 1169537 by kuemmel:

fix bug introduced by cleanup: read size of line not size of file into 'rc'

 M  +8 -10     asciiplugin.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiplugin.cpp #1169536:1169537
@@ -315,11 +315,9 @@
 
   QFile f(filename);
   if (f.open(QIODevice::ReadOnly)) {
-    QByteArray s;
-    qint64 rc = 0;
-    bool done = false;
 
-    QRegExp commentRE, dataRE;
+    QRegExp commentRE;
+    QRegExp dataRE;
     if (config._columnType == AsciiSourceConfig::Custom && !config._columnDelimiter.value().isEmpty()) {
       commentRE.setPattern(QString("^[%1]*[%2].*").arg(QRegExp::escape(config._columnDelimiter)).arg(config._delimiters));
       dataRE.setPattern(QString("^[%1]*(([Nn][Aa][Nn]|(\\-\\+)?[Ii][Nn][Ff]|[0-9\\+\\-\\.eE]+)[\\s]*)+").arg(QRegExp::escape(config._columnDelimiter)));
@@ -329,10 +327,10 @@
     }
 
     int skip = config._dataLine;
-
+    bool done = false;
     while (!done) {
-      QByteArray s = f.readLine();
-      rc = f.size();
+      const QByteArray line = f.readLine();
+      const qint64 rc = line.size();
       if (skip > 0) {
         --skip;
         if (rc <= 0) {
@@ -344,14 +342,14 @@
         done = true;
       } else if (rc == 1) {
         // empty line; do nothing
-      } else if (commentRE.exactMatch(s)) {
+      } else if (commentRE.exactMatch(line)) {
         // comment; do nothing
-      } else if (dataRE.exactMatch(s)) {
+      } else if (dataRE.exactMatch(line)) {
         // a number - this may be an ascii file - assume that it is
         // This line checks for an indirect file and gives that a chance too.
         // Indirect files look like ascii files.
         return 75;
-        //return QFile::exists(s.trimmed()) ? 49 : 75;
+        //return QFile::exists(line.trimmed()) ? 49 : 75;
       } else {
         return 20;
       }


More information about the Kst mailing list