mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-06 11:10:24 +00:00
base: print last character of unterminated strings
The last character should only be skipped if a `\0` or `\n` is found. If the string ends without such a character or the maximum line length is hit, we do not skip the last character. Fixes genodelabs/genode#4985
This commit is contained in:
parent
e78a84196d
commit
0622446f09
@ -67,17 +67,16 @@ void Genode::print_lines(char const *string, size_t len, FUNC const &func)
|
|||||||
string += num_indent_chars;
|
string += num_indent_chars;
|
||||||
|
|
||||||
size_t line_len = 0;
|
size_t line_len = 0;
|
||||||
size_t skip_char = 1;
|
size_t skip_char = 0;
|
||||||
|
|
||||||
for (; line_len < len; line_len++) {
|
for (; line_len < len; line_len++) {
|
||||||
if (string[line_len] == '\0' || string[line_len] == '\n') {
|
if (string[line_len] == '\0' || string[line_len] == '\n') {
|
||||||
line_len++;
|
line_len++;
|
||||||
|
skip_char = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (line_len == MAX_LINE_LEN) {
|
if (line_len == MAX_LINE_LEN)
|
||||||
skip_char = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!line_len)
|
if (!line_len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user