diff options
-rw-r--r-- | apps/X11/cheatah/cheatah.cpp | 2 | ||||
-rw-r--r-- | apps/X11/cheatah/cheatah.h | 1 | ||||
-rw-r--r-- | apps/X11/cheatah/cheatsig.cpp | 2 | ||||
-rw-r--r-- | include/gbfosis.h | 28 | ||||
-rw-r--r-- | src/modules/filters/gbfosis.cpp | 35 |
5 files changed, 64 insertions, 4 deletions
diff --git a/apps/X11/cheatah/cheatah.cpp b/apps/X11/cheatah/cheatah.cpp index f01db16..58314cd 100644 --- a/apps/X11/cheatah/cheatah.cpp +++ b/apps/X11/cheatah/cheatah.cpp @@ -29,6 +29,8 @@ #include <thmlplain.h> #include <string.h> +using namespace sword; +using namespace std; MainWindow *cheatahWindow = NULL; diff --git a/apps/X11/cheatah/cheatah.h b/apps/X11/cheatah/cheatah.h index 42fae6d..7631759 100644 --- a/apps/X11/cheatah/cheatah.h +++ b/apps/X11/cheatah/cheatah.h @@ -22,6 +22,7 @@ #include <gtk/gtk.h> #include <swmgr.h> #include <swdisp.h> +using namespace sword; /* * This function returns a widget in a component created by Glade. diff --git a/apps/X11/cheatah/cheatsig.cpp b/apps/X11/cheatah/cheatsig.cpp index d3646ba..3b23b0d 100644 --- a/apps/X11/cheatah/cheatsig.cpp +++ b/apps/X11/cheatah/cheatsig.cpp @@ -23,6 +23,8 @@ #include "cheatah.h" #include "cheatsig.h" +using namespace std; + int main (int argc, char *argv[]) { diff --git a/include/gbfosis.h b/include/gbfosis.h index 95e069b..60ed9af 100644 --- a/include/gbfosis.h +++ b/include/gbfosis.h @@ -19,9 +19,37 @@ #include <defs.h> #include <swfilter.h> +#include <string> +#include <stack> + +using std::string; +using std::stack; SWORD_NAMESPACE_START +class QuoteStack { +private: + class QuoteInstance { + char startChar; + char level; + string uniqueID; + char continueCount; + public: + QuoteInstance(char startChar = '\"', char level = 1, string uniqueID = "", char continueCount = 0) { + this->startChar = startChar; + this->level = level; + this->uniqueID = uniqueID; + this->continueCount = continueCount; + } + }; + + stack<QuoteInstance> quotes; +public: + QuoteStack(); + virtual ~QuoteStack(); + void handleQuote(char *buf, char *quotePos, char *to); +}; + /** this filter converts GBF text to HTML text with hrefs */ class SWDLLEXPORT GBFOSIS : public SWFilter { diff --git a/src/modules/filters/gbfosis.cpp b/src/modules/filters/gbfosis.cpp index eb65952..4b9ed81 100644 --- a/src/modules/filters/gbfosis.cpp +++ b/src/modules/filters/gbfosis.cpp @@ -43,6 +43,7 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu char *ch; char *textStart, *textEnd; char *wordStart, *wordEnd; + char *fromStart; bool newText = false; bool newWord = false; std::string tmp; @@ -57,8 +58,11 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu else from = text; textStart = from; + fromStart = from; wordStart = text; + QuoteStack quoteStack; + // ------------------------------- for (to = text; *from; from++) { @@ -239,10 +243,18 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu } } else { - if (newWord && (*from != ' ')) {wordStart = to; newWord = false; memset(to, 0, 10); } - if (!suspendTextPassThru) { - *to++ = *from; - lastspace = (*from == ' '); + switch (*from) { + case '\'': + case '\"': + case '`': + quoteStack.handleQuote(fromStart, from, to); + break; + default: + if (newWord && (*from != ' ')) {wordStart = to; newWord = false; memset(to, 0, 10); } + if (!suspendTextPassThru) { + *to++ = *from; + lastspace = (*from == ' '); + } } } } @@ -335,4 +347,19 @@ const char *GBFOSIS::convertToOSIS(const char *inRef, const SWKey *key) { return outRef.c_str(); } + +QuoteStack::QuoteStack() { + while (!quotes.empty()) quotes.pop(); +} + + +QuoteStack::~QuoteStack() { + while (!quotes.empty()) quotes.pop(); +} + + +void QuoteStack::handleQuote(char *buf, char *quotePos, char *to) { +} + + SWORD_NAMESPACE_END |