1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
--- cutecom-0.22.0/qcppdialogimpl.cpp
+++ cutecom-0.22.0/qcppdialogimpl.cpp
@@ -1322,7 +1322,7 @@
return;
}
- const char* c=m_buf;
+ const char *c = m_buf;
if (m_sz!=0)
{
// std::cerr<<"readData() "<<bytesRead<<std::endl;
@@ -1347,8 +1347,7 @@
snprintf(buf, 16, "%08x: ", m_hexBytes);
text+=buf;
}
- unsigned int b=*c;
- snprintf(buf, 16, "%02x ", b & 0xff);
+ snprintf(buf, 16, "%02hhx ", *c);
text+=buf;
m_hexBytes++;
@@ -1363,33 +1362,29 @@
}
else
{
- // also print a newline for \r, and print only one newline for \r\n
- if ((isprint(*c)) || (*c=='\n') || (*c=='\r'))
- {
- if (*c=='\r')
- {
- text+='\n';
- }
- else if (*c=='\n')
+ switch (*c) {
+ case '\n':
+ if (m_previousChar == '\r') break;
+ // fall through
+ case '\r':
+ text += '\n';
+ break;
+ case '\t':
+ text += " ";
+ break;
+ default:
+ if (isprint(*c))
{
- if (m_previousChar != '\r')
- {
- text+='\n';
- }
+ text += *c;
}
else
{
- text+=(*c);
+ unsigned int b = *c;
+ snprintf(buf, 16, "\\0x%02x", b & 0xff);
+ text += buf;
}
-
- m_previousChar = *c;
- }
- else
- {
- unsigned int b=*c;
- snprintf(buf, 16, "\\0x%02x", b & 0xff);
- text+=buf;
}
+ m_previousChar = *c;
}
c++;
}
|