From 1d0ff54794b5edea7cdf1d2d66710a0fa885bcc5 Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Sun, 28 Oct 2018 11:51:26 +0100 Subject: New upstream version 1.8.1 --- src/modules/filters/osisstrongs.cpp | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/modules/filters/osisstrongs.cpp') diff --git a/src/modules/filters/osisstrongs.cpp b/src/modules/filters/osisstrongs.cpp index b937883..0c17446 100644 --- a/src/modules/filters/osisstrongs.cpp +++ b/src/modules/filters/osisstrongs.cpp @@ -3,7 +3,7 @@ * osisstrongs.cpp - SWFilter descendant to hide or show Strong's number * in a OSIS module * - * $Id: osisstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $ + * $Id: osisstrongs.cpp 3515 2017-11-01 11:38:09Z scribe $ * * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society @@ -57,7 +57,7 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod SWBuf token; bool intoken = false; int wordNum = 1; - char wordstr[5]; + char wordstr[11]; const char *wordStart = 0; SWBuf page = ""; // some modules include page info, so we add these to the words @@ -88,6 +88,15 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod if (token.startsWith("w ")) { // Word XMLTag wtag(token); + + // always save off lemma if we haven't yet + if (!wtag.getAttribute("savlm")) { + const char *l = wtag.getAttribute("lemma"); + if (l) { + wtag.setAttribute("savlm", l); + } + } + if (module->isProcessEntryAttributes()) { wordStart = from+1; char gh = 0; @@ -117,7 +126,7 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod const char *m = strchr(attrib, ':'); if (m) { - int len = m-attrib; + int len = (int)(m-attrib); mClass.append(attrib, len); attrib += (len+1); } @@ -138,19 +147,19 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod } while (++i < count); } - if ((attrib = wtag.getAttribute("lemma"))) { - int count = wtag.getAttributePartCount("lemma", ' '); + if ((attrib = wtag.getAttribute("savlm"))) { + int count = wtag.getAttributePartCount("savlm", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { gh = 0; SWBuf lClass = ""; SWBuf l = ""; - attrib = wtag.getAttribute("lemma", i, ' '); + attrib = wtag.getAttribute("savlm", i, ' '); if (i < 0) i = 0; // to handle our -1 condition const char *m = strchr(attrib, ':'); if (m) { - int len = m-attrib; + int len = (int)(m-attrib); lClass.append(attrib, len); attrib += (len+1); } @@ -217,7 +226,7 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod if (wtag.isEmpty()) { int j; - for (j = token.length()-1; ((j>0) && (strchr(" /", token[j]))); j--); + for (j = (int)token.length()-1; ((j>0) && (strchr(" /", token[j]))); j--); token.size(j+1); } @@ -232,35 +241,27 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod wordNum++; } + // if we won't want strongs, then lets get them out of lemma if (!option) { -/* - * Code which handles multiple lemma types. Kindof works but breaks at least WEBIF filters for strongs. - * int count = wtag.getAttributePartCount("lemma", ' '); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; ++i) { SWBuf a = wtag.getAttribute("lemma", i, ' '); const char *prefix = a.stripPrefix(':'); if ((prefix) && (!strcmp(prefix, "x-Strongs") || !strcmp(prefix, "strong") || !strcmp(prefix, "Strong"))) { // remove attribute part wtag.setAttribute("lemma", 0, i, ' '); - i--; - count--; + --i; + --count; } } -* Instead the codee below just removes the lemma attribute -*****/ - const char *l = wtag.getAttribute("lemma"); - if (l) { - SWBuf savlm = l; - wtag.setAttribute("lemma", 0); - wtag.setAttribute("savlm", savlm); - token = wtag; - token.trim(); - // drop <> - token << 1; - token--; - } + + } + token = wtag; + token.trim(); + // drop <> + token << 1; + token--; } if (token.startsWith("/w")) { // Word End if (module->isProcessEntryAttributes()) { -- cgit v1.2.3