remove spaces around value list assignment, fix for invalid hex in value list
This commit is contained in:
+15
-6
@@ -265,16 +265,25 @@ result_t DataField::create(vector<string>::iterator& it,
|
||||
const char* str = token.c_str();
|
||||
char* strEnd = NULL;
|
||||
unsigned long int id;
|
||||
if (strncasecmp(str, "0x", 2) == 0)
|
||||
id = strtoul(str+2, &strEnd, 16); // hexadecimal
|
||||
else
|
||||
if (strncasecmp(str, "0x", 2) == 0) {
|
||||
str += 2;
|
||||
id = strtoul(str, &strEnd, 16); // hexadecimal
|
||||
} else {
|
||||
id = strtoul(str, &strEnd, 10); // decimal
|
||||
if (strEnd == NULL || strEnd == str || *strEnd != '=' || id > MAX_VALUE) {
|
||||
}
|
||||
if (strEnd == NULL || strEnd == str || id > MAX_VALUE) {
|
||||
result = RESULT_ERR_INVALID_LIST;
|
||||
break;
|
||||
}
|
||||
|
||||
values[(unsigned int)id] = string(strEnd + 1);
|
||||
// remove blanks around '=' sign
|
||||
while (*strEnd == ' ') strEnd++;
|
||||
if (*strEnd != '=') {
|
||||
result = RESULT_ERR_INVALID_LIST;
|
||||
break;
|
||||
}
|
||||
token = string(strEnd + 1);
|
||||
FileReader::trim(token);
|
||||
values[(unsigned int)id] = token;
|
||||
}
|
||||
}
|
||||
if (result != RESULT_OK)
|
||||
|
||||
@@ -249,8 +249,9 @@ int main()
|
||||
{"x,,ulg", "-", "10feffff04ffffffff", "00", ""},
|
||||
{"x,,ulg,10","3.8", "10feffff0426000000", "00", ""},
|
||||
{"x,,ulg,-10","380", "10feffff0426000000", "00", ""},
|
||||
{"x,,ulg,0x0FF0F00F=VRT 350;0x33CCCC33=VRT 360;0x3CC3C33C=SD 17;0x66999966=SD 37;0x69969669=VRT 360+",
|
||||
"VRT 350", "10feffff040FF0F00F", "00", ""},
|
||||
{"x,,ulg,0x0FF0F00F = VRT 350 ;0x33CCCC33=VRT 360;0x3CC3C33C=SD 17;0x66999966=SD 37;0x69969669=VRT 360+",
|
||||
"VRT 350", "10feffff040FF0F00F", "00", ""},
|
||||
{"x,,ulg,0x=test", "", "10feffff040FF0F00F", "00", "c"},
|
||||
{"x,,ulr", "38", "10feffff0400000026", "00", ""},
|
||||
{"x,,ulr", "0", "10feffff0400000000", "00", ""},
|
||||
{"x,,ulr", "4294967294", "10feffff04fffffffe", "00", ""},
|
||||
|
||||
Reference in New Issue
Block a user