Allow settings.toml to end without a newline

This commit is contained in:
Jeff Epler 2022-12-26 10:49:57 -06:00
parent 4dbbfa0931
commit f6b69cf5e3
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 5 additions and 1 deletions

View File

@ -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 '#':

View File

@ -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)

View File

@ -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: ''