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 '#':
|
case '#':
|
||||||
next_line(active_file);
|
next_line(active_file);
|
||||||
MP_FALLTHROUGH;
|
MP_FALLTHROUGH;
|
||||||
|
case 0:
|
||||||
case '\n':
|
case '\n':
|
||||||
return GETENV_OK;
|
return GETENV_OK;
|
||||||
default:
|
default:
|
||||||
|
@ -257,7 +258,6 @@ STATIC os_getenv_err_t read_bare_value(file_arg *active_file, vstr_t *buf, int f
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (character) {
|
switch (character) {
|
||||||
case 0:
|
case 0:
|
||||||
return GETENV_ERR_UNEXPECTED | character;
|
|
||||||
case '\n':
|
case '\n':
|
||||||
return GETENV_OK;
|
return GETENV_OK;
|
||||||
case '#':
|
case '#':
|
||||||
|
|
|
@ -75,5 +75,8 @@ def run_test(key, content):
|
||||||
for i in range(13):
|
for i in range(13):
|
||||||
run_test(f"key{i}", content_good)
|
run_test(f"key{i}", content_good)
|
||||||
|
|
||||||
|
# Test value without trailing newline
|
||||||
|
run_test(f"noeol", "noeol=3")
|
||||||
|
|
||||||
for content in content_bad:
|
for content in content_bad:
|
||||||
run_test("key", content)
|
run_test("key", content)
|
||||||
|
|
|
@ -11,6 +11,7 @@ key9 'hello comment'
|
||||||
key10 127
|
key10 127
|
||||||
key11 0
|
key11 0
|
||||||
key12 None
|
key12 None
|
||||||
|
noeol 3
|
||||||
key Invalid byte '\n'
|
key Invalid byte '\n'
|
||||||
key Invalid byte '"'
|
key Invalid byte '"'
|
||||||
key invalid syntax for integer with base 10: ''
|
key invalid syntax for integer with base 10: ''
|
||||||
|
|
Loading…
Reference in New Issue