diff options
author | pommicket <pommicket@gmail.com> | 2025-09-15 14:06:17 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-15 14:06:17 -0400 |
commit | 4f2644f354184d5febc1aa8f37e987eca03f7f25 (patch) | |
tree | 9f35a24eee9c46ddbc14c59909b4d5b1dfad0e62 /pom.c | |
parent | ee88497b4451225c3140f56d98ebcbc166175407 (diff) |
More tests; fix locations
Diffstat (limited to 'pom.c')
-rw-r--r-- | pom.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -799,6 +799,7 @@ parse_line(struct parser *parser) { check_if_key_is_valid(parser, current_section); return; } + uint64_t start_line_number = parser->line_number; size_t equals_idx; for (size_t i = 0; ; i++) { if (line[i] == '=') { @@ -847,7 +848,7 @@ parse_line(struct parser *parser) { if (!item) return; item->key = key_idx; item->value = value_idx; - item->line = parser->line_number; + item->line = start_line_number; } static void @@ -1385,11 +1386,23 @@ pom_conf_has(const pom_conf *conf, const char *key) { bool pom_conf_location(const pom_conf *conf, const char *key, const char **file, uint64_t *line) { struct conf_item *item = conf_get_item(conf, key); + bool found; + size_t i; if (item) { if (file) *file = item->file; if (line) *line = item->line; return true; + } else if ((i = conf_binary_search_sections(conf, key, 0, &found)), found) { + // pick an item from this section + const struct conf_section *section = &conf->sections[i]; + if (section->conf.items_count == 0) + goto fail; + const struct conf_item *item = §ion->conf.items[0]; + if (file) *file = item->file; + if (line) *line = item->line; + return true; } else { + fail: if (file) *file = NULL; if (line) *line = 0; return false; |