summaryrefslogtreecommitdiff
path: root/pom.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-09-15 14:06:17 -0400
committerpommicket <pommicket@gmail.com>2025-09-15 14:06:17 -0400
commit4f2644f354184d5febc1aa8f37e987eca03f7f25 (patch)
tree9f35a24eee9c46ddbc14c59909b4d5b1dfad0e62 /pom.c
parentee88497b4451225c3140f56d98ebcbc166175407 (diff)
More tests; fix locations
Diffstat (limited to 'pom.c')
-rw-r--r--pom.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/pom.c b/pom.c
index 37afeca..78eb41b 100644
--- a/pom.c
+++ b/pom.c
@@ -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 = &section->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;