summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
commit7a00574163029c0c2b649878c95d5acbd083564a (patch)
treec13cc5736025834df2874ed87ee8598070025ea6 /src/modules
parentb745315323de9f27538edac9453205ca70e6186e (diff)
Imported Upstream version 1.7.2+dfsg
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/comments/hrefcom/hrefcom.cpp14
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp39
-rw-r--r--src/modules/comments/rawcom4/Makefile5
-rw-r--r--src/modules/comments/rawcom4/rawcom4.cpp39
-rw-r--r--src/modules/comments/rawfiles/rawfiles.cpp58
-rw-r--r--src/modules/comments/swcom.cpp30
-rw-r--r--src/modules/comments/zcom/zcom.cpp47
-rw-r--r--src/modules/common/Makefile.am4
-rw-r--r--src/modules/common/bz2comprs.cpp181
-rw-r--r--src/modules/common/compress.cpp.txt767
-rw-r--r--src/modules/common/entriesblk.cpp9
-rw-r--r--src/modules/common/lzsscomprs.cpp120
-rw-r--r--src/modules/common/lzsscomprs.txt (renamed from src/modules/common/swcomprs.doc)0
-rw-r--r--src/modules/common/rawstr.cpp22
-rw-r--r--src/modules/common/rawstr4.cpp24
-rw-r--r--src/modules/common/rawverse.cpp13
-rw-r--r--src/modules/common/rawverse4.cpp17
-rw-r--r--src/modules/common/sapphire.cpp48
-rw-r--r--src/modules/common/swcipher.cpp8
-rw-r--r--src/modules/common/swcomprs.cpp7
-rw-r--r--src/modules/common/xzcomprs.cpp181
-rw-r--r--src/modules/common/zipcomprs.cpp8
-rw-r--r--src/modules/common/zstr.cpp27
-rw-r--r--src/modules/common/zverse.cpp38
-rw-r--r--src/modules/filters/Makefile.am14
-rw-r--r--src/modules/filters/cipherfil.cpp11
-rw-r--r--src/modules/filters/gbffootnotes.cpp28
-rw-r--r--src/modules/filters/gbfheadings.cpp29
-rw-r--r--src/modules/filters/gbfhtml.cpp12
-rw-r--r--src/modules/filters/gbfhtmlhref.cpp22
-rw-r--r--src/modules/filters/gbfmorph.cpp26
-rw-r--r--src/modules/filters/gbfosis.cpp22
-rw-r--r--src/modules/filters/gbfplain.cpp11
-rw-r--r--src/modules/filters/gbfredletterwords.cpp26
-rw-r--r--src/modules/filters/gbfrtf.cpp7
-rw-r--r--src/modules/filters/gbfstrongs.cpp26
-rw-r--r--src/modules/filters/gbfthml.cpp13
-rw-r--r--src/modules/filters/gbfwebif.cpp17
-rw-r--r--src/modules/filters/gbfwordjs.cpp43
-rw-r--r--src/modules/filters/gbfxhtml.cpp236
-rw-r--r--src/modules/filters/greeklexattribs.cpp7
-rw-r--r--src/modules/filters/latin1utf16.cpp7
-rw-r--r--src/modules/filters/latin1utf8.cpp12
-rw-r--r--src/modules/filters/osisenum.cpp99
-rw-r--r--src/modules/filters/osisfootnotes.cpp29
-rw-r--r--src/modules/filters/osisglosses.cpp (renamed from src/modules/filters/osisruby.cpp)192
-rw-r--r--src/modules/filters/osisheadings.cpp228
-rw-r--r--src/modules/filters/osishtmlhref.cpp157
-rw-r--r--src/modules/filters/osislemma.cpp28
-rw-r--r--src/modules/filters/osismorph.cpp27
-rw-r--r--src/modules/filters/osismorphsegmentation.cpp27
-rw-r--r--src/modules/filters/osisosis.cpp24
-rw-r--r--src/modules/filters/osisplain.cpp64
-rw-r--r--src/modules/filters/osisredletterwords.cpp25
-rw-r--r--src/modules/filters/osisreferencelinks.cpp114
-rw-r--r--src/modules/filters/osisrtf.cpp25
-rw-r--r--src/modules/filters/osisscripref.cpp26
-rw-r--r--src/modules/filters/osisstrongs.cpp29
-rw-r--r--src/modules/filters/osisvariants.cpp82
-rw-r--r--src/modules/filters/osiswebif.cpp60
-rw-r--r--src/modules/filters/osiswordjs.cpp34
-rw-r--r--src/modules/filters/osisxhtml.cpp772
-rw-r--r--src/modules/filters/osisxlit.cpp99
-rw-r--r--src/modules/filters/papyriplain.cpp6
-rw-r--r--src/modules/filters/plainfootnotes.cpp85
-rw-r--r--src/modules/filters/plainhtml.cpp89
-rw-r--r--src/modules/filters/rtfhtml.cpp38
-rw-r--r--src/modules/filters/scsuutf8.cpp246
-rw-r--r--src/modules/filters/swbasicfilter.cpp28
-rw-r--r--src/modules/filters/swoptfilter.cpp9
-rw-r--r--src/modules/filters/teihtmlhref.cpp22
-rw-r--r--src/modules/filters/teiplain.cpp10
-rw-r--r--src/modules/filters/teirtf.cpp416
-rw-r--r--src/modules/filters/teixhtml.cpp290
-rw-r--r--src/modules/filters/thmlfootnotes.cpp30
-rw-r--r--src/modules/filters/thmlgbf.cpp9
-rw-r--r--src/modules/filters/thmlheadings.cpp26
-rw-r--r--src/modules/filters/thmlhtml.cpp11
-rw-r--r--src/modules/filters/thmlhtmlhref.cpp34
-rw-r--r--src/modules/filters/thmllemma.cpp26
-rw-r--r--src/modules/filters/thmlmorph.cpp25
-rw-r--r--src/modules/filters/thmlosis.cpp22
-rw-r--r--src/modules/filters/thmlplain.cpp7
-rw-r--r--src/modules/filters/thmlrtf.cpp17
-rw-r--r--src/modules/filters/thmlscripref.cpp32
-rw-r--r--src/modules/filters/thmlstrongs.cpp26
-rw-r--r--src/modules/filters/thmlvariants.cpp59
-rw-r--r--src/modules/filters/thmlwebif.cpp14
-rw-r--r--src/modules/filters/thmlwordjs.cpp43
-rw-r--r--src/modules/filters/thmlxhtml.cpp378
-rw-r--r--src/modules/filters/unicodertf.cpp6
-rw-r--r--src/modules/filters/utf16utf8.cpp10
-rw-r--r--src/modules/filters/utf8arabicpoints.cpp174
-rw-r--r--src/modules/filters/utf8arshaping.cpp9
-rw-r--r--src/modules/filters/utf8bidireorder.cpp15
-rw-r--r--src/modules/filters/utf8cantillation.cpp26
-rw-r--r--src/modules/filters/utf8greekaccents.cpp29
-rw-r--r--src/modules/filters/utf8hebrewpoints.cpp30
-rw-r--r--src/modules/filters/utf8html.cpp14
-rw-r--r--src/modules/filters/utf8latin1.cpp11
-rw-r--r--src/modules/filters/utf8nfc.cpp7
-rw-r--r--src/modules/filters/utf8nfkd.cpp12
-rw-r--r--src/modules/filters/utf8transliterator.cpp126
-rw-r--r--src/modules/filters/utf8utf16.cpp8
-rw-r--r--src/modules/genbook/rawgenbook/rawgenbook.cpp22
-rw-r--r--src/modules/genbook/swgenbook.cpp17
-rw-r--r--src/modules/lexdict/rawld/rawld.cpp28
-rw-r--r--src/modules/lexdict/rawld4/rawld4.cpp27
-rw-r--r--src/modules/lexdict/swld.cpp30
-rw-r--r--src/modules/lexdict/zld/zld.cpp28
-rw-r--r--src/modules/readme9
-rw-r--r--src/modules/swmodule.cpp454
-rw-r--r--src/modules/tests/echomod.cpp10
-rw-r--r--src/modules/texts/rawtext/rawtext.cpp49
-rw-r--r--src/modules/texts/rawtext4/Makefile5
-rw-r--r--src/modules/texts/rawtext4/rawtext4.cpp54
-rw-r--r--src/modules/texts/swtext.cpp31
-rw-r--r--src/modules/texts/ztext/ztext.cpp59
118 files changed, 4965 insertions, 2749 deletions
diff --git a/src/modules/comments/hrefcom/hrefcom.cpp b/src/modules/comments/hrefcom/hrefcom.cpp
index 7035b08..3716dbf 100644
--- a/src/modules/comments/hrefcom/hrefcom.cpp
+++ b/src/modules/comments/hrefcom/hrefcom.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
+ *
+ * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
* files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * $Id: hrefcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -67,19 +69,19 @@ HREFCom::~HREFCom()
* RET: string buffer with verse
*/
-SWBuf &HREFCom::getRawEntryBuf() {
+SWBuf &HREFCom::getRawEntryBuf() const {
long start;
unsigned short size;
VerseKey *key = 0;
key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
SWBuf tmpbuf;
- readText(key->Testament(), start, size, tmpbuf);
+ readText(key->getTestament(), start, size, tmpbuf);
entryBuf = prefix;
entryBuf += tmpbuf.c_str();
prepText(entryBuf);
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
index c0404ae..5189cdc 100644
--- a/src/modules/comments/rawcom/rawcom.cpp
+++ b/src/modules/comments/rawcom/rawcom.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * rawcom.cpp - code for class 'RawCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawcom.cpp - code for class 'RawCom'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +57,7 @@ RawCom::~RawCom()
}
-bool RawCom::isWritable() {
+bool RawCom::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
@@ -64,16 +67,16 @@ bool RawCom::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawCom::getRawEntryBuf() {
+SWBuf &RawCom::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
@@ -98,7 +101,7 @@ void RawCom::increment(int steps) {
unsigned short size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -108,12 +111,12 @@ void RawCom::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -129,7 +132,7 @@ void RawCom::increment(int steps) {
void RawCom::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
}
@@ -137,7 +140,7 @@ void RawCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -153,7 +156,7 @@ void RawCom::linkEntry(const SWKey *inkey) {
void RawCom::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
@@ -161,10 +164,10 @@ bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned short size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -174,7 +177,7 @@ bool RawCom::hasEntry(const SWKey *k) const {
unsigned short size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/comments/rawcom4/Makefile b/src/modules/comments/rawcom4/Makefile
new file mode 100644
index 0000000..a08e07e
--- /dev/null
+++ b/src/modules/comments/rawcom4/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/rawcom4/rawcom4.cpp b/src/modules/comments/rawcom4/rawcom4.cpp
index c0c4a1d..7cfc603 100644
--- a/src/modules/comments/rawcom4/rawcom4.cpp
+++ b/src/modules/comments/rawcom4/rawcom4.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * rawcom4.cpp - code for class 'RawCom4'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawcom4.cpp - code for class 'RawCom4'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawcom4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,7 +56,7 @@ RawCom4::~RawCom4()
}
-bool RawCom4::isWritable() {
+bool RawCom4::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
@@ -63,16 +66,16 @@ bool RawCom4::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawCom4::getRawEntryBuf() {
+SWBuf &RawCom4::getRawEntryBuf() const {
long start = 0;
unsigned long size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
@@ -97,7 +100,7 @@ void RawCom4::increment(int steps) {
unsigned long size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -107,12 +110,12 @@ void RawCom4::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -128,14 +131,14 @@ void RawCom4::increment(int steps) {
void RawCom4::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
}
void RawCom4::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -148,7 +151,7 @@ void RawCom4::linkEntry(const SWKey *inkey) {
void RawCom4::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
@@ -156,10 +159,10 @@ bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -169,7 +172,7 @@ bool RawCom4::hasEntry(const SWKey *k) const {
unsigned long size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/comments/rawfiles/rawfiles.cpp b/src/modules/comments/rawfiles/rawfiles.cpp
index b0e24fc..7c2d524 100644
--- a/src/modules/comments/rawfiles/rawfiles.cpp
+++ b/src/modules/comments/rawfiles/rawfiles.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
+ *
+ * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
* files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * $Id: rawfiles.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -57,31 +59,31 @@ RawFiles::~RawFiles()
/** Is the module writable? :)
* @return yes or no
*/
-bool RawFiles::isWritable() {
+bool RawFiles::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
- * RawFiles::getRawEntry - Returns the correct verse when char * cast
- * is requested
+ * RawFiles::getRawEntry - Retrieve the unprocessed entry contents at
+ * the current key position of this module
*
- * RET: string buffer with verse
+ * RET: entry contents
*/
-SWBuf &RawFiles::getRawEntryBuf() {
+SWBuf &RawFiles::getRawEntryBuf() const {
FileDesc *datafile;
long start = 0;
unsigned short size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entryBuf = "";
if (size) {
SWBuf tmpbuf = path;
tmpbuf += '/';
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
tmpbuf += entryBuf;
entryBuf = "";
datafile = FileMgr::getSystemFileMgr()->open(tmpbuf.c_str(), FileMgr::RDONLY);
@@ -102,7 +104,7 @@ SWBuf &RawFiles::getRawEntryBuf() {
/******************************************************************************
- * RawFiles::setEntry(char *)- Update the modules current key entry with
+ * RawFiles::setEntry(char *)- Update the module's current key entry with
* provided text
*/
@@ -114,13 +116,13 @@ void RawFiles::setEntry(const char *inbuf, long len) {
len = (len<0)?strlen(inbuf):len;
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
if (size) {
SWBuf tmpbuf;
entryBuf = path;
entryBuf += '/';
- readText(key->Testament(), start, size, tmpbuf);
+ readText(key->getTestament(), start, size, tmpbuf);
entryBuf += tmpbuf;
}
else {
@@ -128,7 +130,7 @@ void RawFiles::setEntry(const char *inbuf, long len) {
entryBuf = path;
entryBuf += '/';
tmpbuf = getNextFilename();
- doSetText(key->Testament(), key->TestamentIndex(), tmpbuf);
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf);
entryBuf += tmpbuf;
}
datafile = FileMgr::getSystemFileMgr()->open(entryBuf, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
@@ -152,14 +154,14 @@ void RawFiles::linkEntry(const SWKey *inkey) {
unsigned short size;
const VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
if (size) {
SWBuf tmpbuf;
- readText(key->Testament(), start, size + 2, tmpbuf);
+ readText(key->getTestament(), start, size + 2, tmpbuf);
key = &getVerseKey(inkey);
- doSetText(key->Testament(), key->TestamentIndex(), tmpbuf.c_str());
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf.c_str());
}
}
@@ -172,7 +174,7 @@ void RawFiles::linkEntry(const SWKey *inkey) {
void RawFiles::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
@@ -183,22 +185,22 @@ void RawFiles::deleteEntry() {
* RET: filename
*/
-char *RawFiles::getNextFilename() {
- static char incfile[255];
- __u32 number;
+const char *RawFiles::getNextFilename() {
+ static SWBuf incfile;
+ __u32 number = 0;
FileDesc *datafile;
- sprintf(incfile, "%s/incfile", path);
+ incfile.setFormatted("%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::RDONLY);
-
- if (datafile->read(&number, 4) != 4) number = 0;
- number = swordtoarch32(number);
-
+ if (datafile->getFd() != -1) {
+ if (datafile->read(&number, 4) != 4) number = 0;
+ number = swordtoarch32(number);
+ }
number++;
FileMgr::getSystemFileMgr()->close(datafile);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
- sprintf(incfile, "%.7d", number-1);
+ incfile.setFormatted("%.7d", number-1);
number = archtosword32(number);
datafile->write(&number, 4);
@@ -208,7 +210,7 @@ char *RawFiles::getNextFilename() {
}
-char RawFiles::createModule (const char *path) {
+char RawFiles::createModule(const char *path) {
char *incfile = new char [ strlen (path) + 16 ];
__u32 zero = 0;
diff --git a/src/modules/comments/swcom.cpp b/src/modules/comments/swcom.cpp
index e82751b..52bd61b 100644
--- a/src/modules/comments/swcom.cpp
+++ b/src/modules/comments/swcom.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
- * modules
*
+ * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
+ * modules
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcom.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -41,9 +43,9 @@ SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTex
this->versification = 0;
stdstr(&(this->versification), versification);
delete key;
- key = (VerseKey *)CreateKey();
- tmpVK1 = (VerseKey *)CreateKey();
- tmpVK2 = (VerseKey *)CreateKey();
+ key = (VerseKey *)createKey();
+ tmpVK1 = (VerseKey *)createKey();
+ tmpVK2 = (VerseKey *)createKey();
tmpSecond = false;
}
@@ -59,7 +61,7 @@ SWCom::~SWCom() {
}
-SWKey *SWCom::CreateKey() const {
+SWKey *SWCom::createKey() const {
VerseKey *vk = new VerseKey();
vk->setVersificationSystem(versification);
@@ -68,22 +70,20 @@ SWKey *SWCom::CreateKey() const {
}
-long SWCom::Index() const {
+long SWCom::getIndex() const {
VerseKey *key = &getVerseKey();
- entryIndex = key->Index();
+ entryIndex = key->getIndex();
return entryIndex;
}
-long SWCom::Index(long iindex) {
+void SWCom::setIndex(long iindex) {
VerseKey *key = &getVerseKey();
- key->Testament(1);
- key->Index(iindex);
+ key->setTestament(1);
+ key->setIndex(iindex);
if (key != this->key) {
this->key->copyFrom(*key);
}
-
- return Index();
}
@@ -104,7 +104,7 @@ VerseKey &SWCom::getVerseKey(const SWKey *keyToConvert) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
diff --git a/src/modules/comments/zcom/zcom.cpp b/src/modules/comments/zcom/zcom.cpp
index 35b8946..65c4ca8 100644
--- a/src/modules/comments/zcom/zcom.cpp
+++ b/src/modules/comments/zcom/zcom.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawcom.cpp - code for class 'zCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * zcom.cpp - code for class 'zCom'- a module that reads raw commentary
+ * files
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: zcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,6 +25,7 @@
#include <stdio.h>
#include <fcntl.h>
+#include <swbuf.h>
#include <zverse.h>
#include <versekey.h>
#include <zcom.h>
@@ -59,7 +62,7 @@ zCom::~zCom() {
}
-bool zCom::isWritable() {
+bool zCom::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -70,17 +73,17 @@ bool zCom::isWritable() {
*
* RET: string buffer with verse
*/
-SWBuf &zCom::getRawEntryBuf() {
+SWBuf &zCom::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
unsigned long buffnum;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size, &buffnum);
entrySize = size; // support getEntrySize call
entryBuf = "";
- zReadText(key->Testament(), start, size, buffnum, entryBuf);
+ zReadText(key->getTestament(), start, size, buffnum, entryBuf);
rawFilter(entryBuf, key);
@@ -92,18 +95,18 @@ SWBuf &zCom::getRawEntryBuf() {
bool zCom::sameBlock(VerseKey *k1, VerseKey *k2) {
- if (k1->Testament() != k2->Testament())
+ if (k1->getTestament() != k2->getTestament())
return false;
switch (blockType) {
case VERSEBLOCKS:
- if (k1->Verse() != k2->Verse())
+ if (k1->getVerse() != k2->getVerse())
return false;
case CHAPTERBLOCKS:
- if (k1->Chapter() != k2->Chapter())
+ if (k1->getChapter() != k2->getChapter())
return false;
case BOOKBLOCKS:
- if (k1->Book() != k2->Book())
+ if (k1->getBook() != k2->getBook())
return false;
}
return true;
@@ -120,7 +123,7 @@ void zCom::setEntry(const char *inbuf, long len) {
delete lastWriteKey;
}
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
lastWriteKey = (VerseKey *)key->clone(); // must delete
}
@@ -130,7 +133,7 @@ void zCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -145,7 +148,7 @@ void zCom::linkEntry(const SWKey *inkey) {
void zCom::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
@@ -163,7 +166,7 @@ void zCom::increment(int steps) {
unsigned long buffnum;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -173,12 +176,12 @@ void zCom::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size, &buffnum);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -197,10 +200,10 @@ bool zCom::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long buffnum1, buffnum2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1, &buffnum1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2, &buffnum2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
return start1 == start2 && buffnum1 == buffnum2;
}
@@ -210,7 +213,7 @@ bool zCom::hasEntry(const SWKey *k) const {
unsigned long buffnum;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
return size;
}
diff --git a/src/modules/common/Makefile.am b/src/modules/common/Makefile.am
index 34a14bf..90a3f98 100644
--- a/src/modules/common/Makefile.am
+++ b/src/modules/common/Makefile.am
@@ -6,7 +6,9 @@ libsword_la_SOURCES += $(commondir)/swcomprs.cpp
libsword_la_SOURCES += $(commondir)/lzsscomprs.cpp
if HAVE_LIBZ
-SWZLIB = $(commondir)/zipcomprs.cpp
+SWZLIB = $(commondir)/zipcomprs.cpp
+SWZLIB += $(commondir)/bz2comprs.cpp
+SWZLIB += $(commondir)/xzcomprs.cpp
else
SWZLIB =
endif
diff --git a/src/modules/common/bz2comprs.cpp b/src/modules/common/bz2comprs.cpp
new file mode 100644
index 0000000..16f6d11
--- /dev/null
+++ b/src/modules/common/bz2comprs.cpp
@@ -0,0 +1,181 @@
+/******************************************************************************
+ *
+ * bz2comprs.cpp - Bzip2Compress, a driver class that provides bzip2
+ * compression (Burrows–Wheeler with Huffman coding)
+ *
+ * $Id: bz2comprs.cpp 2858 2013-07-08 03:08:10Z chrislit $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <bz2comprs.h>
+#include <zlib.h>
+
+SWORD_NAMESPACE_START
+
+/******************************************************************************
+ * Bzip2Compress Constructor - Initializes data for instance of Bzip2Compress
+ *
+ */
+
+Bzip2Compress::Bzip2Compress() : SWCompress() {
+}
+
+
+/******************************************************************************
+ * Bzip2Compress Destructor - Cleans up instance of Bzip2Compress
+ */
+
+Bzip2Compress::~Bzip2Compress() {
+}
+
+
+/******************************************************************************
+ * Bzip2Compress::Encode - This function "encodes" the input stream into the
+ * output stream.
+ * The GetChars() and SendChars() functions are
+ * used to separate this method from the actual
+ * i/o.
+ * NOTE: must set zlen for parent class to know length of
+ * compressed buffer.
+ */
+
+void Bzip2Compress::Encode(void)
+{
+/*
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+ Compresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be at least 0.1% larger than
+ sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
+ compressed buffer.
+ This function can be used to compress a whole file at once if the
+ input file is mmap'ed.
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer.
+*/
+ direct = 0; // set direction needed by parent [Get|Send]Chars()
+
+ // get buffer
+ char chunk[1024];
+ char *buf = (char *)calloc(1, 1024);
+ char *chunkbuf = buf;
+ unsigned long chunklen;
+ unsigned long len = 0;
+ while((chunklen = GetChars(chunk, 1023))) {
+ memcpy(chunkbuf, chunk, chunklen);
+ len += chunklen;
+ if (chunklen < 1023)
+ break;
+ else buf = (char *)realloc(buf, len + 1024);
+ chunkbuf = buf+len;
+ }
+
+
+ zlen = (long) (len*1.001)+15;
+ char *zbuf = new char[zlen+1];
+ if (len)
+ {
+ //printf("Doing compress\n");
+ if (compress((Bytef*)zbuf, &zlen, (const Bytef*)buf, len) != Z_OK)
+ {
+ printf("ERROR in compression\n");
+ }
+ else {
+ SendChars(zbuf, zlen);
+ }
+ }
+ else
+ {
+ fprintf(stderr, "ERROR: no buffer to compress\n");
+ }
+ delete [] zbuf;
+ free (buf);
+}
+
+
+/******************************************************************************
+ * Bzip2Compress::Decode - This function "decodes" the input stream into the
+ * output stream.
+ * The GetChars() and SendChars() functions are
+ * used to separate this method from the actual
+ * i/o.
+ */
+
+void Bzip2Compress::Decode(void)
+{
+/*
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be large enough to hold the
+ entire uncompressed data. (The size of the uncompressed data must have
+ been saved previously by the compressor and transmitted to the decompressor
+ by some mechanism outside the scope of this compression library.)
+ Upon exit, destLen is the actual size of the compressed buffer.
+ This function can be used to decompress a whole file at once if the
+ input file is mmap'ed.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted.
+*/
+
+ // get buffer
+ char chunk[1024];
+ char *zbuf = (char *)calloc(1, 1024);
+ char *chunkbuf = zbuf;
+ int chunklen;
+ unsigned long zlen = 0;
+ while((chunklen = GetChars(chunk, 1023))) {
+ memcpy(chunkbuf, chunk, chunklen);
+ zlen += chunklen;
+ if (chunklen < 1023)
+ break;
+ else zbuf = (char *)realloc(zbuf, zlen + 1024);
+ chunkbuf = zbuf + zlen;
+ }
+
+ //printf("Decoding complength{%ld} uncomp{%ld}\n", zlen, blen);
+ if (zlen) {
+ unsigned long blen = zlen*20; // trust compression is less than 1000%
+ char *buf = new char[blen];
+ //printf("Doing decompress {%s}\n", zbuf);
+ slen = 0;
+ switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){
+ case Z_OK: SendChars(buf, blen); slen = blen; break;
+ case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break;
+ case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break;
+ case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break;
+ default: fprintf(stderr, "ERROR: an unknown error occured during decompression.\n"); break;
+ }
+ delete [] buf;
+ }
+ else {
+ fprintf(stderr, "ERROR: no buffer to decompress!\n");
+ }
+ //printf("Finished decoding\n");
+ free (zbuf);
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/common/compress.cpp.txt b/src/modules/common/compress.cpp.txt
deleted file mode 100644
index 5031adb..0000000
--- a/src/modules/common/compress.cpp.txt
+++ /dev/null
@@ -1,767 +0,0 @@
-Compression Info, 10-11-95
-Jeff Wheeler
-
-Source of Algorithm
--------------------
-
-The compression algorithms used here are based upon the algorithms developed and published by Haruhiko Okumura in a paper entitled "Data Compression Algorithms of LARC and LHarc." This paper discusses three compression algorithms, LSZZ, LZARI, and LZHUF. LZSS is described as the "first" of these, and is described as providing moderate compression with good speed. LZARI is described as an improved LZSS, a combination of the LZSS algorithm with adaptive arithmetic compression. It is described as being slower than LZSS but with better compression. LZHUF (the basis of the common LHA compression program) was included in the paper, however, a free usage license was not included.
-
-The following are copies of the statements included at the beginning of each source code listing that was supplied in the working paper.
-
- LZSS, dated 4/6/89, marked as "Use, distribute and
- modify this program freely."
-
- LZARI, dated 4/7/89, marked as "Use, distribute and
- modify this program freely."
-
- LZHUF, dated 11/20/88, written by Haruyasu Yoshizaki,
- translated by Haruhiko Okumura on 4/7/89. Not
- expressly marked as redistributable or modifiable.
-
-Since both LZSS and LZARI are marked as "use, distribute and modify freely" we have felt at liberty basing our compression algorithm on either of these.
-
-Selection of Algorithm
-----------------------
-
-Working samples of three possible compression algorithms are supplied in Okumura's paper. Which should be used?
-
-LZSS is the fastest at decompression, but does not generated as small a compressed file as the other methods. The other two methods provided, perhaps, a 15% improvement in compression. Or, put another way, on a 100K file, LZSS might compress it to 50K while the others might approach 40-45K. For STEP purposes, it was decided that decoding speed was of more importance than tighter compression. For these reasons, the first compression algorithm implemented is the LZSS algorithm.
-
-About LZSS Encoding
--------------------
-
-(adapted from Haruhiko Okumura's paper)
-
-This scheme was proposed by Ziv and Lempel [1]. A slightly modified version is described by Storer and Szymanski [2]. An implementation using a binary tree has been proposed by Bell [3].
-
-The algorithm is quite simple.
-1. Keep a ring buffer which initially contains all space characters.
-2. Read several letters from the file to the buffer.
-3. Search the buffer for the longest string that matches the letters just read, and send its length and position into the buffer.
-
-If the ring buffer is 4096 bytes, the position can be stored in 12 bits. If the length is represented in 4 bits, the <position, length> pair is two bytes long. If the longest match is no more than two characters, then just one character is sent without encoding. The process starts again with the next character. An extra bit is sent each time to tell the decoder whether the next item is a character of a <position, length> pair.
-
-[1] J. Ziv and A. Lempel, IEEE Transactions IT-23, 337-343 (1977).
-[2] J. A. Storer and T. G. Szymanski, J. ACM, 29, 928-951 (1982).
-[3] T.C. Gell, IEEE Transactions COM-34, 1176-1182 (1986).
-
-void InitTree( // no return value
- void); // no parameters
-
-void InsertNode( // no return value
- short int Pos); // position in the buffer
-
-void DeleteNode( // no return value
- short int Node); // node to be removed
-
-void Encode( // no return value
- void); // no parameters
-
-void Decode( // no return value
- void); // no parameters
-
-// The following are constant sizes used by the compression algorithm.
-//
-// N - This is the size of the ring buffer. It is set
-// to 4K. It is important to note that a position
-// within the ring buffer requires 12 bits.
-//
-// F - This is the maximum length of a character sequence
-// that can be taken from the ring buffer. It is set
-// to 18. Note that a length must be 3 before it is
-// worthwhile to store a position/length pair, so the
-// length can be encoded in only 4 bits. Or, put yet
-// another way, it is not necessary to encode a length
-// of 0-18, it is necessary to encode a length of
-// 3-18, which requires 4 bits.
-//
-// THRESHOLD - It takes 2 bytes to store an offset and
-// a length. If a character sequence only
-// requires 1 or 2 characters to store
-// uncompressed, then it is better to store
-// it uncompressed than as an offset into
-// the ring buffer.
-//
-// Note that the 12 bits used to store the position and the 4 bits
-// used to store the length equal a total of 16 bits, or 2 bytes.
-
-#define N 4096
-#define F 18
-#define THRESHOLD 3
-#define NOT_USED N
-
-// m_ring_buffer is a text buffer. It contains "nodes" of
-// uncompressed text that can be indexed by position. That is,
-// a substring of the ring buffer can be indexed by a position
-// and a length. When decoding, the compressed text may contain
-// a position in the ring buffer and a count of the number of
-// bytes from the ring buffer that are to be moved into the
-// uncompressed buffer.
-//
-// This ring buffer is not maintained as part of the compressed
-// text. Instead, it is reconstructed dynamically. That is,
-// it starts out empty and gets built as the text is decompressed.
-//
-// The ring buffer contain N bytes, with an additional F - 1 bytes
-// to facilitate string comparison.
-
-unsigned char m_ring_buffer[N + F - 1];
-
-// m_match_position and m_match_length are set by InsertNode().
-//
-// These variables indicate the position in the ring buffer
-// and the number of characters at that position that match
-// a given string.
-
-short int m_match_position;
-short int m_match_length;
-
-// m_lson, m_rson, and m_dad are the Japanese way of referring to
-// a tree structure. The dad is the parent and it has a right and
-// left son (child).
-//
-// For i = 0 to N-1, m_rson[i] and m_lson[i] will be the right
-// and left children of node i.
-//
-// For i = 0 to N-1, m_dad[i] is the parent of node i.
-//
-// For i = 0 to 255, rson[N + i + 1] is the root of the tree for
-// strings that begin with the character i. Note that this requires
-// one byte characters.
-//
-// These nodes store values of 0...(N-1). Memory requirements
-// can be reduces by using 2-byte integers instead of full 4-byte
-// integers (for 32-bit applications). Therefore, these are
-// defined as "short ints."
-
-short int m_lson[N + 1];
-short int m_rson[N + 257];
-short int m_dad[N + 1];
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InitTree
-
- This function initializes the tree nodes to "empty" states.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InitTree( // no return value
- void) // no parameters
- throw() // exception list
-
- {
- int i;
-
- // For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
- // and left children of node i. These nodes need not be
- // initialized. However, for debugging purposes, it is nice to
- // have them initialized. Since this is only used for compression
- // (not decompression), I don't mind spending the time to do it.
- //
- // For the same range of i, m_dad[i] is the parent of node i.
- // These are initialized to a known value that can represent
- // a "not used" state.
-
- for (i = 0; i < N; i++)
- {
- m_lson[i] = NOT_USED;
- m_rson[i] = NOT_USED;
- m_dad[i] = NOT_USED;
- }
-
- // For i = 0 to 255, m_rson[N + i + 1] is the root of the tree
- // for strings that begin with the character i. This is why
- // the right child array is larger than the left child array.
- // These are also initialzied to a "not used" state.
- //
- // Note that there are 256 of these, one for each of the possible
- // 256 characters.
-
- for (i = N + 1; i <= (N + 256); i++)
- {
- m_rson[i] = NOT_USED;
- }
-
- // Done.
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InsertNode
-
- This function inserts a string from the ring buffer into one of
- the trees. It loads the match position and length member variables
- for the longest match.
-
- The string to be inserted is identified by the parameter Pos,
- A full F bytes are inserted. So, m_ring_buffer[Pos ... Pos+F-1]
- are inserted.
-
- If the matched length is exactly F, then an old node is removed
- in favor of the new one (because the old one will be deleted
- sooner).
-
- Note that Pos plays a dual role. It is used as both a position
- in the ring buffer and also as a tree node. m_ring_buffer[Pos]
- defines a character that is used to identify a tree node.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InsertNode( // no return value
- short int Pos) // position in the buffer
- throw() // exception list
-
- {
- short int i;
- short int p;
- int cmp;
- unsigned char * key;
-
- ASSERT(Pos >= 0);
- ASSERT(Pos < N);
-
- cmp = 1;
- key = &(m_ring_buffer[Pos]);
-
- // The last 256 entries in m_rson contain the root nodes for
- // strings that begin with a letter. Get an index for the
- // first letter in this string.
-
- p = (short int) (N + 1 + key[0]);
-
- // Set the left and right tree nodes for this position to "not
- // used."
-
- m_lson[Pos] = NOT_USED;
- m_rson[Pos] = NOT_USED;
-
- // Haven't matched anything yet.
-
- m_match_length = 0;
-
- for ( ; ; )
- {
- if (cmp >= 0)
- {
- if (m_rson[p] != NOT_USED)
- {
- p = m_rson[p];
- }
- else
- {
- m_rson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
- else
- {
- if (m_lson[p] != NOT_USED)
- {
- p = m_lson[p];
- }
- else
- {
- m_lson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
-
- // Should we go to the right or the left to look for the
- // next match?
-
- for (i = 1; i < F; i++)
- {
- cmp = key[i] - m_ring_buffer[p + i];
- if (cmp != 0)
- break;
- }
-
- if (i > m_match_length)
- {
- m_match_position = p;
- m_match_length = i;
-
- if (i >= F)
- break;
- }
- }
-
- m_dad[Pos] = m_dad[p];
- m_lson[Pos] = m_lson[p];
- m_rson[Pos] = m_rson[p];
-
- m_dad[ m_lson[p] ] = Pos;
- m_dad[ m_rson[p] ] = Pos;
-
- if (m_rson[ m_dad[p] ] == p)
- {
- m_rson[ m_dad[p] ] = Pos;
- }
- else
- {
- m_lson[ m_dad[p] ] = Pos;
- }
-
- // Remove "p"
-
- m_dad[p] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::DeleteNode
-
- This function removes the node "Node" from the tree.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::DeleteNode( // no return value
- short int Node) // node to be removed
- throw() // exception list
-
- {
- short int q;
-
- ASSERT(Node >= 0);
- ASSERT(Node < (N+1));
-
- if (m_dad[Node] == NOT_USED)
- {
- // not in tree, nothing to do
- return;
- }
-
- if (m_rson[Node] == NOT_USED)
- {
- q = m_lson[Node];
- }
- else if (m_lson[Node] == NOT_USED)
- {
- q = m_rson[Node];
- }
- else
- {
- q = m_lson[Node];
- if (m_rson[q] != NOT_USED)
- {
- do
- {
- q = m_rson[q];
- }
- while (m_rson[q] != NOT_USED);
-
- m_rson[ m_dad[q] ] = m_lson[q];
- m_dad[ m_lson[q] ] = m_dad[q];
- m_lson[q] = m_lson[Node];
- m_dad[ m_lson[Node] ] = q;
- }
-
- m_rson[q] = m_rson[Node];
- m_dad[ m_rson[Node] ] = q;
- }
-
- m_dad[q] = m_dad[Node];
-
- if (m_rson[ m_dad[Node] ] == Node)
- {
- m_rson[ m_dad[Node] ] = q;
- }
- else
- {
- m_lson[ m_dad[Node] ] = q;
- }
-
- m_dad[Node] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Encode
-
- This function "encodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Encode( // no return value
- void) // no parameters
-
- {
- short int i; // an iterator
- short int r; // node number in the binary tree
- short int s; // position in the ring buffer
- unsigned short int len; // len of initial string
- short int last_match_length; // length of last match
- short int code_buf_pos; // position in the output buffer
- unsigned char code_buf[17]; // the output buffer
- unsigned char mask; // bit mask for byte 0 of out buf
- unsigned char c; // character read from string
-
- // Start with a clean tree.
-
- InitTree();
-
- // code_buf[0] works as eight flags. A "1" represents that the
- // unit is an unencoded letter (1 byte), and a "0" represents
- // that the next unit is a <position,length> pair (2 bytes).
- //
- // code_buf[1..16] stores eight units of code. Since the best
- // we can do is store eight <position,length> pairs, at most 16
- // bytes are needed to store this.
- //
- // This is why the maximum size of the code buffer is 17 bytes.
-
- code_buf[0] = 0;
- code_buf_pos = 1;
-
- // Mask iterates over the 8 bits in the code buffer. The first
- // character ends up being stored in the low bit.
- //
- // bit 8 7 6 5 4 3 2 1
- // | |
- // | first sequence in code buffer
- // |
- // last sequence in code buffer
-
- mask = 1;
-
- s = 0;
- r = (short int) N - (short int) F;
-
- // Initialize the ring buffer with spaces...
-
- // Note that the last F bytes of the ring buffer are not filled.
- // This is because those F bytes will be filled in immediately
- // with bytes from the input stream.
-
- memset(m_ring_buffer, ' ', N - F);
-
- // Read F bytes into the last F bytes of the ring buffer.
- //
- // This function loads the buffer with X characters and returns
- // the actual amount loaded.
-
- len = GetChars(&(m_ring_buffer[r]), F);
-
- // Make sure there is something to be compressed.
-
- if (len == 0)
- return;
-
- // Insert the F strings, each of which begins with one or more
- // 'space' characters. Note the order in which these strings
- // are inserted. This way, degenerate trees will be less likely
- // to occur.
-
- for (i = 1; i <= F; i++)
- {
- InsertNode((short int) (r - i));
- }
-
- // Finally, insert the whole string just read. The
- // member variables match_length and match_position are set.
-
- InsertNode(r);
-
- // Now that we're preloaded, continue till done.
-
- do
- {
-
- // m_match_length may be spuriously long near the end of
- // text.
-
- if (m_match_length > len)
- {
- m_match_length = len;
- }
-
- // Is it cheaper to store this as a single character? If so,
- // make it so.
-
- if (m_match_length < THRESHOLD)
- {
- // Send one character. Remember that code_buf[0] is the
- // set of flags for the next eight items.
-
- m_match_length = 1;
- code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
- }
-
- // Otherwise, we do indeed have a string that can be stored
- // compressed to save space.
-
- else
- {
- // The next 16 bits need to contain the position (12 bits)
- // and the length (4 bits).
-
- code_buf[code_buf_pos++] = (unsigned char) m_match_position;
- code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
- }
-
- // Shift the mask one bit to the left so that it will be ready
- // to store the new bit.
-
- mask = (unsigned char) (mask << 1);
-
- // If the mask is now 0, then we know that we have a full set
- // of flags and items in the code buffer. These need to be
- // output.
-
- if (mask == 0)
- {
- // code_buf is the buffer of characters to be output.
- // code_buf_pos is the number of characters it contains.
-
- SendChars(code_buf, code_buf_pos);
-
- // Reset for next buffer...
-
- code_buf[0] = 0;
- code_buf_pos = 1;
- mask = 1;
- }
-
- last_match_length = m_match_length;
-
- // Delete old strings and read new bytes...
-
- for (i = 0; i < last_match_length; i++)
- {
-
- // Get next character...
-
- if (GetChars(&c, 1) != 1)
- break;
-
- // Delete "old strings"
-
- DeleteNode(s);
-
- // Put this character into the ring buffer.
- //
- // The original comment here says "If the position is near
- // the end of the buffer, extend the buffer to make
- // string comparison easier."
- //
- // That's a little misleading, because the "end" of the
- // buffer is really what we consider to be the "beginning"
- // of the buffer, that is, positions 0 through F.
- //
- // The idea is that the front end of the buffer is duplicated
- // into the back end so that when you're looking at characters
- // at the back end of the buffer, you can index ahead (beyond
- // the normal end of the buffer) and see the characters
- // that are at the front end of the buffer wihtout having
- // to adjust the index.
- //
- // That is...
- //
- // 1234xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1234
- // | | |
- // position 0 end of buffer |
- // |
- // duplicate of front of buffer
-
- m_ring_buffer[s] = c;
-
- if (s < F - 1)
- {
- m_ring_buffer[s + N] = c;
- }
-
- // Increment the position, and wrap around when we're at
- // the end. Note that this relies on N being a power of 2.
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Register the string that is found in
- // m_ring_buffer[r..r+F-1].
-
- InsertNode(r);
- }
-
- // If we didn't quit because we hit the last_match_length,
- // then we must have quit because we ran out of characters
- // to process.
-
- while (i++ < last_match_length)
- {
- DeleteNode(s);
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Note that len hitting 0 is the key that causes the
- // do...while() to terminate. This is the only place
- // within the loop that len is modified.
- //
- // Its original value is F (or a number less than F for
- // short strings).
-
- if (--len)
- {
- InsertNode(r); /* buffer may not be empty. */
- }
- }
-
- // End of do...while() loop. Continue processing until there
- // are no more characters to be compressed. The variable
- // "len" is used to signal this condition.
- }
- while (len > 0);
-
- // There could still be something in the output buffer. Send it
- // now.
-
- if (code_buf_pos > 1)
- {
- // code_buf is the encoded string to send.
- // code_buf_ptr is the number of characters.
-
- SendChars(code_buf, code_buf_pos);
- }
-
- // Done!
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Decode
-
- This function "decodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Decode( // no return value
- void) // no parameters
-
- {
- int k;
- int r; // node number
- unsigned char c[F]; // an array of chars
- unsigned char flags; // 8 bits of flags
- int flag_count; // which flag we're on
- short int pos; // position in the ring buffer
- short int len; // number of chars in ring buffer
-
- // Initialize the ring buffer with a common string.
- //
- // Note that the last F bytes of the ring buffer are not filled.
-
- memset(m_ring_buffer, ' ', N - F);
-
- r = N - F;
-
- flags = (char) 0;
- flag_count = 0;
-
- for ( ; ; )
- {
-
- // If there are more bits of interest in this flag, then
- // shift that next interesting bit into the 1's position.
- //
- // If this flag has been exhausted, the next byte must
- // be a flag.
-
- if (flag_count > 0)
- {
- flags = (unsigned char) (flags >> 1);
- flag_count--;
- }
- else
- {
- // Next byte must be a flag.
-
- if (GetChars(&flags, 1) != 1)
- break;
-
- // Set the flag counter. While at first it might appear
- // that this should be an 8 since there are 8 bits in the
- // flag, it should really be a 7 because the shift must
- // be performed 7 times in order to see all 8 bits.
-
- flag_count = 7;
- }
-
- // If the low order bit of the flag is now set, then we know
- // that the next byte is a single, unencoded character.
-
- if (flags & 1)
- {
- if (GetChars(c, 1) != 1)
- break;
-
- if (SendChars(c, 1) != 1)
- break;
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[0];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Otherwise, we know that the next two bytes are a
- // <position,length> pair. The position is in 12 bits and
- // the length is in 4 bits.
-
- else
- {
- // Original code:
- // if ((i = getc(infile)) == EOF)
- // break;
- // if ((j = getc(infile)) == EOF)
- // break;
- // i |= ((j & 0xf0) << 4);
- // j = (j & 0x0f) + THRESHOLD;
- //
- // I've modified this to only make one input call, and
- // have changed the variable names to something more
- // obvious.
-
- if (GetChars(c, 2) != 2)
- break;
-
- // Convert these two characters into the position and
- // length. Note that the length is always at least
- // THRESHOLD, which is why we're able to get a length
- // of 18 out of only 4 bits.
-
- pos = (short int) ( c[0] | ((c[1] & 0xf0) << 4) );
-
- len = (short int) ( (c[1] & 0x0f) + THRESHOLD );
-
- // There are now "len" characters at position "pos" in
- // the ring buffer that can be pulled out. Note that
- // len is never more than F.
-
- for (k = 0; k < len; k++)
- {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[k];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Add the "len" characters to the output stream.
-
- if (SendChars(c, len) != len)
- break;
- }
- }
- }
-
diff --git a/src/modules/common/entriesblk.cpp b/src/modules/common/entriesblk.cpp
index 6e4c9aa..4872d28 100644
--- a/src/modules/common/entriesblk.cpp
+++ b/src/modules/common/entriesblk.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * entriesblk.cpp - EntriesBlock facilitates compressed lex/dict modules
+ *
+ * $Id: entriesblk.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/lzsscomprs.cpp b/src/modules/common/lzsscomprs.cpp
index 624942d..ef1bc8c 100644
--- a/src/modules/common/lzsscomprs.cpp
+++ b/src/modules/common/lzsscomprs.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * lzsscomprs.cpp - code for class 'LZSSCompress'- a driver class that
- * provides LZSS compression
*
+ * lzssomprs.cpp - LZSSCompress: a driver class that provides LZSS
+ * compression
+ *
+ * $Id: lzsscomprs.cpp 2935 2013-08-02 11:06:30Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,8 +25,52 @@
#include <string.h>
#include <lzsscomprs.h>
+// The following are constant sizes used by the compression algorithm.
+//
+// N - This is the size of the ring buffer. It is set
+// to 4K. It is important to note that a position
+// within the ring buffer requires 12 bits.
+//
+// F - This is the maximum length of a character sequence
+// that can be taken from the ring buffer. It is set
+// to 18. Note that a length must be 3 before it is
+// worthwhile to store a position/length pair, so the
+// length can be encoded in only 4 bits. Or, put yet
+// another way, it is not necessary to encode a length
+// of 0-18, it is necessary to encode a length of
+// 3-18, which requires 4 bits.
+//
+// THRESHOLD - It takes 2 bytes to store an offset and
+// a length. If a character sequence only
+// requires 1 or 2 characters to store
+// uncompressed, then it is better to store
+// it uncompressed than as an offset into
+// the ring buffer.
+//
+// Note that the 12 bits used to store the position and the 4 bits
+// used to store the length equal a total of 16 bits, or 2 bytes.
+
+#define N 4096
+#define F 18
+#define THRESHOLD 3
+#define NOT_USED N
+
+
SWORD_NAMESPACE_START
+class LZSSCompress::Private {
+public:
+ static unsigned char m_ring_buffer[N + F - 1];
+ static short int m_match_position;
+ static short int m_match_length;
+ static short int m_lson[N + 1];
+ static short int m_rson[N + 257];
+ static short int m_dad[N + 1];
+ void InitTree();
+ void InsertNode(short int Pos);
+ void DeleteNode(short int Node);
+};
+
/******************************************************************************
* LZSSCompress Statics
*/
@@ -44,7 +90,7 @@ SWORD_NAMESPACE_START
// The ring buffer contain N bytes, with an additional F - 1 bytes
// to facilitate string comparison.
-unsigned char LZSSCompress::m_ring_buffer[N + F - 1];
+unsigned char LZSSCompress::Private::m_ring_buffer[N + F - 1];
// m_match_position and m_match_length are set by InsertNode().
//
@@ -52,8 +98,8 @@ unsigned char LZSSCompress::m_ring_buffer[N + F - 1];
// and the number of characters at that position that match
// a given string.
-short int LZSSCompress::m_match_position;
-short int LZSSCompress::m_match_length;
+short int LZSSCompress::Private::m_match_position;
+short int LZSSCompress::Private::m_match_length;
// m_lson, m_rson, and m_dad are the Japanese way of referring to
// a tree structure. The dad is the parent and it has a right and
@@ -73,9 +119,9 @@ short int LZSSCompress::m_match_length;
// integers (for 32-bit applications). Therefore, these are
// defined as "short ints."
-short int LZSSCompress::m_lson[N + 1];
-short int LZSSCompress::m_rson[N + 257];
-short int LZSSCompress::m_dad[N + 1];
+short int LZSSCompress::Private::m_lson[N + 1];
+short int LZSSCompress::Private::m_rson[N + 257];
+short int LZSSCompress::Private::m_dad[N + 1];
/******************************************************************************
@@ -84,6 +130,7 @@ short int LZSSCompress::m_dad[N + 1];
*/
LZSSCompress::LZSSCompress() : SWCompress() {
+ p = new Private();
}
@@ -92,6 +139,7 @@ LZSSCompress::LZSSCompress() : SWCompress() {
*/
LZSSCompress::~LZSSCompress() {
+ delete p;
}
@@ -100,7 +148,7 @@ LZSSCompress::~LZSSCompress() {
* "empty" states.
*/
-void LZSSCompress::InitTree(void) {
+void LZSSCompress::Private::InitTree(void) {
int i;
// For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
@@ -159,7 +207,7 @@ void LZSSCompress::InitTree(void) {
* ENT: pos - position in the buffer
*/
-void LZSSCompress::InsertNode(short int Pos)
+void LZSSCompress::Private::InsertNode(short int Pos)
{
short int i;
short int p;
@@ -257,7 +305,7 @@ void LZSSCompress::InsertNode(short int Pos)
* ENT: node - node to be removed
*/
-void LZSSCompress::DeleteNode(short int Node)
+void LZSSCompress::Private::DeleteNode(short int Node)
{
short int q;
@@ -330,7 +378,7 @@ void LZSSCompress::Encode(void)
// Start with a clean tree.
- InitTree();
+ p->InitTree();
direct = 0; // set direction needed by parent [Get|Send]Chars()
// code_buf[0] works as eight flags. A "1" represents that the
@@ -366,14 +414,14 @@ void LZSSCompress::Encode(void)
// This is because those F bytes will be filled in immediately
// with bytes from the input stream.
- memset(m_ring_buffer, ' ', N - F);
+ memset(p->m_ring_buffer, ' ', N - F);
// Read F bytes into the last F bytes of the ring buffer.
//
// This function loads the buffer with X characters and returns
// the actual amount loaded.
- len = GetChars((char *) &(m_ring_buffer[r]), F);
+ len = GetChars((char *) &(p->m_ring_buffer[r]), F);
// Make sure there is something to be compressed.
@@ -386,13 +434,13 @@ void LZSSCompress::Encode(void)
// to occur.
for (i = 1; i <= F; i++) {
- InsertNode((short int) (r - i));
+ p->InsertNode((short int) (r - i));
}
// Finally, insert the whole string just read. The
// member variables match_length and match_position are set.
- InsertNode(r);
+ p->InsertNode(r);
// Now that we're preloaded, continue till done.
@@ -401,20 +449,20 @@ void LZSSCompress::Encode(void)
// m_match_length may be spuriously long near the end of
// text.
- if (m_match_length > len) {
- m_match_length = len;
+ if (p->m_match_length > len) {
+ p->m_match_length = len;
}
// Is it cheaper to store this as a single character? If so,
// make it so.
- if (m_match_length < THRESHOLD) {
+ if (p->m_match_length < THRESHOLD) {
// Send one character. Remember that code_buf[0] is the
// set of flags for the next eight items.
- m_match_length = 1;
+ p->m_match_length = 1;
code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
+ code_buf[code_buf_pos++] = p->m_ring_buffer[r];
}
// Otherwise, we do indeed have a string that can be stored
@@ -424,10 +472,10 @@ void LZSSCompress::Encode(void)
// The next 16 bits need to contain the position (12 bits)
// and the length (4 bits).
- code_buf[code_buf_pos++] = (unsigned char) m_match_position;
+ code_buf[code_buf_pos++] = (unsigned char) p->m_match_position;
code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
+ ((p->m_match_position >> 4) & 0xf0) |
+ (p->m_match_length - THRESHOLD) );
}
// Shift the mask one bit to the left so that it will be ready
@@ -452,7 +500,7 @@ void LZSSCompress::Encode(void)
mask = 1;
}
- last_match_length = m_match_length;
+ last_match_length = p->m_match_length;
// Delete old strings and read new bytes...
@@ -464,7 +512,7 @@ void LZSSCompress::Encode(void)
// Delete "old strings"
- DeleteNode(s);
+ p->DeleteNode(s);
// Put this character into the ring buffer.
//
@@ -491,10 +539,10 @@ void LZSSCompress::Encode(void)
// |
// duplicate of front of buffer
- m_ring_buffer[s] = c;
+ p->m_ring_buffer[s] = c;
if (s < F - 1) {
- m_ring_buffer[s + N] = c;
+ p->m_ring_buffer[s + N] = c;
}
// Increment the position, and wrap around when we're at
@@ -506,7 +554,7 @@ void LZSSCompress::Encode(void)
// Register the string that is found in
// m_ring_buffer[r..r+F-1].
- InsertNode(r);
+ p->InsertNode(r);
}
// If we didn't quit because we hit the last_match_length,
@@ -514,7 +562,7 @@ void LZSSCompress::Encode(void)
// to process.
while (i++ < last_match_length) {
- DeleteNode(s);
+ p->DeleteNode(s);
s = (short int) ( (s + 1) & (N - 1) );
r = (short int) ( (r + 1) & (N - 1) );
@@ -527,7 +575,7 @@ void LZSSCompress::Encode(void)
// short strings).
if (--len) {
- InsertNode(r); /* buffer may not be empty. */
+ p->InsertNode(r); /* buffer may not be empty. */
}
}
@@ -577,7 +625,7 @@ void LZSSCompress::Decode(void)
//
// Note that the last F bytes of the ring buffer are not filled.
- memset(m_ring_buffer, ' ', N - F);
+ memset(p->m_ring_buffer, ' ', N - F);
r = N - F;
@@ -624,7 +672,7 @@ void LZSSCompress::Decode(void)
// Add to buffer, and increment to next spot. Wrap at end.
- m_ring_buffer[r] = c[0];
+ p->m_ring_buffer[r] = c[0];
r = (short int) ( (r + 1) & (N - 1) );
}
@@ -662,11 +710,11 @@ void LZSSCompress::Decode(void)
// len is never more than F.
for (k = 0; k < len; k++) {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
+ c[k] = p->m_ring_buffer[(pos + k) & (N - 1)];
// Add to buffer, and increment to next spot. Wrap at end.
- m_ring_buffer[r] = c[k];
+ p->m_ring_buffer[r] = c[k];
r = (short int) ( (r + 1) & (N - 1) );
}
diff --git a/src/modules/common/swcomprs.doc b/src/modules/common/lzsscomprs.txt
index b6817f2..b6817f2 100644
--- a/src/modules/common/swcomprs.doc
+++ b/src/modules/common/lzsscomprs.txt
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
index 6f17628..788ab6e 100644
--- a/src/modules/common/rawstr.cpp
+++ b/src/modules/common/rawstr.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * rawstr.cpp - code for class 'RawStr'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class StrKey
*
+ * rawstr.cpp - code for class 'RawStr'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ * and provides lookup and parsing functions based on
+ * class StrKey
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawstr.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +56,7 @@ const int RawStr::IDXENTRYSIZE = 6;
* (e.g. 'modules/texts/rawtext/webster/')
*/
-RawStr::RawStr(const char *ipath, int fileMode)
+RawStr::RawStr(const char *ipath, int fileMode, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
@@ -121,7 +123,7 @@ void RawStr::getIDXBufDat(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -181,7 +183,7 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -302,7 +304,7 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
*
*/
-void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf)
+void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf) const
{
unsigned int ch;
char *idxbuflocal = 0;
@@ -380,7 +382,7 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey, 2);
- toupperstr_utf8(key, strlen(key)*2);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*2);
len = (len < 0) ? strlen(buf) : len;
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
index 003b2fe..e2ce899 100644
--- a/src/modules/common/rawstr4.cpp
+++ b/src/modules/common/rawstr4.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * rawstr.cpp - code for class 'RawStr'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class StrKey
*
+ * rawstr4.cpp - code for class 'RawStr'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ * and provides lookup and parsing functions based on
+ * class StrKey
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawstr4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,7 +55,7 @@ const int RawStr4::IDXENTRYSIZE = 8;
* (e.g. 'modules/texts/rawtext/webster/')
*/
-RawStr4::RawStr4(const char *ipath, int fileMode)
+RawStr4::RawStr4(const char *ipath, int fileMode, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
@@ -121,7 +123,7 @@ void RawStr4::getIDXBufDat(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -157,7 +159,7 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) const
}
*targetbuf = 0;
trybuf = 0;
- toupperstr_utf8(targetbuf);
+ if (!caseSensitive) toupperstr_utf8(targetbuf);
*/
}
}
@@ -191,7 +193,7 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -311,7 +313,7 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
*
*/
-void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf)
+void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf) const
{
unsigned int ch;
char *idxbuflocal = 0;
@@ -388,7 +390,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
len = (len < 0) ? strlen(buf) : len;
getIDXBufDat(start, &dbKey);
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
index 99beaa2..5527d38 100644
--- a/src/modules/common/rawverse.cpp
+++ b/src/modules/common/rawverse.cpp
@@ -1,11 +1,12 @@
/******************************************************************************
- * rawverse.cpp - code for class 'RawVerse'- a module that reads raw text
+ *
+ * rawverse.cpp - code for class 'RawVerse'- a module that reads raw text
* files: ot and nt using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey
*
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -149,7 +150,7 @@ void RawVerse::findOffset(char testmt, long idxoff, long *start, unsigned short
*
*/
-void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) {
+void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) const {
buf = "";
buf.setFillByte(0);
buf.setSize(size + 1);
@@ -278,15 +279,15 @@ char RawVerse::createModule(const char *ipath, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(1);
__s32 offset = 0;
__u16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4);
fd->write(&size, 2);
}
diff --git a/src/modules/common/rawverse4.cpp b/src/modules/common/rawverse4.cpp
index ee0b207..b87ea0d 100644
--- a/src/modules/common/rawverse4.cpp
+++ b/src/modules/common/rawverse4.cpp
@@ -1,11 +1,14 @@
/******************************************************************************
- * rawverse.cpp - code for class 'RawVerse4'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * rawverse4.cpp - code for class 'RawVerse4'- a module that reads raw
+ * text files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey
*
+ * $Id: rawverse4.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -149,7 +152,7 @@ void RawVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long
*
*/
-void RawVerse4::readText(char testmt, long start, unsigned long size, SWBuf &buf) {
+void RawVerse4::readText(char testmt, long start, unsigned long size, SWBuf &buf) const {
buf = "";
buf.setFillByte(0);
buf.setSize(size + 1);
@@ -278,14 +281,14 @@ char RawVerse4::createModule(const char *ipath, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(1);
__u32 offset = 0;
__u32 size = 0;
offset = archtosword32(offset);
size = archtosword32(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4);
fd->write(&size, 4);
}
diff --git a/src/modules/common/sapphire.cpp b/src/modules/common/sapphire.cpp
index 7b141d2..8cc3e15 100644
--- a/src/modules/common/sapphire.cpp
+++ b/src/modules/common/sapphire.cpp
@@ -1,15 +1,39 @@
-/* sapphire.cpp -- the Saphire II stream cipher class.
- Dedicated to the Public Domain the author and inventor:
- (Michael Paul Johnson). This code comes with no warranty.
- Use it at your own risk.
- Ported from the Pascal implementation of the Sapphire Stream
- Cipher 9 December 1994.
- Added hash pre- and post-processing 27 December 1994.
- Modified initialization to make index variables key dependent,
- made the output function more resistant to cryptanalysis,
- and renamed to Sapphire II 2 January 1995
-*/
-
+/******************************************************************************
+ *
+ * sapphire.cpp - the Saphire II stream cipher class
+ *
+ * $Id: sapphire.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+/******************************************************************************
+ *
+ * Original license notice & credits:
+ * Dedicated to the Public Domain the author and inventor:
+ * (Michael Paul Johnson). This code comes with no warranty.
+ * Use it at your own risk.
+ * Ported from the Pascal implementation of the Sapphire Stream
+ * Cipher 9 December 1994.
+ * Added hash pre- and post-processing 27 December 1994.
+ * Modified initialization to make index variables key dependent,
+ * made the output function more resistant to cryptanalysis,
+ * and renamed to Sapphire II 2 January 1995
+ *
+ */
#include <string.h>
diff --git a/src/modules/common/swcipher.cpp b/src/modules/common/swcipher.cpp
index 5ab91ea..16279dc 100644
--- a/src/modules/common/swcipher.cpp
+++ b/src/modules/common/swcipher.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcipher.cpp - code for class 'SWCipher'- a driver class that provides
- * cipher utilities.
*
+ * swcipher.cpp - code for class 'SWCipher'- a driver class that
+ * provides cipher utilities
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcipher.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/swcomprs.cpp b/src/modules/common/swcomprs.cpp
index 378c8b1..9df8e7d 100644
--- a/src/modules/common/swcomprs.cpp
+++ b/src/modules/common/swcomprs.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * swcomprs.cpp - code for class 'SWCompress'- a driver class that provides
- * compression utilities.
*
+ * swcomprs.cpp - a driver class that provides compression utilities
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/xzcomprs.cpp b/src/modules/common/xzcomprs.cpp
new file mode 100644
index 0000000..db8a4a8
--- /dev/null
+++ b/src/modules/common/xzcomprs.cpp
@@ -0,0 +1,181 @@
+/******************************************************************************
+ *
+ * xzcomprs.cpp - XzCompress, a driver class that provides xz (LZMA2)
+ * compression
+ *
+ * $Id: xzcomprs.cpp 2850 2013-07-02 09:57:20Z chrislit $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <xzcomprs.h>
+#include <zlib.h>
+
+SWORD_NAMESPACE_START
+
+/******************************************************************************
+ * XzCompress Constructor - Initializes data for instance of XzCompress
+ *
+ */
+
+XzCompress::XzCompress() : SWCompress() {
+}
+
+
+/******************************************************************************
+ * XzCompress Destructor - Cleans up instance of XzCompress
+ */
+
+XzCompress::~XzCompress() {
+}
+
+
+/******************************************************************************
+ * XzCompress::Encode - This function "encodes" the input stream into the
+ * output stream.
+ * The GetChars() and SendChars() functions are
+ * used to separate this method from the actual
+ * i/o.
+ * NOTE: must set zlen for parent class to know length of
+ * compressed buffer.
+ */
+
+void XzCompress::Encode(void)
+{
+/*
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+ Compresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be at least 0.1% larger than
+ sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
+ compressed buffer.
+ This function can be used to compress a whole file at once if the
+ input file is mmap'ed.
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer.
+*/
+ direct = 0; // set direction needed by parent [Get|Send]Chars()
+
+ // get buffer
+ char chunk[1024];
+ char *buf = (char *)calloc(1, 1024);
+ char *chunkbuf = buf;
+ unsigned long chunklen;
+ unsigned long len = 0;
+ while((chunklen = GetChars(chunk, 1023))) {
+ memcpy(chunkbuf, chunk, chunklen);
+ len += chunklen;
+ if (chunklen < 1023)
+ break;
+ else buf = (char *)realloc(buf, len + 1024);
+ chunkbuf = buf+len;
+ }
+
+
+ zlen = (long) (len*1.001)+15;
+ char *zbuf = new char[zlen+1];
+ if (len)
+ {
+ //printf("Doing compress\n");
+ if (compress((Bytef*)zbuf, &zlen, (const Bytef*)buf, len) != Z_OK)
+ {
+ printf("ERROR in compression\n");
+ }
+ else {
+ SendChars(zbuf, zlen);
+ }
+ }
+ else
+ {
+ fprintf(stderr, "ERROR: no buffer to compress\n");
+ }
+ delete [] zbuf;
+ free (buf);
+}
+
+
+/******************************************************************************
+ * XzCompress::Decode - This function "decodes" the input stream into the
+ * output stream.
+ * The GetChars() and SendChars() functions are
+ * used to separate this method from the actual
+ * i/o.
+ */
+
+void XzCompress::Decode(void)
+{
+/*
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be large enough to hold the
+ entire uncompressed data. (The size of the uncompressed data must have
+ been saved previously by the compressor and transmitted to the decompressor
+ by some mechanism outside the scope of this compression library.)
+ Upon exit, destLen is the actual size of the compressed buffer.
+ This function can be used to decompress a whole file at once if the
+ input file is mmap'ed.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted.
+*/
+
+ // get buffer
+ char chunk[1024];
+ char *zbuf = (char *)calloc(1, 1024);
+ char *chunkbuf = zbuf;
+ int chunklen;
+ unsigned long zlen = 0;
+ while((chunklen = GetChars(chunk, 1023))) {
+ memcpy(chunkbuf, chunk, chunklen);
+ zlen += chunklen;
+ if (chunklen < 1023)
+ break;
+ else zbuf = (char *)realloc(zbuf, zlen + 1024);
+ chunkbuf = zbuf + zlen;
+ }
+
+ //printf("Decoding complength{%ld} uncomp{%ld}\n", zlen, blen);
+ if (zlen) {
+ unsigned long blen = zlen*20; // trust compression is less than 1000%
+ char *buf = new char[blen];
+ //printf("Doing decompress {%s}\n", zbuf);
+ slen = 0;
+ switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){
+ case Z_OK: SendChars(buf, blen); slen = blen; break;
+ case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break;
+ case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break;
+ case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break;
+ default: fprintf(stderr, "ERROR: an unknown error occured during decompression.\n"); break;
+ }
+ delete [] buf;
+ }
+ else {
+ fprintf(stderr, "ERROR: no buffer to decompress!\n");
+ }
+ //printf("Finished decoding\n");
+ free (zbuf);
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/common/zipcomprs.cpp b/src/modules/common/zipcomprs.cpp
index 534d840..3e44abd 100644
--- a/src/modules/common/zipcomprs.cpp
+++ b/src/modules/common/zipcomprs.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcomprs.cpp - code for class 'ZipCompress'- a driver class that provides
- * compression utilities. - using zlib
*
+ * zipcomprs.cpp - ZipCompress, a driver class that provides zlib
+ * compression
+ *
+ * $Id: zipcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
index 5b4da64..a745502 100644
--- a/src/modules/common/zstr.cpp
+++ b/src/modules/common/zstr.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * zstr.cpp - code for class 'zStr'- a module that reads compressed text
+ *
+ * zstr.cpp - code for class 'zStr'- a module that reads compressed text
* files and provides lookup and parsing functions based on
* class StrKey
*
+ * $Id: zstr.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,11 +56,10 @@ const int zStr::ZDXENTRYSIZE = 8;
* ENT: ipath - path of the directory where data and index files are located.
*/
-zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp)
+zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
- nl = '\n';
lastoff = -1;
path = 0;
stdstr(&path, ipath);
@@ -144,7 +145,7 @@ void zStr::getKeyFromDatOffset(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -201,7 +202,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
if (*ikey) {
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -321,7 +322,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
*
*/
-void zStr::getText(long offset, char **idxbuf, char **buf) {
+void zStr::getText(long offset, char **idxbuf, char **buf) const {
char *ch;
char *idxbuflocal = 0;
getKeyFromIdxOffset(offset, &idxbuflocal);
@@ -386,7 +387,7 @@ void zStr::getText(long offset, char **idxbuf, char **buf) {
* file.
*/
-void zStr::getCompressedText(long block, long entry, char **buf) {
+void zStr::getCompressedText(long block, long entry, char **buf) const {
__u32 size = 0;
@@ -431,12 +432,13 @@ void zStr::getCompressedText(long block, long entry, char **buf) {
void zStr::setText(const char *ikey, const char *buf, long len) {
+ static const char nl[] = {13, 10};
+
__u32 start, outstart;
__u32 size, outsize;
__s32 endoff;
long idxoff = 0;
__s32 shiftSize;
- static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
char *dbKey = 0;
@@ -446,7 +448,7 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
len = (len < 0) ? strlen(buf) : len;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
char notFound = findKeyIndex(ikey, &idxoff, 0);
if (!notFound) {
@@ -583,7 +585,10 @@ void zStr::linkEntry(const char *destkey, const char *srckey) {
}
-void zStr::flushCache() {
+void zStr::flushCache() const {
+
+ static const char nl[] = {13, 10};
+
if (cacheBlock) {
if (cacheDirty) {
__u32 start = 0;
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index fa76467..c280d98 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * zverse.h - code for class 'zVerse'- a module that reads raw text
+ *
+ * zverse.cpp - code for class 'zVerse'- a module that reads raw text
* files: ot and nt using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey for compressed modules
*
+ * $Id: zverse.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -155,7 +157,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
// set size to
// set
*start = *size = *buffnum = 0;
- //printf ("Finding offset %ld\n", idxoff);
+ //fprintf(stderr, "Finding offset %ld\n", idxoff);
idxoff *= 10;
if (!testmt) {
testmt = ((idxfp[0]) ? 1:2);
@@ -168,7 +170,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
long newOffset = compfp[testmt-1]->seek(idxoff, SEEK_SET);
if (newOffset == idxoff) {
if (compfp[testmt-1]->read(&ulBuffNum, 4) != 4) {
- printf ("Error reading ulBuffNum\n");
+ fprintf(stderr, "Error reading ulBuffNum\n");
return;
}
}
@@ -176,12 +178,12 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
if (compfp[testmt-1]->read(&ulVerseStart, 4) < 2)
{
- printf ("Error reading ulVerseStart\n");
+ fprintf(stderr, "Error reading ulVerseStart\n");
return;
}
if (compfp[testmt-1]->read(&usVerseSize, 2) < 2)
{
- printf ("Error reading usVerseSize\n");
+ fprintf(stderr, "Error reading usVerseSize\n");
return;
}
@@ -202,7 +204,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
*
*/
-void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) {
+void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) const {
__u32 ulCompOffset = 0; // compressed buffer start
__u32 ulCompSize = 0; // buffer size compressed
__u32 ulUnCompSize = 0; // buffer size uncompressed
@@ -217,26 +219,26 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (size &&
!(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) {
- //printf ("Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
+ //fprintf(stderr, "Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
{
- printf ("Error seeking compressed file index\n");
+ fprintf(stderr, "Error seeking compressed file index\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4)
{
- printf ("Error reading ulCompOffset\n");
+ fprintf(stderr, "Error reading ulCompOffset\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompSize, 4)<4)
{
- printf ("Error reading ulCompSize\n");
+ fprintf(stderr, "Error reading ulCompSize\n");
return;
}
if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4)
{
- printf ("Error reading ulUnCompSize\n");
+ fprintf(stderr, "Error reading ulUnCompSize\n");
return;
}
@@ -246,14 +248,14 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
{
- printf ("Error: could not seek to right place in compressed text\n");
+ fprintf(stderr, "Error: could not seek to right place in compressed text\n");
return;
}
SWBuf pcCompText;
pcCompText.setSize(ulCompSize+5);
if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
- printf ("Error reading compressed text\n");
+ fprintf(stderr, "Error reading compressed text\n");
return;
}
pcCompText.setSize(ulCompSize);
@@ -335,7 +337,7 @@ void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
}
-void zVerse::flushCache() {
+void zVerse::flushCache() const {
if (dirtyCache) {
__u32 idxoff;
__u32 start, outstart;
@@ -469,15 +471,15 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(true);
__s32 offset = 0;
__s16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4); //compBufIdxOffset
fd->write(&offset, 4);
fd->write(&size, 2);
diff --git a/src/modules/filters/Makefile.am b/src/modules/filters/Makefile.am
index 80e65d9..a3d1154 100644
--- a/src/modules/filters/Makefile.am
+++ b/src/modules/filters/Makefile.am
@@ -5,6 +5,7 @@ libsword_la_SOURCES += $(filtersdir)/swoptfilter.cpp
GBFFIL = $(filtersdir)/gbfhtml.cpp
GBFFIL += $(filtersdir)/gbfhtmlhref.cpp
+GBFFIL += $(filtersdir)/gbfxhtml.cpp
GBFFIL += $(filtersdir)/gbfwebif.cpp
GBFFIL += $(filtersdir)/gbfplain.cpp
GBFFIL += $(filtersdir)/gbfrtf.cpp
@@ -26,12 +27,14 @@ THMLFIL += $(filtersdir)/thmlgbf.cpp
THMLFIL += $(filtersdir)/thmlrtf.cpp
THMLFIL += $(filtersdir)/thmlhtml.cpp
THMLFIL += $(filtersdir)/thmlhtmlhref.cpp
+THMLFIL += $(filtersdir)/thmlxhtml.cpp
THMLFIL += $(filtersdir)/thmlwebif.cpp
THMLFIL += $(filtersdir)/thmlwordjs.cpp
TEIFIL = $(filtersdir)/teiplain.cpp
TEIFIL += $(filtersdir)/teirtf.cpp
TEIFIL += $(filtersdir)/teihtmlhref.cpp
+TEIFIL += $(filtersdir)/teixhtml.cpp
CONVFIL = $(filtersdir)/gbfthml.cpp
CONVFIL += $(filtersdir)/gbfosis.cpp
@@ -42,6 +45,7 @@ CONVFIL += $(filtersdir)/osisosis.cpp
OSISFIL = $(filtersdir)/osisheadings.cpp
OSISFIL += $(filtersdir)/osisfootnotes.cpp
OSISFIL += $(filtersdir)/osishtmlhref.cpp
+OSISFIL += $(filtersdir)/osisxhtml.cpp
OSISFIL += $(filtersdir)/osiswebif.cpp
OSISFIL += $(filtersdir)/osismorph.cpp
OSISFIL += $(filtersdir)/osisstrongs.cpp
@@ -53,7 +57,10 @@ OSISFIL += $(filtersdir)/osisscripref.cpp
OSISFIL += $(filtersdir)/osisvariants.cpp
OSISFIL += $(filtersdir)/osiswordjs.cpp
OSISFIL += $(filtersdir)/osismorphsegmentation.cpp
-OSISFIL += $(filtersdir)/osisruby.cpp
+OSISFIL += $(filtersdir)/osisglosses.cpp
+OSISFIL += $(filtersdir)/osisenum.cpp
+OSISFIL += $(filtersdir)/osisxlit.cpp
+OSISFIL += $(filtersdir)/osisreferencelinks.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf8.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf16.cpp
@@ -61,6 +68,8 @@ libsword_la_SOURCES += $(filtersdir)/utf8utf16.cpp
libsword_la_SOURCES += $(filtersdir)/utf16utf8.cpp
libsword_la_SOURCES += $(filtersdir)/utf8html.cpp
libsword_la_SOURCES += $(filtersdir)/utf8latin1.cpp
+libsword_la_SOURCES += $(filtersdir)/unicodertf.cpp
+libsword_la_SOURCES += $(filtersdir)/scsuutf8.cpp
libsword_la_SOURCES += $(filtersdir)/utf8cantillation.cpp
libsword_la_SOURCES += $(filtersdir)/utf8hebrewpoints.cpp
@@ -70,10 +79,7 @@ libsword_la_SOURCES += $(filtersdir)/utf8greekaccents.cpp
libsword_la_SOURCES += $(filtersdir)/cipherfil.cpp
PLFIL = $(filtersdir)/rtfhtml.cpp
-PLFIL += $(filtersdir)/plainfootnotes.cpp
-PLFIL += $(filtersdir)/plainhtml.cpp
PLFIL += $(filtersdir)/greeklexattribs.cpp
-PLFIL += $(filtersdir)/unicodertf.cpp
PLFIL += $(filtersdir)/papyriplain.cpp
diff --git a/src/modules/filters/cipherfil.cpp b/src/modules/filters/cipherfil.cpp
index 34d0465..e5422f3 100644
--- a/src/modules/filters/cipherfil.cpp
+++ b/src/modules/filters/cipherfil.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
*
- * cipherfil - SWFilter descendant to decipher a module
+ * cipherfil.cpp - CipherFilter, a SWFilter descendant to decipher
+ * a module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: cipherfil.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +27,10 @@
#include <swcipher.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
CipherFilter::CipherFilter(const char *key) {
cipher = new SWCipher((unsigned char *)key);
}
@@ -58,4 +63,6 @@ char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *mo
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/gbffootnotes.cpp b/src/modules/filters/gbffootnotes.cpp
index a5384cb..7b867f1 100644
--- a/src/modules/filters/gbffootnotes.cpp
+++ b/src/modules/filters/gbffootnotes.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * gbffootnotes - SWFilter descendant to hide or show footnotes
- * in a GBF module.
+ * gbffootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in a GBF module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: gbffootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +30,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-GBFFootnotes::GBFFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFFootnotes::GBFFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -86,7 +94,7 @@ char GBFFootnotes::processText (SWBuf &text, const SWKey *key, const SWModule *m
if (module->isProcessEntryAttributes()) {
//tag = token;
- if((tagText.length() == 1) || !strcmp(module->Name(), "IGNT")) {
+ if((tagText.length() == 1) || !strcmp(module->getName(), "IGNT")) {
if (option) { // for ASV marks text in verse then put explanation at end of verse
text.append(" <FS>[");
text.append(tagText);
diff --git a/src/modules/filters/gbfheadings.cpp b/src/modules/filters/gbfheadings.cpp
index 122445e..7e19ea1 100644
--- a/src/modules/filters/gbfheadings.cpp
+++ b/src/modules/filters/gbfheadings.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * gbfheadings - SWFilter descendant to hide or show headings
- * in a GBF module.
+ * gbfheadings.cpp - SWFilter descendant to hide or show headings
+ * in a GBF module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: gbfheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -19,20 +21,27 @@
*
*/
+
#include <stdlib.h>
#include <gbfheadings.h>
+
SWORD_NAMESPACE_START
+namespace {
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -40,7 +49,7 @@ GBFHeadings::~GBFHeadings() {
}
-char GBFHeadings::processText (SWBuf &text, const SWKey *key, const SWModule *module) {
+char GBFHeadings::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
if (!option) { // if we don't want headings
char token[2048]; // cheese. Fix.
int tokpos = 0;
diff --git a/src/modules/filters/gbfhtml.cpp b/src/modules/filters/gbfhtml.cpp
index 2467e36..542c4c9 100644
--- a/src/modules/filters/gbfhtml.cpp
+++ b/src/modules/filters/gbfhtml.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * gbfhtml.cpp - GBF to HTML filter
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfhtml.cpp - GBF to HTML filter
+ *
+ * $Id: gbfhtml.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +54,7 @@ GBFHTML::GBFHTML() {
addTokenSubstitute("Pp", "</cite>");
addTokenSubstitute("Fn", "</font>"); // font end
addTokenSubstitute("CL", "<br />"); // new line
- addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
+ addTokenSubstitute("CM", "<br /><br />"); // two new-lines
addTokenSubstitute("CG", ""); // ???
addTokenSubstitute("CT", ""); // ???
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp
index 3f25e3a..6df038e 100644
--- a/src/modules/filters/gbfhtmlhref.cpp
+++ b/src/modules/filters/gbfhtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * gbfhtmlhref.cpp - GBF to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfhtmlhref.cpp - GBF to HTML filter with hrefs
+ *
+ * $Id: gbfhtmlhref.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -34,7 +33,7 @@ SWORD_NAMESPACE_START
GBFHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
if (module) {
- version = module->Name();
+ version = module->getName();
}
}
@@ -73,7 +72,8 @@ GBFHTMLHREF::GBFHTMLHREF() {
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
addTokenSubstitute("JL", "</div>"); // align end
-
+
+ renderNoteNumbers = false;
}
@@ -231,6 +231,7 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
else if (!strcmp(tag.getName(), "RF")) {
SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -240,10 +241,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
//char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a> ",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str());
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
}
u->suspendTextPassThru = true;
}
diff --git a/src/modules/filters/gbfmorph.cpp b/src/modules/filters/gbfmorph.cpp
index d7c8ab4..3399ae8 100644
--- a/src/modules/filters/gbfmorph.cpp
+++ b/src/modules/filters/gbfmorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfmorph - SWFilter descendant to hide or show morph tags
- * in a GBF module.
+ * gbfmorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a GBF module
*
+ * $Id: gbfmorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,16 +24,23 @@
#include <stdlib.h>
#include <gbfmorph.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFMorph::GBFMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFMorph::GBFMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfosis.cpp b/src/modules/filters/gbfosis.cpp
index 526167a..9333f62 100644
--- a/src/modules/filters/gbfosis.cpp
+++ b/src/modules/filters/gbfosis.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfosis.cpp - GBF to OSIS filter
*
+ * $Id: gbfosis.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,8 +29,10 @@
#include <swlog.h>
#include <stdarg.h>
+
SWORD_NAMESPACE_START
+
GBFOSIS::GBFOSIS() {
}
@@ -347,7 +349,7 @@ char GBFOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module)
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -355,24 +357,24 @@ char GBFOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module)
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
/*
diff --git a/src/modules/filters/gbfplain.cpp b/src/modules/filters/gbfplain.cpp
index e90bf94..b2a1ae4 100644
--- a/src/modules/filters/gbfplain.cpp
+++ b/src/modules/filters/gbfplain.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfplain - SWFilter descendant to strip out all GBF tags or convert to
- * ASCII rendered symbols.
+ * gbfplain.cpp - SWFilter descendant to strip out all GBF tags or
+ * convert to ASCII rendered symbols
*
+ * $Id: gbfplain.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +25,10 @@
#include <gbfplain.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
GBFPlain::GBFPlain() {
}
@@ -109,4 +112,6 @@ char GBFPlain::processText (SWBuf &text, const SWKey *key, const SWModule *modul
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/gbfredletterwords.cpp b/src/modules/filters/gbfredletterwords.cpp
index 7397781..cac3cd9 100644
--- a/src/modules/filters/gbfredletterwords.cpp
+++ b/src/modules/filters/gbfredletterwords.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * GBFRedLetterWords - SWFilter descendant to toggle red coloring of words of
- * Christ in a GBF module.
+ * gbfredletterwords.cpp - SWFilter descendant to toggle red coloring of
+ * words of Christ in a GBF module
*
+ * $Id: gbfredletterwords.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,16 +26,23 @@
#include <swmodule.h>
#include <ctype.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Words of Christ in Red";
-const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
+namespace {
+
+ static const char oName[] = "Words of Christ in Red";
+ static const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFRedLetterWords::GBFRedLetterWords() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFRedLetterWords::GBFRedLetterWords() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfrtf.cpp b/src/modules/filters/gbfrtf.cpp
index 7471d0b..8a8e1b1 100644
--- a/src/modules/filters/gbfrtf.cpp
+++ b/src/modules/filters/gbfrtf.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
*
- * gbfrtf - SWFilter descendant to convert all GBF tags to RTF tags
+ * gbfrtf.cpp - SWFilter descendant to convert all GBF tags to RTF tags
*
+ * $Id: gbfrtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -42,7 +43,6 @@ char GBFRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
SWBuf strongnum;
SWBuf strongtense;
bool hideText = false;
- int wordLen = 0;
int wordCount = 0;
const char *from;
@@ -50,7 +50,6 @@ char GBFRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
from = orig.c_str();
for (text = ""; *from; from++) {
if (*from == '<') {
- wordLen = wordCount;
wordCount = 0;
intoken = true;
tokpos = 0;
diff --git a/src/modules/filters/gbfstrongs.cpp b/src/modules/filters/gbfstrongs.cpp
index c7cf6c5..dd4e167 100644
--- a/src/modules/filters/gbfstrongs.cpp
+++ b/src/modules/filters/gbfstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfstrongs.cpp - SWFilter descendant to hide or show Strong's number
+ * in a GBF module
*
+ * $Id: gbfstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,16 +27,23 @@
#include <swmodule.h>
#include <ctype.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Strong's Numbers";
-const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfthml.cpp b/src/modules/filters/gbfthml.cpp
index 4feb1fa..303b240 100644
--- a/src/modules/filters/gbfthml.cpp
+++ b/src/modules/filters/gbfthml.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * gbfthml.cpp - GBF to ThML filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfthml.cpp - GBF to ThML filter
+ *
+ * $Id: gbfthml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +24,10 @@
#include <gbfthml.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
GBFThML::GBFThML()
{
}
@@ -218,5 +220,4 @@ char GBFThML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
}
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfwebif.cpp b/src/modules/filters/gbfwebif.cpp
index b5ff798..b7b8a0f 100644
--- a/src/modules/filters/gbfwebif.cpp
+++ b/src/modules/filters/gbfwebif.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * GBFWEBIF.cpp - GBF to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfwebif.cpp - GBF to HTML filter with hrefs for strongs and morph
+ * tags
+ *
+ * $Id: gbfwebif.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,9 +29,6 @@
SWORD_NAMESPACE_START
GBFWEBIF::GBFWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.jsp") {
-//all is done in GBFHTMLHREF since it inherits form this class
- addTokenSubstitute("FR", "<span class=\"wordsOfJesus\">"); // words of Jesus begin
- addTokenSubstitute("Fr", "</span>");
}
bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
@@ -189,7 +186,7 @@ bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u
}
else {
- return GBFHTMLHREF::handleToken(buf, token, userData);
+ return GBFXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/gbfwordjs.cpp b/src/modules/filters/gbfwordjs.cpp
index c3ab166..c9d1bd3 100644
--- a/src/modules/filters/gbfwordjs.cpp
+++ b/src/modules/filters/gbfwordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfwordjs.cpp - SWFilter descendant for ???
*
+ * $Id: gbfwordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +28,23 @@
#include <utilstr.h>
#include <versekey.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-GBFWordJS::GBFWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFWordJS::GBFWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -57,7 +63,6 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int word = 1;
char val[128];
char wordstr[5];
@@ -66,7 +71,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
bool newText = false;
bool needWordOut = false;
AttributeValue *wordAttrs = 0;
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
SWBuf wordSrcPrefix = modName;
const SWBuf orig = text;
@@ -146,7 +151,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -165,7 +170,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -174,7 +179,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -192,10 +197,11 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
+ if (!sMorph) sMorph = 0; // to pass unused warning for now
/*
if (sMorph) {
SWBuf popMorph = "<a onclick=\"";
- popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), wordID.c_str(), morph.c_str());
+ popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->getName(), morph.c_str(), wordID.c_str(), morph.c_str());
morph = popMorph;
}
*/
@@ -223,7 +229,6 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text += *from;
- lastspace = (*from == ' ');
}
}
@@ -241,7 +246,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -257,7 +262,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -266,7 +271,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
diff --git a/src/modules/filters/gbfxhtml.cpp b/src/modules/filters/gbfxhtml.cpp
new file mode 100644
index 0000000..56d7663
--- /dev/null
+++ b/src/modules/filters/gbfxhtml.cpp
@@ -0,0 +1,236 @@
+/******************************************************************************
+ *
+ * gbfxhtml.cpp - GBF to classed XHTML
+ *
+ * $Id: gbfxhtml.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <gbfxhtml.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <versekey.h>
+#include <ctype.h>
+#include <url.h>
+
+SWORD_NAMESPACE_START
+
+const char *GBFXHTML::getHeader() const {
+ return "\
+ .wordsOfJesus {\
+ color: red;\
+ }\
+ ";
+}
+
+GBFXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ if (module) {
+ version = module->getName();
+ }
+}
+
+GBFXHTML::GBFXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setTokenCaseSensitive(true);
+
+ //addTokenSubstitute("Rf", ")</small></font>");
+ addTokenSubstitute("FA", "<font color=\"#800000\">"); // for ASV footnotes to mark text
+ addTokenSubstitute("Rx", "</a>");
+ addTokenSubstitute("FI", "<i>"); // italics begin
+ addTokenSubstitute("Fi", "</i>");
+ addTokenSubstitute("FB", "<b>"); // bold begin
+ addTokenSubstitute("Fb", "</b>");
+ addTokenSubstitute("FR", "<span class=\"wordsOfJesus\">"); // words of Jesus begin
+ addTokenSubstitute("Fr", "</span>");
+ addTokenSubstitute("FU", "<u>"); // underline begin
+ addTokenSubstitute("Fu", "</u>");
+ addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
+ addTokenSubstitute("Fo", "</cite>");
+ addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
+ addTokenSubstitute("Fs", "</sup>");
+ addTokenSubstitute("FV", "<sub>"); // Subscript begin
+ addTokenSubstitute("Fv", "</sub>");
+ addTokenSubstitute("TT", "<big>"); // Book title begin
+ addTokenSubstitute("Tt", "</big>");
+ addTokenSubstitute("PP", "<cite>"); // poetry begin
+ addTokenSubstitute("Pp", "</cite>");
+ addTokenSubstitute("Fn", "</font>"); // font end
+ addTokenSubstitute("CL", "<br />"); // new line
+ addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
+ addTokenSubstitute("CG", ""); // ???
+ addTokenSubstitute("CT", ""); // ???
+ addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
+ addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
+ addTokenSubstitute("JL", "</div>"); // align end
+
+ renderNoteNumbers = false;
+}
+
+
+bool GBFXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ const char *tok;
+ MyUserData *u = (MyUserData *)userData;
+
+ if (!substituteToken(buf, token)) {
+ XMLTag tag(token);
+
+ if (!strncmp(token, "WG", 2)) { // strong's numbers
+ //buf += " <small><em>&lt;<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
+ for (tok = token+2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (!strncmp(token, "WH", 2)) { // strong's numbers
+ //buf += " <small><em>&lt;<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
+ for (tok = token+2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense
+ //buf += " <small><em>(<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "</a>)</em></small>";
+ }
+ else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense
+ //buf += " <small><em>(<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "</a>)</em></small>";
+ }
+
+ else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
+ //buf += " <small><em>(<a href=\"type=morph class=none value=";
+ buf += " <small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=";
+
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"morph\">";
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "</a>)</em></small>";
+ }
+
+ else if (!strcmp(tag.getName(), "RX")) {
+ buf += "<a href=\"";
+ for (tok = token + 3; *tok; tok++) {
+ if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
+ buf += *tok;
+ }
+ else {
+ break;
+ }
+ }
+ buf += "\">";
+ }
+ else if (!strcmp(tag.getName(), "RF")) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ //char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
+ }
+ u->suspendTextPassThru = true;
+ }
+ else if (!strcmp(tag.getName(), "Rf")) {
+ u->suspendTextPassThru = false;
+ }
+/*
+ else if (!strncmp(token, "RB", 2)) {
+ buf += "<i> ";
+ u->hasFootnotePreTag = true;
+ }
+
+ else if (!strncmp(token, "Rf", 2)) {
+ buf += "&nbsp<a href=\"note=";
+ buf += u->lastTextNode.c_str();
+ buf += "\">";
+ buf += "<small><sup>*n</sup></small></a>&nbsp";
+ // let's let text resume to output again
+ u->suspendTextPassThru = false;
+ }
+
+ else if (!strncmp(token, "RF", 2)) {
+ if (u->hasFootnotePreTag) {
+ u->hasFootnotePreTag = false;
+ buf += "</i> ";
+ }
+ u->suspendTextPassThru = true;
+ }
+*/
+ else if (!strncmp(token, "FN", 2)) {
+ buf += "<font face=\"";
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\">";
+ }
+
+ else if (!strncmp(token, "CA", 2)) { // ASCII value
+ buf += (char)atoi(&token[2]);
+ }
+
+ else {
+ return false;
+ }
+ }
+ return true;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/greeklexattribs.cpp b/src/modules/filters/greeklexattribs.cpp
index e1a60a2..1c2533d 100644
--- a/src/modules/filters/greeklexattribs.cpp
+++ b/src/modules/filters/greeklexattribs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * greeklexattribs - SWFilter descendant to set entry attributes for greek
- * lexicons
+ * greeklexattribs.cpp - SWFilter descendant to set entry attributes
+ * for greek lexicons
*
+ * $Id: greeklexattribs.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/latin1utf16.cpp b/src/modules/filters/latin1utf16.cpp
index bf2f3f8..ef27245 100644
--- a/src/modules/filters/latin1utf16.cpp
+++ b/src/modules/filters/latin1utf16.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * Latin1UTF16 - SWFilter descendant to convert a Latin-1 character to UTF-16
+ * latin1utf16.cpp - SWFilter descendant Latin1UTF16 to convert a Latin-1
+ * character to UTF-16
*
+ * $Id: latin1utf16.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/latin1utf8.cpp b/src/modules/filters/latin1utf8.cpp
index 784aafe..a784893 100644
--- a/src/modules/filters/latin1utf8.cpp
+++ b/src/modules/filters/latin1utf8.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * Latin1UTF8 - SWFilter descendant to convert a Latin-1 character to UTF-8
+ * latin1utf8.cpp - SWFilter descendant Latin1UTF8 to convert a Latin-1
+ * character to UTF-8
*
+ * $Id: latin1utf8.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,8 +26,10 @@
#include <latin1utf8.h>
#include <swmodule.h>
+
SWORD_NAMESPACE_START
+
Latin1UTF8::Latin1UTF8() {
}
@@ -35,7 +38,7 @@ char Latin1UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modu
{
const unsigned char *from;
- if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
+ if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return (char)-1;
SWBuf orig = text;
@@ -185,4 +188,5 @@ char Latin1UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modu
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisenum.cpp b/src/modules/filters/osisenum.cpp
new file mode 100644
index 0000000..db433b0
--- /dev/null
+++ b/src/modules/filters/osisenum.cpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ *
+ * osisenum.cpp - SWFilter descendant to hide or show word enumations
+ * in an OSIS module
+ *
+ * $Id: osisenum.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisenum.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Enumerations";
+ static const char oTip[] = "Toggles Enumerations On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISEnum::OSISEnum() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISEnum::~OSISEnum() {
+}
+
+
+char OSISEnum::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("n");
+ if (l) {
+ wtag.setAttribute("n", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisfootnotes.cpp b/src/modules/filters/osisfootnotes.cpp
index 3d0d2d4..8008d5c 100644
--- a/src/modules/filters/osisfootnotes.cpp
+++ b/src/modules/filters/osisfootnotes.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisfootnotes - SWFilter descendant to hide or show footnotes
- * in an OSIS module.
+ * osisfootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in an OSIS module
*
+ * $Id: osisfootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,17 +30,23 @@
#include <utilxml.h>
#include <utilstr.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -56,7 +63,7 @@ char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -122,7 +129,7 @@ char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
startTag.setAttribute("swordFootnote", buf);
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
if (!refs.length())
- refs = parser->ParseVerseList(tagText.c_str(), *parser, true).getRangeText();
+ refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
diff --git a/src/modules/filters/osisruby.cpp b/src/modules/filters/osisglosses.cpp
index c17ea43..d232acc 100644
--- a/src/modules/filters/osisruby.cpp
+++ b/src/modules/filters/osisglosses.cpp
@@ -1,93 +1,99 @@
-/******************************************************************************
- *
- * osisruby - SWFilter descendant to hide or show ruby
- * in a OSIS module.
- *
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <stdlib.h>
-#include <osisruby.h>
-#include <utilxml.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Ruby";
-const char oTip[] = "Toggles Ruby On and Off if they exist";
-
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-OSISRuby::OSISRuby() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-OSISRuby::~OSISRuby() {
-}
-
-
-char OSISRuby::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool lastspace = false;
-
- const SWBuf orig = text;
- const char * from = orig.c_str();
-
- if (!option) {
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- if (token.startsWith("w ")) { // Word
- XMLTag wtag(token);
- const char *l = wtag.getAttribute("gloss");
- if (l) {
- wtag.setAttribute("gloss", 0);
- token = wtag;
- token.trim();
- // drop <>
- token << 1;
- token--;
- }
- }
-
- // keep token in text
- text.append('<');
- text.append(token);
- text.append('>');
-
- continue;
- }
- if (intoken) {
- token += *from;
- }
- else {
- text.append(*from);
- lastspace = (*from == ' ');
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
+/******************************************************************************
+ *
+ * osisglosses.cpp - SWFilter descendant to hide or show glosses
+ * in an OSIS module
+ *
+ * $Id: osisglosses.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisglosses.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Glosses";
+ static const char oTip[] = "Toggles Glosses On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISGlosses::OSISGlosses() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISGlosses::~OSISGlosses() {
+}
+
+
+char OSISGlosses::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("gloss");
+ if (l) {
+ wtag.setAttribute("gloss", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisheadings.cpp b/src/modules/filters/osisheadings.cpp
index 8872f24..783fa81 100644
--- a/src/modules/filters/osisheadings.cpp
+++ b/src/modules/filters/osisheadings.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- *osisheadings - SWFilter descendant to hide or show headings
- * in an OSIS module.
+ * osisheadings.cpp - SWFilter descendant to hide or show headings
+ * in an OSIS module
*
+ * $Id: osisheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,151 +28,120 @@
#include <utilxml.h>
#include <utilstr.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ class MyUserData : public BasicFilterUserData {
+ public:
+ SWBuf currentHeadingName;
+ XMLTag currentHeadingTag;
+ const char *sID;
+ SWBuf heading;
+ int depth;
+ int headerNum;
-OSISHeadings::OSISHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ clear();
+ }
+ void clear() {
+ currentHeadingName = "";
+ currentHeadingTag = "";
+ sID = 0;
+ heading = "";
+ depth = 0;
+ headerNum = 0;
+ }
+ };
}
-OSISHeadings::~OSISHeadings() {
+BasicFilterUserData *OSISHeadings::createUserData(const SWModule *module, const SWKey *key) {
+ return new MyUserData(module, key);
}
-char OSISHeadings::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool hide = false;
- bool preverse = false;
- bool withinTitle = false;
- bool withinPreverseDiv = false;
- SWBuf preverseDivID = "";
- const char *pvDID = 0;
- bool canonical = false;
- SWBuf header;
- int headerNum = 0;
- int pvHeaderNum = 0;
- char buf[254];
- XMLTag startTag;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
-
- XMLTag tag;
-
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
-
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- tag = token;
-
- // <title> </title> <div subType="x-preverse"> (</div> ## when in previous)
- if ( (!withinPreverseDiv && !strcmp(tag.getName(), "title")) ||
- (!strcmp(tag.getName(), "div") &&
- ((withinPreverseDiv && (tag.isEndTag(pvDID))) ||
- (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-preverse")))
- )) {
-
- withinTitle = (!tag.isEndTag(pvDID));
- if (!strcmp(tag.getName(), "div")) {
- withinPreverseDiv = (!tag.isEndTag(pvDID));
- if (!pvDID) {
- preverseDivID = tag.getAttribute("sID");
- pvDID = (preverseDivID.length())? preverseDivID.c_str() : 0;
- }
- }
-
- if (!tag.isEndTag(pvDID)) { //start tag
- if (!tag.isEmpty() || pvDID) {
- startTag = tag;
- }
- }
-
- if ( !tag.isEndTag(pvDID) && (withinPreverseDiv
- || (tag.getAttribute("subType") && !stricmp(tag.getAttribute("subType"), "x-preverse"))
- || (tag.getAttribute("subtype") && !stricmp(tag.getAttribute("subtype"), "x-preverse")) // deprecated
- )) {
- hide = true;
- preverse = true;
- header = "";
- canonical = (tag.getAttribute("canonical") && (!stricmp(tag.getAttribute("canonical"), "true")));
- continue;
- }
- if (!tag.isEndTag(pvDID)) { //start tag
- hide = true;
- header = "";
- if (option || canonical) { // we want the tag in the text
- text.append('<');
- text.append(token);
- text.append('>');
- }
- continue;
- }
- if (hide && tag.isEndTag(pvDID)) {
- if (module->isProcessEntryAttributes() && ((option || canonical) || (!preverse))) {
- if (preverse) {
- sprintf(buf, "%i", pvHeaderNum++);
- module->getEntryAttributes()["Heading"]["Preverse"][buf] = header;
- }
- else {
- sprintf(buf, "%i", headerNum++);
- module->getEntryAttributes()["Heading"]["Interverse"][buf] = header;
- if (option || canonical) { // we want the tag in the text
- text.append(header);
- }
- }
-
- StringList attributes = startTag.getAttributeNames();
+OSISHeadings::OSISHeadings() : SWOptionFilter(oName, oTip, oValues()) {
+ setPassThruUnknownToken(true);
+}
+
+
+bool OSISHeadings::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+ SWBuf name = tag.getName();
+
+ // we only care about titles and divs or if we're already in a heading
+ //
+ // are we currently in a heading?
+ if (u->currentHeadingName.size()) {
+ u->heading.append(u->lastTextNode);
+ if (name == u->currentHeadingName) {
+ if (tag.isEndTag(u->sID)) {
+ if (!u->depth-- || u->sID) {
+ // we've just finished a heading. It's all stored up in u->heading
+ bool canonical = (SWBuf("true") == u->currentHeadingTag.getAttribute("canonical"));
+ bool preverse = (SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subType") || SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subtype"));
+
+ // do we want to put anything in EntryAttributes?
+ if (u->module->isProcessEntryAttributes() && (option || canonical || !preverse)) {
+ SWBuf buf; buf.appendFormatted("%i", u->headerNum++);
+ u->module->getEntryAttributes()["Heading"][(preverse)?"Preverse":"Interverse"][buf] = u->heading;
+
+ StringList attributes = u->currentHeadingTag.getAttributeNames();
for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
- module->getEntryAttributes()["Heading"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
+ u->module->getEntryAttributes()["Heading"][buf][it->c_str()] = u->currentHeadingTag.getAttribute(it->c_str());
}
}
-
- hide = false;
- if (!(option || canonical) || preverse) { // we don't want the tag in the text anymore
- preverse = false;
- continue;
- }
- preverse = false;
- pvDID = 0;
- }
- }
- if (withinTitle) {
- header.append('<');
- header.append(token);
- header.append('>');
- } else {
- // if not a heading token, keep token in text
- if (!hide) {
- text.append('<');
- text.append(token);
- text.append('>');
+ // do we want the heading in the body?
+ if (!preverse && (option || canonical)) {
+ buf.append(u->currentHeadingTag);
+ buf.append(u->heading);
+ buf.append(tag);
+ }
+ u->suspendTextPassThru = false;
+ u->clear();
}
}
- continue;
+ else u->depth++;
}
- if (intoken) { //copy token
- token.append(*from);
- }
- else if (!hide) { //copy text which is not inside a token
- text.append(*from);
- }
- else header.append(*from);
+ u->heading.append(tag);
+ return true;
}
- return 0;
+
+ // are we a title or a preverse div?
+ else if ( name == "title"
+ || (name == "div"
+ && ( SWBuf("x-preverse") == tag.getAttribute("subType")
+ || SWBuf("x-preverse") == tag.getAttribute("subtype")))) {
+
+ u->currentHeadingName = name;
+ u->currentHeadingTag = tag;
+ u->heading = "";
+ u->sID = u->currentHeadingTag.getAttribute("sID");
+ u->depth = 0;
+ u->suspendTextPassThru = true;
+
+ return true;
+ }
+
+ return false;
}
+
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp
index 3406e1b..74b2da7 100644
--- a/src/modules/filters/osishtmlhref.cpp
+++ b/src/modules/filters/osishtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * osishtmlhref.cpp - OSIS to HTML with hrefs filter
- * -------------------
- * begin : 2003-06-24
- * copyright : 2003 by CrossWire Bible Society
+ *
+ * osishtmlhref.cpp - OSIS to HTML with hrefs filter
*
+ * $Id: osishtmlhref.cpp 3005 2014-01-09 04:06:11Z greg.hellings $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -36,60 +35,6 @@ SWORD_NAMESPACE_START
namespace {
typedef std::stack<SWBuf> TagStack;
-}
-
-// TODO: this bridge pattern is to preserve binary compat on 1.6.x
-class OSISHTMLHREF::TagStacks {
-public:
- TagStack quoteStack;
- TagStack hiStack;
-};
-
-OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- inXRefNote = false;
- suspendLevel = 0;
- tagStacks = new TagStacks();
- wordsOfChristStart = "<font color=\"red\"> ";
- wordsOfChristEnd = "</font> ";
- if (module) {
- osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
- }
- else {
- osisQToTick = true; // default
- version = "";
- }
-}
-
-OSISHTMLHREF::MyUserData::~MyUserData() {
- delete tagStacks;
-}
-
-OSISHTMLHREF::OSISHTMLHREF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
- setPassThruNumericEscapeString(true);
-
- addAllowedEscapeString("quot");
- addAllowedEscapeString("apos");
- addAllowedEscapeString("amp");
- addAllowedEscapeString("lt");
- addAllowedEscapeString("gt");
-
- setTokenCaseSensitive(true);
-
- // addTokenSubstitute("lg", "<br />");
- // addTokenSubstitute("/lg", "<br />");
-
- morphFirst = false;
-}
-
// though this might be slightly slower, possibly causing an extra bool check, this is a renderFilter
// so speed isn't the absolute highest priority, and this is a very minor possible hit
static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
@@ -157,6 +102,61 @@ void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
//}
}
}
+} // end anonymous namespace
+
+// TODO: this bridge pattern is to preserve binary compat on 1.6.x
+class OSISHTMLHREF::TagStacks {
+public:
+ TagStack quoteStack;
+ TagStack hiStack;
+};
+
+OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ inXRefNote = false;
+ suspendLevel = 0;
+ tagStacks = new TagStacks();
+ wordsOfChristStart = "<font color=\"red\"> ";
+ wordsOfChristEnd = "</font> ";
+ if (module) {
+ osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+ else {
+ osisQToTick = true; // default
+ version = "";
+ }
+}
+
+OSISHTMLHREF::MyUserData::~MyUserData() {
+ delete tagStacks;
+}
+
+OSISHTMLHREF::OSISHTMLHREF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ // addTokenSubstitute("lg", "<br />");
+ // addTokenSubstitute("/lg", "<br />");
+
+ morphFirst = false;
+ renderNoteNumbers = false;
+}
+
bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
MyUserData *u = (MyUserData *)userData;
@@ -240,6 +240,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
@@ -251,25 +252,14 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
vkey = SWDYNAMIC_CAST(VerseKey, u->key);
}
SWCATCH ( ... ) { }
- if (vkey) {
- //printf("URL = %s\n",URL::encode(vkey->getText()).c_str());
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
- ch,
- URL::encode(footnoteNumber.c_str()).c_str(),
- URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str(),
- ch,
- ch);
- }
- else {
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
- ch,
- URL::encode(footnoteNumber.c_str()).c_str(),
- URL::encode(u->version.c_str()).c_str(),
- URL::encode(u->key->getText()).c_str(),
- ch,
- ch);
- }
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey ? vkey->getText() : u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? noteName.c_str() : ""));
}
}
u->suspendTextPassThru = (++u->suspendLevel);
@@ -381,7 +371,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
}
// <lb.../>
- else if (!strcmp(tag.getName(), "lb")) {
+ else if (!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) {
outText("<br />", buf, u);
userData->supressAdjacentWhitespace = true;
}
@@ -485,10 +475,15 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
// <hi> text highlighting
else if (!strcmp(tag.getName(), "hi")) {
SWBuf type = tag.getAttribute("type");
+ // handle tei rend attribute
+ if (!type.length()) type = tag.getAttribute("rend");
if ((!tag.isEndTag()) && (!tag.isEmpty())) {
if (type == "bold" || type == "b" || type == "x-b") {
outText("<b>", buf, u);
}
+ else if (type == "ol") {
+ outText("<span style=\"text-decoration:overline\">", buf, u);
+ }
else { // all other types
outText("<i>", buf, u);
}
@@ -500,10 +495,14 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
XMLTag tag(u->tagStacks->hiStack.top());
u->tagStacks->hiStack.pop();
type = tag.getAttribute("type");
+ if (!type.length()) type = tag.getAttribute("rend");
}
if (type == "bold" || type == "b" || type == "x-b") {
outText("</b>", buf, u);
}
+ else if (type == "ol") {
+ outText("</span>", buf, u);
+ }
else outText("</i>", buf, u);
}
}
diff --git a/src/modules/filters/osislemma.cpp b/src/modules/filters/osislemma.cpp
index 7b56024..cf5d8f4 100644
--- a/src/modules/filters/osislemma.cpp
+++ b/src/modules/filters/osislemma.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osislemma - SWFilter descendant to hide or show lemmata
- * in a OSIS module.
+ * osislemma.cpp - SWFilter descendant to hide or show lemmata
+ * in a OSIS module
*
+ * $Id: osislemma.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,16 +25,23 @@
#include <osislemma.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Lemmas";
-const char oTip[] = "Toggles Lemmas On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Lemmas";
+ static const char oTip[] = "Toggles Lemmas On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISLemma::OSISLemma() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISLemma::OSISLemma() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -44,7 +52,6 @@ OSISLemma::~OSISLemma() {
char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
- bool lastspace = false;
const SWBuf orig = text;
const char * from = orig.c_str();
@@ -90,7 +97,6 @@ char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osismorph.cpp b/src/modules/filters/osismorph.cpp
index 7ceec79..71de8e5 100644
--- a/src/modules/filters/osismorph.cpp
+++ b/src/modules/filters/osismorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osismorph - SWFilter descendant to hide or show morph tags
- * in a OSIS module.
+ * osismorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a OSIS module
*
+ * $Id: osismorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,14 +26,20 @@
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
-OSISMorph::OSISMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
+}
+
+OSISMorph::OSISMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -45,7 +52,6 @@ char OSISMorph::processText(SWBuf &text, const SWKey *key, const SWModule *modul
char token[2048]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
SWBuf orig = text;
const char *from = orig.c_str();
@@ -90,7 +96,6 @@ char OSISMorph::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osismorphsegmentation.cpp b/src/modules/filters/osismorphsegmentation.cpp
index fef7af7..9afc0a1 100644
--- a/src/modules/filters/osismorphsegmentation.cpp
+++ b/src/modules/filters/osismorphsegmentation.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
*
- * osismorphsegmentation - SWFilter descendant to toggle splitting of morphemes
- * (for morpheme segmented Hebrew in the WLC)
+ * osismorphsegmentation.cpp - SWFilter descendant to toggle splitting of
+ * morphemes (for morpheme segmented Hebrew in
+ * the WLC)
*
+ * $Id: osismorphsegmentation.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,16 +28,23 @@
#include <swmodule.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Morpheme Segmentation";
-const char oTip[] = "Toggles Morpheme Segmentation On and Off, when present";
+namespace {
+
+ static const char oName[] = "Morpheme Segmentation";
+ static const char oTip[] = "Toggles Morpheme Segmentation On and Off, when present";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISMorphSegmentation::OSISMorphSegmentation() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISMorphSegmentation::OSISMorphSegmentation() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisosis.cpp b/src/modules/filters/osisosis.cpp
index 82a6bfc..2bc5cbb 100644
--- a/src/modules/filters/osisosis.cpp
+++ b/src/modules/filters/osisosis.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * osisosis.cpp - internal OSIS to public OSIS filter
- * -------------------
- * begin : 2004-03-13
- * copyright : 2003 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * osisosis.cpp - internal OSIS to public OSIS filter
+ *
+ * $Id: osisosis.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -59,7 +59,7 @@ char OSISOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -67,24 +67,24 @@ char OSISOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
}
diff --git a/src/modules/filters/osisplain.cpp b/src/modules/filters/osisplain.cpp
index 57105f0..6e583a4 100644
--- a/src/modules/filters/osisplain.cpp
+++ b/src/modules/filters/osisplain.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
- * osisplain.cpp - An SWFilter
- * impl that provides stripping of OSIS tags
*
- * $Id: osisplain.cpp 2334 2009-04-24 00:14:12Z scribe $
+ * osisplain.cpp - An SWFilter that provides stripping of OSIS tags
*
- * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: osisplain.cpp 2984 2013-09-20 12:18:45Z scribe $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +28,21 @@
SWORD_NAMESPACE_START
+
namespace {
-class MyUserData : public BasicFilterUserData {
-public:
- SWBuf w;
- XMLTag tag;
- VerseKey *vk;
- char testament;
- MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {}
-};
+
+ class MyUserData : public BasicFilterUserData {
+ public:
+ SWBuf w;
+ XMLTag tag;
+ VerseKey *vk;
+ char testament;
+ SWBuf hiType;
+ MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {}
+ };
}
+
OSISPlain::OSISPlain() {
setTokenStart("<");
setTokenEnd(">");
@@ -65,7 +69,7 @@ OSISPlain::OSISPlain() {
BasicFilterUserData *OSISPlain::createUserData(const SWModule *module, const SWKey *key) {
MyUserData *u = new MyUserData(module, key);
u->vk = SWDYNAMIC_CAST(VerseKey, u->key);
- u->testament = (u->vk) ? u->vk->Testament() : 2; // default to NT
+ u->testament = (u->vk) ? u->vk->getTestament() : 2; // default to NT
return u;
}
@@ -202,6 +206,40 @@ bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
end += buf.size() - u->lastTextNode.size();
toupperstr(end);
}
+ else if (!strncmp(token, "hi", 2)) {
+
+ // handle both OSIS 'type' and TEI 'rend' attributes
+ // there is no officially supported OSIS overline attribute,
+ // thus either TEI overline or OSIS x-overline would be best,
+ // but we have used "ol" in the past, as well. Once a valid
+ // OSIS overline attribute is made available, these should all
+ // eventually be deprecated and never documented that they are supported.
+ if (strstr(token, "rend=\"ol\"") || strstr(token, "rend=\"x-overline\"") || strstr(token, "rend=\"overline\"")
+ || strstr(token, "type=\"ol\"") || strstr(token, "type=\"x-overline\"") || strstr(token, "type=\"overline\"")) {
+ u->hiType = "overline";
+ }
+ else u->hiType = "";
+ u->suspendTextPassThru = true;
+ }
+ else if (!strncmp(token, "/hi", 3)) {
+ if (u->hiType == "overline") {
+ const unsigned char *b = (const unsigned char *)u->lastTextNode.c_str();
+ while (*b) {
+ const unsigned char *o = b;
+ if (getUniCharFromUTF8(&b)) {
+ while (o != b) buf.append(*(o++));
+ buf.append((unsigned char)0xCC);
+ buf.append((unsigned char)0x85);
+ }
+ }
+ }
+ else {
+ buf.append("*");
+ buf.append(u->lastTextNode);
+ buf.append("*");
+ }
+ u->suspendTextPassThru = false;
+ }
// <milestone type="line"/>
else if (!strncmp(token, "milestone", 9)) {
diff --git a/src/modules/filters/osisredletterwords.cpp b/src/modules/filters/osisredletterwords.cpp
index 9075fd8..e7c921c 100644
--- a/src/modules/filters/osisredletterwords.cpp
+++ b/src/modules/filters/osisredletterwords.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * OSISRedLetterWords - SWFilter descendant to toggle red coloring for words
- * of Christ in an OSIS module.
+ * osisredletterwords.cpp - SWFilter descendant to toggle red coloring for
+ * words of Christ in an OSIS module
*
+ * $Id: osisredletterwords.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,14 +28,20 @@
SWORD_NAMESPACE_START
-const char oName[] = "Words of Christ in Red";
-const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Words of Christ in Red";
+ static const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
-OSISRedLetterWords::OSISRedLetterWords() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISRedLetterWords::OSISRedLetterWords() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisreferencelinks.cpp b/src/modules/filters/osisreferencelinks.cpp
new file mode 100644
index 0000000..83308e4
--- /dev/null
+++ b/src/modules/filters/osisreferencelinks.cpp
@@ -0,0 +1,114 @@
+/******************************************************************************
+ *
+ * osisreferencelinks.cpp - SWFilter descendant to toggle OSIS reference
+ * links with specified type/subType
+ *
+ * $Id: osisreferencelinks.cpp 2995 2013-12-28 06:32:26Z greg.hellings $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisreferencelinks.h>
+#include <utilxml.h>
+#include <swmodule.h>
+
+
+SWORD_NAMESPACE_START
+
+
+namespace {
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISReferenceLinks::OSISReferenceLinks(const char *optionName, const char *optionTip, const char *type, const char *subType, const char *defaultValue)
+ : SWOptionFilter(),
+ optionName(optionName),
+ optionTip(optionTip),
+ type(type),
+ subType(subType) {
+
+ optName = this->optionName.c_str();
+ optTip = this->optionTip.c_str();
+ optValues = oValues();
+ setOptionValue(defaultValue);
+}
+
+
+OSISReferenceLinks::~OSISReferenceLinks() {
+}
+
+
+char OSISReferenceLinks::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ if (option) return 0;
+
+ SWBuf token;
+ bool intoken = false;
+ bool stripThisToken = false;
+
+ SWBuf orig = text;
+ const char *from = orig.c_str();
+
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ else if (*from == '>') { // process tokens
+ intoken = false;
+ if (strncmp(token, "reference", 9) && strncmp(token.c_str(), "/reference", 10)) {
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ else {
+ XMLTag tag;
+ tag = token;
+ if (!tag.isEndTag() && type == tag.getAttribute("type") && (!subType.size() || subType == tag.getAttribute("subType"))) {
+ stripThisToken = true;
+ continue;
+ }
+ else if (tag.isEndTag() && stripThisToken) {
+ stripThisToken = false;
+ continue;
+ }
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ continue;
+ }
+
+ if (intoken) { //copy token
+ token.append(*from);
+ }
+ else { //copy text which is not inside a token
+ text.append(*from);
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
+
+
diff --git a/src/modules/filters/osisrtf.cpp b/src/modules/filters/osisrtf.cpp
index b8cf30c..291aa08 100644
--- a/src/modules/filters/osisrtf.cpp
+++ b/src/modules/filters/osisrtf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * osisrtf.cpp - OSIS to RTF filter
- * -------------------
- * begin : 2003-02-15
- * copyright : 2003 by CrossWire Bible Society
*
+ * osisrtf.cpp - OSIS to RTF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: osisrtf.cpp 3005 2014-01-09 04:06:11Z greg.hellings $ *
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,8 +52,8 @@ namespace {
BiblicalText = false;
suspendLevel = 0;
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
}
@@ -68,9 +67,11 @@ namespace {
delete [] tagData;
}
}
-static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
-static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
-};
+
+ static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+ static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+
+}
OSISRTF::OSISRTF() {
@@ -251,7 +252,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
SWCATCH ( ... ) { }
if (vkey) {
char ch = ((!strcmp(type.c_str(), "crossReference")) || (!strcmp(type.c_str(), "x-cross-ref"))) ? 'x':'n';
- scratch.setFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
+ scratch.setFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->getVerse(), footnoteNumber.c_str());
outText(scratch.c_str(), buf, u);
u->inXRefNote = (ch == 'x');
}
@@ -325,7 +326,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
}
// <milestone type="line"/> or <lb.../>
- else if ((!strcmp(tag.getName(), "lb")) || ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line")))) {
+ else if ((!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) || ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line")))) {
outText("{\\par}", buf, u);
userData->supressAdjacentWhitespace = true;
}
diff --git a/src/modules/filters/osisscripref.cpp b/src/modules/filters/osisscripref.cpp
index 73c7309..2bb7d15 100644
--- a/src/modules/filters/osisscripref.cpp
+++ b/src/modules/filters/osisscripref.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * OSISScripref - SWFilter descendant to hide or show scripture references
- * in an OSIS module.
+ * osisscripref.cpp - SWFilter descendant to hide or show scripture
+ * references in an OSIS module
*
+ * $Id: osisscripref.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,16 +26,23 @@
#include <swmodule.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Cross-references";
-const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Cross-references";
+ static const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISScripref::OSISScripref() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+OSISScripref::OSISScripref() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisstrongs.cpp b/src/modules/filters/osisstrongs.cpp
index 8c06b07..b937883 100644
--- a/src/modules/filters/osisstrongs.cpp
+++ b/src/modules/filters/osisstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisstrongs - SWFilter descendant to hide or show strongs number
- * in a OSIS module.
+ * 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 $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +29,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Strong's Numbers";
-const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISStrongs::OSISStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISStrongs::OSISStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -49,7 +56,6 @@ OSISStrongs::~OSISStrongs() {
char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
- bool lastspace = false;
int wordNum = 1;
char wordstr[5];
const char *wordStart = 0;
@@ -151,7 +157,7 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod
if ((lClass == "x-Strongs") || (lClass == "strong") || (lClass == "Strong")) {
if (isdigit(attrib[0])) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else {
@@ -280,7 +286,6 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
return 0;
diff --git a/src/modules/filters/osisvariants.cpp b/src/modules/filters/osisvariants.cpp
index 16e0cfb..6cd3eda 100644
--- a/src/modules/filters/osisvariants.cpp
+++ b/src/modules/filters/osisvariants.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisvariants - SWFilter descendant to hide or show textual variants
- * in an OSIS module.
+ * osisvariants.cpp - SWFilter descendant to hide or show textual variants
+ * in an OSIS module
*
+ * $Id: osisvariants.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,51 +24,41 @@
#include <stdlib.h>
#include <osisvariants.h>
#include <utilstr.h>
+#include <utilxml.h>
-SWORD_NAMESPACE_START
-const char OSISVariants::primary[] = "Primary Reading";
-const char OSISVariants::secondary[] = "Secondary Reading";
-const char OSISVariants::all[] = "All Readings";
+SWORD_NAMESPACE_START
-const char OSISVariants::optName[] = "Textual Variants";
-const char OSISVariants::optTip[] = "Switch between Textual Variants modes";
+namespace {
+ static const char oName[] = "Textual Variants";
+ static const char oTip[] = "Switch between Textual Variants modes";
+ static const char *choices[4] = { "Primary Reading", "Secondary Reading", "All Readings", "" };
-OSISVariants::OSISVariants() {
- option = false;
- options.push_back(primary);
- options.push_back(secondary);
- options.push_back(all);
+ static const StringList *oValues() {
+ static const StringList oVals(&choices[0], &choices[3]);
+ return &oVals;
+ }
}
-OSISVariants::~OSISVariants() {
+OSISVariants::OSISVariants() : SWOptionFilter(oName, oTip, oValues()) {
}
-void OSISVariants::setOptionValue(const char *ival)
-{
- if (!stricmp(ival, primary)) option = 0;
- else if (!stricmp(ival, secondary)) option = 1;
- else option = 2;
-}
-const char *OSISVariants::getOptionValue()
-{
- if (option == 0) {
- return primary;
- }
- else if (option == 1) {
- return secondary;
- }
- else {
- return all;
- }
+OSISVariants::~OSISVariants() {
}
+
char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
- if (option == 0 || option == 1) { //we want primary or variant only
+
+ int option = 0;
+ if (optionValue == choices[0]) option = 0;
+ else if (optionValue == choices[1]) option = 1;
+ else option = 2;
+
+ if (option == 0 || option == 1) { //we want primary or variant only
bool intoken = false;
bool hide = false;
bool invar = false;
@@ -75,9 +66,10 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
SWBuf token;
SWBuf orig = text;
const char *from = orig.c_str();
+ XMLTag tag;
//we use a fixed comparision string to make sure the loop is as fast as the original two blocks with almost the same code
- //const char* variantCompareString = (option == 0) ? "div type=\"variant\" class=\"1\"" : "div type=\"variant\" class=\"2\"";
+ const char* variantChoice = (option == 0) ? "x-2" : "x-1";
for (text = ""; *from; from++) {
if (*from == '<') {
@@ -88,16 +80,16 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
else if (*from == '>') { // process tokens
intoken = false;
- if (!strncmp(token.c_str(), "seg ", 4)) { //only one of the variants
- invar = true;
- hide = true;
- continue;
- }
- if (!strncmp(token.c_str(), "div type=\"variant\"", 18)) {
- invar = true;
- continue;
+ if (!strncmp(token.c_str(), "seg", 3)) {
+ tag = token;
+
+ if (tag.getAttribute("type") && !strcmp("x-variant", tag.getAttribute("type")) && tag.getAttribute("subType") && !strcmp(variantChoice, tag.getAttribute("subType"))) {
+ invar = true;
+ hide = true;
+ continue;
+ }
}
- if (!strncmp(token.c_str(), "/div", 4)) {
+ if (!strncmp(token.c_str(), "/seg", 4)) {
hide = false;
if (invar) {
invar = false;
@@ -126,8 +118,4 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
}
-
-
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osiswebif.cpp b/src/modules/filters/osiswebif.cpp
index e313836..2cbca0b 100644
--- a/src/modules/filters/osiswebif.cpp
+++ b/src/modules/filters/osiswebif.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * OSISWEBIF.cpp - OSIS to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2003-10-23
- * copyright : 2003 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * osiswebif.cpp - OSIS to HTML filter with hrefs for strongs and
+ * morph tags
+ *
+ * $Id: osiswebif.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -37,20 +37,13 @@ OSISWEBIF::OSISWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.js
}
-BasicFilterUserData *OSISWEBIF::createUserData(const SWModule *module, const SWKey *key) {
- MyUserData *u = new MyUserData(module, key);
- u->wordsOfChristStart = "<span class=\"wordsOfJesus\"> ";
- u->wordsOfChristEnd = "</span> ";
- return u;
-}
-
-
bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
MyUserData *u = (MyUserData *)userData;
SWBuf scratch;
bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
if (!sub) {
- // manually process if it wasn't a simple substitution
+
+ // manually process if it wasn't a simple substitution
XMLTag tag(token);
// <w> tag
@@ -143,7 +136,7 @@ bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
if (!tag.isEmpty()) {
if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- SWBuf modName = (u->module) ? u->module->Name() : "";
+ SWBuf modName = (u->module) ? u->module->getName() : "";
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -165,43 +158,10 @@ bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
}
}
- // <title>
- else if (!strcmp(tag.getName(), "title")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "<h3>";
- }
- else if (tag.isEndTag()) {
- buf += "</h3>";
- }
- }
-
- // Milestoned paragraphs, created by osis2mod
- // <div type="paragraph" sID.../>
- // <div type="paragraph" eID.../>
- else if (tag.isEmpty() && !strcmp(tag.getName(), "div") && tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "paragraph")) {
- // This is properly handled by base class.
- return OSISHTMLHREF::handleToken(buf, token, userData);
- }
-
- // ok to leave these in
- else if (!strcmp(tag.getName(), "div")) {
- buf += tag;
- }
- else if (!strcmp(tag.getName(), "span")) {
- buf += tag;
- }
- else if (!strcmp(tag.getName(), "br")) {
- buf += tag;
- }
// handled appropriately in base class
- // <catchWord> & <rdg> tags (italicize)
- // <hi> text highlighting
- // <q> quote
- // <milestone type="cQuote" marker="x"/>
- // <transChange>
else {
- return OSISHTMLHREF::handleToken(buf, token, userData);
+ return OSISXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/osiswordjs.cpp b/src/modules/filters/osiswordjs.cpp
index da573d3..75946a8 100644
--- a/src/modules/filters/osiswordjs.cpp
+++ b/src/modules/filters/osiswordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * osisstrongs - SWFilter descendant to hide or show strongs number
- * in a OSIS module.
+ * osiswordjs.cpp - SWFilter descendant for ???
*
+ * $Id: osiswordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,17 +30,23 @@
#include <versekey.h>
#include <stdio.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISWordJS::OSISWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISWordJS::OSISWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -59,10 +65,9 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int wordNum = 1;
char wordstr[5];
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
// add TR to w src in KJV then remove this next line
SWBuf wordSrcPrefix = (modName == "KJV")?SWBuf("TR"):modName;
@@ -135,10 +140,10 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
if ((gh == 'G') && (defaultGreekLex)) {
- lexName = (!strcmp(defaultGreekLex->Name(), "StrongsGreek"))?"G":defaultGreekLex->Name();
+ lexName = (!strcmp(defaultGreekLex->getName(), "StrongsGreek"))?"G":defaultGreekLex->getName();
}
else if ((gh == 'H') && (defaultHebLex)) {
- lexName = (!strcmp(defaultHebLex->Name(), "StrongsHebrew"))?"H":defaultHebLex->Name();
+ lexName = (!strcmp(defaultHebLex->getName(), "StrongsHebrew"))?"H":defaultHebLex->getName();
}
SWBuf xlit = wtag.getAttribute("xlit");
@@ -151,7 +156,7 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -186,7 +191,6 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osisxhtml.cpp b/src/modules/filters/osisxhtml.cpp
new file mode 100644
index 0000000..b1040a9
--- /dev/null
+++ b/src/modules/filters/osisxhtml.cpp
@@ -0,0 +1,772 @@
+/******************************************************************************
+ *
+ * osisxhtml.cpp - Render filter for classed XHTML of an OSIS module
+ *
+ * $Id: osisxhtml.cpp 3005 2014-01-09 04:06:11Z greg.hellings $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <osisxhtml.h>
+#include <utilxml.h>
+#include <utilstr.h>
+#include <versekey.h>
+#include <swmodule.h>
+#include <url.h>
+#include <stringmgr.h>
+#include <stack>
+
+SWORD_NAMESPACE_START
+
+const char *OSISXHTML::getHeader() const {
+ const static char *header = "\
+ .divineName { font-variant: small-caps; }\n\
+ .wordsOfJesus { color: red; }\n\
+ .transChangeSupplied { font-style: italic; }\n\
+ .small, .sub, .sup { font-size: .83em }\n\
+ .sub { vertical-align: sub }\n\
+ .sup { vertical-align: super }\n\
+ .indent1 { margin-left: 10px }\n\
+ .indent2 { margin-left: 20px }\n\
+ .indent3 { margin-left: 30px }\n\
+ .indent4 { margin-left: 40px }\n\
+ ";
+ return header;
+}
+
+
+namespace {
+
+// though this might be slightly slower, possibly causing an extra bool check, this is a renderFilter
+// so speed isn't the absolute highest priority, and this is a very minor possible hit
+static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+
+void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+ const char *attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("lemma"))) {
+ int count = tag.getAttributePartCount("lemma", ' ');
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ do {
+ attrib = tag.getAttribute("lemma", i, ' ');
+ if (i < 0) i = 0; // to handle our -1 condition
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ SWBuf gh;
+ if(*val == 'G')
+ gh = "Greek";
+ if(*val == 'H')
+ gh = "Hebrew";
+ const char *val2 = val;
+ if ((strchr("GH", *val)) && (isdigit(val[1])))
+ val2++;
+ //if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
+ // show = false;
+ //else {
+ if (!suspendTextPassThru) {
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">%s</a>&gt;</em></small>",
+ (gh.length()) ? gh.c_str() : "",
+ URL::encode(val2).c_str(),
+ val2);
+ }
+ //}
+
+ } while (++i < count);
+ }
+}
+
+
+
+void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+ const char * attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("morph"))) { // && (show)) {
+ SWBuf savelemma = tag.getAttribute("savlm");
+ //if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
+ // show = false;
+ //if (show) {
+ int count = tag.getAttributePartCount("morph", ' ');
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ do {
+ attrib = tag.getAttribute("morph", i, ' ');
+ if (i < 0) i = 0; // to handle our -1 condition
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ const char *val2 = val;
+ if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
+ val2+=2;
+ if (!suspendTextPassThru) {
+ buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\" class=\"morph\">%s</a>)</em></small>",
+ URL::encode(tag.getAttribute("morph")).c_str(),
+ URL::encode(val).c_str(),
+ val2);
+ }
+ } while (++i < count);
+ //}
+ }
+}
+
+
+} // end anonymous namespace
+
+BasicFilterUserData *OSISXHTML::createUserData(const SWModule *module, const SWKey *key) {
+ return new MyUserData(module, key);
+}
+
+
+OSISXHTML::OSISXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ // addTokenSubstitute("lg", "<br />");
+ // addTokenSubstitute("/lg", "<br />");
+
+ morphFirst = false;
+ renderNoteNumbers = false;
+}
+
+class OSISXHTML::TagStack : public std::stack<SWBuf> {
+};
+
+OSISXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key), quoteStack(new TagStack()), hiStack(new TagStack()), titleStack(new TagStack()), lineStack(new TagStack()) {
+ inXRefNote = false;
+ suspendLevel = 0;
+ wordsOfChristStart = "<span class=\"wordsOfJesus\"> ";
+ wordsOfChristEnd = "</span> ";
+ if (module) {
+ osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+ else {
+ osisQToTick = true; // default
+ version = "";
+ }
+ consecutiveNewlines = 0;
+}
+
+OSISXHTML::MyUserData::~MyUserData() {
+ delete quoteStack;
+ delete hiStack;
+ delete titleStack;
+ delete lineStack;
+}
+
+void OSISXHTML::MyUserData::outputNewline(SWBuf &buf) {
+ if (++consecutiveNewlines <= 2) {
+ outText("<br />\n", buf, this);
+ supressAdjacentWhitespace = true;
+ }
+}
+bool OSISXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ MyUserData *u = (MyUserData *)userData;
+ SWBuf scratch;
+ bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
+ if (!sub) {
+ // manually process if it wasn't a simple substitution
+ XMLTag tag(token);
+
+ // <w> tag
+ if (!strcmp(tag.getName(), "w")) {
+
+ // start <w> tag
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) {
+ u->w = token;
+ }
+
+ // end or empty <w> tag
+ else {
+ bool endTag = tag.isEndTag();
+ SWBuf lastText;
+ //bool show = true; // to handle unplaced article in kjv2003-- temporary till combined
+
+ if (endTag) {
+ tag = u->w.c_str();
+ lastText = u->lastTextNode.c_str();
+ }
+ else lastText = "stuff";
+
+ const char *attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("xlit"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText(" ", buf, u);
+ outText(val, buf, u);
+ }
+ if ((attrib = tag.getAttribute("gloss"))) {
+ // I'm sure this is not the cleanest way to do it, but it gets the job done
+ // for rendering ruby chars properly ^_^
+ buf -= lastText.length();
+
+ outText("<ruby><rb>", buf, u);
+ outText(lastText, buf, u);
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText("</rb><rp>(</rp><rt>", buf, u);
+ outText(val, buf, u);
+ outText("</rt><rp>)</rp></ruby>", buf, u);
+ }
+ if (!morphFirst) {
+ processLemma(u->suspendTextPassThru, tag, buf);
+ processMorph(u->suspendTextPassThru, tag, buf);
+ }
+ else {
+ processMorph(u->suspendTextPassThru, tag, buf);
+ processLemma(u->suspendTextPassThru, tag, buf);
+ }
+ if ((attrib = tag.getAttribute("POS"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText(" ", buf, u);
+ outText(val, buf, u);
+ }
+
+ /*if (endTag)
+ buf += "}";*/
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ SWBuf type = tag.getAttribute("type");
+ bool strongsMarkup = (type == "x-strongsMarkup" || type == "strongsMarkup"); // the latter is deprecated
+ if (strongsMarkup) {
+ tag.setEmpty(false); // handle bug in KJV2003 module where some note open tags were <note ... />
+ }
+
+ if (!tag.isEmpty()) {
+
+ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+
+ u->inXRefNote = true; // Why this change? Ben Morgan: Any note can have references in, so we need to set this to true for all notes
+// u->inXRefNote = (ch == 'x');
+
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ //printf("URL = %s\n",URL::encode(vkey->getText()).c_str());
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ else {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ }
+ }
+ u->suspendTextPassThru = (++u->suspendLevel);
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = (--u->suspendLevel);
+ u->inXRefNote = false;
+ u->lastSuspendSegment = ""; // fix/work-around for nasb devineName in note bug
+ }
+ }
+
+ // <p> paragraph and <lg> linegroup tags
+ else if (!strcmp(tag.getName(), "p") || !strcmp(tag.getName(), "lg")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
+ u->outputNewline(buf);
+ }
+ else if (tag.isEndTag()) { // end tag
+ u->outputNewline(buf);
+ }
+ else { // empty paragraph break marker
+ u->outputNewline(buf);
+ }
+ }
+
+ // Milestoned paragraphs, created by osis2mod
+ // <div type="paragraph" sID.../>
+ // <div type="paragraph" eID.../>
+ else if (tag.isEmpty() && !strcmp(tag.getName(), "div") && tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "paragraph")) {
+ // <div type="paragraph" sID... />
+ if (tag.getAttribute("sID")) { // non-empty start tag
+ u->outputNewline(buf);
+ }
+ // <div type="paragraph" eID... />
+ else if (tag.getAttribute("eID")) {
+ u->outputNewline(buf);
+ }
+ }
+
+ // <reference> tag
+ else if (!strcmp(tag.getName(), "reference")) {
+ if (!u->inXRefNote) { // only show these if we're not in an xref note
+ if (!tag.isEndTag()) {
+ SWBuf target;
+ SWBuf work;
+ SWBuf ref;
+ bool is_scripRef = false;
+
+ target = tag.getAttribute("osisRef");
+ const char* the_ref = strchr(target, ':');
+
+ if(!the_ref) {
+ // No work
+ ref = target;
+ is_scripRef = true;
+ }
+ else {
+ // Compensate for starting :
+ ref = the_ref + 1;
+
+ int size = target.size() - ref.size() - 1;
+ work.setSize(size);
+ strncpy(work.getRawData(), target, size);
+
+ // For Bible:Gen.3.15 or Bible.vulgate:Gen.3.15
+ if(!strncmp(work, "Bible", 5))
+ is_scripRef = true;
+ }
+
+ if(is_scripRef)
+ {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=\">",
+ URL::encode(ref.c_str()).c_str()
+// (work.size()) ? URL::encode(work.c_str()).c_str() : "")
+ );
+ }
+ else
+ {
+ // Dictionary link, or something
+ buf.appendFormatted("<a href=\"sword://%s/%s\">",
+ URL::encode(work.c_str()).c_str(),
+ URL::encode(ref.c_str()).c_str()
+ );
+ }
+ }
+ else {
+ outText("</a>", buf, u);
+ }
+ }
+ }
+
+ // <l> poetry, etc
+ else if (!strcmp(tag.getName(), "l")) {
+ // start line marker
+ if (tag.getAttribute("sID") || (!tag.isEndTag() && !tag.isEmpty())) {
+ // nested lines plus if the line itself has an x-indent type attribute value
+ outText(SWBuf("<span class=\"line indent").appendFormatted("%d\">", u->lineStack->size() + (SWBuf("x-indent") == tag.getAttribute("type")?1:0)).c_str(), buf, u);
+ u->lineStack->push(tag.toString());
+ }
+ // end line marker
+ else if (tag.getAttribute("eID") || tag.isEndTag()) {
+ outText("</span>", buf, u);
+ u->outputNewline(buf);
+ if (u->lineStack->size()) u->lineStack->pop();
+ }
+ // <l/> without eID or sID
+ // Note: this is improper osis. This should be <lb/>
+ else if (tag.isEmpty() && !tag.getAttribute("sID")) {
+ u->outputNewline(buf);
+ }
+ }
+
+ // <lb.../>
+ else if (!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) {
+ u->outputNewline(buf);
+ }
+ // <milestone type="line"/>
+ // <milestone type="x-p"/>
+ // <milestone type="cQuote" marker="x"/>
+ else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type"))) {
+ if (!strcmp(tag.getAttribute("type"), "line")) {
+ u->outputNewline(buf);
+ if (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-PM")) {
+ u->outputNewline(buf);
+ }
+ }
+ else if (!strcmp(tag.getAttribute("type"),"x-p")) {
+ if (tag.getAttribute("marker"))
+ outText(tag.getAttribute("marker"), buf, u);
+ else outText("<!p>", buf, u);
+ }
+ else if (!strcmp(tag.getAttribute("type"), "cQuote")) {
+ const char *tmp = tag.getAttribute("marker");
+ bool hasMark = tmp;
+ SWBuf mark = tmp;
+ tmp = tag.getAttribute("level");
+ int level = (tmp) ? atoi(tmp) : 1;
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ // finally, alternate " and ', if config says we should supply a mark
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+ }
+ }
+
+ // <title>
+ else if (!strcmp(tag.getName(), "title")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ if (vkey && !vkey->getVerse()) {
+ if (!vkey->getChapter()) {
+ if (!vkey->getBook()) {
+ if (!vkey->getTestament()) {
+ buf += "<h1 class=\"moduleHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ else {
+ buf += "<h1 class=\"testamentHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ }
+ else {
+ buf += "<h1 class=\"bookHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ }
+ else {
+ buf += "<h2 class=\"chapterHeader\">";
+ tag.setAttribute("pushed", "h2");
+ }
+ }
+ else {
+ buf += "<h3>";
+ tag.setAttribute("pushed", "h3");
+ }
+ u->titleStack->push(tag.toString());
+ }
+ else if (tag.isEndTag()) {
+ if (!u->titleStack->empty()) {
+ XMLTag tag(u->titleStack->top());
+ if (u->titleStack->size()) u->titleStack->pop();
+ SWBuf pushed = tag.getAttribute("pushed");
+ if (pushed.size()) {
+ buf += (SWBuf)"</" + pushed + ">\n\n";
+ }
+ else {
+ buf += "</h3>\n\n";
+ }
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+ }
+
+ // <list>
+ else if (!strcmp(tag.getName(), "list")) {
+ if((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("<ul>\n", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</ul>\n", buf, u);
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+
+ // <item>
+ else if (!strcmp(tag.getName(), "item")) {
+ if((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("\t<li>", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</li>\n", buf, u);
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+ // <catchWord> & <rdg> tags (italicize)
+ else if (!strcmp(tag.getName(), "rdg") || !strcmp(tag.getName(), "catchWord")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("<i>", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</i>", buf, u);
+ }
+ }
+
+ // divineName
+ else if (!strcmp(tag.getName(), "divineName")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ u->suspendTextPassThru = (++u->suspendLevel);
+ }
+ else if (tag.isEndTag()) {
+ SWBuf lastText = u->lastSuspendSegment.c_str();
+ u->suspendTextPassThru = (--u->suspendLevel);
+ if (lastText.size()) {
+ scratch.setFormatted("<span class=\"divineName\">%s</span>", lastText.c_str());
+ outText(scratch.c_str(), buf, u);
+ }
+ }
+ }
+
+ // <hi> text highlighting
+ else if (!strcmp(tag.getName(), "hi")) {
+ SWBuf type = tag.getAttribute("type");
+
+ // handle tei rend attribute if type doesn't exist
+ if (!type.length()) type = tag.getAttribute("rend");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold" || type == "b" || type == "x-b") {
+ outText("<b>", buf, u);
+ }
+
+ // there is no officially supported OSIS overline attribute,
+ // thus either TEI overline or OSIS x-overline would be best,
+ // but we have used "ol" in the past, as well. Once a valid
+ // OSIS overline attribute is made available, these should all
+ // eventually be deprecated and never documented that they are supported.
+ else if (type == "ol" || type == "overline" || type == "x-overline") {
+ outText("<span style=\"text-decoration:overline\">", buf, u);
+ }
+
+ else if (type == "super") {
+ outText("<span class=\"sup\">", buf, u);
+ }
+ else if (type == "sub") {
+ outText("<span class=\"sub\">", buf, u);
+ }
+ else { // all other types
+ outText("<i>", buf, u);
+ }
+ u->hiStack->push(tag.toString());
+ }
+ else if (tag.isEndTag()) {
+ SWBuf type = "";
+ if (!u->hiStack->empty()) {
+ XMLTag tag(u->hiStack->top());
+ if (u->hiStack->size()) u->hiStack->pop();
+ type = tag.getAttribute("type");
+ if (!type.length()) type = tag.getAttribute("rend");
+ }
+ if (type == "bold" || type == "b" || type == "x-b") {
+ outText("</b>", buf, u);
+ }
+ else if ( type == "ol"
+ || type == "super"
+ || type == "sub") {
+ outText("</span>", buf, u);
+ }
+ else outText("</i>", buf, u);
+ }
+ }
+
+ // <q> quote
+ // Rules for a quote element:
+ // If the tag is empty with an sID or an eID then use whatever it specifies for quoting.
+ // Note: empty elements without sID or eID are ignored.
+ // If the tag is <q> then use it's specifications and push it onto a stack for </q>
+ // If the tag is </q> then use the pushed <q> for specification
+ // If there is a marker attribute, possibly empty, this overrides osisQToTick.
+ // If osisQToTick, then output the marker, using level to determine the type of mark.
+ else if (!strcmp(tag.getName(), "q")) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf who = tag.getAttribute("who");
+ const char *tmp = tag.getAttribute("level");
+ int level = (tmp) ? atoi(tmp) : 1;
+ tmp = tag.getAttribute("marker");
+ bool hasMark = tmp;
+ SWBuf mark = tmp;
+
+ // open <q> or <q sID... />
+ if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("sID"))) {
+ // if <q> then remember it for the </q>
+ if (!tag.isEmpty()) {
+ u->quoteStack->push(tag.toString());
+ }
+
+ // Do this first so quote marks are included as WoC
+ if (who == "Jesus")
+ outText(u->wordsOfChristStart, buf, u);
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ //alternate " and '
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+ }
+ // close </q> or <q eID... />
+ else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("eID"))) {
+ // if it is </q> then pop the stack for the attributes
+ if (tag.isEndTag() && !u->quoteStack->empty()) {
+ XMLTag qTag(u->quoteStack->top());
+ if (u->quoteStack->size()) u->quoteStack->pop();
+
+ type = qTag.getAttribute("type");
+ who = qTag.getAttribute("who");
+ tmp = qTag.getAttribute("level");
+ level = (tmp) ? atoi(tmp) : 1;
+ tmp = qTag.getAttribute("marker");
+ hasMark = tmp;
+ mark = tmp;
+ }
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ // finally, alternate " and ', if config says we should supply a mark
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+
+ // Do this last so quote marks are included as WoC
+ if (who == "Jesus")
+ outText(u->wordsOfChristEnd, buf, u);
+ }
+ }
+
+ // <transChange>
+ else if (!strcmp(tag.getName(), "transChange")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf type = tag.getAttribute("type");
+ u->lastTransChange = type;
+
+ // just do all transChange tags this way for now
+ if ((type == "added") || (type == "supplied"))
+ outText("<span class=\"transChangeSupplied\">", buf, u);
+ else if (type == "tenseChange")
+ buf += "*";
+ }
+ else if (tag.isEndTag()) {
+ SWBuf type = u->lastTransChange;
+ if ((type == "added") || (type == "supplied"))
+ outText("</span>", buf, u);
+ }
+ else { // empty transChange marker?
+ }
+ }
+
+ // image
+ else if (!strcmp(tag.getName(), "figure")) {
+ const char *src = tag.getAttribute("src");
+ if (src) { // assert we have a src attribute
+ SWBuf filepath;
+ if (userData->module) {
+ filepath = userData->module->getConfigEntry("AbsoluteDataPath");
+ if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (src[0] != '/'))
+ filepath += '/';
+ }
+ filepath += src;
+
+ // images become clickable, if the UI supports showImage.
+ outText("<a href=\"passagestudy.jsp?action=showImage&value=", buf, u);
+ outText(URL::encode(filepath.c_str()).c_str(), buf, u);
+ outText("&module=", buf, u);
+ outText(URL::encode(u->version.c_str()).c_str(), buf, u);
+ outText("\">", buf, u);
+
+ outText("<img src=\"file:", buf, u);
+ outText(filepath, buf, u);
+ outText("\" border=\"0\" />", buf, u);
+
+ outText("</a>", buf, u);
+ }
+ }
+
+ // ok to leave these in
+ else if (!strcmp(tag.getName(), "div")) {
+ SWBuf type = tag.getAttribute("type");
+ if (type == "bookGroup") {
+ }
+ else if (type == "book") {
+ }
+ else if (type == "section") {
+ }
+ else if (type == "majorSection") {
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else if (!strcmp(tag.getName(), "span")) {
+ buf += tag;
+ }
+ else if (!strcmp(tag.getName(), "br")) {
+ buf += tag;
+ }
+ else if (!strcmp(tag.getName(), "table")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<table><tbody>\n";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</tbody></table>\n";
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+
+ }
+ else if (!strcmp(tag.getName(), "row")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "\t<tr>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</tr>\n";
+ }
+
+ }
+ else if (!strcmp(tag.getName(), "cell")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<td>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</td>";
+ }
+ }
+ else {
+ if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
+ return false; // we still didn't handle token
+ }
+ }
+ if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisxlit.cpp b/src/modules/filters/osisxlit.cpp
new file mode 100644
index 0000000..d5ccbe4
--- /dev/null
+++ b/src/modules/filters/osisxlit.cpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ *
+ * osisxlit.cpp - SWFilter descendant to hide or show xlit values
+ * (encoded transliterations) in an OSIS module
+ *
+ * $Id: osisxlit.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisxlit.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Transliterated Forms";
+ static const char oTip[] = "Toggles transliterated forms On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISXlit::OSISXlit() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISXlit::~OSISXlit() {
+}
+
+
+char OSISXlit::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("xlit");
+ if (l) {
+ wtag.setAttribute("xlit", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/papyriplain.cpp b/src/modules/filters/papyriplain.cpp
index 782b52a..bf6c9dd 100644
--- a/src/modules/filters/papyriplain.cpp
+++ b/src/modules/filters/papyriplain.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
*
- * papyriplain - SWFilter descendant to strip out all Papyri tags
+ * papyriplain.cpp - SWFilter descendant to strip out all Papyri tags
*
+ * $Id: papyriplain.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,6 +25,7 @@
SWORD_NAMESPACE_START
+
PapyriPlain::PapyriPlain() {
}
diff --git a/src/modules/filters/plainfootnotes.cpp b/src/modules/filters/plainfootnotes.cpp
deleted file mode 100644
index 449f7da..0000000
--- a/src/modules/filters/plainfootnotes.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/***************************************************************************
- * plainfootnotes.cpp - description
- * -------------------
- * begin : Wed Oct 13 1999
- * copyright : (C) 1999 by The team of BibleTime
- * email : info@bibletime.de
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <plainfootnotes.h>
-#include <swkey.h>
-
-#include <stdlib.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off In Bible Texts If They Exist";
-
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-PLAINFootnotes::PLAINFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-PLAINFootnotes::~PLAINFootnotes(){
-}
-
-
-char PLAINFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) { // if we don't want footnotes
- //char token[2048];
- //SWBuf token;
- //int tokpos = 0;
- //bool intoken = false;
- //bool lastspace = false;
-
- bool hide = false;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '{') // Footnote start
- {
- hide = true;
- continue;
- }
- else if (*from == '}') // Footnote end
- {
- hide = false;
- continue;
- }
-
- //if (intoken) {
- //if (tokpos < 2045)
- // token += *from;
- // token[tokpos+2] = 0;
- //}
- //else {
- if (!hide) {
- text = *from;
- //lastspace = (*from == ' ');
- }
- //}
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/plainhtml.cpp b/src/modules/filters/plainhtml.cpp
deleted file mode 100644
index 3f989fa..0000000
--- a/src/modules/filters/plainhtml.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/***************************************************************************
- * plainhtml.cpp - description
- * -------------------
- * begin : Thu Jun 24 1999
- * copyright : (C) 1999 by Torsten Uhlmann
- * email : TUhlmann@gmx.de
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <plainhtml.h>
-#include <swbuf.h>
-
-SWORD_NAMESPACE_START
-
-PLAINHTML::PLAINHTML()
-{
-}
-
-
-char PLAINHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
-{
- int count = 0;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph
- {
- text += "<P>";
- from++;
- continue;
- } else {
- if ((*from == '\n')) // && (from[1] != '\n')) // only one new line
- {
- text += "<BR>";
- continue;
- }
- }
-
- if (*from == '{') { //footnote start
- text += "<FONT COLOR=\"#80000\"><SMALL> (";
- continue;
- }
- else if (*from == '}') //footnote end
- {
- text += ") </SMALL></FONT>";
- continue;
- }
- else if (*from == '<') {
- text += "&lt;";
- continue;
- }
- else if (*from == '>') {
- text += "&gt;";
- continue;
- }
- else if (*from == '&') {
- text += "&amp;";
- continue;
- }
- else if ((*from == ' ') && (count > 5000))
- {
- text += "<WBR>";
- count = 0;
- continue;
- }
-
- text += *from;
- count++;
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/rtfhtml.cpp b/src/modules/filters/rtfhtml.cpp
index 7b55721..df02f38 100644
--- a/src/modules/filters/rtfhtml.cpp
+++ b/src/modules/filters/rtfhtml.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * rtfhtml.cpp - description
- * -------------------
- * begin : Wed Oct 13 1999
- * copyright : (C) 1999 by The team of BibleTime
- * email : info@bibletime.de
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * rtfhtml.cpp - filter to convert RTF to HTML
+ *
+ * $Id: rtfhtml.cpp 2981 2013-09-15 00:05:26Z scribe $
+ *
+ * Copyright 1999 The team of Bibletime (info@bibletime.de)
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,11 +24,14 @@
#include <stdlib.h>
#include <rtfhtml.h>
#include <swbuf.h>
+#include <utilstr.h>
+#include <ctype.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
-RTFHTML::RTFHTML() {
-
+RTFHTML::RTFHTML()
+{
}
@@ -43,12 +46,25 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (*from == '\\') // a RTF command
{
+ // \u12345?
+ if ( *(from+1) == 'u' && (*(from+2) == '-' || isdigit(*(from+2)))) {
+ from += 2;
+ const char *end = from;
+ while (isdigit(*++end));
+ SWBuf num;
+ num.append(from, end-from);
+ __s16 n = atoi(num.c_str());
+ __u32 u = (__u16)n;
+ text.append(getUTF8FromUniChar(u));
+ from += (end-from);
+ continue;
+ }
if ( !strncmp(from+1, "pard", 4) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
{ // switch all modifiers off
if (center)
{
- text += "</CENTER>";
+ text += "</center>";
center = false;
}
from += 4;
@@ -57,7 +73,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
if ( !strncmp(from+1, "par", 3) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
{
- text += "<P>\n";
+ text += "<p/>\n";
from += 3;
continue;
}
@@ -71,7 +87,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!center)
{
- text += "<CENTER>";
+ text += "<center>";
center = true;
}
from += 2;
diff --git a/src/modules/filters/scsuutf8.cpp b/src/modules/filters/scsuutf8.cpp
new file mode 100644
index 0000000..c68ea1f
--- /dev/null
+++ b/src/modules/filters/scsuutf8.cpp
@@ -0,0 +1,246 @@
+/******************************************************************************
+ *
+ * scsuutf8.cpp - SWFilter descendant to convert a SCSU character to
+ * UTF-8
+ *
+ * $Id: scsuutf8.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+/* This class is based on:
+ * http://czyborra.com/scsu/scsu.c written by Roman Czyborra@dds.nl
+ * on Andrea's balcony in North Amsterdam on 1998-08-04
+ * Thanks to Richard Verhoeven <rcb5@win.tue.nl> for his suggestion
+ * to correct the haphazard "if" after UQU to "else if" on 1998-10-01
+ *
+ * This is a deflator to UTF-8 output for input compressed in SCSU,
+ * the (Reuters) Standard Compression Scheme for Unicode as described
+ * in http://www.unicode.org/unicode/reports/tr6.html
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <swmodule.h>
+
+#include <scsuutf8.h>
+
+
+SWORD_NAMESPACE_START
+
+
+SCSUUTF8::SCSUUTF8() {
+}
+
+
+unsigned char* SCSUUTF8::UTF8Output(unsigned long uchar, unsigned char* text)
+{
+ /* join UTF-16 surrogates without any pairing sanity checks */
+
+ static int d;
+
+ if (uchar >= 0xd800 && uchar <= 0xdbff) { d = uchar & 0x3f; return text; }
+ if (uchar >= 0xdc00 && uchar <= 0xdfff) { uchar = uchar + 0x2400 + d * 0x400; }
+
+ /* output one character as UTF-8 multibyte sequence */
+
+ if (uchar < 0x80) {
+ *text++ = c;
+ }
+ else if (uchar < 0x800) {
+ *text++ = 0xc0 | uchar >> 6;
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+ else if (uchar < 0x10000) {
+ *text++ = 0xe0 | uchar >> 12;
+ *text++ = 0x80 | (uchar >> 6 & 0x3f);
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+ else if (uchar < 0x200000) {
+ *text++ = 0xf0 | uchar >> 18;
+ *text++ = 0x80 | (uchar >> 12 & 0x3f);
+ *text++ = 0x80 | (uchar >> 6 & 0x3f);
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+
+ return text;
+}
+
+
+char SCSUUTF8::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+/*
+ unsigned char *to, *from;
+ unsigned long buflen = len * FILTERPAD;
+ char active = 0, mode = 0;
+ if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
+ return -1;
+
+ static unsigned short start[8] = {0x0000,0x0080,0x0100,0x0300,0x2000,0x2080,0x2100,0x3000};
+ static unsigned short slide[8] = {0x0080,0x00C0,0x0400,0x0600,0x0900,0x3040,0x30A0,0xFF00};
+ static unsigned short win[256] = {
+ 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
+ 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
+ 0x0800, 0x0880, 0x0900, 0x0980, 0x0A00, 0x0A80, 0x0B00, 0x0B80,
+ 0x0C00, 0x0C80, 0x0D00, 0x0D80, 0x0E00, 0x0E80, 0x0F00, 0x0F80,
+ 0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380,
+ 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780,
+ 0x1800, 0x1880, 0x1900, 0x1980, 0x1A00, 0x1A80, 0x1B00, 0x1B80,
+ 0x1C00, 0x1C80, 0x1D00, 0x1D80, 0x1E00, 0x1E80, 0x1F00, 0x1F80,
+ 0x2000, 0x2080, 0x2100, 0x2180, 0x2200, 0x2280, 0x2300, 0x2380,
+ 0x2400, 0x2480, 0x2500, 0x2580, 0x2600, 0x2680, 0x2700, 0x2780,
+ 0x2800, 0x2880, 0x2900, 0x2980, 0x2A00, 0x2A80, 0x2B00, 0x2B80,
+ 0x2C00, 0x2C80, 0x2D00, 0x2D80, 0x2E00, 0x2E80, 0x2F00, 0x2F80,
+ 0x3000, 0x3080, 0x3100, 0x3180, 0x3200, 0x3280, 0x3300, 0x3800,
+ 0xE000, 0xE080, 0xE100, 0xE180, 0xE200, 0xE280, 0xE300, 0xE380,
+ 0xE400, 0xE480, 0xE500, 0xE580, 0xE600, 0xE680, 0xE700, 0xE780,
+ 0xE800, 0xE880, 0xE900, 0xE980, 0xEA00, 0xEA80, 0xEB00, 0xEB80,
+ 0xEC00, 0xEC80, 0xED00, 0xED80, 0xEE00, 0xEE80, 0xEF00, 0xEF80,
+ 0xF000, 0xF080, 0xF100, 0xF180, 0xF200, 0xF280, 0xF300, 0xF380,
+ 0xF400, 0xF480, 0xF500, 0xF580, 0xF600, 0xF680, 0xF700, 0xF780,
+ 0xF800, 0xF880, 0xF900, 0xF980, 0xFA00, 0xFA80, 0xFB00, 0xFB80,
+ 0xFC00, 0xFC80, 0xFD00, 0xFD80, 0xFE00, 0xFE80, 0xFF00, 0xFF80,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x00C0, 0x0250, 0x0370, 0x0530, 0x3040, 0x30A0, 0xFF60
+ };
+
+ if (!len)
+ return 0;
+
+ memmove(&text[buflen - len], text, len);
+ from = (unsigned char*)&text[buflen - len];
+ to = (unsigned char *)text;
+
+ // -------------------------------
+
+ for (int i = 0; i < len;) {
+
+
+ if (i >= len) break;
+ c = from[i++];
+
+ if (c >= 0x80)
+ {
+ to = UTF8Output (c - 0x80 + slide[active], to);
+ }
+ else if (c >= 0x20 && c <= 0x7F)
+ {
+ to = UTF8Output (c, to);
+ }
+ else if (c == 0x0 || c == 0x9 || c == 0xA || c == 0xC || c == 0xD)
+ {
+ to = UTF8Output (c, to);
+ }
+ else if (c >= 0x1 && c <= 0x8) // SQn
+ {
+ if (i >= len) break;
+ d = from[i++]; // single quote
+
+ to = UTF8Output (d < 0x80 ? d + start [c - 0x1] :
+ d - 0x80 + slide [c - 0x1], to);
+ }
+ else if (c >= 0x10 && c <= 0x17) // SCn
+ {
+ active = c - 0x10; // change window
+ }
+ else if (c >= 0x18 && c <= 0x1F) // SDn
+ {
+ active = c - 0x18; // define window
+ if (i >= len) break;
+ slide [active] = win [from[i++]];
+ }
+ else if (c == 0xB) // SDX
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ d = from[i++];
+
+ slide [active = c>>5] = 0x10000 + (((c & 0x1F) << 8 | d) << 7);
+ }
+ else if (c == 0xE) // SQU
+ {
+ if (i >= len) break;
+ c = from[i++]; // SQU
+
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c == 0xF) // SCU
+ {
+ mode = 1; // change to Unicode mode
+
+ while (mode)
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (c <= 0xDF || c >= 0xF3)
+ {
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c == 0xF0) // UQU
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c >= 0xE0 && c <= 0xE7) // UCn
+ {
+ active = c - 0xE0; mode = 0;
+ }
+ else if (c >= 0xE8 && c <= 0xEF) // UDn
+ {
+ if (i >= len) break;
+ slide [active=c-0xE8] = win [from[i++]]; mode = 0;
+ }
+ else if (c == 0xF1) // UDX
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ d = from[i++];
+
+ slide [active = c>>5] =
+ 0x10000 + (((c & 0x1F) << 8 | d) << 7); mode = 0;
+ }
+ }
+ }
+
+
+ }
+
+ *to++ = 0;
+ *to = 0;
+*/
+ return 0;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/swbasicfilter.cpp b/src/modules/filters/swbasicfilter.cpp
index ef10e45..e66017e 100644
--- a/src/modules/filters/swbasicfilter.cpp
+++ b/src/modules/filters/swbasicfilter.cpp
@@ -1,12 +1,13 @@
/******************************************************************************
- * swbasicfilter.h - definition of class SWBasicFilter. An SWFilter
- * impl that provides some basic methods that
- * many filters will need and can use as a starting
- * point.
*
- * $Id: swbasicfilter.cpp 2167 2008-05-16 23:23:39Z scribe $
+ * swbasicfilter.cpp - definition of class SWBasicFilter. An SWFilter
+ * impl that provides some basic methods that
+ * many filters will need and can use as a starting
+ * point.
*
- * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swbasicfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,9 +34,11 @@
SWORD_NAMESPACE_START
+
typedef std::map<SWBuf, SWBuf> DualStringMap;
typedef std::set<SWBuf> StringSet;
+
// I hate bridge patterns but this isolates std::map from a ton of filters
class SWBasicFilter::Private {
public:
@@ -44,11 +47,13 @@ public:
StringSet escPassSet;
};
+
const char SWBasicFilter::INITIALIZE = 1;
const char SWBasicFilter::PRECHAR = 2;
const char SWBasicFilter::POSTCHAR = 4;
const char SWBasicFilter::FINALIZE = 8;
+
SWBasicFilter::SWBasicFilter() {
p = new Private;
@@ -98,6 +103,7 @@ void SWBasicFilter::setPassThruUnknownEscapeString(bool val) {
passThruUnknownEsc = val;
}
+
void SWBasicFilter::setPassThruNumericEscapeString(bool val) {
passThruUnknownEsc = val;
}
@@ -132,6 +138,7 @@ void SWBasicFilter::removeTokenSubstitute(const char *findString) {
}
}
+
void SWBasicFilter::addAllowedEscapeString(const char *findString) {
char *buf = 0;
@@ -144,12 +151,14 @@ void SWBasicFilter::addAllowedEscapeString(const char *findString) {
else p->escPassSet.insert(StringSet::value_type(findString));
}
+
void SWBasicFilter::removeAllowedEscapeString(const char *findString) {
if (p->escPassSet.find(findString) != p->escPassSet.end()) {
p->escPassSet.erase( p->escPassSet.find(findString) );
}
}
+
void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char *replaceString) {
char *buf = 0;
@@ -162,12 +171,14 @@ void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char
else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
}
+
void SWBasicFilter::removeEscapeStringSubstitute(const char *findString) {
if (p->escSubMap.find(findString) != p->escSubMap.end()) {
p->escSubMap.erase( p->escSubMap.find(findString) );
}
}
+
bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
DualStringMap::iterator it;
@@ -187,12 +198,14 @@ bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
return false;
}
+
void SWBasicFilter::appendEscapeString(SWBuf &buf, const char *escString) {
buf += escStart;
buf += escString;
buf += escEnd;
}
+
bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
StringSet::iterator it;
@@ -213,6 +226,7 @@ bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
return false;
}
+
bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString) {
if (passThruNumericEsc) {
appendEscapeString(buf, escString);
@@ -221,6 +235,7 @@ bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString)
return false;
}
+
bool SWBasicFilter::substituteEscapeString(SWBuf &buf, const char *escString) {
DualStringMap::iterator it;
@@ -403,4 +418,5 @@ char SWBasicFilter::processText(SWBuf &text, const SWKey *key, const SWModule *m
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/swoptfilter.cpp b/src/modules/filters/swoptfilter.cpp
index 9d6dac4..5c205f5 100644
--- a/src/modules/filters/swoptfilter.cpp
+++ b/src/modules/filters/swoptfilter.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * swoptfilter - SWFilter descendant and base class for all option filters
+ * swoptfilter.cpp - SWFilter descendant and base class for all option
+ * filters
*
+ * $Id: swoptfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,10 +35,13 @@ SWOptionFilter::SWOptionFilter() {
optValues = &empty;
}
+
SWOptionFilter::SWOptionFilter(const char *oName, const char *oTip, const StringList *oValues) {
optName = oName;
optTip = oTip;
optValues = oValues;
+ if (optValues->begin() != optValues->end()) setOptionValue(*(optValues->begin()));
+ isBooleanVal = optValues->size() == 2 && (optionValue == "On" || optionValue == "Off");
}
diff --git a/src/modules/filters/teihtmlhref.cpp b/src/modules/filters/teihtmlhref.cpp
index 47bb7b9..43fe584 100644
--- a/src/modules/filters/teihtmlhref.cpp
+++ b/src/modules/filters/teihtmlhref.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * teirtf.cpp - TEI to HTMLHREF filter
- * -------------------
- * begin : 2006-07-03
- * copyright : 2006 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * teihtmlhref.cpp - TEI to HTML with hrefs filter
+ *
+ * $Id: teihtmlhref.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2008-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -35,8 +35,8 @@ SWORD_NAMESPACE_START
TEIHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
BiblicalText = false;
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
}
@@ -57,6 +57,8 @@ TEIHTMLHREF::TEIHTMLHREF() {
addAllowedEscapeString("gt");
setTokenCaseSensitive(true);
+
+ renderNoteNumbers = false;
}
bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
@@ -259,11 +261,13 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
}
if (tag.isEndTag()) {
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(u->key->getText()).c_str());
+ URL::encode(u->key->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
u->suspendTextPassThru = false;
}
diff --git a/src/modules/filters/teiplain.cpp b/src/modules/filters/teiplain.cpp
index 90b7c7c..954beb4 100644
--- a/src/modules/filters/teiplain.cpp
+++ b/src/modules/filters/teiplain.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * teiplain.cpp - TEI to Plaintext filter
- * -------------------
- * begin : 2006-07-05
- * copyright : 2006 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * teiplain.cpp - TEI to Plaintext filter
+ *
+ * $Id: teiplain.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/teirtf.cpp b/src/modules/filters/teirtf.cpp
index 8e135b5..979e4a6 100644
--- a/src/modules/filters/teirtf.cpp
+++ b/src/modules/filters/teirtf.cpp
@@ -1,208 +1,208 @@
-/***************************************************************************
- * teirtf.cpp - TEI to RTF filter
- * -------------------
- * begin : 2006-07-03
- * copyright : 2006 by CrossWire Bible Society
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <teirtf.h>
-#include <utilxml.h>
-#include <swmodule.h>
-#include <versekey.h>
-
-SWORD_NAMESPACE_START
-
-
-TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- BiblicalText = false;
- inOsisRef = false;
- if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
- }
-}
-
-
-TEIRTF::TEIRTF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
-
- addEscapeStringSubstitute("amp", "&");
- addEscapeStringSubstitute("apos", "'");
- addEscapeStringSubstitute("lt", "<");
- addEscapeStringSubstitute("gt", ">");
- addEscapeStringSubstitute("quot", "\"");
-
- setTokenCaseSensitive(true);
-}
-
-
-bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- // manually process if it wasn't a simple substitution
- if (!substituteToken(buf, token)) {
- MyUserData *u = (MyUserData *)userData;
- XMLTag tag(token);
-
- // <p> paragraph tag
- if (!strcmp(tag.getName(), "p")) {
- if (!tag.isEndTag()) { // non-empty start tag
- buf += "{\\sb100\\fi200\\par}";
- }
- }
-
- // <hi>
- else if (!strcmp(tag.getName(), "hi") || !strcmp(tag.getName(), "emph")) {
- SWBuf rend = tag.getAttribute("rend");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (rend == "ital" || rend == "italic")
- buf += "{\\i1 ";
- else if (rend == "bold")
- buf += "{\\b1 ";
- else if (rend == "sup")
- buf += "{\\super ";
-
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <entryFree>
- else if (!strcmp(tag.getName(), "entryFree")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\b1 ";
- buf += n;
- buf += ". }"; }
- }
- }
-
- // <sense>
- else if (!strcmp(tag.getName(), "sense")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\sb100\\par\\b1 ";
- buf += n;
- buf += ". }";
- }
- }
- }
-
- // <div>
- else if (!strcmp(tag.getName(), "div")) {
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf.append("{\\pard\\sa300}");
- }
- else if (tag.isEndTag()) {
- }
- }
-
- // <pos>, <gen>, <case>, <gram>, <number>, <mood>
- else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <tr>
- else if (!strcmp(tag.getName(), "tr")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <etym>
- else if (!strcmp(tag.getName(), "etym")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "[";
- }
- else if (tag.isEndTag()) {
- buf += "]";
- }
- }
-
- // <note> tag
- else if (!strcmp(tag.getName(), "note")) {
- if (!tag.isEndTag()) {
- if (!tag.isEmpty()) {
- SWBuf type = tag.getAttribute("type");
-
- SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- VerseKey *vkey = 0;
- // see if we have a VerseKey * or descendant
- SWTRY {
- vkey = SWDYNAMIC_CAST(VerseKey, u->key);
- }
- SWCATCH ( ... ) { }
- if (vkey) {
- buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
- }
- u->suspendTextPassThru = true;
- }
- }
- if (tag.isEndTag()) {
- u->suspendTextPassThru = false;
- }
- }
-
- // <lb/> tag
- else if (!strcmp(tag.getName(), "lb")) {
- buf += "{\\par}";
- userData->supressAdjacentWhitespace = true;
- }
-
- // <ref> tag
- else if (!strcmp(tag.getName(), "ref")) {
- if (!tag.isEndTag() && tag.getAttribute("osisRef")) {
- buf += "{<a href=\"\">";
- u->inOsisRef = true;
- }
- else if (tag.isEndTag() && u->inOsisRef) {
- buf += "</a>}";
- u->inOsisRef = false;
- }
- }
-
-
- else {
- return false; // we still didn't handle token
- }
-
- }
- return true;
-}
-
-
-SWORD_NAMESPACE_END
-
+/***************************************************************************
+ *
+ * teirtf.cpp - TEI to RTF filter
+ *
+ * $Id: teirtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <teirtf.h>
+#include <utilxml.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+
+TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ BiblicalText = false;
+ inOsisRef = false;
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+}
+
+
+TEIRTF::TEIRTF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+
+ addEscapeStringSubstitute("amp", "&");
+ addEscapeStringSubstitute("apos", "'");
+ addEscapeStringSubstitute("lt", "<");
+ addEscapeStringSubstitute("gt", ">");
+ addEscapeStringSubstitute("quot", "\"");
+
+ setTokenCaseSensitive(true);
+}
+
+
+bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+ if (!substituteToken(buf, token)) {
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+
+ // <p> paragraph tag
+ if (!strcmp(tag.getName(), "p")) {
+ if (!tag.isEndTag()) { // non-empty start tag
+ buf += "{\\sb100\\fi200\\par}";
+ }
+ }
+
+ // <hi>
+ else if (!strcmp(tag.getName(), "hi") || !strcmp(tag.getName(), "emph")) {
+ SWBuf rend = tag.getAttribute("rend");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (rend == "ital" || rend == "italic")
+ buf += "{\\i1 ";
+ else if (rend == "bold")
+ buf += "{\\b1 ";
+ else if (rend == "sup")
+ buf += "{\\super ";
+
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <entryFree>
+ else if (!strcmp(tag.getName(), "entryFree")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\b1 ";
+ buf += n;
+ buf += ". }"; }
+ }
+ }
+
+ // <sense>
+ else if (!strcmp(tag.getName(), "sense")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\sb100\\par\\b1 ";
+ buf += n;
+ buf += ". }";
+ }
+ }
+ }
+
+ // <div>
+ else if (!strcmp(tag.getName(), "div")) {
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf.append("{\\pard\\sa300}");
+ }
+ else if (tag.isEndTag()) {
+ }
+ }
+
+ // <pos>, <gen>, <case>, <gram>, <number>, <mood>
+ else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <tr>
+ else if (!strcmp(tag.getName(), "tr")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <etym>
+ else if (!strcmp(tag.getName(), "etym")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "[";
+ }
+ else if (tag.isEndTag()) {
+ buf += "]";
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf type = tag.getAttribute("type");
+
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ VerseKey *vkey = 0;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ // <lb/> tag
+ else if (!strcmp(tag.getName(), "lb")) {
+ buf += "{\\par}";
+ userData->supressAdjacentWhitespace = true;
+ }
+
+ // <ref> tag
+ else if (!strcmp(tag.getName(), "ref")) {
+ if (!tag.isEndTag() && tag.getAttribute("osisRef")) {
+ buf += "{<a href=\"\">";
+ u->inOsisRef = true;
+ }
+ else if (tag.isEndTag() && u->inOsisRef) {
+ buf += "</a>}";
+ u->inOsisRef = false;
+ }
+ }
+
+
+ else {
+ return false; // we still didn't handle token
+ }
+
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/teixhtml.cpp b/src/modules/filters/teixhtml.cpp
new file mode 100644
index 0000000..6a390a1
--- /dev/null
+++ b/src/modules/filters/teixhtml.cpp
@@ -0,0 +1,290 @@
+/***************************************************************************
+ *
+ * teixhtml.cpp - TEI to XHTML filter
+ *
+ * $Id: teixhtml.cpp 2984 2013-09-20 12:18:45Z scribe $
+ *
+ * Copyright 2012-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <teixhtml.h>
+#include <utilxml.h>
+#include <swmodule.h>
+#include <url.h>
+#include <iostream>
+
+
+SWORD_NAMESPACE_START
+
+
+TEIXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ BiblicalText = false;
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+}
+
+
+TEIXHTML::TEIXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ renderNoteNumbers = false;
+}
+
+bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+ if (!substituteToken(buf, token)) {
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+
+ if (!strcmp(tag.getName(), "p")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
+ buf += "<!P><br />";
+ }
+ else if (tag.isEndTag()) { // end tag
+ buf += "<!/P><br />";
+ //userData->supressAdjacentWhitespace = true;
+ }
+ else { // empty paragraph break marker
+ buf += "<!P><br />";
+ //userData->supressAdjacentWhitespace = true;
+ }
+ }
+
+ // <hi>
+ else if (!strcmp(tag.getName(), "hi")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf rend = tag.getAttribute("rend");
+
+ u->lastHi = rend;
+ if (rend == "ital")
+ buf += "<i>";
+ else if (rend == "italic")
+ buf += "<i>";
+ else if (rend == "bold")
+ buf += "<b>";
+ else if (rend == "sup")
+ buf += "<small><sup>";
+ else if (rend == "overline")
+ buf += "<span style=\"text-decoration:overline\">";
+
+ }
+ else if (tag.isEndTag()) {
+ SWBuf rend = u->lastHi;
+ if (rend == "ital")
+ buf += "</i>";
+ else if (rend == "italic")
+ buf += "</i>";
+ else if (rend == "bold")
+ buf += "</b>";
+ else if (rend == "sup")
+ buf += "</sup></small>";
+ else if (rend == "overline")
+ buf += "</span>";
+ }
+ }
+
+ // <entryFree>
+ else if (!strcmp(tag.getName(), "entryFree")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf n = tag.getAttribute("n");
+ if (n != "") {
+ buf += "<b>";
+ buf += n;
+ buf += "</b>";
+ }
+ }
+ }
+
+ // <sense>
+ else if (!strcmp(tag.getName(), "sense")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf n = tag.getAttribute("n");
+ if (n != "") {
+ buf += "<br /><b>";
+ buf += n;
+ buf += "</b>";
+ }
+ }
+ }
+
+ // <div>
+ else if (!strcmp(tag.getName(), "div")) {
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<!P>";
+ }
+ else if (tag.isEndTag()) {
+ }
+ }
+
+ // <lb.../>
+ else if (!strcmp(tag.getName(), "lb")) {
+ buf += "<br />";
+ }
+
+ // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
+ else if (!strcmp(tag.getName(), "pos") ||
+ !strcmp(tag.getName(), "gen") ||
+ !strcmp(tag.getName(), "case") ||
+ !strcmp(tag.getName(), "gram") ||
+ !strcmp(tag.getName(), "number") ||
+ !strcmp(tag.getName(), "pron") /*||
+ !strcmp(tag.getName(), "def")*/) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<i>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</i>";
+ }
+ }
+
+ // <tr>
+ else if (!strcmp(tag.getName(), "tr")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<i>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</i>";
+ }
+ }
+
+ // orth
+ else if (!strcmp(tag.getName(), "orth")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<b>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</b>";
+ }
+ }
+
+ // <etym>, <usg>
+ else if (!strcmp(tag.getName(), "etym") ||
+ !strcmp(tag.getName(), "usg")) {
+ // do nothing here
+ }
+ else if (!strcmp(tag.getName(), "ref")) {
+ if (!tag.isEndTag()) {
+ u->suspendTextPassThru = true;
+ SWBuf target;
+ SWBuf work;
+ SWBuf ref;
+
+ int was_osisref = false;
+ if(tag.getAttribute("osisRef"))
+ {
+ target += tag.getAttribute("osisRef");
+ was_osisref=true;
+ }
+ else if(tag.getAttribute("target"))
+ target += tag.getAttribute("target");
+
+ if(target.size())
+ {
+ const char* the_ref = strchr(target, ':');
+
+ if(!the_ref) {
+ // No work
+ ref = target;
+ }
+ else {
+ // Compensate for starting :
+ ref = the_ref + 1;
+
+ int size = target.size() - ref.size() - 1;
+ work.setSize(size);
+ strncpy(work.getRawData(), target, size);
+ }
+
+ if(was_osisref)
+ {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
+ (ref) ? URL::encode(ref.c_str()).c_str() : "",
+ (work.size()) ? URL::encode(work.c_str()).c_str() : "");
+ }
+ else
+ {
+ // Dictionary link, or something
+ buf.appendFormatted("<a href=\"sword://%s/%s\">",
+ (work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
+ (ref) ? URL::encode(ref.c_str()).c_str() : ""
+ );
+ }
+ }
+ else
+ {
+ //std::cout << "TARGET WASN'T\n";
+ }
+
+ }
+ else {
+ buf += u->lastTextNode.c_str();
+ buf += "</a>";
+
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ else {
+ return false; // we still didn't handle token
+ }
+
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/thmlfootnotes.cpp b/src/modules/filters/thmlfootnotes.cpp
index e75311a..566551f 100644
--- a/src/modules/filters/thmlfootnotes.cpp
+++ b/src/modules/filters/thmlfootnotes.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlfootnotes - SWFilter descendant to hide or show footnotes
- * in a ThML module.
+ * thmlfootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in a ThML module
*
+ * $Id: thmlfootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,16 +31,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLFootnotes::ThMLFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLFootnotes::ThMLFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -56,7 +64,7 @@ char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -101,7 +109,7 @@ char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
startTag.setAttribute("swordFootnote", buf);
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
if (!refs.length())
- refs = parser->ParseVerseList(tagText.c_str(), *parser, true).getRangeText();
+ refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
diff --git a/src/modules/filters/thmlgbf.cpp b/src/modules/filters/thmlgbf.cpp
index e2e8e1c..e85fdef 100644
--- a/src/modules/filters/thmlgbf.cpp
+++ b/src/modules/filters/thmlgbf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlgbf.cpp - ThML to GBF filter
- * -------------------
- * begin : 1999-10-28
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlgbf.cpp - ThML to GBF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlgbf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/thmlheadings.cpp b/src/modules/filters/thmlheadings.cpp
index e2b7c97..46498d0 100644
--- a/src/modules/filters/thmlheadings.cpp
+++ b/src/modules/filters/thmlheadings.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlheadings - SWFilter descendant to hide or show headings
- * in a ThML module.
+ * thmlheadings.cpp - SWFilter descendant to hide or show headings
+ * in a ThML module
*
+ * $Id: thmlheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,16 +29,23 @@
#include <swmodule.h>
#include <stdio.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLHeadings::ThMLHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLHeadings::ThMLHeadings() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlhtml.cpp b/src/modules/filters/thmlhtml.cpp
index 4c66b87..b5f624e 100644
--- a/src/modules/filters/thmlhtml.cpp
+++ b/src/modules/filters/thmlhtml.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlhtml.cpp - ThML to HTML filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlhtml.cpp - ThML to HTML filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlhtml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,8 +25,10 @@
#include <swmodule.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
+
ThMLHTML::ThMLHTML() {
setTokenStart("<");
setTokenEnd(">");
diff --git a/src/modules/filters/thmlhtmlhref.cpp b/src/modules/filters/thmlhtmlhref.cpp
index c0887f1..f72a93e 100644
--- a/src/modules/filters/thmlhtmlhref.cpp
+++ b/src/modules/filters/thmlhtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlhtmlhref.cpp - ThML to HTML filter with hrefs
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlhtmlhref.cpp - ThML to HTML filter with hrefs
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlhtmlhref.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,13 +28,14 @@
#include <versekey.h>
#include <url.h>
+
SWORD_NAMESPACE_START
ThMLHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
SecHead = false;
}
}
@@ -160,6 +160,8 @@ ThMLHTMLHREF::ThMLHTMLHREF() {
setTokenCaseSensitive(true);
// addTokenSubstitute("scripture", "<i> ");
addTokenSubstitute("/scripture", "</i> ");
+
+ renderNoteNumbers = false;
}
@@ -206,6 +208,7 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (!tag.isEmpty()) {
SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -215,23 +218,25 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
ch,
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
URL::encode(vkey->getText()).c_str(),
ch,
- ch);
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
else {
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
ch,
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
URL::encode(u->key->getText()).c_str(),
ch,
- ch);
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
u->suspendTextPassThru = true;
}
@@ -265,6 +270,7 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
}
else {
SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -274,11 +280,11 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
//buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str());
-
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
}
diff --git a/src/modules/filters/thmllemma.cpp b/src/modules/filters/thmllemma.cpp
index 53eec58..acc324f 100644
--- a/src/modules/filters/thmllemma.cpp
+++ b/src/modules/filters/thmllemma.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmllemma - SWFilter descendant to hide or show lemmas
- * in a ThML module.
+ * thmllemma.cpp - SWFilter descendant to hide or show lemmas
+ * in a ThML module
*
+ * $Id: thmllemma.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,16 +24,23 @@
#include <stdlib.h>
#include <thmllemma.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Lemmas";
-const char oTip[] = "Toggles Lemmas On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Lemmas";
+ static const char oTip[] = "Toggles Lemmas On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLLemma::ThMLLemma() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLLemma::ThMLLemma() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlmorph.cpp b/src/modules/filters/thmlmorph.cpp
index d3cf597..3259acc 100644
--- a/src/modules/filters/thmlmorph.cpp
+++ b/src/modules/filters/thmlmorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlmorph - SWFilter descendant to hide or show morph tags
- * in a ThML module.
+ * thmlmorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a ThML module
*
+ * $Id: thmlmorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,14 +26,20 @@
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
-ThMLMorph::ThMLMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+ThMLMorph::ThMLMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlosis.cpp b/src/modules/filters/thmlosis.cpp
index 25fdf23..3acd959 100644
--- a/src/modules/filters/thmlosis.cpp
+++ b/src/modules/filters/thmlosis.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlosis.cpp - filter to convert ThML to OSIS
*
+ * $Id: thmlosis.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -540,7 +540,7 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -548,24 +548,24 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
/*
@@ -578,7 +578,7 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
}
delete tmp;
}
-// else if (vkey->Chapter()) {
+// else if (vkey->getChapter()) {
// sprintf(ref, "\t<div type=\"chapter\" osisID=\"%s\">", vkey->getOSISRef());
// }
// else sprintf(ref, "\t<div type=\"book\" osisID=\"%s\">", vkey->getOSISRef());
diff --git a/src/modules/filters/thmlplain.cpp b/src/modules/filters/thmlplain.cpp
index 8c9358f..b9b9839 100644
--- a/src/modules/filters/thmlplain.cpp
+++ b/src/modules/filters/thmlplain.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlplain - SWFilter descendant to strip out all ThML tags or convert to
- * ASCII rendered symbols.
+ * thmlplain.cpp - SWFilter descendant to strip out all ThML tags or
+ * convert to ASCII rendered symbols
*
+ * $Id: thmlplain.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/thmlrtf.cpp b/src/modules/filters/thmlrtf.cpp
index fdb41df..dc50ae9 100644
--- a/src/modules/filters/thmlrtf.cpp
+++ b/src/modules/filters/thmlrtf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlrtf.cpp - ThML to RTF filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlrtf.cpp - ThML to RTF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlrtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -215,8 +214,8 @@ ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : Basi
this->SecHead = false;
XMLTag startTag = "";
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
}
@@ -263,7 +262,7 @@ bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
+ buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->getVerse(), footnoteNumber.c_str());
}
u->suspendTextPassThru = true;
}
@@ -301,7 +300,7 @@ bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
SWCATCH ( ... ) {}
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
- buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", vkey->Verse(), footnoteNumber.c_str());
+ buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", vkey->getVerse(), footnoteNumber.c_str());
}
}
diff --git a/src/modules/filters/thmlscripref.cpp b/src/modules/filters/thmlscripref.cpp
index e46d679..1ea4a40 100644
--- a/src/modules/filters/thmlscripref.cpp
+++ b/src/modules/filters/thmlscripref.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlscripref - SWFilter descendant to hide or show scripture
- * referebces in a ThML module.
+ * thmlscripref.cpp - SWFilter descendant to hide or show scripture
+ * referebces in a ThML module
*
+ * $Id: thmlscripref.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,16 +28,23 @@
#include <versekey.h>
#include <swmodule.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Cross-references";
-const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Cross-references";
+ static const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLScripref::ThMLScripref() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ThMLScripref::ThMLScripref() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -53,7 +61,7 @@ char ThMLScripref::processText(SWBuf &text, const SWKey *key, const SWModule *mo
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -98,8 +106,8 @@ char ThMLScripref::processText(SWBuf &text, const SWKey *key, const SWModule *mo
startTag.setAttribute("swordFootnote", buf);
SWBuf passage = startTag.getAttribute("passage");
if (passage.length())
- refs = parser->ParseVerseList(passage.c_str(), *parser, true).getRangeText();
- else refs = parser->ParseVerseList(tagText.c_str(), *parser, true).getRangeText();
+ refs = parser->parseVerseList(passage.c_str(), *parser, true).getRangeText();
+ else refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
hide = false;
diff --git a/src/modules/filters/thmlstrongs.cpp b/src/modules/filters/thmlstrongs.cpp
index 457e28b..09658a9 100644
--- a/src/modules/filters/thmlstrongs.cpp
+++ b/src/modules/filters/thmlstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlstrongs.cpp - SWFilter descendant to hide or show Strong's number
+ * in a ThML module
*
+ * $Id: thmlstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,16 +28,23 @@
#include <utilstr.h>
#include <ctype.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Strong's Numbers";
-const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLStrongs::ThMLStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLStrongs::ThMLStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlvariants.cpp b/src/modules/filters/thmlvariants.cpp
index 4f28dbe..1a57971 100644
--- a/src/modules/filters/thmlvariants.cpp
+++ b/src/modules/filters/thmlvariants.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlvariants - SWFilter descendant to hide or show textual variants
- * in a ThML module.
+ * thmlvariants.cpp - SWFilter descendant to hide or show textual variants
+ * in a ThML module
*
+ * $Id: thmlvariants.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,50 +25,39 @@
#include <thmlvariants.h>
#include <utilstr.h>
-SWORD_NAMESPACE_START
-const char ThMLVariants::primary[] = "Primary Reading";
-const char ThMLVariants::secondary[] = "Secondary Reading";
-const char ThMLVariants::all[] = "All Readings";
+SWORD_NAMESPACE_START
-const char ThMLVariants::optName[] = "Textual Variants";
-const char ThMLVariants::optTip[] = "Switch between Textual Variants modes";
+namespace {
+ static const char oName[] = "Textual Variants";
+ static const char oTip[] = "Switch between Textual Variants modes";
+ static const char *choices[4] = { "Primary Reading", "Secondary Reading", "All Readings", "" };
-ThMLVariants::ThMLVariants() {
- option = false;
- options.push_back(primary);
- options.push_back(secondary);
- options.push_back(all);
+ static const StringList *oValues() {
+ static const StringList oVals(&choices[0], &choices[3]);
+ return &oVals;
+ }
}
-ThMLVariants::~ThMLVariants() {
+ThMLVariants::ThMLVariants() : SWOptionFilter(oName, oTip, oValues()) {
}
-void ThMLVariants::setOptionValue(const char *ival)
-{
- if (!stricmp(ival, primary)) option = 0;
- else if (!stricmp(ival, secondary)) option = 1;
- else option = 2;
-}
-const char *ThMLVariants::getOptionValue()
-{
- if (option == 0) {
- return primary;
- }
- else if (option == 1) {
- return secondary;
- }
- else {
- return all;
- }
+ThMLVariants::~ThMLVariants() {
}
+
char ThMLVariants::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
- if ( option == 0 || option == 1) { //we want primary or variant only
+
+ int option = 0;
+ if (optionValue == choices[0]) option = 0;
+ else if (optionValue == choices[1]) option = 1;
+ else option = 2;
+
+ if (option == 0 || option == 1) { //we want primary or variant only
bool intoken = false;
bool hide = false;
bool invar = false;
@@ -127,7 +117,4 @@ char ThMLVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
-
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/thmlwebif.cpp b/src/modules/filters/thmlwebif.cpp
index 0192703..29d9ef5 100644
--- a/src/modules/filters/thmlwebif.cpp
+++ b/src/modules/filters/thmlwebif.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * ThMLWEBIF.cpp - ThML to HTML filter with hrefs
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlwebif.cpp - ThML to HTML filter with hrefs
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlwebif.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,10 +29,11 @@
SWORD_NAMESPACE_START
+
ThMLWEBIF::ThMLWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.jsp") {
- //all's done in ThMLHTMLHREF
}
+
bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
@@ -100,7 +100,7 @@ bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
}
}
else {
- return ThMLHTMLHREF::handleToken(buf,token,userData);
+ return ThMLXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/thmlwordjs.cpp b/src/modules/filters/thmlwordjs.cpp
index 12fbeb1..7d80a00 100644
--- a/src/modules/filters/thmlwordjs.cpp
+++ b/src/modules/filters/thmlwordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlwordjs.cpp - SWFilter descendant to ???
*
+ * $Id: thmlwordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,17 +29,23 @@
#include <utilstr.h>
#include <versekey.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-ThMLWordJS::ThMLWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLWordJS::ThMLWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -58,7 +64,6 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int word = 1;
char val[128];
char *valto;
@@ -69,7 +74,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
bool newText = false;
bool needWordOut = false;
AttributeValue *wordAttrs = 0;
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
SWBuf wordSrcPrefix = modName;
const SWBuf orig = text;
@@ -160,7 +165,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -179,7 +184,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -188,7 +193,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -206,10 +211,11 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
+ if (!sMorph) sMorph = 0; // avoid unused warnings for now
/*
if (sMorph) {
SWBuf popMorph = "<a onclick=\"";
- popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), wordID.c_str(), morph.c_str());
+ popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->getName(), morph.c_str(), wordID.c_str(), morph.c_str());
morph = popMorph;
}
*/
@@ -237,7 +243,6 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
}
else {
text += *from;
- lastspace = (*from == ' ');
}
}
@@ -255,7 +260,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -271,7 +276,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -280,7 +285,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
diff --git a/src/modules/filters/thmlxhtml.cpp b/src/modules/filters/thmlxhtml.cpp
new file mode 100644
index 0000000..b17eb50
--- /dev/null
+++ b/src/modules/filters/thmlxhtml.cpp
@@ -0,0 +1,378 @@
+/******************************************************************************
+ *
+ * thmlxhtml.cpp - ThML to classed XHTML
+ *
+ * $Id: thmlxhtml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <thmlxhtml.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <utilstr.h>
+#include <versekey.h>
+#include <url.h>
+
+SWORD_NAMESPACE_START
+
+
+const char *ThMLXHTML::getHeader() const {
+ return "\
+ ";
+}
+
+
+ThMLXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ SecHead = false;
+ }
+}
+
+
+ThMLXHTML::ThMLXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ addAllowedEscapeString("nbsp");
+ addAllowedEscapeString("brvbar"); // "Š"
+ addAllowedEscapeString("sect"); // "§"
+ addAllowedEscapeString("copy"); // "©"
+ addAllowedEscapeString("laquo"); // "«"
+ addAllowedEscapeString("reg"); // "®"
+ addAllowedEscapeString("acute"); // "Ž"
+ addAllowedEscapeString("para"); // "¶"
+ addAllowedEscapeString("raquo"); // "»"
+
+ addAllowedEscapeString("Aacute"); // "Á"
+ addAllowedEscapeString("Agrave"); // "À"
+ addAllowedEscapeString("Acirc"); // "Â"
+ addAllowedEscapeString("Auml"); // "Ä"
+ addAllowedEscapeString("Atilde"); // "Ã"
+ addAllowedEscapeString("Aring"); // "Å"
+ addAllowedEscapeString("aacute"); // "á"
+ addAllowedEscapeString("agrave"); // "à"
+ addAllowedEscapeString("acirc"); // "â"
+ addAllowedEscapeString("auml"); // "ä"
+ addAllowedEscapeString("atilde"); // "ã"
+ addAllowedEscapeString("aring"); // "å"
+ addAllowedEscapeString("Eacute"); // "É"
+ addAllowedEscapeString("Egrave"); // "È"
+ addAllowedEscapeString("Ecirc"); // "Ê"
+ addAllowedEscapeString("Euml"); // "Ë"
+ addAllowedEscapeString("eacute"); // "é"
+ addAllowedEscapeString("egrave"); // "è"
+ addAllowedEscapeString("ecirc"); // "ê"
+ addAllowedEscapeString("euml"); // "ë"
+ addAllowedEscapeString("Iacute"); // "Í"
+ addAllowedEscapeString("Igrave"); // "Ì"
+ addAllowedEscapeString("Icirc"); // "Î"
+ addAllowedEscapeString("Iuml"); // "Ï"
+ addAllowedEscapeString("iacute"); // "í"
+ addAllowedEscapeString("igrave"); // "ì"
+ addAllowedEscapeString("icirc"); // "î"
+ addAllowedEscapeString("iuml"); // "ï"
+ addAllowedEscapeString("Oacute"); // "Ó"
+ addAllowedEscapeString("Ograve"); // "Ò"
+ addAllowedEscapeString("Ocirc"); // "Ô"
+ addAllowedEscapeString("Ouml"); // "Ö"
+ addAllowedEscapeString("Otilde"); // "Õ"
+ addAllowedEscapeString("oacute"); // "ó"
+ addAllowedEscapeString("ograve"); // "ò"
+ addAllowedEscapeString("ocirc"); // "ô"
+ addAllowedEscapeString("ouml"); // "ö"
+ addAllowedEscapeString("otilde"); // "õ"
+ addAllowedEscapeString("Uacute"); // "Ú"
+ addAllowedEscapeString("Ugrave"); // "Ù"
+ addAllowedEscapeString("Ucirc"); // "Û"
+ addAllowedEscapeString("Uuml"); // "Ü"
+ addAllowedEscapeString("uacute"); // "ú"
+ addAllowedEscapeString("ugrave"); // "ù"
+ addAllowedEscapeString("ucirc"); // "û"
+ addAllowedEscapeString("uuml"); // "ü"
+ addAllowedEscapeString("Yacute"); // "Ý"
+ addAllowedEscapeString("yacute"); // "ý"
+ addAllowedEscapeString("yuml"); // "ÿ"
+
+ addAllowedEscapeString("deg"); // "°"
+ addAllowedEscapeString("plusmn"); // "±"
+ addAllowedEscapeString("sup2"); // "²"
+ addAllowedEscapeString("sup3"); // "³"
+ addAllowedEscapeString("sup1"); // "¹"
+ addAllowedEscapeString("nbsp"); // "º"
+ addAllowedEscapeString("pound"); // "£"
+ addAllowedEscapeString("cent"); // "¢"
+ addAllowedEscapeString("frac14"); // "Œ"
+ addAllowedEscapeString("frac12"); // "œ"
+ addAllowedEscapeString("frac34"); // "Ÿ"
+ addAllowedEscapeString("iquest"); // "¿"
+ addAllowedEscapeString("iexcl"); // "¡"
+ addAllowedEscapeString("ETH"); // "Ð"
+ addAllowedEscapeString("eth"); // "ð"
+ addAllowedEscapeString("THORN"); // "Þ"
+ addAllowedEscapeString("thorn"); // "þ"
+ addAllowedEscapeString("AElig"); // "Æ"
+ addAllowedEscapeString("aelig"); // "æ"
+ addAllowedEscapeString("Oslash"); // "Ø"
+ addAllowedEscapeString("curren"); // "€"
+ addAllowedEscapeString("Ccedil"); // "Ç"
+ addAllowedEscapeString("ccedil"); // "ç"
+ addAllowedEscapeString("szlig"); // "ß"
+ addAllowedEscapeString("Ntilde"); // "Ñ"
+ addAllowedEscapeString("ntilde"); // "ñ"
+ addAllowedEscapeString("yen"); // "¥"
+ addAllowedEscapeString("not"); // "¬"
+ addAllowedEscapeString("ordf"); // "ª"
+ addAllowedEscapeString("uml"); // "š"
+ addAllowedEscapeString("shy"); // "­"
+ addAllowedEscapeString("macr"); // "¯"
+
+ addAllowedEscapeString("micro"); // "µ"
+ addAllowedEscapeString("middot"); // "·"
+ addAllowedEscapeString("cedil"); // "ž"
+ addAllowedEscapeString("ordm"); // "º"
+ addAllowedEscapeString("times"); // "×"
+ addAllowedEscapeString("divide"); // "÷"
+ addAllowedEscapeString("oslash"); // "ø"
+
+ setTokenCaseSensitive(true);
+// addTokenSubstitute("scripture", "<i> ");
+ addTokenSubstitute("/scripture", "</i> ");
+
+ renderNoteNumbers = false;
+}
+
+
+bool ThMLXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
+ MyUserData *u = (MyUserData *)userData;
+
+ XMLTag tag(token);
+ if ((!tag.isEndTag()) && (!tag.isEmpty()))
+ u->startTag = tag;
+
+ if (tag.getName() && !strcmp(tag.getName(), "sync")) {
+ SWBuf value = tag.getAttribute("value");
+ if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt;
+ if(value.length())
+ buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=%s\" class=\"morph\">%s</a>)</em></small>",
+ URL::encode(value.c_str()).c_str(),
+ value.c_str());
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "lemma")) { //&gt;
+ if(value.length())
+ // empty "type=" is deliberate.
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=&value=%s\" class=\"strongs\">%s</a>&gt;</em></small>",
+ URL::encode(value.c_str()).c_str(),
+ value.c_str());
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
+ char ch = *value;
+ value<<1;
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">",
+ ((ch == 'H') ? "Hebrew" : "Greek"),
+ URL::encode(value.c_str()).c_str());
+ buf += (value.length()) ? value.c_str() : "";
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
+ buf += (tag.isEndTag() ? "</b>" : "<b>");
+ }
+
+ }
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ else {
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = false;
+ }
+ }
+ else if (!strcmp(tag.getName(), "scripture")) {
+ buf += (tag.isEndTag() ? "</i>" : "<i>");
+ }
+ // <scripRef> tag
+ else if (!strcmp(tag.getName(), "scripRef")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) { // </scripRef>
+ if (!u->BiblicalText) {
+ SWBuf refList = u->startTag.getAttribute("passage");
+ if (!refList.length())
+ refList = u->lastTextNode;
+ SWBuf version = tag.getAttribute("version");
+
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
+ (refList.length()) ? URL::encode(refList.c_str()).c_str() : "",
+ (version.length()) ? URL::encode(version.c_str()).c_str() : "");
+ buf += u->lastTextNode.c_str();
+ buf += "</a>";
+ }
+ else {
+ SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) {}
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ //buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ }
+
+ // let's let text resume to output again
+ u->suspendTextPassThru = false;
+ }
+ }
+ else if (tag.getName() && !strcmp(tag.getName(), "div")) {
+ if (tag.isEndTag() && u->SecHead) {
+ buf += "</i></b><br />";
+ u->SecHead = false;
+ }
+ else if (tag.getAttribute("class")) {
+ if (!stricmp(tag.getAttribute("class"), "sechead")) {
+ u->SecHead = true;
+ buf += "<br /><b><i>";
+ }
+ else if (!stricmp(tag.getAttribute("class"), "title")) {
+ u->SecHead = true;
+ buf += "<br /><b><i>";
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) {
+ const char *src = strstr(token, "src");
+ if (!src) // assert we have a src attribute
+ return false;
+
+ const char *c, *d;
+ if (((c = strchr(src+3, '"')) == NULL) ||
+ ((d = strchr( ++c , '"')) == NULL)) // identify endpoints.
+ return false; // abandon hope.
+
+ SWBuf imagename = "file:";
+ if (*c == '/') // as below, inside for loop.
+ imagename += userData->module->getConfigEntry("AbsoluteDataPath");
+ while (c != d) // move bits into the name.
+ imagename += *(c++);
+
+ // images become clickable, if the UI supports showImage.
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><",
+ URL::encode(imagename.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str());
+
+ for (c = token; *c; c++) {
+ if ((*c == '/') && (*(c+1) == '\0'))
+ continue;
+ if (c == src) {
+ for (;((*c) && (*c != '"')); c++)
+ buf += *c;
+
+ if (!*c) { c--; continue; }
+
+ buf += '"';
+ if (*(c+1) == '/') {
+ buf += "file:";
+ buf += userData->module->getConfigEntry("AbsoluteDataPath");
+ if (buf[buf.length()-2] == '/')
+ c++; // skip '/'
+ }
+ continue;
+ }
+ buf += *c;
+ }
+ buf += " border=0 /></a>";
+ }
+ else {
+ buf += '<';
+ /*for (const char *tok = token; *tok; tok++)
+ buf += *tok;*/
+ buf += token;
+ buf += '>';
+ //return false; // we still didn't handle token
+ }
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/unicodertf.cpp b/src/modules/filters/unicodertf.cpp
index 768aecc..997597b 100644
--- a/src/modules/filters/unicodertf.cpp
+++ b/src/modules/filters/unicodertf.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * unicodertf - SWFilter descendant to convert a double byte unicode file
- * to RTF tags
+ * unicodertf.cpp - SWFilter descendant to convert UTF-8 to RTF tags
*
+ * $Id: unicodertf.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/utf16utf8.cpp b/src/modules/filters/utf16utf8.cpp
index a488e18..6356284 100644
--- a/src/modules/filters/utf16utf8.cpp
+++ b/src/modules/filters/utf16utf8.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF16UTF8 - SWFilter descendant to convert UTF-16 to UTF-8
+ * utf16utf8.cpp - SWFilter descendant to convert UTF-16 to UTF-8
*
+ * $Id: utf16utf8.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,8 +27,10 @@
#include <utf16utf8.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF16UTF8::UTF16UTF8() {
}
@@ -102,6 +104,4 @@ char UTF16UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8arabicpoints.cpp b/src/modules/filters/utf8arabicpoints.cpp
index bd3169b..42bfaa5 100644
--- a/src/modules/filters/utf8arabicpoints.cpp
+++ b/src/modules/filters/utf8arabicpoints.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8ArabicPoints - SWFilter descendant to remove UTF-8 Arabic vowel points
+ * utf8arabicpoints.cpp - SWFilter descendant to remove UTF-8
+ * Arabic vowel points
*
- * $Id: utf8arabicpoints.h 1688 2008-11-30 04:42:26Z refdoc $
+ * $Id: utf8arabicpoints.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2009-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,36 +26,163 @@
#include <stdio.h>
#include <utf8arabicpoints.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Arabic Vowel Points";
-const char oTip[] = "Toggles Arabic Vowel Points";
+namespace {
+
+ static const char oName[] = "Arabic Vowel Points";
+ static const char oTip[] = "Toggles Arabic Vowel Points";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
+
+ static char *nextMark(const char* from, int* mark_size) {
+ // Arabic vowel points currently targeted for elimination:
+ // Table entries excerpted from
+ // http://www.utf8-chartable.de/unicode-utf8-table.pl.
+ // Code UTF-8 Description
+ // point
+ // ----- --------- -----------
+ // U+064B d9 8b ARABIC FATHATAN
+ // U+064C d9 8c ARABIC DAMMATAN
+ // U+064D d9 8d ARABIC KASRATAN
+ // U+064E d9 8e ARABIC FATHA
+ // U+064F d9 8f ARABIC DAMMA
+ // U+0650 d9 90 ARABIC KASRA
+ // U+0651 d9 91 ARABIC SHADDA
+ // U+0652 d9 92 ARABIC SUKUN
+ // U+0653 d9 93 ARABIC MADDAH ABOVE
+ // U+0654 d9 94 ARABIC HAMZA ABOVE
+ // U+0655 d9 95 ARABIC HAMZA BELOW
+ //
+ // U+FC5E ef b1 9e ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM
+ // U+FC5F ef b1 9f ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM
+ // U+FC60 ef b1 a0 ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM
+ // U+FC61 ef b1 a1 ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM
+ // U+FC62 ef b1 a2 ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM
+ // U+FC63 ef b1 a3 ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM
+ //
+ // U+FE70 ef b9 b0 ARABIC FATHATAN ISOLATED FORM
+ // U+FE71 ef b9 b1 ARABIC TATWEEL WITH FATHATAN ABOVE
+ // U+FE72 ef b9 b2 ARABIC DAMMATAN ISOLATED FORM
+ // U+FE73 ef b9 b3 ARABIC TAIL FRAGMENT
+ // U+FE74 ef b9 b4 ARABIC KASRATAN ISOLATED FORM
+ // U+FE75 ef b9 b5 ???
+ // U+FE76 ef b9 b6 ARABIC FATHA ISOLATED FORM
+ // U+FE77 ef b9 b7 ARABIC FATHA MEDIAL FORM
+ // U+FE78 ef b9 b8 ARABIC DAMMA ISOLATED FORM
+ // U+FE79 ef b9 b9 ARABIC DAMMA MEDIAL FORM
+ // U+FE7A ef b9 ba ARABIC KASRA ISOLATED FORM
+ // U+FE7B ef b9 bb ARABIC KASRA MEDIAL FORM
+ // U+FE7C ef b9 bc ARABIC SHADDA ISOLATED FORM
+ // U+FE7D ef b9 bd ARABIC SHADDA MEDIAL FORM
+ // U+FE7E ef b9 be ARABIC SUKUN ISOLATED FORM
+ // U+FE7F ef b9 bf ARABIC SUKUN MEDIAL FORM
+
+ unsigned char* byte = (unsigned char*) from;
+ for (; *byte; ++byte) {
+ if (byte[0] == 0xD9) {
+ if (byte[1] >= 0x8B && byte[1] <= 0x95) {
+ *mark_size = 2;
+ break;
+ }
+ continue;
+ }
+ if (byte[0] == 0xEF) {
+ if (byte[1] == 0xB1) {
+ if (byte[2] >= 0x9E && byte[2] <= 0xA3) {
+ *mark_size = 3;
+ break;
+ }
+ continue;
+ }
+ if (byte[1] == 0xB9) {
+ if (byte[2] >= 0xB0 && byte[2] <= 0xBF) {
+ *mark_size = 3;
+ break;
+ }
+ continue;
+ }
+ }
+ }
+ return (char*)byte;
+ }
+}
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-UTF8ArabicPoints::UTF8ArabicPoints() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+UTF8ArabicPoints::UTF8ArabicPoints() : SWOptionFilter(oName, oTip, oValues()) {
}
+
UTF8ArabicPoints::~UTF8ArabicPoints(){};
-char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) {
- //The UTF-8 range 0xFC 0xE5 to 0xFC 0x63 consist of Arabic vowel marks so block those out.
- // Also ranges 0xFE70 til OxFE7F and 0x064b-0x0655
- SWBuf orig = text;
- const unsigned char* from = (unsigned char*)orig.c_str();
- for (text = ""; *from; from++) {
- if (((*from == 0xFC) && (*(from + 1) >= 0xE5 && *(from + 1) <= 0x63)) || ((*from == 0xFE) && (*(from + 1) >= 0x70 && *(from + 1) <= 0x7F)) || ((*from == 0x06) && (*(from + 1) >= 0x4B && *(from + 1) <= 0x55))){
- from++;
- }
- else {
- text += *from;
- }
+
+char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *, const SWModule *) {
+ // A non-zero/true option setting means that setOptionValue("On")
+ // was called which apparently means that Arabic Vowel Marks are ENABLED,
+ // so the filter's actions are DISABLED.
+ if (option)
+ return 0;
+
+ // Eliminate Arabic vowel marks from the text.
+ // The recognized marks are determined by the "nextMark" function.
+
+ // If nextMark were polymorphic (a virtual function or a function
+ // pointer), this function could be generically used in any filter that
+ // only removed (vs. replaced) areas of text based on the arbitrary
+ // match criteria encapsulated in the specific nextMark
+ // implementation.
+ int mark_size = 0;
+ char* mark_pos = nextMark(text.c_str(), &mark_size);
+
+ // Here and at the end of the loop,
+ // test BOTH mark_pos AND *mark_pos for safety and to give nextMark
+ // the option of returning either NULL or a pointer to the null
+ // terminator when done.
+ if (!mark_pos || !*mark_pos)
+ return 0; // no marks found.
+
+ // Purposely granting write access into SWBuf internal buffer via
+ // "end_of_output" avoids a needless temporary SWBuf copy.
+ // Everything before the first mark is already in its final position
+ // and can be safely ignored. So start appending at the current mark.
+ char* end_of_output = mark_pos;
+
+ // For consistency, input starts at (vs. after) the first mark as well
+ // -- not a problem since the mark itself gets skipped, anyway.
+ const char* start_of_input = mark_pos;
+ do {
+ // At this point, "mark_pos" and "mark_pos+mark_size" delimit
+ // the text to drop.
+ // "start_of_input" is either mark_pos or any text between the
+ // end of any previous mark and the current mark_pos.
+ // This text is now ready to be moved into the output.
+ int ready_size = mark_pos - start_of_input;
+ if (ready_size > 0) {
+ // Append the input text before the current mark to the
+ // output.
+ // Must use bcopy vs. strncpy because the final
+ // end_of_output may overtake the original
+ // start_of_input.
+ memmove(end_of_output, start_of_input, ready_size);
+ // Keep appending to end_of_output.
+ end_of_output += ready_size;
}
- }
+ // Ensure the mark never gets copied.
+ start_of_input = mark_pos + mark_size;
+ // Find the next mark.
+ mark_pos = nextMark(start_of_input, &mark_size);
+
+ } while (mark_pos && *mark_pos); // No more marks.
+
+ // Copy any trailing input text AND always the terminating null.
+ memmove(end_of_output, start_of_input, strlen(start_of_input)+1);
return 0;
}
diff --git a/src/modules/filters/utf8arshaping.cpp b/src/modules/filters/utf8arshaping.cpp
index 09d8973..04dea2d 100644
--- a/src/modules/filters/utf8arshaping.cpp
+++ b/src/modules/filters/utf8arshaping.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8arshaping - SWFilter descendant to perform Arabic shaping on
- * UTF-8 text
+ * utf8arshaping.cpp - SWFilter descendant to perform Arabic shaping on
+ * UTF-8 text
*
+ * $Id: utf8arshaping.cpp 2931 2013-07-31 13:07:26Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -31,7 +32,7 @@
SWORD_NAMESPACE_START
-UTF8arShaping::UTF8arShaping() {
+UTF8arShaping::UTF8arShaping() : err(U_ZERO_ERROR) {
conv = ucnv_open("UTF-8", &err);
}
diff --git a/src/modules/filters/utf8bidireorder.cpp b/src/modules/filters/utf8bidireorder.cpp
index 71dc804..b945a5b 100644
--- a/src/modules/filters/utf8bidireorder.cpp
+++ b/src/modules/filters/utf8bidireorder.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
*
- * utf8bidireorder - SWFilter descendant to perform reordering of UTF-8
- * text to visual order according to Unicode BiDi
+ * utf8bidireorder.cpp - SWFilter descendant to perform reordering of
+ * UTF-8 text to visual order according to the
+ * Unicode Bidirectional Algorithm (UBA)
*
+ * $Id: utf8bidireorder.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,18 +31,22 @@
#include <utf8bidireorder.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
-UTF8BiDiReorder::UTF8BiDiReorder() {
+
+UTF8BiDiReorder::UTF8BiDiReorder() : err(U_ZERO_ERROR) {
conv = ucnv_open("UTF-8", &err);
}
+
UTF8BiDiReorder::~UTF8BiDiReorder() {
ucnv_close(conv);
}
+
char UTF8BiDiReorder::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
UChar *ustr, *ustr2;
@@ -72,5 +78,6 @@ char UTF8BiDiReorder::processText(SWBuf &text, const SWKey *key, const SWModule
return 0;
}
+
SWORD_NAMESPACE_END
#endif
diff --git a/src/modules/filters/utf8cantillation.cpp b/src/modules/filters/utf8cantillation.cpp
index 73785b4..91ca58a 100644
--- a/src/modules/filters/utf8cantillation.cpp
+++ b/src/modules/filters/utf8cantillation.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8Cantillation - SWFilter descendant to remove UTF-8 Hebrew cantillation
+ * utf8cantillation.cpp - SWFilter descendant to remove UTF-8 Hebrew
+ * cantillation
*
+ * $Id: utf8cantillation.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,16 +25,23 @@
#include <stdio.h>
#include <utf8cantillation.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Hebrew Cantillation";
-const char oTip[] = "Toggles Hebrew Cantillation Marks";
+namespace {
+
+ static const char oName[] = "Hebrew Cantillation";
+ static const char oTip[] = "Toggles Hebrew Cantillation Marks";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/utf8greekaccents.cpp b/src/modules/filters/utf8greekaccents.cpp
index 5fdb047..039f9a4 100644
--- a/src/modules/filters/utf8greekaccents.cpp
+++ b/src/modules/filters/utf8greekaccents.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8GreekAccents - SWFilter descendant to remove UTF-8 Greek accents
+ * utf8greekaccents.cpp - SWFilter descendant to remove UTF-8 Greek
+ * accents
*
+ * $Id: utf8greekaccents.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,19 +31,27 @@
sword::UTF8NFKD decompose;
#endif
+
SWORD_NAMESPACE_START
-const char oName[] = "Greek Accents";
-const char oTip[] = "Toggles Greek Accents";
+namespace {
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Greek Accents";
+ static const char oTip[] = "Toggles Greek Accents";
-UTF8GreekAccents::UTF8GreekAccents() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
}
-UTF8GreekAccents::~UTF8GreekAccents(){};
+
+UTF8GreekAccents::UTF8GreekAccents() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+UTF8GreekAccents::~UTF8GreekAccents() {};
char UTF8GreekAccents::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
diff --git a/src/modules/filters/utf8hebrewpoints.cpp b/src/modules/filters/utf8hebrewpoints.cpp
index ba7c746..ff53e4f 100644
--- a/src/modules/filters/utf8hebrewpoints.cpp
+++ b/src/modules/filters/utf8hebrewpoints.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8HebrewPoints - SWFilter descendant to remove UTF-8 Hebrew vowel points
+ * utf8hebrewpoints.cpp - SWFilter descendant to remove UTF-8 Hebrew
+ * vowel points
*
+ * $Id: utf8hebrewpoints.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,24 +25,32 @@
#include <stdio.h>
#include <utf8hebrewpoints.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Hebrew Vowel Points";
-const char oTip[] = "Toggles Hebrew Vowel Points";
+namespace {
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Hebrew Vowel Points";
+ static const char oTip[] = "Toggles Hebrew Vowel Points";
-UTF8HebrewPoints::UTF8HebrewPoints() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
}
+
+UTF8HebrewPoints::UTF8HebrewPoints() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
UTF8HebrewPoints::~UTF8HebrewPoints(){};
char UTF8HebrewPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
if (!option) {
- //The UTF-8 range 0xD6 0xB0 to 0xD6 0xBF excluding 0xD6 0x consist of Hebrew cantillation marks so block those out.
+ //The UTF-8 range 0xD6 0xB0 to 0xD6 0xBF excluding 0xD6 0xBE consist of Hebrew cantillation marks so block those out.
SWBuf orig = text;
const unsigned char* from = (unsigned char*)orig.c_str();
for (text = ""; *from; from++) {
@@ -56,4 +65,5 @@ char UTF8HebrewPoints::processText(SWBuf &text, const SWKey *key, const SWModule
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8html.cpp b/src/modules/filters/utf8html.cpp
index 0d1dce3..1f05ac7 100644
--- a/src/modules/filters/utf8html.cpp
+++ b/src/modules/filters/utf8html.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8html - SWFilter descendant to convert a UTF-8 stream to HTML escapes
+ * utf8html.cpp - SWFilter descendant to convert a UTF-8 stream to
+ * HTML escapes
*
+ * $Id: utf8html.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,8 +26,10 @@
#include <utf8html.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8HTML::UTF8HTML() {
}
@@ -34,14 +37,11 @@ UTF8HTML::UTF8HTML() {
char UTF8HTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
unsigned char *from;
- int len;
char digit[10];
unsigned long ch;
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return (char)-1;
- len = strlen(text.c_str()) + 2; // shift string to right of buffer
-
SWBuf orig = text;
from = (unsigned char *)orig.c_str();
@@ -82,4 +82,6 @@ char UTF8HTML::processText(SWBuf &text, const SWKey *key, const SWModule *module
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/utf8latin1.cpp b/src/modules/filters/utf8latin1.cpp
index 25df0c1..1bf8d3b 100644
--- a/src/modules/filters/utf8latin1.cpp
+++ b/src/modules/filters/utf8latin1.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF8Latin1 - SWFilter descendant to convert UTF-8 to Latin-1
+ * utf8latin1.cpp - SWFilter descendant to convert UTF-8 to Latin-1
*
+ * $Id: utf8latin1.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,8 +26,10 @@
#include <utf8latin1.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8Latin1::UTF8Latin1(char rchar) : replacementChar(rchar) {
}
@@ -36,14 +38,12 @@ char UTF8Latin1::processText(SWBuf &text, const SWKey *key, const SWModule *modu
{
unsigned char *from;
- int len;
unsigned long uchar;
unsigned char significantFirstBits, subsequent;
if ((unsigned long)key < 2) {// hack, we're en(1)/de(0)ciphering
return (char)-1;
}
- len = strlen(text.c_str()) + 1; // shift string to right of buffer
SWBuf orig = text;
from = (unsigned char*)orig.c_str();
@@ -87,5 +87,6 @@ char UTF8Latin1::processText(SWBuf &text, const SWKey *key, const SWModule *modu
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8nfc.cpp b/src/modules/filters/utf8nfc.cpp
index 82d404e..49f12bb 100644
--- a/src/modules/filters/utf8nfc.cpp
+++ b/src/modules/filters/utf8nfc.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8nfc - SWFilter descendant to perform NFC (canonical composition
- * normalization) on UTF-8 text
+ * utf8nfc.cpp - SWFilter descendant to perform NFC (canonical
+ * composition normalization) on UTF-8 text
*
+ * $Id: utf8nfc.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/utf8nfkd.cpp b/src/modules/filters/utf8nfkd.cpp
index 1d6acf3..e4454d2 100644
--- a/src/modules/filters/utf8nfkd.cpp
+++ b/src/modules/filters/utf8nfkd.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8nfkd - SWFilter descendant to perform NFKD (compatability decomposition
- * normalization) on UTF-8 text
+ * utf8nfkd.cpp - SWFilter descendant to perform NFKD (compatability
+ * decomposition normalization) on UTF-8 text
*
+ * $Id: utf8nfkd.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,16 +30,20 @@
#include <utf8nfkd.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8NFKD::UTF8NFKD() {
conv = ucnv_open("UTF-8", &err);
}
+
UTF8NFKD::~UTF8NFKD() {
ucnv_close(conv);
}
+
char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
@@ -64,5 +69,6 @@ char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module
return 0;
}
+
SWORD_NAMESPACE_END
#endif
diff --git a/src/modules/filters/utf8transliterator.cpp b/src/modules/filters/utf8transliterator.cpp
index d6aafe2..b5b1902 100644
--- a/src/modules/filters/utf8transliterator.cpp
+++ b/src/modules/filters/utf8transliterator.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8transliterators - SWFilter descendant to transliterate between
- * ICU-supported scripts.
+ * utf8transliterator.cpp - SWFilter descendant to transliterate between
+ * ICU-supported scripts
*
+ * $Id: utf8transliterator.cpp 2908 2013-07-17 22:44:29Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -41,54 +42,57 @@ SWORD_NAMESPACE_START
const char UTF8Transliterator::optionstring[NUMTARGETSCRIPTS][16] = {
"Off",
"Latin",
- // "IPA",
- // "Basic Latin",
- // "SBL",
- // "TC",
- // "Beta",
- // "BGreek",
- // "SERA",
- // "Hugoye",
- // "UNGEGN",
- // "ISO",
- // "ALA-LC",
- // "BGN",
- // "Greek",
- // "Hebrew",
- // "Cyrillic",
- // "Arabic",
- // "Syriac",
- // "Katakana",
- // "Hiragana",
- // "Hangul",
- // "Devanagari",
- // "Tamil",
- // "Bengali",
- // "Gurmukhi",
- // "Gujarati",
- // "Oriya",
- // "Telugu",
- // "Kannada",
- // "Malayalam",
- // "Thai",
- // "Georgian",
- // "Armenian",
- // "Ethiopic",
- // "Gothic",
- // "Ugaritic",
- // "Coptic",
- // "Linear B",
- // "Cypriot",
- // "Runic",
- // "Ogham",
- // "Thaana",
- // "Glagolitic",
- // "Cherokee",
+ /*
+ "IPA",
+ "Basic Latin",
+ "SBL",
+ "TC",
+ "Beta",
+ "BGreek",
+ "SERA",
+ "Hugoye",
+ "UNGEGN",
+ "ISO",
+ "ALA-LC",
+ "BGN",
+ "Greek",
+ "Hebrew",
+ "Cyrillic",
+ "Arabic",
+ "Syriac",
+ "Katakana",
+ "Hiragana",
+ "Hangul",
+ "Devanagari",
+ "Tamil",
+ "Bengali",
+ "Gurmukhi",
+ "Gujarati",
+ "Oriya",
+ "Telugu",
+ "Kannada",
+ "Malayalam",
+ "Thai",
+ "Georgian",
+ "Armenian",
+ "Ethiopic",
+ "Gothic",
+ "Ugaritic",
+ "Coptic",
+ "Linear B",
+ "Cypriot",
+ "Runic",
+ "Ogham",
+ "Thaana",
+ "Glagolitic",
+ "Cherokee",
+ */
};
const char UTF8Transliterator::optName[] = "Transliteration";
const char UTF8Transliterator::optTip[] = "Transliterates between scripts";
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
SWTransMap UTF8Transliterator::transMap;
#ifndef _ICUSWORD_
@@ -128,7 +132,7 @@ SWCharString::~SWCharString() {
}
#endif // _ICUSWORD_
-
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
UTF8Transliterator::UTF8Transliterator() {
option = 0;
@@ -136,17 +140,19 @@ UTF8Transliterator::UTF8Transliterator() {
for (i = 0; i < NUMTARGETSCRIPTS; i++) {
options.push_back(optionstring[i]);
}
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifndef _ICUSWORD_
utf8status = U_ZERO_ERROR;
Load(utf8status);
#endif
+#endif
}
UTF8Transliterator::~UTF8Transliterator() {
}
-
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
void UTF8Transliterator::Load(UErrorCode &status)
{
#ifndef _ICUSWORD_
@@ -299,23 +305,29 @@ bool UTF8Transliterator::checkTrans(const UnicodeString& ID, UErrorCode &status
return true;
#endif // _ICUSWORD_
}
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
bool UTF8Transliterator::addTrans(const char* newTrans, SWBuf* transList) {
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifdef _ICUSWORD_
- UErrorCode status;
+ UErrorCode status;
if (checkTrans(UnicodeString(newTrans), status)) {
#endif
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
*transList += newTrans;
- *transList += ";";
- return true;
+ *transList += ";";
+ return true;
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifdef _ICUSWORD_
- }
- else {
- return false;
- }
+ }
+ else {
+ return false;
+ }
#endif
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
}
+
Transliterator * UTF8Transliterator::createTrans(const UnicodeString& ID, UTransDirection dir, UErrorCode &status )
{
Transliterator *trans = Transliterator::createInstance(ID,UTRANS_FORWARD,status);
@@ -450,7 +462,7 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu
//Simple X to Latin transliterators
if (scripts[SE_GREEK]) {
- if (strnicmp (((SWModule*)module)->Lang(), "cop", 3)) {
+ if (strnicmp (((SWModule*)module)->getLanguage(), "cop", 3)) {
if (option == SE_SBL)
addTrans("Greek-Latin/SBL", &ID);
else if (option == SE_TC)
@@ -653,7 +665,7 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu
}
if (scripts[SE_HAN]) {
- if (!strnicmp (((SWModule*)module)->Lang(), "ja", 2)) {
+ if (!strnicmp (((SWModule*)module)->getLanguage(), "ja", 2)) {
addTrans("Kanji-Romaji", &ID);
}
else {
diff --git a/src/modules/filters/utf8utf16.cpp b/src/modules/filters/utf8utf16.cpp
index e5b96d7..be8ad4b 100644
--- a/src/modules/filters/utf8utf16.cpp
+++ b/src/modules/filters/utf8utf16.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF8UTF16 - SWFilter descendant to convert UTF-8 to UTF-16
+ * utf8utf16.cpp - SWFilter descendant to convert UTF-8 to UTF-16
*
+ * $Id: utf8utf16.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +28,10 @@
#include <utilstr.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8UTF16::UTF8UTF16() {
}
diff --git a/src/modules/genbook/rawgenbook/rawgenbook.cpp b/src/modules/genbook/rawgenbook/rawgenbook.cpp
index eff68f5..6101241 100644
--- a/src/modules/genbook/rawgenbook/rawgenbook.cpp
+++ b/src/modules/genbook/rawgenbook/rawgenbook.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext.cpp - code for class 'RawGenBook'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawgenbook.cpp - code for class 'RawGenBook'- a module that reads raw
+ * text files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawgenbook.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -51,13 +53,13 @@ RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc,
stdstr(&path, ipath);
verseKey = !strcmp("VerseKey", keyType);
- if (verseKey) Type("Biblical Texts");
+ if (verseKey) setType("Biblical Texts");
if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
path[strlen(path)-1] = 0;
delete key;
- key = CreateKey();
+ key = createKey();
sprintf(buf, "%s.bdt", path);
@@ -82,7 +84,7 @@ RawGenBook::~RawGenBook() {
}
-bool RawGenBook::isWritable() {
+bool RawGenBook::isWritable() const {
return ((bdtfd->getFd() > 0) && ((bdtfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -94,7 +96,7 @@ bool RawGenBook::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawGenBook::getRawEntryBuf() {
+SWBuf &RawGenBook::getRawEntryBuf() const {
__u32 offset = 0;
__u32 size = 0;
@@ -160,7 +162,7 @@ void RawGenBook::linkEntry(const SWKey *inkey) {
SWCATCH ( ... ) {}
// if we don't have a VerseKey * decendant, create our own
if (!srckey) {
- srckey = (TreeKeyIdx *)CreateKey();
+ srckey = (TreeKeyIdx *)createKey();
(*srckey) = *inkey;
}
@@ -207,7 +209,7 @@ char RawGenBook::createModule(const char *ipath) {
}
-SWKey *RawGenBook::CreateKey() const {
+SWKey *RawGenBook::createKey() const {
TreeKey *tKey = new TreeKeyIdx(path);
if (verseKey) { SWKey *vtKey = new VerseTreeKey(tKey); delete tKey; return vtKey; }
return tKey;
@@ -218,7 +220,7 @@ bool RawGenBook::hasEntry(const SWKey *k) const {
int dsize;
key.getUserData(&dsize);
- return (dsize > 7) && key.Error() == '\x00';
+ return (dsize > 7) && key.popError() == '\x00';
}
SWORD_NAMESPACE_END
diff --git a/src/modules/genbook/swgenbook.cpp b/src/modules/genbook/swgenbook.cpp
index e7feea2..fef41ad 100644
--- a/src/modules/genbook/swgenbook.cpp
+++ b/src/modules/genbook/swgenbook.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
- * types of Lexicon and Dictionary modules (hence the 'LD').
*
+ * swgenbook.cpp - Implementation of SWGenBook class
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swgenbook.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,7 +27,7 @@
SWORD_NAMESPACE_START
/******************************************************************************
- * SWLD Constructor - Initializes data for instance of SWLD
+ * SWGenBook Constructor - Initializes data for instance of SWGenBook
*
* ENT: imodname - Internal name for module
* imoddesc - Name to display to user for module
@@ -39,7 +40,7 @@ SWGenBook::SWGenBook(const char *imodname, const char *imoddesc, SWDisplay *idis
/******************************************************************************
- * SWLD Destructor - Cleans up instance of SWGenBook
+ * SWGenBook Destructor - Cleans up instance of SWGenBook
*/
SWGenBook::~SWGenBook() {
@@ -65,11 +66,11 @@ TreeKey &SWGenBook::getTreeKey(const SWKey *k) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(TreeKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(TreeKey, lkTest->getElement());
if (!key) {
VerseTreeKey *tkey = 0;
SWTRY {
- tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->GetElement());
+ tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->getElement());
}
SWCATCH ( ... ) {}
if (tkey) key = tkey->getTreeKey();
@@ -89,7 +90,7 @@ TreeKey &SWGenBook::getTreeKey(const SWKey *k) const {
if (!key) {
delete tmpTreeKey;
- tmpTreeKey = (TreeKey *)CreateKey();
+ tmpTreeKey = (TreeKey *)createKey();
(*tmpTreeKey) = *(thiskey);
return (*tmpTreeKey);
}
diff --git a/src/modules/lexdict/rawld/rawld.cpp b/src/modules/lexdict/rawld/rawld.cpp
index e6a4d57..7446c10 100644
--- a/src/modules/lexdict/rawld/rawld.cpp
+++ b/src/modules/lexdict/rawld/rawld.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
+ * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
+ * dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -39,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-RawLD::RawLD(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawStr(ipath), SWLD(iname, idesc, idisp, enc, dir, mark, ilang)
+RawLD::RawLD(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : RawStr(ipath, -1, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding)
{
}
@@ -53,7 +57,7 @@ RawLD::~RawLD()
}
-bool RawLD::isWritable() {
+bool RawLD::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -67,7 +71,7 @@ bool RawLD::isWritable() {
* RET: error status
*/
-char RawLD::getEntry(long away)
+char RawLD::getEntry(long away) const
{
__u32 start = 0;
__u16 size = 0;
@@ -77,14 +81,14 @@ char RawLD::getEntry(long away)
char *buf = new char [ strlen(*key) + 6 ];
strcpy(buf, *key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
if (!(retval = findOffset(buf, &start, &size, away))) {
readText(start, &size, &idxbuf, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -106,7 +110,7 @@ char RawLD::getEntry(long away)
* RET: string buffer with entry
*/
-SWBuf &RawLD::getRawEntryBuf() {
+SWBuf &RawLD::getRawEntryBuf() const {
char ret = getEntry();
if (!ret) {
@@ -132,7 +136,7 @@ void RawLD::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -176,7 +180,7 @@ long RawLD::getEntryForKey(const char *key) const {
char *buf = new char [ strlen(key) + 6 ];
strcpy(buf, key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
findOffset(buf, &start, &size, 0, &offset);
@@ -192,4 +196,6 @@ char *RawLD::getKeyForEntry(long entry) const {
return key;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/rawld4/rawld4.cpp b/src/modules/lexdict/rawld4/rawld4.cpp
index 6d60d9a..1f81d83 100644
--- a/src/modules/lexdict/rawld4/rawld4.cpp
+++ b/src/modules/lexdict/rawld4/rawld4.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
+ * rawld4.cpp - code for class 'RawLD'- a module that reads raw
+ * lexicon and dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawld4.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -39,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-RawLD4::RawLD4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawStr4(ipath), SWLD(iname, idesc, idisp, enc, dir, mark, ilang)
+RawLD4::RawLD4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : RawStr4(ipath, -1, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding)
{
}
@@ -53,7 +57,7 @@ RawLD4::~RawLD4()
}
-bool RawLD4::isWritable() {
+bool RawLD4::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -67,7 +71,7 @@ bool RawLD4::isWritable() {
* RET: error status
*/
-char RawLD4::getEntry(long away)
+char RawLD4::getEntry(long away) const
{
__u32 start = 0;
__u32 size = 0;
@@ -85,7 +89,7 @@ char RawLD4::getEntry(long away)
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -104,7 +108,7 @@ char RawLD4::getEntry(long away)
* RET: string buffer with entry
*/
-SWBuf &RawLD4::getRawEntryBuf() {
+SWBuf &RawLD4::getRawEntryBuf() const {
char ret = getEntry();
if (!ret) {
@@ -130,7 +134,7 @@ void RawLD4::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -160,11 +164,13 @@ void RawLD4::deleteEntry() {
doSetText(*key, "");
}
+
long RawLD4::getEntryCount() const {
if (idxfd < 0) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}
+
long RawLD4::getEntryForKey(const char *key) const {
__u32 start, offset;
__u32 size;
@@ -181,10 +187,13 @@ long RawLD4::getEntryForKey(const char *key) const {
return offset / IDXENTRYSIZE;
}
+
char *RawLD4::getKeyForEntry(long entry) const {
char *key = 0;
getIDXBuf(entry * IDXENTRYSIZE, &key);
return key;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/swld.cpp b/src/modules/lexdict/swld.cpp
index bccf5d8..5e1909b 100644
--- a/src/modules/lexdict/swld.cpp
+++ b/src/modules/lexdict/swld.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
- * types of Lexicon and Dictionary modules (hence the 'LD').
*
+ * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
+ * types of Lexicon and Dictionary modules (hence the 'LD').
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,9 +25,12 @@
#include <stdio.h>
#include <swld.h>
#include <strkey.h>
+#include <swkey.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* SWLD Constructor - Initializes data for instance of SWLD
*
@@ -34,10 +39,10 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-SWLD::SWLD(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : SWModule(imodname, imoddesc, idisp, (char *)"Lexicons / Dictionaries", enc, dir, mark, ilang)
+SWLD::SWLD(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool strongsPadding) : SWModule(imodname, imoddesc, idisp, (char *)"Lexicons / Dictionaries", enc, dir, mark, ilang), strongsPadding(strongsPadding)
{
delete key;
- key = CreateKey();
+ key = createKey();
entkeytxt = new char [1];
*entkeytxt = 0;
}
@@ -54,7 +59,7 @@ SWLD::~SWLD()
}
-SWKey *SWLD::CreateKey() const { return new StrKey(); }
+SWKey *SWLD::createKey() const { return new StrKey(); }
/******************************************************************************
@@ -67,13 +72,11 @@ SWKey *SWLD::CreateKey() const { return new StrKey(); }
* RET: pointer to keytext
*/
-const char *SWLD::KeyText(const char *ikeytext)
-{
- if (key->Persist() && !ikeytext) {
+const char *SWLD::getKeyText() const {
+ if (key->isPersist()) {
getRawEntryBuf(); // force module key to snap to entry
- return entkeytxt;
}
- else return SWModule::KeyText(ikeytext);
+ return entkeytxt;
}
@@ -96,12 +99,13 @@ void SWLD::setPosition(SW_POSITION p) {
getRawEntryBuf();
}
+
bool SWLD::hasEntry(const SWKey *key) const {
const char *key_str = *key;
char *buf = new char [ strlen(key_str) + 6 ];
strcpy(buf, key_str);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
bool retVal = !strcmp(buf, getKeyForEntry(getEntryForKey(buf)));
delete buf;
@@ -109,6 +113,7 @@ bool SWLD::hasEntry(const SWKey *key) const {
return retVal;
}
+
/******************************************************************************
* SWLD::strongsPad - Pads a key if (it-1) is 100% digits to 5 places
* allows for final to be alpha, e.g. '123B'
@@ -161,3 +166,4 @@ void SWLD::strongsPad(char *buf)
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/zld/zld.cpp b/src/modules/lexdict/zld/zld.cpp
index 2c46657..71919d4 100644
--- a/src/modules/lexdict/zld/zld.cpp
+++ b/src/modules/lexdict/zld/zld.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * zld.cpp - code for class 'zLD'- a module that reads zlib compressed
+ * lexicon and dictionary files
+ *
+ * $Id: zld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -38,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : zStr(ipath, -1, blockCount, icomp), SWLD(iname, idesc, idisp, enc, dir, mark, ilang) {
+zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : zStr(ipath, -1, blockCount, icomp, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding) {
}
@@ -52,7 +57,7 @@ zLD::~zLD() {
}
-bool zLD::isWritable() {
+bool zLD::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -66,7 +71,7 @@ bool zLD::isWritable() {
* RET: error status
*/
-char zLD::getEntry(long away) {
+char zLD::getEntry(long away) const {
char *idxbuf = 0;
char *ebuf = 0;
char retval = 0;
@@ -75,7 +80,7 @@ char zLD::getEntry(long away) {
char *buf = new char [ strlen(*key) + 6 ];
strcpy(buf, *key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
entryBuf = "";
if (!(retval = findKeyIndex(buf, &index, away))) {
@@ -86,7 +91,7 @@ char zLD::getEntry(long away) {
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -106,7 +111,7 @@ char zLD::getEntry(long away) {
* RET: string buffer with entry
*/
-SWBuf &zLD::getRawEntryBuf() {
+SWBuf &zLD::getRawEntryBuf() const {
if (!getEntry() /*&& !isUnicode()*/) {
prepText(entryBuf);
}
@@ -128,7 +133,7 @@ void zLD::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -172,7 +177,7 @@ long zLD::getEntryForKey(const char* key) const
char *buf = new char [ strlen(key) + 6 ];
strcpy(buf, key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
findKeyIndex(buf, &offset);
@@ -191,3 +196,4 @@ char *zLD::getKeyForEntry(long entry) const
SWORD_NAMESPACE_END
+
diff --git a/src/modules/readme b/src/modules/readme
deleted file mode 100644
index 92cc99e..0000000
--- a/src/modules/readme
+++ /dev/null
@@ -1,9 +0,0 @@
-This directory contains all different module types that are usable by the SWORD
-API.
-
- comments Commentaries
- common common utility objects
- lexdict Lexicons/Dictionaries
- maps Maps
- parsers Language Parsers
- texts Scripture Texts
diff --git a/src/modules/swmodule.cpp b/src/modules/swmodule.cpp
index 758b8d2..6944c4e 100644
--- a/src/modules/swmodule.cpp
+++ b/src/modules/swmodule.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * swmodule.cpp - code for base class 'module'. Module is the basis for all
- * types of modules (e.g. texts, commentaries, maps, lexicons,
- * etc.)
*
+ * swmodule.cpp - code for base class 'SWModule'. SWModule is the basis
+ * for all types of modules (e.g. texts, commentaries,
+ * maps, lexicons, etc.)
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swmodule.cpp 2976 2013-09-10 14:09:44Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,7 +29,6 @@
#include <sysdata.h>
#include <swmodule.h>
#include <utilstr.h>
-#include <regex.h> // GNU
#include <swfilter.h>
#include <versekey.h> // KLUDGE for Search
#include <treekeyidx.h> // KLUDGE for Search
@@ -38,9 +39,17 @@
#include <iostream>
#endif
+#ifdef USECXX11REGEX
+#include <regex>
+#ifndef REG_ICASE
+#define REG_ICASE std::regex::icase
+#endif
+#else
+#include <regex.h> // GNU
+#endif
+
#ifdef USELUCENE
#include <CLucene.h>
-#include <CLucene/CLBackwards.h>
//Lucence includes
//#include "CLucene.h"
@@ -61,7 +70,7 @@ using std::vector;
SWORD_NAMESPACE_START
-SWDisplay SWModule::rawdisp;
+SWModule::StdOutDisplay SWModule::rawdisp;
typedef std::list<SWBuf> StringList;
@@ -77,7 +86,7 @@ typedef std::list<SWBuf> StringList;
*/
SWModule::SWModule(const char *imodname, const char *imoddesc, SWDisplay *idisp, const char *imodtype, SWTextEncoding encoding, SWTextDirection direction, SWTextMarkup markup, const char *imodlang) {
- key = CreateKey();
+ key = createKey();
entryBuf = "";
config = &ownConfig;
modname = 0;
@@ -120,44 +129,44 @@ SWModule::~SWModule()
delete [] modlang;
if (key) {
- if (!key->Persist())
+ if (!key->isPersist())
delete key;
}
stripFilters->clear();
- rawFilters->clear();
- renderFilters->clear();
- optionFilters->clear();
- encodingFilters->clear();
+ rawFilters->clear();
+ renderFilters->clear();
+ optionFilters->clear();
+ encodingFilters->clear();
entryAttributes.clear();
- delete stripFilters;
- delete rawFilters;
- delete renderFilters;
- delete optionFilters;
- delete encodingFilters;
+ delete stripFilters;
+ delete rawFilters;
+ delete renderFilters;
+ delete optionFilters;
+ delete encodingFilters;
}
/******************************************************************************
- * SWModule::CreateKey - Allocates a key of specific type for module
+ * SWModule::createKey - Allocates a key of specific type for module
*
* RET: pointer to allocated key
*/
-SWKey *SWModule::CreateKey() const
+SWKey *SWModule::createKey() const
{
return new SWKey();
}
/******************************************************************************
- * SWModule::Error - Gets and clears error status
+ * SWModule::popError - Gets and clears error status
*
* RET: error status
*/
-char SWModule::Error()
+char SWModule::popError()
{
char retval = error;
@@ -175,11 +184,7 @@ char SWModule::Error()
* RET: pointer to modname
*/
-char *SWModule::Name(const char *imodname) {
- return stdstr(&modname, imodname);
-}
-
-char *SWModule::Name() const {
+const char *SWModule::getName() const {
return modname;
}
@@ -193,11 +198,7 @@ char *SWModule::Name() const {
* RET: pointer to moddesc
*/
-char *SWModule::Description(const char *imoddesc) {
- return stdstr(&moddesc, imoddesc);
-}
-
-char *SWModule::Description() const {
+const char *SWModule::getDescription() const {
return moddesc;
}
@@ -211,70 +212,20 @@ char *SWModule::Description() const {
* RET: pointer to modtype
*/
-char *SWModule::Type(const char *imodtype) {
- return stdstr(&modtype, imodtype);
-}
-
-char *SWModule::Type() const {
+const char *SWModule::getType() const {
return modtype;
}
/******************************************************************************
- * SWModule::Direction - Sets/gets module direction
+ * SWModule::getDirection - Sets/gets module direction
*
* ENT: newdir - value which to set direction
* [-1] - only get
*
* RET: char direction
*/
-char SWModule::Direction(signed char newdir) {
- if (newdir != -1)
- direction = newdir;
- return direction;
-}
-
-/******************************************************************************
- * SWModule::Encoding - Sets/gets module encoding
- *
- * ENT: newdir - value which to set direction
- * [-1] - only get
- *
- * RET: char encoding
- */
-char SWModule::Encoding(signed char newenc) {
- if (newenc != -1)
- encoding = newenc;
- return encoding;
-}
-
-/******************************************************************************
- * SWModule::Markup - Sets/gets module markup
- *
- * ENT: newdir - value which to set direction
- * [-1] - only get
- *
- * RET: char markup
- */
-char SWModule::Markup(signed char newmark) {
- if (newmark != -1)
- markup = newmark;
- return markup;
-}
-
-
-/******************************************************************************
- * SWModule::Lang - Sets/gets module language
- *
- * ENT: imodlang - value which to set modlang
- * [0] - only get
- *
- * RET: pointer to modname
- */
-
-char *SWModule::Lang(const char *imodlang)
-{
- if (imodlang) stdstr(&modlang, imodlang);
- return modlang;
+char SWModule::getDirection() const {
+ return direction;
}
@@ -295,19 +246,17 @@ void SWModule::setDisplay(SWDisplay *idisp) {
disp = idisp;
}
-
/******************************************************************************
- * SWModule::Display - Calls this modules display object and passes itself
- *
- * RET: error status
- */
+ * * SWModule::Display - Calls this modules display object and passes itself
+ * *
+ * * RET: error status
+ * */
-char SWModule::Display() {
- disp->Display(*this);
+char SWModule::display() {
+ disp->display(*this);
return 0;
}
-
/******************************************************************************
* SWModule::getKey - Gets the key from this module that points to the position
* record
@@ -333,12 +282,12 @@ char SWModule::setKey(const SWKey *ikey) {
SWKey *oldKey = 0;
if (key) {
- if (!key->Persist()) // if we have our own copy
+ if (!key->isPersist()) // if we have our own copy
oldKey = key;
}
- if (!ikey->Persist()) { // if we are to keep our own copy
- key = CreateKey();
+ if (!ikey->isPersist()) { // if we are to keep our own copy
+ key = createKey();
*key = *ikey;
}
else key = (SWKey *)ikey; // if we are to just point to an external key
@@ -360,7 +309,7 @@ char SWModule::setKey(const SWKey *ikey) {
void SWModule::setPosition(SW_POSITION p) {
*key = p;
- char saveError = key->Error();
+ char saveError = key->popError();
switch (p) {
case POS_TOP:
@@ -388,7 +337,7 @@ void SWModule::setPosition(SW_POSITION p) {
void SWModule::increment(int steps) {
(*key) += steps;
- error = key->Error();
+ error = key->popError();
}
@@ -402,7 +351,7 @@ void SWModule::increment(int steps) {
void SWModule::decrement(int steps) {
(*key) -= steps;
- error = key->Error();
+ error = key->popError();
}
@@ -426,7 +375,7 @@ void SWModule::decrement(int steps) {
ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *scope, bool *justCheckIfSupported, void (*percent)(char, void *), void *percentUserData) {
- listKey.ClearList();
+ listKey.clear();
SWBuf term = istr;
bool includeComponents = false; // for entryAttrib e.g., /Lemma.1/
@@ -447,10 +396,21 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
return listKey;
}
- SWKey *saveKey = 0;
+ SWKey *saveKey = 0;
SWKey *searchKey = 0;
- SWKey *resultKey = CreateKey();
+ SWKey *resultKey = createKey();
+ SWKey *lastKey = createKey();
+ SWBuf lastBuf = "";
+
+#ifdef USECXX11REGEX
+ std::locale oldLocale;
+ std::locale::global(std::locale("en_US.UTF-8"));
+
+ std::regex preg;
+#else
regex_t preg;
+#endif
+
vector<SWBuf> words;
vector<SWBuf> window;
const char *sres;
@@ -460,36 +420,40 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// determine if we might be doing special strip searches. useful for knowing if we can use shortcuts
bool specialStrips = (getConfigEntry("LocalStripFilter")
- || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
- || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
- || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
- || (strchr(istr, '<')));
+ || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
+ || (strchr(istr, '<')));
- processEntryAttributes(searchType == -3);
+ setProcessEntryAttributes(searchType == -3);
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
- searchKey = (scope)?scope->clone():(key->Persist())?key->clone():0;
+ searchKey = (scope)?scope->clone():(key->isPersist())?key->clone():0;
if (searchKey) {
- searchKey->Persist(1);
+ searchKey->setPersist(true);
setKey(*searchKey);
}
(*percent)(perc, percentUserData);
*this = BOTTOM;
- long highIndex = key->Index();
+ long highIndex = key->getIndex();
if (!highIndex)
highIndex = 1; // avoid division by zero errors.
*this = TOP;
if (searchType >= 0) {
+#ifdef USECXX11REGEX
+ preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended & flags);
+#else
flags |=searchType|REG_NOSUB|REG_EXTENDED;
regcomp(&preg, istr, flags);
+#endif
}
(*percent)(++perc, percentUserData);
@@ -497,10 +461,6 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
#ifdef USELUCENE
if (searchType == -4) { // lucene
- //Buffers for the wchar<->utf8 char* conversion
- const unsigned short int MAX_CONV_SIZE = 2047;
- wchar_t wcharBuffer[MAX_CONV_SIZE + 1];
- char utfBuffer[MAX_CONV_SIZE + 1];
lucene::index::IndexReader *ir = 0;
lucene::search::IndexSearcher *is = 0;
@@ -513,20 +473,18 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
const TCHAR *stopWords[] = { 0 };
standard::StandardAnalyzer analyzer(stopWords);
- lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
- q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
+ q = QueryParser::parse((wchar_t *)utf8ToWChar(istr).getRawData(), _T("content"), &analyzer);
(*percent)(20, percentUserData);
h = is->search(q);
(*percent)(80, percentUserData);
// iterate thru each good module position that meets the search
bool checkBounds = getKey()->isBoundSet();
- for (long i = 0; i < h->length(); i++) {
+ for (unsigned long i = 0; i < (unsigned long)h->length(); i++) {
Document &doc = h->doc(i);
// set a temporary verse key to this module position
- lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);
- *resultKey = utfBuffer; //TODO Does a key always accept utf8?
+ *resultKey = wcharToUTF8(doc.get(_T("key"))); //TODO Does a key always accept utf8?
// check to see if it sets ok (within our bounds) and if not, skip
if (checkBounds) {
@@ -536,7 +494,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
}
}
listKey << *resultKey;
- listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+ listKey.getElement()->userData = (__u64)((__u32)(h->score(i)*100));
}
(*percent)(98, percentUserData);
}
@@ -606,8 +564,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
(*percent)(perc, percentUserData);
- while ((searchType != -4) && !Error() && !terminateSearch) {
- long mindex = key->Index();
+ while ((searchType != -4) && !popError() && !terminateSearch) {
+ long mindex = key->getIndex();
float per = (float)mindex / highIndex;
per *= 93;
per += 5;
@@ -619,17 +577,35 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
else if (newperc < perc) {
#ifndef _MSC_VER
std::cerr << "Serious error: new percentage complete is less than previous value\n";
- std::cerr << "index: " << (key->Index()) << "\n";
+ std::cerr << "index: " << (key->getIndex()) << "\n";
std::cerr << "highIndex: " << highIndex << "\n";
std::cerr << "newperc ==" << (int)newperc << "%" << "is smaller than\n";
std::cerr << "perc == " << (int )perc << "% \n";
#endif
}
if (searchType >= 0) {
- if (!regexec(&preg, StripText(), 0, 0, 0)) {
+ SWBuf textBuf = stripText();
+#ifdef USECXX11REGEX
+ if (std::regex_match(std::string(textBuf.c_str()), preg)) {
+#else
+ if (!regexec(&preg, textBuf, 0, 0, 0)) {
+#endif
*resultKey = *getKey();
resultKey->clearBound();
listKey << *resultKey;
+ lastBuf = "";
+ }
+#ifdef USECXX11REGEX
+ else if (std::regex_match(std::string((lastBuf + ' ' + textBuf).c_str()), preg)) {
+#else
+ else if (!regexec(&preg, lastBuf + ' ' + textBuf, 0, 0, 0)) {
+#endif
+ lastKey->clearBound();
+ listKey << *lastKey;
+ lastBuf = textBuf;
+ }
+ else {
+ lastBuf = textBuf;
}
}
@@ -640,10 +616,10 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// phrase
case -1:
- textBuf = StripText();
+ textBuf = stripText();
if ((flags & REG_ICASE) == REG_ICASE) toupperstr(textBuf);
sres = strstr(textBuf.c_str(), term.c_str());
- if (sres) { //it's also in the StripText(), so we have a valid search result item now
+ if (sres) { //it's also in the stripText(), so we have a valid search result item now
*resultKey = *getKey();
resultKey->clearBound();
listKey << *resultKey;
@@ -655,7 +631,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
int loopCount = 0;
unsigned int foundWords = 0;
do {
- textBuf = ((loopCount == 0)&&(!specialStrips)) ? getRawEntry() : StripText();
+ textBuf = ((loopCount == 0)&&(!specialStrips)) ? getRawEntry() : stripText();
foundWords = 0;
for (unsigned int i = 0; i < words.size(); i++) {
@@ -680,7 +656,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// entry attributes
case -3: {
- RenderText(); // force parse
+ renderText(); // force parse
AttributeTypeList &entryAttribs = getEntryAttributes();
AttributeTypeList::iterator i1Start, i1End;
AttributeList::iterator i2Start, i2End;
@@ -804,25 +780,32 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
break;
} // end switch
}
+ *lastKey = *getKey();
(*this)++;
}
// cleaup work
- if (searchType >= 0)
+ if (searchType >= 0) {
+#ifdef USECXX11REGEX
+ std::locale::global(oldLocale);
+#else
regfree(&preg);
+#endif
+ }
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
if (searchKey)
delete searchKey;
delete resultKey;
+ delete lastKey;
listKey = TOP;
- processEntryAttributes(savePEA);
+ setProcessEntryAttributes(savePEA);
(*percent)(100, percentUserData);
@@ -833,7 +816,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
/******************************************************************************
- * SWModule::StripText() - calls all stripfilters on current text
+ * SWModule::stripText() - calls all stripfilters on current text
*
* ENT: buf - buf to massage instead of this modules current text
* len - max len of buf
@@ -841,29 +824,45 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
* RET: this module's text at current key location massaged by Strip filters
*/
-const char *SWModule::StripText(const char *buf, int len) {
- return RenderText(buf, len, false);
+const char *SWModule::stripText(const char *buf, int len) {
+ static SWBuf local;
+ local = renderText(buf, len, false);
+ return local.c_str();
+}
+
+
+/** SWModule::getRenderHeader() - Produces any header data which might be
+ * useful which associated with the processing done with this filter.
+ * A typical example is a suggested CSS style block for classed
+ * containers.
+ */
+const char *SWModule::getRenderHeader() const {
+ FilterList::const_iterator first = getRenderFilters().begin();
+ if (first != getRenderFilters().end()) {
+ return (*first)->getHeader();
+ }
+ return "";
}
/******************************************************************************
- * SWModule::RenderText - calls all renderfilters on current text
+ * SWModule::renderText - calls all renderfilters on current text
*
* ENT: buf - buffer to Render instead of current module position
*
- * RET: this module's text at current key location massaged by RenderText filters
+ * RET: this module's text at current key location massaged by renderText filters
*/
- const char *SWModule::RenderText(const char *buf, int len, bool render) {
+ SWBuf SWModule::renderText(const char *buf, int len, bool render) {
bool savePEA = isProcessEntryAttributes();
if (!buf) {
entryAttributes.clear();
}
else {
- processEntryAttributes(false);
+ setProcessEntryAttributes(false);
}
- static SWBuf local;
+ SWBuf local;
if (buf)
local = buf;
@@ -889,37 +888,37 @@ const char *SWModule::StripText(const char *buf, int len) {
tmpbuf = null;
}
- processEntryAttributes(savePEA);
+ setProcessEntryAttributes(savePEA);
return tmpbuf;
}
/******************************************************************************
- * SWModule::RenderText - calls all renderfilters on current text
+ * SWModule::renderText - calls all renderfilters on current text
*
* ENT: tmpKey - key to use to grab text
*
* RET: this module's text at current key location massaged by RenderFilers
*/
- const char *SWModule::RenderText(const SWKey *tmpKey) {
+SWBuf SWModule::renderText(const SWKey *tmpKey) {
SWKey *saveKey;
const char *retVal;
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
setKey(*tmpKey);
- retVal = RenderText();
+ retVal = renderText();
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
return retVal;
@@ -927,35 +926,53 @@ const char *SWModule::StripText(const char *buf, int len) {
/******************************************************************************
- * SWModule::StripText - calls all StripTextFilters on current text
+ * SWModule::stripText - calls all StripTextFilters on current text
*
* ENT: tmpKey - key to use to grab text
*
* RET: this module's text at specified key location massaged by Strip filters
*/
-const char *SWModule::StripText(const SWKey *tmpKey) {
+const char *SWModule::stripText(const SWKey *tmpKey) {
SWKey *saveKey;
const char *retVal;
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
setKey(*tmpKey);
- retVal = StripText();
+ retVal = stripText();
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
return retVal;
}
+/******************************************************************************
+ * SWModule::getBibliography -Returns bibliographic data for a module in the
+ * requested format
+ *
+ * ENT: bibFormat format of the bibliographic data
+ *
+ * RET: bibliographic data in the requested format as a string (BibTeX by default)
+ */
+
+SWBuf SWModule::getBibliography(unsigned char bibFormat) const {
+ SWBuf s;
+ switch (bibFormat) {
+ case BIB_BIBTEX:
+ s.append("@Book {").append(modname).append(", Title = \"").append(moddesc).append("\", Publisher = \"CrossWire Bible Society\"}");
+ break;
+ }
+ return s;
+}
const char *SWModule::getConfigEntry(const char *key) const {
ConfigEntMap::iterator it = config->find(key);
@@ -1008,7 +1025,6 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
SWBuf c;
const int MAX_CONV_SIZE = 1024 * 1024;
- wchar_t *wcharBuffer = new wchar_t[MAX_CONV_SIZE + 1];
// turn all filters to default values
StringList filterSettings;
@@ -1030,15 +1046,15 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
// save key information so as not to disrupt original
// module position
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
- searchKey = (key->Persist())?key->clone():0;
+ searchKey = (key->isPersist())?key->clone():0;
if (searchKey) {
- searchKey->Persist(1);
+ searchKey->setPersist(1);
setKey(*searchKey);
}
@@ -1062,19 +1078,19 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
VerseKey *vkcheck = 0;
vkcheck = SWDYNAMIC_CAST(VerseKey, key);
VerseKey *chapMax = 0;
- if (vkcheck) chapMax = (VerseKey *)vkcheck->clone();
+ if (vkcheck) chapMax = (VerseKey *)vkcheck->clone();
TreeKeyIdx *tkcheck = 0;
tkcheck = SWDYNAMIC_CAST(TreeKeyIdx, key);
*this = BOTTOM;
- long highIndex = key->Index();
+ long highIndex = key->getIndex();
if (!highIndex)
highIndex = 1; // avoid division by zero errors.
bool savePEA = isProcessEntryAttributes();
- processEntryAttributes(true);
+ setProcessEntryAttributes(true);
// prox chapter blocks
// position module at the beginning
@@ -1082,14 +1098,17 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
SWBuf proxBuf;
SWBuf proxLem;
+ SWBuf proxMorph;
SWBuf strong;
+ SWBuf morph;
- char err = Error();
+ char err = popError();
while (!err) {
- long mindex = key->Index();
+ long mindex = key->getIndex();
proxBuf = "";
proxLem = "";
+ proxMorph = "";
// computer percent complete so we can report to our progress callback
float per = (float)mindex / highIndex;
@@ -1102,7 +1121,7 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
}
// get "content" field
- const char *content = StripText();
+ const char *content = stripText();
bool good = false;
@@ -1118,8 +1137,10 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
AttributeTypeList::iterator words;
AttributeList::iterator word;
AttributeValue::iterator strongVal;
+ AttributeValue::iterator morphVal;
strong="";
+ morph="";
words = getEntryAttributes().find("Word");
if (words != getEntryAttributes().end()) {
for (word = words->second.begin();word != words->second.end(); word++) {
@@ -1136,16 +1157,22 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
continue; // no text? let's skip
}
strong.append(strongVal->second);
+ morph.append(strongVal->second);
+ morph.append('@');
+ SWBuf tmp = "Morph";
+ if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+ morphVal = word->second.find(tmp);
+ if (morphVal != word->second.end()) {
+ morph.append(morphVal->second);
+ }
strong.append(' ');
+ morph.append(' ');
}
}
}
}
- lucene_utf8towcs(wcharBuffer, keyText, MAX_CONV_SIZE); //keyText must be utf8
-// doc->add( *(new Field("key", wcharBuffer, Field::STORE_YES | Field::INDEX_TOKENIZED)));
- doc->add( *Field::Text(_T("key"), wcharBuffer ) );
-
+ doc->add(*_CLNEW Field(_T("key"), (wchar_t *)utf8ToWChar(keyText).getRawData(), Field::STORE_YES | Field::INDEX_UNTOKENIZED));
if (includeKeyInSearch) {
c = keyText;
@@ -1154,12 +1181,11 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
content = c.c_str();
}
- lucene_utf8towcs(wcharBuffer, content, MAX_CONV_SIZE); //content must be utf8
- doc->add( *Field::UnStored(_T("content"), wcharBuffer) );
+ doc->add(*_CLNEW Field(_T("content"), (wchar_t *)utf8ToWChar(content).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
if (strong.length() > 0) {
- lucene_utf8towcs(wcharBuffer, strong, MAX_CONV_SIZE);
- doc->add( *Field::UnStored(_T("lemma"), wcharBuffer) );
+ doc->add(*_CLNEW Field(_T("lemma"), (wchar_t *)utf8ToWChar(strong).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
+ doc->add(*_CLNEW Field(_T("morph"), (wchar_t *)utf8ToWChar(morph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
//printf("setting fields (%s).\ncontent: %s\nlemma: %s\n", (const char *)*key, content, strong.c_str());
}
@@ -1172,20 +1198,22 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
if (vkcheck) {
*chapMax = *vkcheck;
// we're the first verse in a chapter
- if (vkcheck->Verse() == 1) {
+ if (vkcheck->getVerse() == 1) {
*chapMax = MAXVERSE;
VerseKey saveKey = *vkcheck;
while ((!err) && (*vkcheck <= *chapMax)) {
//printf("building proxBuf from (%s).\nproxBuf.c_str(): %s\n", (const char *)*key, proxBuf.c_str());
//printf("building proxBuf from (%s).\n", (const char *)*key);
- content = StripText();
+ content = stripText();
if (content && *content) {
// build "strong" field
strong = "";
+ morph = "";
AttributeTypeList::iterator words;
AttributeList::iterator word;
AttributeValue::iterator strongVal;
+ AttributeValue::iterator morphVal;
words = getEntryAttributes().find("Word");
if (words != getEntryAttributes().end()) {
@@ -1203,7 +1231,16 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
continue; // no text? let's skip
}
strong.append(strongVal->second);
+ morph.append(strongVal->second);
+ morph.append('@');
+ SWBuf tmp = "Morph";
+ if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+ morphVal = word->second.find(tmp);
+ if (morphVal != word->second.end()) {
+ morph.append(morphVal->second);
+ }
strong.append(' ');
+ morph.append(' ');
}
}
}
@@ -1211,11 +1248,14 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
proxBuf += content;
proxBuf.append(' ');
proxLem += strong;
- if (proxLem.length())
+ proxMorph += morph;
+ if (proxLem.length()) {
proxLem.append("\n");
+ proxMorph.append("\n");
+ }
}
(*this)++;
- err = Error();
+ err = popError();
}
err = 0;
*vkcheck = saveKey;
@@ -1230,13 +1270,15 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
//printf("building proxBuf from (%s).\n", (const char *)*key);
//fflush(stdout);
- content = StripText();
+ content = stripText();
if (content && *content) {
// build "strong" field
strong = "";
+ morph = "";
AttributeTypeList::iterator words;
AttributeList::iterator word;
AttributeValue::iterator strongVal;
+ AttributeValue::iterator morphVal;
words = getEntryAttributes().find("Word");
if (words != getEntryAttributes().end()) {
@@ -1254,7 +1296,16 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
continue; // no text? let's skip
}
strong.append(strongVal->second);
+ morph.append(strongVal->second);
+ morph.append('@');
+ SWBuf tmp = "Morph";
+ if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+ morphVal = word->second.find(tmp);
+ if (morphVal != word->second.end()) {
+ morph.append(morphVal->second);
+ }
strong.append(' ');
+ morph.append(' ');
}
}
}
@@ -1263,8 +1314,11 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
proxBuf += content;
proxBuf.append(' ');
proxLem += strong;
- if (proxLem.length())
+ proxMorph += morph;
+ if (proxLem.length()) {
proxLem.append("\n");
+ proxMorph.append("\n");
+ }
}
} while (tkcheck->nextSibling());
tkcheck->parent();
@@ -1276,16 +1330,12 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
if (proxBuf.length() > 0) {
- lucene_utf8towcs(wcharBuffer, proxBuf, MAX_CONV_SIZE); //keyText must be utf8
-
-//printf("proxBuf after (%s).\nprox: %s\nproxLem: %s\n", (const char *)*key, proxBuf.c_str(), proxLem.c_str());
-
- doc->add( *Field::UnStored(_T("prox"), wcharBuffer) );
+ doc->add(*_CLNEW Field(_T("prox"), (wchar_t *)utf8ToWChar(proxBuf).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
good = true;
}
if (proxLem.length() > 0) {
- lucene_utf8towcs(wcharBuffer, proxLem, MAX_CONV_SIZE); //keyText must be utf8
- doc->add( *Field::UnStored(_T("proxlem"), wcharBuffer) );
+ doc->add(*_CLNEW Field(_T("proxlem"), (wchar_t *)utf8ToWChar(proxLem).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
+ doc->add(*_CLNEW Field(_T("proxmorph"), (wchar_t *)utf8ToWChar(proxMorph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
good = true;
}
if (good) {
@@ -1296,27 +1346,39 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
delete doc;
(*this)++;
- err = Error();
+ err = popError();
}
// Optimizing automatically happens with the call to addIndexes
//coreWriter->optimize();
coreWriter->close();
+#ifdef CLUCENE2
+ d = FSDirectory::getDirectory(target.c_str());
+#endif
if (IndexReader::indexExists(target.c_str())) {
+#ifndef CLUCENE2
d = FSDirectory::getDirectory(target.c_str(), false);
+#endif
if (IndexReader::isLocked(d)) {
IndexReader::unlock(d);
}
-
fsWriter = new IndexWriter( d, an, false);
- } else {
+ }
+ else {
+#ifndef CLUCENE2
d = FSDirectory::getDirectory(target.c_str(), true);
+#endif
fsWriter = new IndexWriter(d, an, true);
}
Directory *dirs[] = { ramDir, 0 };
+#ifdef CLUCENE2
+ lucene::util::ConstValueArray< lucene::store::Directory *>dirsa(dirs, 1);
+ fsWriter->addIndexes(dirsa);
+#else
fsWriter->addIndexes(dirs);
+#endif
fsWriter->close();
delete ramDir;
@@ -1327,15 +1389,15 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
// reposition module back to where it was before we were called
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
if (searchKey)
delete searchKey;
- delete chapMax;
+ delete chapMax;
- processEntryAttributes(savePEA);
+ setProcessEntryAttributes(savePEA);
// reset option filters back to original values
StringList::iterator origVal = filterSettings.begin();
@@ -1343,8 +1405,6 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
(*filter)->setOptionValue(*origVal++);
}
- delete [] wcharBuffer;
-
return 0;
#else
return SWSearchable::createSearchFramework(percent, percentUserData);
@@ -1356,7 +1416,7 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
* @param buf the buffer to filter
* @param key key location from where this buffer was extracted
*/
-void SWModule::filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) {
+void SWModule::filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const {
OptionFilterList::iterator it;
for (it = filters->begin(); it != filters->end(); it++) {
(*it)->processText(buf, key, this);
@@ -1368,7 +1428,7 @@ void SWModule::filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *
* @param buf the buffer to filter
* @param key key location from where this buffer was extracted
*/
-void SWModule::filterBuffer(FilterList *filters, SWBuf &buf, const SWKey *key) {
+void SWModule::filterBuffer(FilterList *filters, SWBuf &buf, const SWKey *key) const {
FilterList::iterator it;
for (it = filters->begin(); it != filters->end(); it++) {
(*it)->processText(buf, key, this);
diff --git a/src/modules/tests/echomod.cpp b/src/modules/tests/echomod.cpp
index 99b00cd..4de772d 100644
--- a/src/modules/tests/echomod.cpp
+++ b/src/modules/tests/echomod.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * echomod.cpp - code for class 'echomod'- a dummy test text module that just
- * echos back the key
*
+ * echomod.cpp - code for class 'EchoMod'- a dummy test text module
+ * that just echos back the key
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: echomod.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,7 +35,7 @@ EchoMod::~EchoMod() {
}
-SWBuf &EchoMod::getRawEntryBuf()
+SWBuf &EchoMod::getRawEntryBuf() const
{
static SWBuf retVal;
retVal = *key;
diff --git a/src/modules/texts/rawtext/rawtext.cpp b/src/modules/texts/rawtext/rawtext.cpp
index 8641a45..4fb716c 100644
--- a/src/modules/texts/rawtext/rawtext.cpp
+++ b/src/modules/texts/rawtext/rawtext.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext.cpp - code for class 'RawText'- a module that reads raw text files:
- * ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawtext.cpp - code for class 'RawText'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawtext.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -71,7 +73,7 @@ RawText::~RawText() {
}
-bool RawText::isWritable() {
+bool RawText::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -83,16 +85,16 @@ bool RawText::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawText::getRawEntryBuf() {
+SWBuf &RawText::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key.Testament(), start, size, entryBuf);
+ readText(key.getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, &key);
@@ -106,14 +108,14 @@ SWBuf &RawText::getRawEntryBuf() {
void RawText::setEntry(const char *inbuf, long len) {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
}
void RawText::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -125,7 +127,7 @@ void RawText::linkEntry(const SWKey *inkey) {
void RawText::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
/******************************************************************************
@@ -141,7 +143,7 @@ void RawText::increment(int steps) {
unsigned short size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -151,17 +153,21 @@ void RawText::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
+
if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
+ (
+ ((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ && (size) // and we actually have a size
+ )
+ || !skipConsecutiveLinks
+ ) { // or we don't want to skip consecutive links
steps += (steps < 0) ? 1 : -1;
lastgood = *tmpkey;
}
@@ -169,15 +175,16 @@ void RawText::increment(int steps) {
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
}
+
bool RawText::isLinked(const SWKey *k1, const SWKey *k2) const {
long start1, start2;
unsigned short size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -187,7 +194,7 @@ bool RawText::hasEntry(const SWKey *k) const {
unsigned short size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/texts/rawtext4/Makefile b/src/modules/texts/rawtext4/Makefile
new file mode 100644
index 0000000..a08e07e
--- /dev/null
+++ b/src/modules/texts/rawtext4/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/texts/rawtext4/rawtext4.cpp b/src/modules/texts/rawtext4/rawtext4.cpp
index 65f5cef..5980801 100644
--- a/src/modules/texts/rawtext4/rawtext4.cpp
+++ b/src/modules/texts/rawtext4/rawtext4.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext4.cpp - code for class 'RawText4'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawtext4.cpp - code for class 'RawText4'- a module that reads raw text
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawtext4.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -31,24 +33,8 @@
#include <versekey.h>
#include <stringmgr.h>
-#include <regex.h> // GNU
-#include <map>
-#include <list>
-#include <algorithm>
-
-#ifndef USELUCENE
-using std::map;
-using std::list;
-using std::find;
-#endif
-
SWORD_NAMESPACE_START
-#ifndef USELUCENE
-typedef map < SWBuf, list<long> > strlist;
-typedef list<long> longlist;
-#endif
-
/******************************************************************************
* RawText4 Constructor - Initializes data for instance of RawText4
*
@@ -71,7 +57,7 @@ RawText4::~RawText4() {
}
-bool RawText4::isWritable() {
+bool RawText4::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -83,16 +69,16 @@ bool RawText4::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawText4::getRawEntryBuf() {
+SWBuf &RawText4::getRawEntryBuf() const {
long start = 0;
unsigned long size = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key.Testament(), start, size, entryBuf);
+ readText(key.getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, &key);
@@ -106,14 +92,14 @@ SWBuf &RawText4::getRawEntryBuf() {
void RawText4::setEntry(const char *inbuf, long len) {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
}
void RawText4::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -125,7 +111,7 @@ void RawText4::linkEntry(const SWKey *inkey) {
void RawText4::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
/******************************************************************************
@@ -141,7 +127,7 @@ void RawText4::increment(int steps) {
unsigned long size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -151,12 +137,12 @@ void RawText4::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -174,10 +160,10 @@ bool RawText4::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
return start1 == start2;
}
@@ -186,7 +172,7 @@ bool RawText4::hasEntry(const SWKey *k) const {
unsigned long size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/texts/swtext.cpp b/src/modules/texts/swtext.cpp
index a7f5f92..9c3c02d 100644
--- a/src/modules/texts/swtext.cpp
+++ b/src/modules/texts/swtext.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
- * swtext.cpp - code for base class 'SWText'- The basis for all text modules
*
+ * swtext.cpp - code for base class 'SWText'- The basis for all text
+ * modules
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swtext.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -38,9 +41,9 @@ SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWT
this->versification = 0;
stdstr(&(this->versification), versification);
delete key;
- key = (VerseKey *)CreateKey();
- tmpVK1 = (VerseKey *)CreateKey();
- tmpVK2 = (VerseKey *)CreateKey();
+ key = (VerseKey *)createKey();
+ tmpVK1 = (VerseKey *)createKey();
+ tmpVK2 = (VerseKey *)createKey();
tmpSecond = false;
skipConsecutiveLinks = false;
}
@@ -58,10 +61,10 @@ SWText::~SWText() {
/******************************************************************************
- * SWText CreateKey - Create the correct key (VerseKey) for use with SWText
+ * SWText createKey - Create the correct key (VerseKey) for use with SWText
*/
-SWKey *SWText::CreateKey() const {
+SWKey *SWText::createKey() const {
VerseKey *vk = new VerseKey();
vk->setVersificationSystem(versification);
@@ -70,24 +73,22 @@ SWKey *SWText::CreateKey() const {
}
-long SWText::Index() const {
+long SWText::getIndex() const {
VerseKey *key = &getVerseKey();
- entryIndex = key->Index();
+ entryIndex = key->getIndex();
return entryIndex;
}
-long SWText::Index(long iindex) {
+void SWText::setIndex(long iindex) {
VerseKey *key = &getVerseKey();
- key->Testament(1);
- key->Index(iindex);
+ key->setTestament(1);
+ key->setIndex(iindex);
if (key != this->key) {
this->key->copyFrom(*key);
}
-
- return Index();
}
@@ -108,7 +109,7 @@ VerseKey &SWText::getVerseKey(const SWKey *keyToConvert) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
diff --git a/src/modules/texts/ztext/ztext.cpp b/src/modules/texts/ztext/ztext.cpp
index 61b3008..f0afe6d 100644
--- a/src/modules/texts/ztext/ztext.cpp
+++ b/src/modules/texts/ztext/ztext.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * ztext.cpp - code for class 'zText'- a module that reads compressed text
- * files: ot and nt using indexs ??.vss
*
+ * ztext.cpp - code for class 'zText'- a module that reads compressed text
+ * files
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: ztext.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,9 +30,6 @@
#include <ztext.h>
-#include <regex.h> // GNU
-
-
SWORD_NAMESPACE_START
/******************************************************************************
@@ -65,7 +64,7 @@ zText::~zText()
}
-bool zText::isWritable() { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR)); }
+bool zText::isWritable() const { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR)); }
/******************************************************************************
@@ -74,18 +73,18 @@ bool zText::isWritable() { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode &
* RET: buffer with verse
*/
-SWBuf &zText::getRawEntryBuf() {
+SWBuf &zText::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
unsigned long buffnum = 0;
VerseKey &key = getVerseKey();
- findOffset(key.Testament(), key.TestamentIndex(), &start, &size, &buffnum);
+ findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size, &buffnum);
entrySize = size; // support getEntrySize call
entryBuf = "";
- zReadText(key.Testament(), start, size, buffnum, entryBuf);
+ zReadText(key.getTestament(), start, size, buffnum, entryBuf);
rawFilter(entryBuf, &key);
// if (!isUnicode())
@@ -96,18 +95,18 @@ SWBuf &zText::getRawEntryBuf() {
bool zText::sameBlock(VerseKey *k1, VerseKey *k2) {
- if (k1->Testament() != k2->Testament())
+ if (k1->getTestament() != k2->getTestament())
return false;
switch (blockType) {
case VERSEBLOCKS:
- if (k1->Verse() != k2->Verse())
+ if (k1->getVerse() != k2->getVerse())
return false;
case CHAPTERBLOCKS:
- if (k1->Chapter() != k2->Chapter())
+ if (k1->getChapter() != k2->getChapter())
return false;
case BOOKBLOCKS:
- if (k1->Book() != k2->Book())
+ if (k1->getBook() != k2->getBook())
return false;
}
return true;
@@ -125,7 +124,7 @@ void zText::setEntry(const char *inbuf, long len) {
delete lastWriteKey;
}
- doSetText(key.Testament(), key.TestamentIndex(), inbuf, len);
+ doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
lastWriteKey = (VerseKey *)key.clone(); // must delete
}
@@ -134,7 +133,7 @@ void zText::setEntry(const char *inbuf, long len) {
void zText::linkEntry(const SWKey *inkey) {
VerseKey &destkey = getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey.Testament(), destkey.TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -147,7 +146,7 @@ void zText::deleteEntry() {
VerseKey &key = getVerseKey();
- doSetText(key.Testament(), key.TestamentIndex(), "");
+ doSetText(key.getTestament(), key.getTestamentIndex(), "");
}
@@ -164,7 +163,7 @@ void zText::increment(int steps) {
unsigned long buffnum;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -174,18 +173,21 @@ void zText::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size, &buffnum);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
+ (
+ ((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ && (size) // and we actually have a size
+ )
+ || !skipConsecutiveLinks
+ ) { // or we don't want to skip consecutive links
steps += (steps < 0) ? 1 : -1;
lastgood = *tmpkey;
}
@@ -193,16 +195,17 @@ void zText::increment(int steps) {
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
}
+
bool zText::isLinked(const SWKey *k1, const SWKey *k2) const {
long start1, start2;
unsigned short size1, size2;
unsigned long buffnum1, buffnum2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1, &buffnum1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2, &buffnum2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
return start1 == start2 && buffnum1 == buffnum2;
}
@@ -212,7 +215,7 @@ bool zText::hasEntry(const SWKey *k) const {
unsigned long buffnum;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
return size;
}