yield error when field name was specified but nothing else

This commit is contained in:
john30
2015-11-07 09:15:00 +01:00
parent 7b21cacd41
commit 077ab86056
+6 -3
View File
@@ -178,7 +178,7 @@ result_t DataField::create(vector<string>::iterator& it,
if (it == end) if (it == end)
return RESULT_ERR_EOF; return RESULT_ERR_EOF;
do { while (it != end && result == RESULT_OK) {
string unit, comment; string unit, comment;
PartType partType; PartType partType;
int divisor = 0; int divisor = 0;
@@ -188,8 +188,11 @@ result_t DataField::create(vector<string>::iterator& it,
// template: name,type[:len][,[divisor|values][,[unit][,[comment]]]] // template: name,type[:len][,[divisor|values][,[unit][,[comment]]]]
// std: name,part,type[:len][,[divisor|values][,[unit][,[comment]]]] // std: name,part,type[:len][,[divisor|values][,[unit][,[comment]]]]
const string name = *it++; // name const string name = *it++; // name
if (it == end) if (it == end) {
if (!name.empty())
result = RESULT_ERR_MISSING_TYPE;
break; break;
}
if (isTemplate) if (isTemplate)
partType = pt_any; partType = pt_any;
@@ -307,7 +310,7 @@ result_t DataField::create(vector<string>::iterator& it,
} }
firstType = false; firstType = false;
} }
} while (it != end && result == RESULT_OK); }
if (result != RESULT_OK) { if (result != RESULT_OK) {
while (!fields.empty()) { // cleanup already created fields while (!fields.empty()) { // cleanup already created fields