summaryrefslogtreecommitdiff
path: root/pom.c
diff options
context:
space:
mode:
Diffstat (limited to 'pom.c')
-rw-r--r--pom.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pom.c b/pom.c
index e19c287..4f8882f 100644
--- a/pom.c
+++ b/pom.c
@@ -1414,13 +1414,19 @@ pom_conf_location(const pom_conf *conf, const char *key, const char **file, uint
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
+ // pick item from this section with least line number
const struct conf_section *section = &conf->sections[i];
if (section->conf.items_count == 0)
goto fail;
- item = &section->conf.items[0];
- if (file) *file = item->file;
- if (line) *line = item->line;
+ uint64_t least_line = UINT64_MAX;
+ for (i = 0; i < section->conf.items_count; i++) {
+ item = &section->conf.items[i];
+ if (item->line < least_line) {
+ if (file) *file = item->file;
+ if (line) *line = item->line;
+ least_line = item->line;
+ }
+ }
return true;
} else {
fail: