From b745315323de9f27538edac9453205ca70e6186e Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Sat, 29 Mar 2014 10:54:04 -0400 Subject: Imported Upstream version 1.6.2+dfsg --- src/modules/common/lzsscomprs.cpp | 4 +-- src/modules/filters/gbfhtmlhref.cpp | 22 ++++++------- src/modules/filters/osishtmlhref.cpp | 64 ++++++++++++++++++++---------------- src/modules/filters/teihtmlhref.cpp | 13 ++++++-- src/modules/filters/thmlhtmlhref.cpp | 14 ++++---- src/modules/filters/utf8utf16.cpp | 1 + src/modules/lexdict/zld/zld.cpp | 2 +- 7 files changed, 69 insertions(+), 51 deletions(-) (limited to 'src/modules') diff --git a/src/modules/common/lzsscomprs.cpp b/src/modules/common/lzsscomprs.cpp index 00177db..624942d 100644 --- a/src/modules/common/lzsscomprs.cpp +++ b/src/modules/common/lzsscomprs.cpp @@ -618,9 +618,9 @@ void LZSSCompress::Decode(void) break; if (SendChars((char *) c, 1) != 1) { - totalLen++; break; } + totalLen++; // Add to buffer, and increment to next spot. Wrap at end. @@ -673,9 +673,9 @@ void LZSSCompress::Decode(void) // Add the "len" :characters to the output stream. if (SendChars((char *) c, len) != (unsigned int)len) { - totalLen += len; break; } + totalLen += len; } } slen = totalLen; diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp index b4cdde0..3f25e3a 100644 --- a/src/modules/filters/gbfhtmlhref.cpp +++ b/src/modules/filters/gbfhtmlhref.cpp @@ -155,11 +155,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData // else if (!strncmp(token, "WG", 2)) { // strong's numbers //buf += " <<<"; + buf += "\" class=\"strongs\">"; for (tok = token + 2; *tok; tok++) //if(token[i] != '\"') buf += *tok; @@ -167,11 +167,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData } else if (!strncmp(token, "WH", 2)) { // strong's numbers //buf += " <<<"; + buf += "\" class=\"strongs\">"; for (tok = token + 2; *tok; tok++) //if(token[i] != '\"') buf += *tok; @@ -179,11 +179,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData } else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense //buf += " ((("; + buf += "\" class=\"strongs\">"; for (tok = token + 3; *tok; tok++) if(*tok != '\"') buf += *tok; @@ -191,11 +191,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData } else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense //buf += " ((("; + buf += "\" class=\"strongs\">"; for (tok = token + 3; *tok; tok++) if(*tok != '\"') buf += *tok; @@ -204,12 +204,12 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags //buf += " ((("; + buf += "\" class=\"morph\">"; for (tok = token + 2; *tok; tok++) if(*tok != '\"') buf += *tok; @@ -240,7 +240,7 @@ 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("*n ", + buf.appendFormatted("*n ", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str()); diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp index bdabd83..3406e1b 100644 --- a/src/modules/filters/osishtmlhref.cpp +++ b/src/modules/filters/osishtmlhref.cpp @@ -34,14 +34,21 @@ SWORD_NAMESPACE_START -class OSISHTMLHREF::QuoteStack : public std::stack { +namespace { + typedef std::stack 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) { - inBold = false; inXRefNote = false; suspendLevel = 0; - quoteStack = new QuoteStack(); + tagStacks = new TagStacks(); wordsOfChristStart = " "; wordsOfChristEnd = " "; if (module) { @@ -56,13 +63,7 @@ OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : } OSISHTMLHREF::MyUserData::~MyUserData() { - // Just in case the quotes are not well formed - while (!quoteStack->empty()) { - char *tagData = quoteStack->top(); - quoteStack->pop(); - delete [] tagData; - } - delete quoteStack; + delete tagStacks; } OSISHTMLHREF::OSISHTMLHREF() { @@ -117,7 +118,7 @@ void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) { // show = false; //else { if (!suspendTextPassThru) { - buf.appendFormatted("<%s>", + buf.appendFormatted("<%s>", (gh.length()) ? gh.c_str() : "", URL::encode(val2).c_str(), val2); @@ -147,7 +148,7 @@ void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) { if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2]))) val2+=2; if (!suspendTextPassThru) { - buf.appendFormatted("(%s)", + buf.appendFormatted("(%s)", URL::encode(tag.getAttribute("morph")).c_str(), URL::encode(val).c_str(), val2); @@ -252,19 +253,21 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat SWCATCH ( ... ) { } if (vkey) { //printf("URL = %s\n",URL::encode(vkey->getText()).c_str()); - buf.appendFormatted("*%c", + buf.appendFormatted("*%c", 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("*%c", + buf.appendFormatted("*%c", 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); } } @@ -386,12 +389,15 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat // // else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type"))) { - if(!strcmp(tag.getAttribute("type"), "line")) { + if (!strcmp(tag.getAttribute("type"), "line")) { outText("
", buf, u); + if (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-PM")) { + outText("
", buf, u); + } userData->supressAdjacentWhitespace = true; } - else if(!strcmp(tag.getAttribute("type"),"x-p")) { - if( tag.getAttribute("marker")) + else if (!strcmp(tag.getAttribute("type"),"x-p")) { + if (tag.getAttribute("marker")) outText(tag.getAttribute("marker"), buf, u); else outText("", buf, u); } @@ -482,17 +488,21 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat if ((!tag.isEndTag()) && (!tag.isEmpty())) { if (type == "bold" || type == "b" || type == "x-b") { outText("", buf, u); - u->inBold = true; } else { // all other types outText("", buf, u); - u->inBold = false; } + u->tagStacks->hiStack.push(tag.toString()); } else if (tag.isEndTag()) { - if(u->inBold) { + SWBuf type = ""; + if (!u->tagStacks->hiStack.empty()) { + XMLTag tag(u->tagStacks->hiStack.top()); + u->tagStacks->hiStack.pop(); + type = tag.getAttribute("type"); + } + if (type == "bold" || type == "b" || type == "x-b") { outText("", buf, u); - u->inBold = false; } else outText("", buf, u); } @@ -519,9 +529,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("sID"))) { // if then remember it for the if (!tag.isEmpty()) { - char *tagData = 0; - stdstr(&tagData, tag.toString()); - u->quoteStack->push(tagData); + u->tagStacks->quoteStack.push(tag.toString()); } // Do this first so quote marks are included as WoC @@ -538,11 +546,9 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat // close or else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("eID"))) { // if it is then pop the stack for the attributes - if (tag.isEndTag() && !u->quoteStack->empty()) { - char *tagData = u->quoteStack->top(); - u->quoteStack->pop(); - XMLTag qTag(tagData); - delete [] tagData; + if (tag.isEndTag() && !u->tagStacks->quoteStack.empty()) { + XMLTag qTag(u->tagStacks->quoteStack.top()); + u->tagStacks->quoteStack.pop(); type = qTag.getAttribute("type"); who = qTag.getAttribute("who"); diff --git a/src/modules/filters/teihtmlhref.cpp b/src/modules/filters/teihtmlhref.cpp index 7e27667..47bb7b9 100644 --- a/src/modules/filters/teihtmlhref.cpp +++ b/src/modules/filters/teihtmlhref.cpp @@ -55,7 +55,7 @@ TEIHTMLHREF::TEIHTMLHREF() { addAllowedEscapeString("amp"); addAllowedEscapeString("lt"); addAllowedEscapeString("gt"); - + setTokenCaseSensitive(true); } @@ -87,6 +87,8 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData u->lastHi = rend; if (rend == "ital") buf += ""; + else if (rend == "italic") + buf += ""; else if (rend == "bold") buf += ""; else if (rend == "sup") @@ -97,6 +99,8 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData SWBuf rend = u->lastHi; if (rend == "ital") buf += ""; + else if (rend == "italic") + buf += ""; else if (rend == "bold") buf += ""; else if (rend == "sup") @@ -138,6 +142,11 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData } } + // + else if (!strcmp(tag.getName(), "lb")) { + buf += "
"; + } + // , , , , , , , else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || @@ -251,7 +260,7 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData if (tag.isEndTag()) { SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - buf.appendFormatted("*n", + buf.appendFormatted("*n", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str()); diff --git a/src/modules/filters/thmlhtmlhref.cpp b/src/modules/filters/thmlhtmlhref.cpp index 83f5a80..c0887f1 100644 --- a/src/modules/filters/thmlhtmlhref.cpp +++ b/src/modules/filters/thmlhtmlhref.cpp @@ -175,21 +175,21 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //> if(value.length()) - buf.appendFormatted("(%s)", + buf.appendFormatted("(%s)", URL::encode(value.c_str()).c_str(), value.c_str()); } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "lemma")) { //> if(value.length()) // empty "type=" is deliberate. - buf.appendFormatted("<%s>", + buf.appendFormatted("<%s>", 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("<", + buf.appendFormatted("<", ((ch == 'H') ? "Hebrew" : "Greek"), URL::encode(value.c_str()).c_str()); buf += (value.length()) ? value.c_str() : ""; @@ -215,20 +215,22 @@ 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("*%c", + buf.appendFormatted("*%c", 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 { char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); - buf.appendFormatted("*%c", + buf.appendFormatted("*%c", 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); } u->suspendTextPassThru = true; @@ -272,7 +274,7 @@ 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("*x ", vkey->getText(), footnoteNumber.c_str()); - buf.appendFormatted("*x", + buf.appendFormatted("*x", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str()); diff --git a/src/modules/filters/utf8utf16.cpp b/src/modules/filters/utf8utf16.cpp index a770d5f..e5b96d7 100644 --- a/src/modules/filters/utf8utf16.cpp +++ b/src/modules/filters/utf8utf16.cpp @@ -63,6 +63,7 @@ char UTF8UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *modul } text.setSize(text.size()+2); *((__u16 *)(text.getRawData()+(text.size()-2))) = (__u16)0; + text.setSize(text.size()-2); return 0; diff --git a/src/modules/lexdict/zld/zld.cpp b/src/modules/lexdict/zld/zld.cpp index 4e786bc..2c46657 100644 --- a/src/modules/lexdict/zld/zld.cpp +++ b/src/modules/lexdict/zld/zld.cpp @@ -48,7 +48,7 @@ zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCoun */ zLD::~zLD() { - + flushCache(); } -- cgit v1.2.3