aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keys/listkey.cpp18
-rw-r--r--src/keys/swkey.cpp34
-rw-r--r--src/keys/versekey.cpp75
-rw-r--r--src/modules/filters/gbfrtf.cpp48
4 files changed, 114 insertions, 61 deletions
diff --git a/src/keys/listkey.cpp b/src/keys/listkey.cpp
index 0d1ff33..a8afd93 100644
--- a/src/keys/listkey.cpp
+++ b/src/keys/listkey.cpp
@@ -255,3 +255,21 @@ void ListKey::Remove() {
SetToElement((arraypos)?arraypos-1:0);
}
}
+
+
+/******************************************************************************
+ * VerseKey::getRangeText - returns parsable range text for this key
+ */
+
+const char *ListKey::getRangeText() const {
+ char *buf = new char[(arraycnt + 1) * 255];
+ buf[0] = 0;
+ for (int i = 0; i < arraycnt; i++) {
+ strcat(buf, array[i]->getRangeText());
+ if (i < arraycnt-1)
+ strcat(buf, "; ");
+ }
+ stdstr(&rangeText, buf);
+ return rangeText;
+}
+
diff --git a/src/keys/swkey.cpp b/src/keys/swkey.cpp
index 307e848..f2491c4 100644
--- a/src/keys/swkey.cpp
+++ b/src/keys/swkey.cpp
@@ -19,21 +19,23 @@ SWClass SWKey::classdef(classes);
SWKey::SWKey(const char *ikey)
{
- index = 0;
- persist = 0;
- keytext = 0;
- error = 0;
+ index = 0;
+ persist = 0;
+ keytext = 0;
+ rangeText = 0;
+ error = 0;
stdstr(&keytext, ikey);
init();
}
SWKey::SWKey(SWKey const &k)
{
- index = k.index;
- persist = k.persist;
- userData = k.userData;
- keytext = 0;
- error = k.error;
+ index = k.index;
+ persist = k.persist;
+ userData = k.userData;
+ keytext = 0;
+ rangeText = 0;
+ error = k.error;
stdstr(&keytext, k.keytext);
init();
}
@@ -54,6 +56,8 @@ SWKey *SWKey::clone() const
SWKey::~SWKey() {
if (keytext)
delete [] keytext;
+ if (rangeText)
+ delete [] rangeText;
}
@@ -130,7 +134,7 @@ void SWKey::copyFrom(const SWKey &ikey) {
/******************************************************************************
- * SWKey::getText - returns text key if (char *) cast is requested
+ * SWKey::getText - returns text key if (const char *) cast is requested
*/
const char *SWKey::getText() const {
@@ -139,6 +143,16 @@ const char *SWKey::getText() const {
/******************************************************************************
+ * SWKey::getRangeText - returns parsable range text for this key
+ */
+
+const char *SWKey::getRangeText() const {
+ stdstr(&rangeText, keytext);
+ return rangeText;
+}
+
+
+/******************************************************************************
* SWKey::compare - Compares another VerseKey object
*
* ENT: ikey - key to compare with this one
diff --git a/src/keys/versekey.cpp b/src/keys/versekey.cpp
index 484e5ce..8773298 100644
--- a/src/keys/versekey.cpp
+++ b/src/keys/versekey.cpp
@@ -310,34 +310,39 @@ void VerseKey::freshtext() const
int VerseKey::getBookAbbrev(const char *iabbr)
{
- int loop, diff, abLen, min, max, target, retVal = -1;
-
- char *abbr = 0;
-
- stdstr(&abbr, iabbr);
- strstrip(abbr);
- toupperstr(abbr);
- abLen = strlen(abbr);
-
- if (abLen) {
- min = 0;
-// max = abbrevsCnt - 1;
- max = abbrevsCnt;
- while(1) {
- target = min + ((max - min) / 2);
- diff = strncmp(abbr, abbrevs[target].ab, abLen);
- if ((!diff)||(target >= max)||(target <= min))
- break;
- if (diff > 0)
- min = target;
- else max = target;
- }
- for (; target > 0; target--) {
- if (strncmp(abbr, abbrevs[target-1].ab, abLen))
- break;
+ int loop, diff, abLen, min, max, target, retVal = -1;
+
+ char *abbr = 0;
+
+ for (int i = 0; i < 2; i++) {
+ stdstr(&abbr, iabbr);
+ strstrip(abbr);
+ if (!i)
+ toupperstr(abbr);
+ abLen = strlen(abbr);
+
+ if (abLen) {
+ min = 0;
+// max = abbrevsCnt - 1;
+ max = abbrevsCnt;
+ while(1) {
+ target = min + ((max - min) / 2);
+ diff = strncmp(abbr, abbrevs[target].ab, abLen);
+ if ((!diff)||(target >= max)||(target <= min))
+ break;
+ if (diff > 0)
+ min = target;
+ else max = target;
+ }
+ for (; target > 0; target--) {
+ if (strncmp(abbr, abbrevs[target-1].ab, abLen))
+ break;
+ }
+
+ retVal = (!diff) ? abbrevs[target].book : -1;
}
-
- retVal = (!diff) ? abbrevs[target].book : -1;
+ if (retVal > 0)
+ break;
}
delete [] abbr;
return retVal;
@@ -1454,3 +1459,19 @@ const char *VerseKey::getOSISRef() const {
else sprintf(buf[loop], "");
return buf[loop++];
}
+
+
+/******************************************************************************
+ * VerseKey::getRangeText - returns parsable range text for this key
+ */
+
+const char *VerseKey::getRangeText() const {
+ if ((upperBound) && (lowerBound)) {
+ char buf[1023];
+ sprintf(buf, "%s-%s", (const char *)lowerBound, (const char *)upperBound);
+ stdstr(&rangeText, buf);
+ }
+ else stdstr(&rangeText, getText());
+ return rangeText;
+}
+
diff --git a/src/modules/filters/gbfrtf.cpp b/src/modules/filters/gbfrtf.cpp
index 40e5752..d704702 100644
--- a/src/modules/filters/gbfrtf.cpp
+++ b/src/modules/filters/gbfrtf.cpp
@@ -136,10 +136,9 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
*to++ = '1';
*to++ = ' ';
*to++ = '\\';
- *to++ = 'f';
*to++ = 's';
- *to++ = '1';
- *to++ = '7';
+ *to++ = 'u';
+ *to++ = 'b';
*to++ = ' ';
*to++ = '(';
continue;
@@ -177,8 +176,8 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
*to++ = ' ';
continue;
case 'N':
- *to++ = '{';
- if (!strnicmp(token+2, "Symbol", 6)) {
+ *to++ = '{';
+ if (!strnicmp(token+2, "Symbol", 6)) {
*to++ = '\\';
*to++ = 'f';
*to++ = '7';
@@ -189,8 +188,8 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
*to++ = '}';
continue;
case 'S':
- *to++ = '{';
- *to++ = '\\';
+ *to++ = '{';
+ *to++ = '\\';
*to++ = 's';
*to++ = 'u';
*to++ = 'p';
@@ -199,10 +198,10 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
*to++ = ' ';
continue;
case 's':
- *to++ = '}';
+ *to++ = '}';
continue;
case 'R':
- *to++ = '{';
+ *to++ = '{';
*to++ = '\\';
*to++ = 'c';
*to++ = 'f';
@@ -210,7 +209,7 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
*to++ = ' ';
continue;
case 'r':
- *to++ = '}';
+ *to++ = '}';
continue;
}
break;
@@ -247,22 +246,23 @@ char GBFRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModul
case 'T': // Book title begin
*to++ = '{';
*to++ = '\\';
- *to++ = 'f';
- *to++ = 's';
- *to++ = '2';
- *to++ = '2';
- *to++ = ' ';
- continue;
+ *to++ = 'l';
+ *to++ = 'a';
+ *to++ = 'r';
+ *to++ = 'g';
+ *to++ = 'e';
+ *to++ = ' ';
+ continue;
case 't':
- *to++ = '}';
- continue;
+ *to++ = '}';
+ continue;
case 'S':
- *to++ = '\\';
- *to++ = 'p';
- *to++ = 'a';
- *to++ = 'r';
- *to++ = ' ';
- *to++ = '{';
+ *to++ = '\\';
+ *to++ = 'p';
+ *to++ = 'a';
+ *to++ = 'r';
+ *to++ = ' ';
+ *to++ = '{';
*to++ = '\\';
*to++ = 'i';
*to++ = '1';