corrected termination of NTS

This commit is contained in:
john30
2016-02-06 11:28:23 +01:00
parent 6e41246d42
commit bd1587e1c9
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -645,6 +645,7 @@ result_t StringDataField::readSymbols(SymbolString& input, const unsigned char b
size_t start = 0, count = m_length; size_t start = 0, count = m_length;
int incr = 1; int incr = 1;
unsigned char ch, last = 0, hour = 0; unsigned char ch, last = 0, hour = 0;
bool terminated = false;
if (count==REMAIN_LEN && input.size()>baseOffset) { if (count==REMAIN_LEN && input.size()>baseOffset) {
count = input.size()-baseOffset; count = input.size()-baseOffset;
} else if (baseOffset + count > input.size()) { } else if (baseOffset + count > input.size()) {
@@ -725,7 +726,9 @@ result_t StringDataField::readSymbols(SymbolString& input, const unsigned char b
default: default:
if (ch < 0x20) if (ch < 0x20)
ch = (unsigned char)m_dataType.replacement; ch = (unsigned char)m_dataType.replacement;
if (ch != 0x00) if (ch == 0x00)
terminated = true;
else if (!terminated)
output << setw(0) << dec << static_cast<char>(ch); output << setw(0) << dec << static_cast<char>(ch);
break; break;
} }
+1
View File
@@ -62,6 +62,7 @@ int main()
{"x,,nts:10", "Hallo, Du", "10fe07000a48616c6c6f2c20447500", "00", ""}, {"x,,nts:10", "Hallo, Du", "10fe07000a48616c6c6f2c20447500", "00", ""},
{"x,,nts:10", " ", "10fe07000a20202020202020202020", "00", ""}, {"x,,nts:10", " ", "10fe07000a20202020202020202020", "00", ""},
{"x,,nts:10", "", "10fe07000a00000000000000000000", "00", ""}, {"x,,nts:10", "", "10fe07000a00000000000000000000", "00", ""},
{"x,,nts:10", "abc", "10fe07000a6162630065666768696a", "00", "W"},
{"x,,nts:11", "", "10fe07000a20202020202020202020", "00", "rW"}, {"x,,nts:11", "", "10fe07000a20202020202020202020", "00", "rW"},
{"x,,nts:24", "abcdefghijklmnopqrstuvwx", "10fe0700186162636465666768696a6b6c6d6e6f707172737475767778", "00", ""}, {"x,,nts:24", "abcdefghijklmnopqrstuvwx", "10fe0700186162636465666768696a6b6c6d6e6f707172737475767778", "00", ""},
{"x,,nts:*", "abcde", "10fe0700056162636465", "00", "W"}, {"x,,nts:*", "abcde", "10fe0700056162636465", "00", "W"},