Allow settings.toml to end without a newline
This commit is contained in:
parent
4dbbfa0931
commit
f6b69cf5e3
|
@ -201,6 +201,7 @@ STATIC os_getenv_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
|
|||
case '#':
|
||||
next_line(active_file);
|
||||
MP_FALLTHROUGH;
|
||||
case 0:
|
||||
case '\n':
|
||||
return GETENV_OK;
|
||||
default:
|
||||
|
@ -257,7 +258,6 @@ STATIC os_getenv_err_t read_bare_value(file_arg *active_file, vstr_t *buf, int f
|
|||
while (true) {
|
||||
switch (character) {
|
||||
case 0:
|
||||
return GETENV_ERR_UNEXPECTED | character;
|
||||
case '\n':
|
||||
return GETENV_OK;
|
||||
case '#':
|
||||
|
|
|
@ -75,5 +75,8 @@ def run_test(key, content):
|
|||
for i in range(13):
|
||||
run_test(f"key{i}", content_good)
|
||||
|
||||
# Test value without trailing newline
|
||||
run_test(f"noeol", "noeol=3")
|
||||
|
||||
for content in content_bad:
|
||||
run_test("key", content)
|
||||
|
|
|
@ -11,6 +11,7 @@ key9 'hello comment'
|
|||
key10 127
|
||||
key11 0
|
||||
key12 None
|
||||
noeol 3
|
||||
key Invalid byte '\n'
|
||||
key Invalid byte '"'
|
||||
key invalid syntax for integer with base 10: ''
|
||||
|
|
Loading…
Reference in New Issue