usb-dbg: fix frame parse
Fixed that indent being incorrectly appended.
Change-Id: I427bbbc961e4d2e3c393947ff4b53d6b866fa1f0
Signed-off-by: Cosmo Chou <cosmo.chou@quantatw.com>
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index a61b59c..c9f464f 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -273,24 +273,24 @@
for (auto ch : input)
{
- // Pad the line.
- result.append(indent, ' ');
- linepos = indent;
-
- bool esc = isEscSeq(ch);
-
- // Check if new line is needed.
- if (!esc && linepos == line_width)
+ if (linepos == 0)
{
- result.push_back(LINE_DELIMITER);
result.append(indent, ' ');
linepos = indent;
}
// Insert character.
result.push_back(ch);
- if (!esc)
- ++linepos;
+
+ if (!isEscSeq(ch))
+ {
+ // Check if new line is needed.
+ if (++linepos == line_width)
+ {
+ result.push_back(LINE_DELIMITER);
+ linepos = 0;
+ }
+ }
}
// Fill out remaining line.