aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-10-19 13:01:53 +0000
committerdanglassey <danglassey>2002-10-19 13:01:53 +0000
commitb2ca6e454c439c8e09ef3fc74f7464aa6740a57d (patch)
treef274a656497171ff92b513a82b7675f3e144ce68 /src
parent3233d36c65606df0336f45ff6d832d842798d349 (diff)
downloadsword-sf-cvs-b2ca6e454c439c8e09ef3fc74f7464aa6740a57d.tar.gz
sync with crosswire 20021019-1300
Diffstat (limited to 'src')
-rw-r--r--src/modules/filters/gbfosis.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/modules/filters/gbfosis.cpp b/src/modules/filters/gbfosis.cpp
index 4b9ed81..a921225 100644
--- a/src/modules/filters/gbfosis.cpp
+++ b/src/modules/filters/gbfosis.cpp
@@ -12,6 +12,7 @@
#include <gbfosis.h>
#include <swmodule.h>
#include <versekey.h>
+#include <swlog.h>
#include <stdarg.h>
#ifndef __GNUC__
#else
@@ -61,7 +62,7 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu
fromStart = from;
wordStart = text;
- QuoteStack quoteStack;
+ static QuoteStack quoteStack;
// -------------------------------
@@ -247,7 +248,8 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu
case '\'':
case '\"':
case '`':
- quoteStack.handleQuote(fromStart, from, to);
+ quoteStack.handleQuote(fromStart, from, &to);
+ from++;
break;
default:
if (newWord && (*from != ' ')) {wordStart = to; newWord = false; memset(to, 0, 10); }
@@ -292,6 +294,10 @@ char GBFOSIS::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu
tmp.Verse(0);
sprintf(ref, "\t</div>");
pushString(&to, ref);
+ if (!quoteStack.empty()) {
+ SWLog::systemlog->LogError("popping unclosed quote at end of book");
+ quoteStack.clear();
+ }
}
}
}
@@ -349,17 +355,41 @@ const char *GBFOSIS::convertToOSIS(const char *inRef, const SWKey *key) {
QuoteStack::QuoteStack() {
+ clear();
+}
+
+
+void QuoteStack::clear() {
while (!quotes.empty()) quotes.pop();
}
QuoteStack::~QuoteStack() {
- while (!quotes.empty()) quotes.pop();
+ clear();
}
-void QuoteStack::handleQuote(char *buf, char *quotePos, char *to) {
+void QuoteStack::handleQuote(char *buf, char *quotePos, char **to) {
+//QuoteInstance(char startChar = '\"', char level = 1, string uniqueID = "", char continueCount = 0) {
+ if (!quotes.empty()) {
+ QuoteInstance last = quotes.top();
+ if (last.startChar == *quotePos) {
+ GBFOSIS::pushString(to, "</quote>");
+ quotes.pop();
+ }
+ else {
+ quotes.push(QuoteInstance(*quotePos, last.level+1));
+ quotes.top().pushStartStream(to);
+ }
+ }
+ else {
+ quotes.push(QuoteInstance(*quotePos));
+ quotes.top().pushStartStream(to);
+ }
}
+void QuoteStack::QuoteInstance::pushStartStream(char **to) {
+ GBFOSIS::pushString(to, "<quote level=\"%d\">", level);
+}
SWORD_NAMESPACE_END