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 // Determine parameter type and set value
switch (curproto->type) { switch (curproto->type) {
case VARDATA_INT: { case VARDATA_INT: {
long temp = 0; if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
curtok.ToLong(&temp); long temp = 0;
newparam->SetInt(temp); curtok.ToLong(&temp);
newparam->SetInt(temp);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_FLOAT: { case VARDATA_FLOAT: {
double temp = 0.0; if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
curtok.ToDouble(&temp); double temp = 0.0;
newparam->SetFloat(temp); curtok.ToDouble(&temp);
newparam->SetFloat(temp);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_TEXT: { case VARDATA_TEXT: {
@ -679,9 +685,12 @@ end_tokenizing:
break; break;
} }
case VARDATA_BOOL: { case VARDATA_BOOL: {
long temp = false; if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) {
curtok.ToLong(&temp); long temp = false;
newparam->SetBool(temp != 0); curtok.ToLong(&temp);
newparam->SetBool(temp != 0);
}
else newparam->SetText(curtok);
break; break;
} }
case VARDATA_BLOCK: { 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_BOOL) return (*value_bool)?1:0;
if (type == VARDATA_INT) return *value_int; if (type == VARDATA_INT) return *value_int;
if (type == VARDATA_FLOAT) return (int)(*value_float); if (type == VARDATA_FLOAT) return (int)(*value_float);
if (type == VARDATA_TEXT) return 0;
throw _T("Wrong parameter type, should be int"); throw _T("Wrong parameter type, should be int");
} }
@ -182,6 +183,7 @@ double VariableData::AsFloat() const {
if (!value) throw _T("Null parameter"); if (!value) throw _T("Null parameter");
if (type == VARDATA_FLOAT) return *value_float; if (type == VARDATA_FLOAT) return *value_float;
if (type == VARDATA_INT) return (float)(*value_int); if (type == VARDATA_INT) return (float)(*value_int);
if (type == VARDATA_TEXT) return 0.0f;
throw _T("Wrong parameter type, should be float"); 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_BOOL) return *value_bool;
if (type == VARDATA_INT) return ((*value_int)!=0); if (type == VARDATA_INT) return ((*value_int)!=0);
if (type == VARDATA_FLOAT) return ((*value_float)!=0); if (type == VARDATA_FLOAT) return ((*value_float)!=0);
if (type == VARDATA_TEXT) return false;
throw _T("Wrong parameter type, should be bool"); throw _T("Wrong parameter type, should be bool");
} }