mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-30 08:03:59 +00:00
gems/vfs.h: fix end-of-data condition
The 'File_content::for_each_line' method did not correctly detect the end of data for files without a trailing linebreak, thereby cutting the last character from the last line.
This commit is contained in:
parent
5d6f97cc1d
commit
75e22fef4a
@ -362,10 +362,10 @@ class Genode::File_content
|
||||
char const *curr_line = src;
|
||||
size_t curr_line_len = 0;
|
||||
|
||||
for (size_t n = 0; n < _size; n++) {
|
||||
for (size_t n = 0; ; n++) {
|
||||
|
||||
char const c = *src++;
|
||||
bool const end_of_data = (c == 0 || n + 1 == _size);
|
||||
bool const end_of_data = (c == 0 || n == _size);
|
||||
bool const end_of_line = (c == '\n');
|
||||
|
||||
if (!end_of_data && !end_of_line) {
|
||||
@ -373,10 +373,11 @@ class Genode::File_content
|
||||
continue;
|
||||
}
|
||||
|
||||
fn(STRING(Cstring(curr_line, curr_line_len)));
|
||||
if (!end_of_data || curr_line_len > 0)
|
||||
fn(STRING(Cstring(curr_line, curr_line_len)));
|
||||
|
||||
if (end_of_data)
|
||||
return;
|
||||
break;
|
||||
|
||||
curr_line = src;
|
||||
curr_line_len = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user