Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/backend/sword_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,35 @@ GList *BackEnd::parse_verse_list(const char *module_name, const char *list, char
* reference from the input. */
for (int i = 0; i < count; i++) {
SWKey *elem = vs.getElement(i);
if (elem && !elem->popError())
retlist = g_list_append(retlist, strdup((char *)elem->getText()));
if (!elem || elem->popError())
continue;

/* If this element is a hyphenated range (e.g. "Jer 3:6-11"),
* elem->getText() only gives the START of the range -- Sword
* does not auto-expand it into individual verses here. Empirically,
* for a VerseKey list element, getUpperBound() (and getLowerBound(),
* which mirrors it) return the END of the range when there is one,
* and are otherwise equal to the element itself for a plain single
* verse. So: if the upper bound differs from the element's own
* value, walk every verse from the element (start) through the
* upper bound (end) and add each individually -- restoring the
* full-range expansion behaviour this used to have before this
* function was switched to indexed access. */
VerseKey *velem = dynamic_cast<VerseKey *>(elem);
if (velem) {
VerseKey &bound = velem->getUpperBound();
if (bound.compare(*velem) != 0) {
VerseKey walker(*velem);
int guard = 0;
while ((walker.compare(bound) <= 0) && !walker.popError() && (guard++ < 2000)) {
retlist = g_list_append(retlist, strdup((char *)walker.getText()));
walker.increment(1);
}
continue;
}
}

retlist = g_list_append(retlist, strdup((char *)elem->getText()));
}
return retlist;
}
Expand Down