summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-09-23 01:54:18 -0400
committerpommicket <pommicket@gmail.com>2025-09-23 01:54:18 -0400
commitdead03ddbc60151cc6405f31b1c03e12b1a28b52 (patch)
tree4f13c190c60e579206f03330af7b130b7a1b42c6
parente36a67d03647444efbe94b5379552fbac3e5c367 (diff)
Update location of sections to match specHEADv0.1.0trunk
-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: