Commit b21cfb58 authored by Hanspeter Portner's avatar Hanspeter Portner

nk: support loading text files without eof newline

parent c69a7f24
Pipeline #17914459 passed with stages
in 4 minutes and 14 seconds
......@@ -2000,7 +2000,9 @@ _set_string(struct nk_str *str, uint32_t size, const char *body)
nk_str_clear(str);
// replace tab with 2 spaces
const char *end = body + size - 1;
const char *end = (size > 0) && (body[size - 1] == '\n')
? body + size - 1 // ignore newline in sane files
: body + size; // handle non-sane files without a newline
const char *from = body;
for(const char *to = strchr(from, '\t');
to && (to < end);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment