From 67e8524b40cbee17409f8ee4199f3055f9c29425 Mon Sep 17 00:00:00 2001 From: hellerve Date: Sun, 27 Sep 2020 16:48:08 +0200 Subject: [PATCH] array: allow omitting space after array dash when linebreak follows --- README.md | 3 ++- cfg.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 79e5ea0..e5797a5 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ my_section ``` Keys cannot contain spaces. Indents are always two spaces. There is one space -between the hyphen and the value and an array. This is all. +between the hyphen and the value in an array, unless there is a linebreak +immediately after. This is all. It is a simple format, some might think it is too simple. It is, however, possible, to write a simple, fast implementation in a few hundred lines of C diff --git a/cfg.h b/cfg.h index 2212f55..843e0fb 100644 --- a/cfg.h +++ b/cfg.h @@ -571,8 +571,8 @@ parsed_value config_parse_list(string* s, size_t* line, size_t* col, size_t inde *l =new_list_config_value(); while(true) { - if (s->str[0] != ' ') return config_value_parse_error("expected space to start list element", *line, *col); - s->str++; + if (s->str[0] != ' ' && s->str[0] != '\n') return config_value_parse_error("expected space to start list element", *line, *col); + if (s->str[0] == ' ') s->str++; consumed += 1; elem = config_parse_value(s, line, col, indent);