Skip to content

Commit f70ddaf

Browse files
author
lilian
committed
use tabs instead of spaces for indentation
1 parent e8af2a7 commit f70ddaf

24 files changed

+3755
-3755
lines changed

.clang-format

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ StatementAttributeLikeMacros:
233233
StatementMacros:
234234
- Q_UNUSED
235235
- QT_REQUIRE_VERSION
236-
TabWidth: 8
237-
UseTab: Never
236+
TabWidth: 4
237+
UseTab: ForIndentation
238238
VerilogBreakBetweenInstancePorts: true
239239
WhitespaceSensitiveMacros:
240240
- BOOST_PP_STRINGIZE

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trim_trailing_whitespace = true
66
insert_final_newline = true
77

88
[*.{c,h,cpp,hpp}]
9-
indent_style = space
9+
indent_style = tab
1010
indent_size = 4
1111

1212
[*.{go}]

src/SEGGER_RTT.c

+978-978
Large diffs are not rendered by default.

src/SEGGER_RTT.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -302,25 +302,25 @@ Revision: $Rev: 24346 $
302302
// which is used as up-buffer (T->H)
303303
//
304304
typedef struct {
305-
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
306-
char* pBuffer; // Pointer to start of buffer
307-
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
308-
unsigned WrOff; // Position of next item to be written by either target.
309-
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
310-
unsigned Flags; // Contains configuration flags
305+
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
306+
char* pBuffer; // Pointer to start of buffer
307+
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
308+
unsigned WrOff; // Position of next item to be written by either target.
309+
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
310+
unsigned Flags; // Contains configuration flags
311311
} SEGGER_RTT_BUFFER_UP;
312312

313313
//
314314
// Description for a circular buffer (also called "ring buffer")
315315
// which is used as down-buffer (H->T)
316316
//
317317
typedef struct {
318-
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
319-
char* pBuffer; // Pointer to start of buffer
320-
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
321-
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
322-
unsigned RdOff; // Position of next item to be read by target (down-buffer).
323-
unsigned Flags; // Contains configuration flags
318+
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
319+
char* pBuffer; // Pointer to start of buffer
320+
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
321+
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
322+
unsigned RdOff; // Position of next item to be read by target (down-buffer).
323+
unsigned Flags; // Contains configuration flags
324324
} SEGGER_RTT_BUFFER_DOWN;
325325

326326
//
@@ -329,13 +329,13 @@ typedef struct {
329329
//
330330
//
331331
typedef struct {
332-
char acID[16]; // Initialized to "SEGGER RTT"
333-
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
334-
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
335-
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
336-
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
332+
char acID[16]; // Initialized to "SEGGER RTT"
333+
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
334+
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
335+
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
336+
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
337337
#if SEGGER_RTT__CB_PADDING
338-
unsigned char aDummy[SEGGER_RTT__CB_PADDING];
338+
unsigned char aDummy[SEGGER_RTT__CB_PADDING];
339339
#endif
340340
} SEGGER_RTT_CB;
341341

src/cobsDecode.c

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
//! @return Number of bytes successfully decoded.
1111
//! @note Stops decoding if delimiter byte is found. Code taken from Wikipedia and slightly modyfied.
1212
size_t COBSDecode(void* __restrict out, const void* __restrict in, size_t length) {
13-
uint8_t* data = out;
14-
const uint8_t* buffer = in;
15-
const uint8_t* byte = buffer; // Encoded input byte pointer
16-
uint8_t* decode = (uint8_t*)data; // Decoded output byte pointer
13+
uint8_t* data = out;
14+
const uint8_t* buffer = in;
15+
const uint8_t* byte = buffer; // Encoded input byte pointer
16+
uint8_t* decode = (uint8_t*)data; // Decoded output byte pointer
1717

18-
for (uint8_t code = 0xff, block = 0; byte < buffer + length; --block) {
19-
if (block) { // Decode block byte
20-
*decode++ = *byte++;
21-
} else {
22-
if (code != 0xff) { // Encoded zero, write it
23-
*decode++ = 0;
24-
}
25-
block = code = *byte++; // Next block length
26-
if (!code) { // Delimiter code found
27-
break;
28-
}
29-
}
30-
}
31-
return (size_t)(decode - data);
18+
for (uint8_t code = 0xff, block = 0; byte < buffer + length; --block) {
19+
if (block) { // Decode block byte
20+
*decode++ = *byte++;
21+
} else {
22+
if (code != 0xff) { // Encoded zero, write it
23+
*decode++ = 0;
24+
}
25+
block = code = *byte++; // Next block length
26+
if (!code) { // Delimiter code found
27+
break;
28+
}
29+
}
30+
}
31+
return (size_t)(decode - data);
3232
}

src/cobsEncode.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
//! @return Encoded buffer length in bytes.
1111
//! @note Does not output delimiter byte. Code taken from Wikipedia and slightly adapted.
1212
size_t COBSEncode(void* __restrict out, const void* __restrict in, size_t length) {
13-
uint8_t* buffer = out;
14-
uint8_t* encode = buffer; // Encoded byte pointer
15-
uint8_t* codep = encode++; // Output code pointer
16-
uint8_t code = 1; // Code value
13+
uint8_t* buffer = out;
14+
uint8_t* encode = buffer; // Encoded byte pointer
15+
uint8_t* codep = encode++; // Output code pointer
16+
uint8_t code = 1; // Code value
1717

18-
for (const uint8_t* byte = (const uint8_t*)in; length--; ++byte) {
19-
if (*byte) { // Byte not zero, write it
20-
*encode++ = *byte, ++code;
21-
}
22-
if (!*byte || code == 0xff) { // Input is zero or block completed, restart
23-
*codep = code, code = 1, codep = encode;
24-
if (!*byte || length) {
25-
++encode;
26-
}
27-
}
28-
}
29-
*codep = code; // Write final code value
30-
return (size_t)(encode - buffer);
18+
for (const uint8_t* byte = (const uint8_t*)in; length--; ++byte) {
19+
if (*byte) { // Byte not zero, write it
20+
*encode++ = *byte, ++code;
21+
}
22+
if (!*byte || code == 0xff) { // Input is zero or block completed, restart
23+
*codep = code, code = 1, codep = encode;
24+
if (!*byte || length) {
25+
++encode;
26+
}
27+
}
28+
}
29+
*codep = code; // Write final code value
30+
return (size_t)(encode - buffer);
3131
}

src/tcobsv1Decode.c

+87-87
Original file line numberDiff line numberDiff line change
@@ -14,105 +14,105 @@ static int sigilAndOffset(uint8_t* sigil, uint8_t b);
1414
static uint8_t repeatByte(int offset, uint8_t* in, int len);
1515

1616
int TCOBSDecode(void* __restrict output, size_t max, const void* __restrict input, size_t length) {
17-
uint8_t* in = (uint8_t*)input;
18-
int ilen = (int)length; // remaining input length
19-
uint8_t* out = (uint8_t*)output;
20-
int olen = 0; // output length
21-
while (ilen > 0) {
22-
uint8_t next = in[ilen - 1]; // get next sigil byte (starting from the end)
23-
uint8_t sigil;
24-
uint8_t r;
25-
int offset = sigilAndOffset(&sigil, next);
26-
if (offset + 1 > ilen) {
27-
return INPUT_DATA_CORRUPTED - __LINE__;
28-
}
29-
ilen -= 1; // remove sigil byte from buffer
30-
switch (sigil) {
31-
case N:
32-
goto copyBytes;
17+
uint8_t* in = (uint8_t*)input;
18+
int ilen = (int)length; // remaining input length
19+
uint8_t* out = (uint8_t*)output;
20+
int olen = 0; // output length
21+
while (ilen > 0) {
22+
uint8_t next = in[ilen - 1]; // get next sigil byte (starting from the end)
23+
uint8_t sigil;
24+
uint8_t r;
25+
int offset = sigilAndOffset(&sigil, next);
26+
if (offset + 1 > ilen) {
27+
return INPUT_DATA_CORRUPTED - __LINE__;
28+
}
29+
ilen -= 1; // remove sigil byte from buffer
30+
switch (sigil) {
31+
case N:
32+
goto copyBytes;
3333

34-
case Z3:
35-
olen += 1;
36-
out[max - olen] = 0;
37-
// fallthrough
38-
case Z2:
39-
olen += 1;
40-
out[max - olen] = 0;
41-
// fallthrough
42-
case Z1:
43-
olen += 1;
44-
out[max - olen] = 0;
45-
goto copyBytes;
34+
case Z3:
35+
olen += 1;
36+
out[max - olen] = 0;
37+
// fallthrough
38+
case Z2:
39+
olen += 1;
40+
out[max - olen] = 0;
41+
// fallthrough
42+
case Z1:
43+
olen += 1;
44+
out[max - olen] = 0;
45+
goto copyBytes;
4646

47-
case F4:
48-
olen += 1;
49-
out[max - olen] = 0xFF;
50-
// fallthrough
51-
case F3:
52-
olen += 1;
53-
out[max - olen] = 0xFF;
54-
// fallthrough
55-
case F2:
56-
olen += 1;
57-
out[max - olen] = 0xFF;
58-
olen += 1;
59-
out[max - olen] = 0xFF;
60-
goto copyBytes;
47+
case F4:
48+
olen += 1;
49+
out[max - olen] = 0xFF;
50+
// fallthrough
51+
case F3:
52+
olen += 1;
53+
out[max - olen] = 0xFF;
54+
// fallthrough
55+
case F2:
56+
olen += 1;
57+
out[max - olen] = 0xFF;
58+
olen += 1;
59+
out[max - olen] = 0xFF;
60+
goto copyBytes;
6161

62-
case R4:
63-
olen += 1;
64-
out[max - olen] = repeatByte(offset, in, ilen);
65-
// fallthrough
66-
case R3:
67-
olen += 1;
68-
out[max - olen] = repeatByte(offset, in, ilen);
69-
// fallthrough
70-
case R2:
71-
r = repeatByte(offset, in, ilen);
72-
olen += 1;
73-
out[max - olen] = r;
74-
olen += 1;
75-
out[max - olen] = r;
76-
goto copyBytes;
62+
case R4:
63+
olen += 1;
64+
out[max - olen] = repeatByte(offset, in, ilen);
65+
// fallthrough
66+
case R3:
67+
olen += 1;
68+
out[max - olen] = repeatByte(offset, in, ilen);
69+
// fallthrough
70+
case R2:
71+
r = repeatByte(offset, in, ilen);
72+
olen += 1;
73+
out[max - olen] = r;
74+
olen += 1;
75+
out[max - olen] = r;
76+
goto copyBytes;
7777

78-
default:
79-
return INPUT_DATA_CORRUPTED - __LINE__;
80-
}
78+
default:
79+
return INPUT_DATA_CORRUPTED - __LINE__;
80+
}
8181

82-
copyBytes: {
83-
uint8_t* to = out + max - olen - offset; // to := len(d) - n - offset
84-
uint8_t* from = in + ilen - offset; // from := len(in) - offset // sigil byte is already removed
85-
if (to < out) {
86-
return OUT_BUFFER_TOO_SMALL - __LINE__;
87-
}
88-
memcpy(to, from, offset); // n += copy(d[to:], in[from:])
89-
olen += offset;
90-
ilen -= offset; // in = in[:len(in)-offset] // remove copied bytes
91-
continue;
92-
}
93-
}
94-
return olen;
82+
copyBytes: {
83+
uint8_t* to = out + max - olen - offset; // to := len(d) - n - offset
84+
uint8_t* from = in + ilen - offset; // from := len(in) - offset // sigil byte is already removed
85+
if (to < out) {
86+
return OUT_BUFFER_TOO_SMALL - __LINE__;
87+
}
88+
memcpy(to, from, offset); // n += copy(d[to:], in[from:])
89+
olen += offset;
90+
ilen -= offset; // in = in[:len(in)-offset] // remove copied bytes
91+
continue;
92+
}
93+
}
94+
return olen;
9595
}
9696

9797
// sigilAndOffset interprets b as sigil byte with offset, fills sigil and returns offset.
9898
// For details see TCOBSv1Specification.md.
9999
static int sigilAndOffset(uint8_t* sigil, uint8_t b) {
100-
int offset;
101-
*sigil = b & 0xE0; // 0x11100000
102-
if (*sigil == 0) {
103-
*sigil = b & 0xF8; // 0x11111000
104-
offset = 7 & b; // 0x00000111
105-
} else {
106-
offset = 0x1F & b; // 0x00011111
107-
}
108-
return offset;
100+
int offset;
101+
*sigil = b & 0xE0; // 0x11100000
102+
if (*sigil == 0) {
103+
*sigil = b & 0xF8; // 0x11111000
104+
offset = 7 & b; // 0x00000111
105+
} else {
106+
offset = 0x1F & b; // 0x00011111
107+
}
108+
return offset;
109109
}
110110

111111
// repeatByte returns the value to repeat
112112
static uint8_t repeatByte(int offset, uint8_t* in, int len) {
113-
if (offset == 0) { // left byte of Ri is a sigil byte (probably N)
114-
return in[len - 2]; // a buffer cannot start with Ri
115-
} else {
116-
return in[len - 1];
117-
}
113+
if (offset == 0) { // left byte of Ri is a sigil byte (probably N)
114+
return in[len - 2]; // a buffer cannot start with Ri
115+
} else {
116+
return in[len - 1];
117+
}
118118
}

0 commit comments

Comments
 (0)