kjv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c43861ddfed6049e07d748533934da404330c235
parent 3065e48532b5c172931616623cb7c7ce357b7dd5
Author: Tim Cooper <tim.cooper@layeh.com>
Date:   Sun, 12 Aug 2018 10:25:17 -0300

allow books to be matched based on beginning substring

Diffstat:
Mkjv.awk | 24++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/kjv.awk b/kjv.awk @@ -112,6 +112,22 @@ function cleanbook(book) { return book } +function bookmatches(book, bookabbr, query) { + book = cleanbook(book) + if (book == query) { + return book + } + + bookabbr = cleanbook(bookabbr) + if (bookabbr == query) { + return book + } + + if (substr(book, 1, length(query)) == query) { + return book + } +} + function printverse(verse, word_count, characters_printed) { if (ENVIRON["KJV_NOLINEWRAP"] != "" && ENVIRON["KJV_NOLINEWRAP"] != "0") { printf("%s\n", verse) @@ -145,19 +161,19 @@ function processline() { outputted_records++ } -cmd == "ref" && mode == "exact" && (cleanbook($1) == p["book"] || cleanbook($2) == p["book"]) && (p["chapter"] == "" || $4 == p["chapter"]) && (p["verse"] == "" || $5 == p["verse"]) { +cmd == "ref" && mode == "exact" && bookmatches($1, $2, p["book"]) && (p["chapter"] == "" || $4 == p["chapter"]) && (p["verse"] == "" || $5 == p["verse"]) { processline() } -cmd == "ref" && mode == "range" && (cleanbook($1) == p["book"] || cleanbook($2) == p["book"]) && ((p["chapter_end"] == "" && $4 == p["chapter"]) || ($4 >= p["chapter"] && $4 <= p["chapter_end"])) && (p["verse"] == "" || $5 >= p["verse"]) && (p["verse_end"] == "" || $5 <= p["verse_end"]) { +cmd == "ref" && mode == "range" && bookmatches($1, $2, p["book"]) && ((p["chapter_end"] == "" && $4 == p["chapter"]) || ($4 >= p["chapter"] && $4 <= p["chapter_end"])) && (p["verse"] == "" || $5 >= p["verse"]) && (p["verse_end"] == "" || $5 <= p["verse_end"]) { processline() } -cmd == "ref" && mode == "range_ext" && (cleanbook($1) == p["book"] || cleanbook($2) == p["book"]) && (($4 == p["chapter"] && $5 >= p["verse"] && p["chapter"] != p["chapter_end"]) || ($4 > p["chapter"] && $4 < p["chapter_end"]) || ($4 == p["chapter_end"] && $5 <= p["verse_end"] && p["chapter"] != p["chapter_end"]) || (p["chapter"] == p["chapter_end"] && $4 == p["chapter"] && $5 >= p["verse"] && $5 <= p["verse_end"])) { +cmd == "ref" && mode == "range_ext" && bookmatches($1, $2, p["book"]) && (($4 == p["chapter"] && $5 >= p["verse"] && p["chapter"] != p["chapter_end"]) || ($4 > p["chapter"] && $4 < p["chapter_end"]) || ($4 == p["chapter_end"] && $5 <= p["verse_end"] && p["chapter"] != p["chapter_end"]) || (p["chapter"] == p["chapter_end"] && $4 == p["chapter"] && $5 >= p["verse"] && $5 <= p["verse_end"])) { processline() } -cmd == "ref" && mode == "search" && (p["book"] == "" || cleanbook($1) == p["book"] || cleanbook($2) == p["book"]) && (p["chapter"] == "" || $4 == p["chapter"]) && match(tolower($6), tolower(p["search"])) { +cmd == "ref" && mode == "search" && (p["book"] == "" || bookmatches($1, $2, p["book"])) && (p["chapter"] == "" || $4 == p["chapter"]) && match(tolower($6), tolower(p["search"])) { processline() }