do not modify iterator content in DataField::create()
This commit is contained in:
+15
-10
@@ -193,7 +193,7 @@ result_t DataField::create(vector<string>::iterator& it,
|
|||||||
firstComment = comment;
|
firstComment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
string typeStr = *it++;
|
const string typeStr = *it++;
|
||||||
if (typeStr.empty() == true) {
|
if (typeStr.empty() == true) {
|
||||||
if (name.empty() == false || hasPartStr == true)
|
if (name.empty() == false || hasPartStr == true)
|
||||||
result = RESULT_ERR_MISSING_TYPE;
|
result = RESULT_ERR_MISSING_TYPE;
|
||||||
@@ -202,7 +202,7 @@ result_t DataField::create(vector<string>::iterator& it,
|
|||||||
|
|
||||||
map<unsigned int, string> values;
|
map<unsigned int, string> values;
|
||||||
if (it != end) {
|
if (it != end) {
|
||||||
string divisorStr = *it++;
|
const string divisorStr = *it++;
|
||||||
if (divisorStr.empty() == false) {
|
if (divisorStr.empty() == false) {
|
||||||
if (divisorStr.find('=') == string::npos)
|
if (divisorStr.find('=') == string::npos)
|
||||||
divisor = parseInt(divisorStr.c_str(), 10, 1, 10000, result);
|
divisor = parseInt(divisorStr.c_str(), 10, 1, 10000, result);
|
||||||
@@ -232,19 +232,24 @@ result_t DataField::create(vector<string>::iterator& it,
|
|||||||
if (it == end)
|
if (it == end)
|
||||||
unit = "";
|
unit = "";
|
||||||
else {
|
else {
|
||||||
unit = *it++;
|
const string str = *it++;
|
||||||
if (strcasecmp(unit.c_str(), NULL_VALUE) == 0)
|
if (strcasecmp(str.c_str(), NULL_VALUE) == 0)
|
||||||
unit.clear();
|
unit = "";
|
||||||
|
else
|
||||||
|
unit = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == end)
|
if (it == end)
|
||||||
comment = "";
|
comment = "";
|
||||||
else {
|
else {
|
||||||
comment = *it++;
|
const string str = *it++;
|
||||||
if (strcasecmp(comment.c_str(), NULL_VALUE) == 0)
|
if (strcasecmp(str.c_str(), NULL_VALUE) == 0)
|
||||||
comment.clear();
|
comment = "";
|
||||||
|
else
|
||||||
|
comment = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* typeName;
|
||||||
size_t pos = typeStr.find(LENGTH_SEPARATOR);
|
size_t pos = typeStr.find(LENGTH_SEPARATOR);
|
||||||
unsigned char length;
|
unsigned char length;
|
||||||
if (pos == string::npos) {
|
if (pos == string::npos) {
|
||||||
@@ -271,16 +276,16 @@ result_t DataField::create(vector<string>::iterator& it,
|
|||||||
if (found == true)
|
if (found == true)
|
||||||
continue; // go to next definition
|
continue; // go to next definition
|
||||||
}
|
}
|
||||||
|
typeName = typeStr.c_str();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
length = parseInt(typeStr.substr(pos+1).c_str(), 10, 1, MAX_POS, result);
|
length = parseInt(typeStr.substr(pos+1).c_str(), 10, 1, MAX_POS, result);
|
||||||
if (result != RESULT_OK)
|
if (result != RESULT_OK)
|
||||||
break;
|
break;
|
||||||
typeStr = typeStr.substr(0, pos);
|
typeName = typeStr.substr(0, pos).c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleDataField* add = NULL;
|
SingleDataField* add = NULL;
|
||||||
const char* typeName = typeStr.c_str();
|
|
||||||
for (size_t i = 0; result == RESULT_OK && add == NULL && i < sizeof(dataTypes) / sizeof(dataTypes[0]); i++) {
|
for (size_t i = 0; result == RESULT_OK && add == NULL && i < sizeof(dataTypes) / sizeof(dataTypes[0]); i++) {
|
||||||
dataType_t dataType = dataTypes[i];
|
dataType_t dataType = dataTypes[i];
|
||||||
if (strcasecmp(typeName, dataType.name) == 0) {
|
if (strcasecmp(typeName, dataType.name) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user