Applied Mosc's patch (plus a small change to variable_data.cpp) to fix #605 and #557, both related to $ variables in the middle of tags being wiped by different features.

Originally committed to SVN as r1698.
This commit is contained in:
Rodrigo Braz Monteiro 2008-01-13 19:36:05 +00:00
parent 10fa94f768
commit acc26dba67
2 changed files with 21 additions and 9 deletions

View file

@ -663,15 +663,21 @@ end_tokenizing:
// Determine parameter type and set value
switch (curproto->type) {
case VARDATA_INT: {
long temp = 0;
curtok.ToLong(&temp);
newparam->SetInt(temp);
if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
long temp = 0;
curtok.ToLong(&temp);
newparam->SetInt(temp);
}
else newparam->SetText(curtok);
break;
}
case VARDATA_FLOAT: {
double temp = 0.0;
curtok.ToDouble(&temp);
newparam->SetFloat(temp);
if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
double temp = 0.0;
curtok.ToDouble(&temp);
newparam->SetFloat(temp);
}
else newparam->SetText(curtok);
break;
}
case VARDATA_TEXT: {
@ -679,9 +685,12 @@ end_tokenizing:
break;
}
case VARDATA_BOOL: {
long temp = false;
curtok.ToLong(&temp);
newparam->SetBool(temp != 0);
if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
long temp = false;
curtok.ToLong(&temp);
newparam->SetBool(temp != 0);
}
else newparam->SetText(curtok);
break;
}
case VARDATA_BLOCK: {

View file

@ -172,6 +172,7 @@ int VariableData::AsInt() const {
if (type == VARDATA_BOOL) return (*value_bool)?1:0;
if (type == VARDATA_INT) return *value_int;
if (type == VARDATA_FLOAT) return (int)(*value_float);
if (type == VARDATA_TEXT) return 0;
throw _T("Wrong parameter type, should be int");
}
@ -182,6 +183,7 @@ double VariableData::AsFloat() const {
if (!value) throw _T("Null parameter");
if (type == VARDATA_FLOAT) return *value_float;
if (type == VARDATA_INT) return (float)(*value_int);
if (type == VARDATA_TEXT) return 0.0f;
throw _T("Wrong parameter type, should be float");
}
@ -193,6 +195,7 @@ bool VariableData::AsBool() const {
if (type == VARDATA_BOOL) return *value_bool;
if (type == VARDATA_INT) return ((*value_int)!=0);
if (type == VARDATA_FLOAT) return ((*value_float)!=0);
if (type == VARDATA_TEXT) return false;
throw _T("Wrong parameter type, should be bool");
}