Adeguata valutazione della funzione mid con TString::mid

git-svn-id: svn://10.65.10.50/trunk@305 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-10-03 11:23:56 +00:00
parent 832f08d056
commit a20472dccc

View File

@ -455,12 +455,13 @@ void TExpression::eval()
evalstack.push(s1); evalstack.push(s1);
break; break;
case _mid: case _mid:
o2 = (real&) evalstack.pop(); {
o1 = (real&) evalstack.pop(); int count = (int)((const real&)evalstack.pop()).integer();
o1 -= 1.00; if (count == 0) count--;
s2 = (TString&) evalstack.pop(); const int from = (int)((const real&)evalstack.pop()).integer() - 1;
s1 = s2.mid((int)o1.integer(), (int)o2.integer()); const TString& s = ((const TString&)evalstack.pop()).mid(from, count);
evalstack.push(s1); evalstack.push(s);
}
break; break;
case _pow: case _pow:
o2 = (real&) evalstack.pop(); o2 = (real&) evalstack.pop();
@ -837,7 +838,7 @@ bool TExpression::compile(const char* expression, TTypeexp type)
else else
{ {
const int n2 = atoi(s2); const int n2 = atoi(s2);
sc << format(" mid(%s,%d,%d)", _tok, n1, (n2 < n1) ? -1 : n2 - n1 + 1); sc << format(" mid(%s,%d,%d)", _tok, n1, (n2 < n1) ? 0 : n2 - n1 + 1);
} }
} }
} }