summaryrefslogtreecommitdiff
path: root/src/modules/filters/osisstrongs.cpp
diff options
context:
space:
mode:
authorTeus Benschop <teusjannette@gmail.com>2018-10-28 11:51:26 +0100
committerTeus Benschop <teusjannette@gmail.com>2018-10-28 11:51:26 +0100
commit1d0ff54794b5edea7cdf1d2d66710a0fa885bcc5 (patch)
tree8ece5f9ef437fbb151f2b22ed0c6e1a714879c7c /src/modules/filters/osisstrongs.cpp
parentc7dbdc9161a7c460526b80fe01af49d714856126 (diff)
New upstream version 1.8.1
Diffstat (limited to 'src/modules/filters/osisstrongs.cpp')
-rw-r--r--src/modules/filters/osisstrongs.cpp55
1 files changed, 28 insertions, 27 deletions
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 <seg> 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()) {