From 7b0671f3fda91d76321558ad6d06eca1c0c2df40 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Wed, 7 Dec 2016 16:52:20 -0600 Subject: [PATCH] =?UTF-8?q?Monor=20cleanup=20in=20XIO=20of=20=E2=80=9C!\n?= =?UTF-8?q?=E2=80=9D=20and=20=E2=80=9C~\n=E2=80=9D=20handling.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g2core/xio.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/g2core/xio.cpp b/g2core/xio.cpp index e1ce0b53..cc9dc874 100755 --- a/g2core/xio.cpp +++ b/g2core/xio.cpp @@ -612,6 +612,14 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { } if (is_control) { // we found a control + // Quick check for single-character with a \n after it + while (_is_more_to_scan() && + ((_data[_scan_offset] == '\n') || + (_data[_scan_offset] == '\r')) + ) + { + _scan_offset = _get_next_scan_offset(); + } return true; } else { // we did find one more line, though. _lines_found++; @@ -682,6 +690,9 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { _line_start_offset = (_line_start_offset+1)&(_size-1); } + // null-terminate the string + *dst_ptr = 0; + if (ctrl_is_at_beginning_of_data) { _read_offset = _scan_offset; } else { @@ -781,6 +792,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> { _restartTransfer(); + // null-terminate the string *dst_ptr = 0; return _line_buffer; }; // readline