return -ENOMEM;
if (sections && !nulstr_contains(sections, n)) {
+ bool ignore = flags & CONFIG_PARSE_RELAXED;
+ const char *t;
- if (!(flags & CONFIG_PARSE_RELAXED) && !startswith(n, "X-"))
+ ignore = ignore || startswith(n, "X-");
+
+ if (!ignore)
+ NULSTR_FOREACH(t, sections)
+ if (streq_ptr(n, startswith(t, "-"))) {
+ ignore = true;
+ break;
+ }
+
+ if (!ignore)
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown section '%s'. Ignoring.", n);
free(n);
"[Section]\n"
"setting1=" /* many continuation lines, together above the limit */
x1000(x1000("x") x10("abcde") "\\\n") "xxx",
+
+ "[Section]\n"
+ "setting1=2\n"
+ "[NoWarnSection]\n"
+ "setting1=3\n"
+ "[WarnSection]\n"
+ "setting1=3\n"
+ "[X-Section]\n"
+ "setting1=3\n",
};
static void test_config_parse(unsigned i, const char *s) {
const char *sections,
ConfigItemLookup lookup,
const void *table,
- bool relaxed,
- bool allow_include,
- bool warn,
+ ConfigParseFlags flags,
void *userdata)
*/
r = config_parse(NULL, name, f,
- "Section\0",
+ "Section\0-NoWarnSection\0",
config_item_table_lookup, items,
CONFIG_PARSE_WARN, NULL);
assert_se(r == -ENOBUFS);
assert_se(setting1 == NULL);
break;
+
+ case 17:
+ assert_se(r == 0);
+ assert_se(streq(setting1, "2"));
+ break;
}
}