diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:02 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:02 -0400 |
commit | 936d9e8484ff73282c8c0a277310d1ffdde86e10 (patch) | |
tree | 084d6d2e50f188b0e9c00c109a935efa6ad665fc /src/modules | |
parent | 71a39f4652cd51df814c930dd268f3c9ad2aee86 (diff) |
Imported Upstream version 1.6.1+dfsg
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/common/Makefile.am | 2 | ||||
-rw-r--r-- | src/modules/common/sapphire.cpp | 4 | ||||
-rw-r--r-- | src/modules/filters/Makefile.am | 7 | ||||
-rw-r--r-- | src/modules/filters/osishtmlhref.cpp | 24 | ||||
-rw-r--r-- | src/modules/filters/osisrtf.cpp | 16 | ||||
-rw-r--r-- | src/modules/filters/teirtf.cpp | 2 | ||||
-rw-r--r-- | src/modules/filters/utf8transliterator.cpp | 9 | ||||
-rw-r--r-- | src/modules/swmodule.cpp | 77 |
8 files changed, 88 insertions, 53 deletions
diff --git a/src/modules/common/Makefile.am b/src/modules/common/Makefile.am index e688094..34a14bf 100644 --- a/src/modules/common/Makefile.am +++ b/src/modules/common/Makefile.am @@ -5,7 +5,7 @@ libsword_la_SOURCES += $(commondir)/rawstr4.cpp libsword_la_SOURCES += $(commondir)/swcomprs.cpp libsword_la_SOURCES += $(commondir)/lzsscomprs.cpp -if ZLIB +if HAVE_LIBZ SWZLIB = $(commondir)/zipcomprs.cpp else SWZLIB = diff --git a/src/modules/common/sapphire.cpp b/src/modules/common/sapphire.cpp index a2c5ce0..7b141d2 100644 --- a/src/modules/common/sapphire.cpp +++ b/src/modules/common/sapphire.cpp @@ -144,7 +144,6 @@ sapphire::~sapphire() unsigned char sapphire::encrypt(unsigned char b) { -#ifdef USBINARY // Picture a single enigma rotor with 256 positions, rewired // on the fly by card-shuffling. @@ -172,9 +171,6 @@ unsigned char sapphire::encrypt(unsigned char b) cards[avalanche])&0xFF]]; last_plain = b; return last_cipher; -#else - return b; -#endif } unsigned char sapphire::decrypt(unsigned char b) diff --git a/src/modules/filters/Makefile.am b/src/modules/filters/Makefile.am index f212cbf..80e65d9 100644 --- a/src/modules/filters/Makefile.am +++ b/src/modules/filters/Makefile.am @@ -83,13 +83,11 @@ SWICUSRC += $(filtersdir)/utf8nfkd.cpp SWICUSRC += $(filtersdir)/utf8arshaping.cpp SWICUSRC += $(filtersdir)/utf8bidireorder.cpp -if ICU -ICUDEFS = -D_ICU_ +if HAVE_ICU DISTSWICUSRC = SWREALICUSRC = $(SWICUSRC) else -if ICUSWORD -ICUDEFS = -D_ICU_ -D_ICUSWORD_ +if HAVE_ICUSWORD DISTSWICUSRC = SWREALICUSRC = $(SWICUSRC) else @@ -98,7 +96,6 @@ SWREALICUSRC = endif endif -AM_CPPFLAGS += $(ICUDEFS) libsword_la_SOURCES += $(SWREALICUSRC) EXTRA_DIST = $(DISTSWICUSRC) diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp index 6fce987..bdabd83 100644 --- a/src/modules/filters/osishtmlhref.cpp +++ b/src/modules/filters/osishtmlhref.cpp @@ -83,8 +83,8 @@ OSISHTMLHREF::OSISHTMLHREF() { setTokenCaseSensitive(true); - addTokenSubstitute("lg", "<br />"); - addTokenSubstitute("/lg", "<br />"); + // addTokenSubstitute("lg", "<br />"); + // addTokenSubstitute("/lg", "<br />"); morphFirst = false; } @@ -194,11 +194,17 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat 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("(", buf, u); + outText("</rb><rp>(</rp><rt>", buf, u); outText(val, buf, u); - outText(")", buf, u); + outText("</rt><rp>)</rp></ruby>", buf, u); } if (!morphFirst) { processLemma(u->suspendTextPassThru, tag, buf); @@ -272,8 +278,8 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat } } - // <p> paragraph tag - else if (!strcmp(tag.getName(), "p")) { + // <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 outText("<!P><br />", buf, u); } @@ -474,7 +480,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat else if (!strcmp(tag.getName(), "hi")) { SWBuf type = tag.getAttribute("type"); if ((!tag.isEndTag()) && (!tag.isEmpty())) { - if (type == "b" || type == "x-b") { + if (type == "bold" || type == "b" || type == "x-b") { outText("<b>", buf, u); u->inBold = true; } @@ -602,9 +608,9 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat outText(URL::encode(u->version.c_str()).c_str(), buf, u); outText("\">", buf, u); - outText("<img border=\"0\" src=\"", buf, u); + outText("<img src=\"file:", buf, u); outText(filepath, buf, u); - outText("\" />", buf, u); + outText("\" border=\"0\" />", buf, u); outText("</a>", buf, u); } diff --git a/src/modules/filters/osisrtf.cpp b/src/modules/filters/osisrtf.cpp index 84801e3..b8cf30c 100644 --- a/src/modules/filters/osisrtf.cpp +++ b/src/modules/filters/osisrtf.cpp @@ -87,8 +87,8 @@ OSISRTF::OSISRTF() { addEscapeStringSubstitute("lt", "<"); addEscapeStringSubstitute("gt", ">"); addEscapeStringSubstitute("quot", "\""); - addTokenSubstitute("lg", "{\\par}"); - addTokenSubstitute("/lg", "{\\par}"); + // addTokenSubstitute("lg", "{\\par}"); + // addTokenSubstitute("/lg", "{\\par}"); setTokenCaseSensitive(true); } @@ -239,8 +239,8 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); - if ( (type != "x-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 - && (type != "strongsMarkup") // deprecated + if ((type != "x-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 + && (type != "strongsMarkup") // deprecated ) { SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); VerseKey *vkey = NULL; @@ -265,8 +265,8 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us } } - // <p> paragraph tag - else if (!strcmp(tag.getName(), "p")) { + // <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 outText("{\\fi200\\par}", buf, u); } @@ -275,7 +275,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us userData->supressAdjacentWhitespace = true; } else { // empty paragraph break marker - outText("{\\pard\\par\\par}", buf, u); + outText("{\\pard\\par}", buf, u); userData->supressAdjacentWhitespace = true; } } @@ -373,7 +373,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us else if (!strcmp(tag.getName(), "hi")) { SWBuf type = tag.getAttribute("type"); if ((!tag.isEndTag()) && (!tag.isEmpty())) { - if (type == "b" || type == "x-b") + if (type == "bold" || type == "b" || type == "x-b") outText("{\\b1 ", buf, u); else // all other types outText("{\\i1 ", buf, u); diff --git a/src/modules/filters/teirtf.cpp b/src/modules/filters/teirtf.cpp index 8560f5c..8e135b5 100644 --- a/src/modules/filters/teirtf.cpp +++ b/src/modules/filters/teirtf.cpp @@ -159,7 +159,7 @@ bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *use SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- VerseKey *vkey;
+ VerseKey *vkey = 0;
// see if we have a VerseKey * or descendant
SWTRY {
vkey = SWDYNAMIC_CAST(VerseKey, u->key);
diff --git a/src/modules/filters/utf8transliterator.cpp b/src/modules/filters/utf8transliterator.cpp index 552ec3e..d6aafe2 100644 --- a/src/modules/filters/utf8transliterator.cpp +++ b/src/modules/filters/utf8transliterator.cpp @@ -83,6 +83,7 @@ const char UTF8Transliterator::optionstring[NUMTARGETSCRIPTS][16] = { // "Ogham", // "Thaana", // "Glagolitic", + // "Cherokee", }; const char UTF8Transliterator::optName[] = "Transliteration"; @@ -403,6 +404,7 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu case UBLOCK_OGHAM: scripts[SE_OGHAM] = true; break; case UBLOCK_THAANA: scripts[SE_THAANA] = true; break; case UBLOCK_GLAGOLITIC: scripts[SE_GLAGOLITIC] = true; break; + case UBLOCK_CHEROKEE: scripts[SE_CHEROKEE] = true; break; // case UBLOCK_TENGWAR: scripts[SE_TENGWAR] = true; break; // case UBLOCK_CIRTH: scripts[SE_CIRTH] = true; break; case UBLOCK_CJK_RADICALS_SUPPLEMENT: @@ -637,6 +639,10 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu scripts[SE_LATIN] = true; } } + if (scripts[SE_CHEROKEE]) { + addTrans("Cherokee-Latin", &ID); + scripts[SE_LATIN] = true; + } if (scripts[SE_THAI]) { addTrans("Thai-Latin", &ID); scripts[SE_LATIN] = true; @@ -869,6 +875,9 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu case SE_GLAGOLITIC: addTrans("Latin-Glagolitic", &ID); break; + case SE_CHEROKEE: + addTrans("Latin-Cherokee", &ID); + break; // case SE_TENGWAR: // addTrans("Latin-Tengwar", &ID); // break; diff --git a/src/modules/swmodule.cpp b/src/modules/swmodule.cpp index 3eb7ce1..758b8d2 100644 --- a/src/modules/swmodule.cpp +++ b/src/modules/swmodule.cpp @@ -432,9 +432,9 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc #ifdef USELUCENE SWBuf target = getConfigEntry("AbsoluteDataPath"); - char ch = target.c_str()[strlen(target.c_str())-1]; - if ((ch != '/') && (ch != '\\')) + if (!target.endsWith("/") && !target.endsWith("\\")) { target.append('/'); + } target.append("lucene"); #endif if (justCheckIfSupported) { @@ -461,6 +461,8 @@ 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, '<'))); processEntryAttributes(searchType == -3); @@ -509,7 +511,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc is = new IndexSearcher(ir); (*percent)(10, percentUserData); - standard::StandardAnalyzer analyzer; + 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); (*percent)(20, percentUserData); @@ -672,7 +675,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc resultKey->clearBound(); listKey << *resultKey; } - } break; + } + break; // entry attributes case -3: { @@ -683,10 +687,15 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc AttributeValue::iterator i3Start, i3End; if ((words.size()) && (words[0].length())) { +// cout << "Word: " << words[0] << endl; + for (i1Start = entryAttribs.begin(); i1Start != entryAttribs.end(); ++i1Start) { +// cout << "stuff: " << i1Start->first.c_str() << endl; + } i1Start = entryAttribs.find(words[0]); i1End = i1Start; - if (i1End != entryAttribs.end()) - i1End++; + if (i1End != entryAttribs.end()) { + i1End++; + } } else { i1Start = entryAttribs.begin(); @@ -846,7 +855,13 @@ const char *SWModule::StripText(const char *buf, int len) { */ const char *SWModule::RenderText(const char *buf, int len, bool render) { - entryAttributes.clear(); + bool savePEA = isProcessEntryAttributes(); + if (!buf) { + entryAttributes.clear(); + } + else { + processEntryAttributes(false); + } static SWBuf local; if (buf) @@ -874,6 +889,8 @@ const char *SWModule::StripText(const char *buf, int len) { tmpbuf = null; } + processEntryAttributes(savePEA); + return tmpbuf; } @@ -962,9 +979,9 @@ bool SWModule::hasSearchFramework() { void SWModule::deleteSearchFramework() { #ifdef USELUCENE SWBuf target = getConfigEntry("AbsoluteDataPath"); - char ch = target.c_str()[strlen(target.c_str())-1]; - if ((ch != '/') && (ch != '\\')) + if (!target.endsWith("/") && !target.endsWith("\\")) { target.append('/'); + } target.append("lucene"); FileMgr::removeDir(target.c_str()); @@ -975,12 +992,23 @@ void SWModule::deleteSearchFramework() { signed char SWModule::createSearchFramework(void (*percent)(char, void *), void *percentUserData) { + #ifdef USELUCENE + SWBuf target = getConfigEntry("AbsoluteDataPath"); + if (!target.endsWith("/") && !target.endsWith("\\")) { + target.append('/'); + } + target.append("lucene"); + int status = FileMgr::createParent(target+"/dummy"); + if (status) return -1; + SWKey *saveKey = 0; SWKey *searchKey = 0; SWKey textkey; 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; @@ -988,7 +1016,10 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void filterSettings.push_back((*filter)->getOptionValue()); (*filter)->setOptionValue(*((*filter)->getOptionValues().begin())); - if (!strcmp("Greek Accents", (*filter)->getOptionName())) { + if ( (!strcmp("Greek Accents", (*filter)->getOptionName())) || + (!strcmp("Hebrew Vowel Points", (*filter)->getOptionName())) || + (!strcmp("Arabic Vowel Points", (*filter)->getOptionName())) + ) { (*filter)->setOptionValue("Off"); } } @@ -1011,22 +1042,19 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void setKey(*searchKey); } - RAMDirectory *ramDir = NULL; - IndexWriter *coreWriter = NULL; - IndexWriter *fsWriter = NULL; - Directory *d = NULL; + RAMDirectory *ramDir = 0; + IndexWriter *coreWriter = 0; + IndexWriter *fsWriter = 0; + Directory *d = 0; - standard::StandardAnalyzer *an = new standard::StandardAnalyzer(); - SWBuf target = getConfigEntry("AbsoluteDataPath"); + const TCHAR *stopWords[] = { 0 }; + standard::StandardAnalyzer *an = new standard::StandardAnalyzer(stopWords); bool includeKeyInSearch = getConfig().has("SearchOption", "IncludeKeyInSearch"); - char ch = target.c_str()[strlen(target.c_str())-1]; - if ((ch != '/') && (ch != '\\')) - target.append('/'); - target.append("lucene"); - FileMgr::createParent(target+"/dummy"); ramDir = new RAMDirectory(); coreWriter = new IndexWriter(ramDir, an, true); + coreWriter->setMaxFieldLength(MAX_CONV_SIZE); + @@ -1056,9 +1084,6 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void SWBuf proxLem; SWBuf strong; - const short int MAX_CONV_SIZE = 2047; - wchar_t wcharBuffer[MAX_CONV_SIZE + 1]; - char err = Error(); while (!err) { long mindex = key->Index(); @@ -1287,7 +1312,7 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void fsWriter = new IndexWriter( d, an, false); } else { d = FSDirectory::getDirectory(target.c_str(), true); - fsWriter = new IndexWriter( d ,an, true); + fsWriter = new IndexWriter(d, an, true); } Directory *dirs[] = { ramDir, 0 }; @@ -1318,6 +1343,8 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void (*filter)->setOptionValue(*origVal++); } + delete [] wcharBuffer; + return 0; #else return SWSearchable::createSearchFramework(percent, percentUserData); |