corrected csv err position reporting

This commit is contained in:
john30
2016-12-23 14:01:21 +01:00
parent c777376449
commit f4d0348679
+10 -2
View File
@@ -93,6 +93,7 @@ result_t DataField::create(vector<string>::iterator& it,
}
const string typeStr = *it++; // basetype[:len]|template[:name]
vector<string>::iterator typePos = it;
if (typeStr.empty()) {
if (!name.empty() || hasPartStr) {
result = RESULT_ERR_MISSING_TYPE;
@@ -203,10 +204,14 @@ result_t DataField::create(vector<string>::iterator& it,
result = SingleDataField::create(typeName, length, firstType ? name : "", firstType ? comment : "", firstType ? unit : "", partType, divisor, values, constantValue, verifyValue, add);
if (add != NULL) {
fields.push_back(add);
} else if (result == RESULT_OK) {
result = RESULT_ERR_NOTFOUND; // type not found
} else {
it = typePos; // back to type
if (result == RESULT_OK) {
result = RESULT_ERR_NOTFOUND; // type not found
}
}
} else if (!constantValue.empty()) {
it = typePos; // back to type
result = RESULT_ERR_INVALID_ARG; // invalid value list
} else { // template[:name]
string fieldName;
@@ -217,6 +222,9 @@ result_t DataField::create(vector<string>::iterator& it,
fieldName = (firstType && lastType) ? name : "";
}
result = templ->derive(fieldName, firstType ? comment : "", firstType ? unit : "", partType, divisor, values, fields);
if (result != RESULT_OK) {
it = typePos; // back to type
}
}
firstType = false;
}