Commit 09161ea8 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed XER list decoding with leading whitespaces (bug 540607)



Change-Id: Ic3f574de0895accee746f960b1ba6705669527bf
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 927414ab
......@@ -1404,7 +1404,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
* then use that to decode the value. */
" for(char * str = strtok(x_val, \" \\t\\x0A\\x0D\"); str != 0; str = strtok(x_val + x_pos, \" \\t\\x0A\\x0D\")) {\n"
// Calling strtok with NULL won't work here, since the decoded element can have strtok calls aswell
" x_pos += strlen(str) + 1;\n"
" x_pos = (str - x_val) + strlen(str) + 1;\n"
" TTCN_Buffer buf_2;\n"
" buf_2.put_c('<');\n"
" write_ns_prefix(*p_td.oftype_descr, buf_2);\n"
......
......@@ -2480,7 +2480,7 @@ int Record_Of_Type::XER_decode(const XERdescriptor_t& p_td,
* to decode the value. */
for(char * str = strtok(val, " \t\x0A\x0D"); str != 0; str = strtok(val + pos, " \t\x0A\x0D")) {
// Calling strtok with NULL won't work here, since the decoded element can have strtok calls aswell
pos += strlen(str) + 1;
pos = (str - val) + strlen(str) + 1;
// Construct a new XML Reader with the current token.
TTCN_Buffer buf2;
const XERdescriptor_t& sub_xer = *p_td.oftype_descr;
......
......@@ -7,6 +7,7 @@
*
* Contributors:
* Balasko, Jeno
* Baranyi, Botond
* Raduly, Csaba
*
******************************************************************************/
......@@ -92,11 +93,38 @@ testcase decode_floats() runs on L
/* * * * * * * * * * * * * * * * * * * * */
// decoding a list with leading whitespaces (bug 540607)
type record of universal charstring Strings
with {
variant "list"
}
DECLARE_EXER_ENCODERS(Strings, strings);
const Strings str := { "first", "second", "third", "fourth" }
const universal charstring str_dec :=
"<Strings>
first
second
third
fourth
</Strings>";
testcase decode_strings() runs on L
{
CHECK_DECODE(exer_dec_strings, str_dec, Strings, str);
}
/* * * * * * * * * * * * * * * * * * * * */
control {
execute(encode_ints());
execute(decode_ints());
execute(encode_floats());
execute(decode_floats());
execute(decode_strings());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment