[Kst] kdeextragear-2/kst/kst [POSSIBLY UNSAFE]

Barth Netterfield netterfield at astro.utoronto.ca
Wed Oct 29 22:22:36 CET 2003


CVS commit by netterfield: 

Fix optimization for zooming into large vectors
Fix equation parser and multiple '['
Fix interpolation bug in equations


  M +14 -8     kstequationcurve.cpp   1.34 [POSSIBLY UNSAFE: printf]
  M +9 -3      kstvector.cpp   1.48


--- kdeextragear-2/kst/kst/kstequationcurve.cpp  #1.33:1.34
@@ -291,5 +291,5 @@ void KstEquationCurve::preProcess() {
 
   char TempString[1024];
-  char ts[100];
+  char ts[1020];
   int i,j,Prev;
   int i_t;
@@ -334,9 +334,15 @@ void KstEquationCurve::preProcess() {
       i++;
     } else if (TempString[i]=='[') {
-      for (i_t = i; (TempString[i_t]!='\0') && (TempString[i_t]!=']'); i_t++)
-        ;
+      int i_brace = 1;
+      for (i_t = i+1; (TempString[i_t]!='\0') && (i_brace>0); i_t++) {
+        if (TempString[i_t]=='[')
+          i_brace++;
+        if (TempString[i_t]==']')
+          i_brace--;
+      }
+      i_t--;
 
-      if (i_t - i - 1>98)
-        i_t = i + 98;
+      if (i_t - i - 1>1019)
+        i_t = i + 1019;
 
       strncpy(ts,TempString+i+1, i_t - i - 1);
@@ -377,4 +382,5 @@ void KstEquationCurve::preProcess() {
   }
   String[j]='\0';
+  printf("%s\n", String);
 }
 
@@ -519,5 +525,5 @@ bool KstEquationCurve::FillY(bool force)
     }
     if (_inputVectors[XVECTOR]->sampleCount() > 0) {
-      Interp = ns / _inputVectors[XVECTOR]->sampleCount();
+      Interp = (ns+1) / (_inputVectors[XVECTOR]->sampleCount());
     } else { // avoid divide by zero
       Interp = 1;
@@ -529,5 +535,5 @@ bool KstEquationCurve::FillY(bool force)
   if (NS != _inputVectors[XVECTOR]->sampleCount() || Interp != 1 ||
       _inputVectors[XVECTOR]->numShift() != _inputVectors[XVECTOR]->numNew() || ScalarsUsed.count()) {
-    NS = _inputVectors[XVECTOR]->sampleCount()*Interp;
+    NS = _inputVectors[XVECTOR]->sampleCount()*Interp-1;
 
     KstVectorPtr yv = _outputVectors[OUTVECTOR];

--- kdeextragear-2/kst/kst/kstvector.cpp  #1.47:1.48
@@ -230,4 +230,6 @@ KstObject::UpdateType KstVector::update(
   double dv2=0.0, dv, no_spike_max_dv;
 
+  max = min = sum = sum2 = minpos = 0.0;
+
   if (KstObject::checkUpdateCounter(update_counter))
     return NO_CHANGE;
@@ -254,6 +256,7 @@ KstObject::UpdateType KstVector::update(
     i0 = i;
 
-    if (i0>0)
+    if (i0>0) {
       _is_rising = false;
+    }
 
     max = min = sum = sum2 = _v[i0];
@@ -272,6 +275,9 @@ KstObject::UpdateType KstVector::update(
         dv2 += dv*dv;
 
-        if (v<=last_v)
+        if (v<=last_v) {
+          if (i!=i0) {
           _is_rising = false;
+          }
+        }
         last_v = v;
 




More information about the Kst mailing list