diff options
Diffstat (limited to 'src/modules/filters/gbfplain.cpp')
-rw-r--r-- | src/modules/filters/gbfplain.cpp | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/src/modules/filters/gbfplain.cpp b/src/modules/filters/gbfplain.cpp index 65766d3..f519a25 100644 --- a/src/modules/filters/gbfplain.cpp +++ b/src/modules/filters/gbfplain.cpp @@ -1,34 +1,28 @@ /****************************************************************************** * - * gbfplain - SWFilter decendant to strip out all GBF tags or convert to + * gbfplain - SWFilter descendant to strip out all GBF tags or convert to * ASCII rendered symbols. */ #include <stdlib.h> -#include <string.h> #include <gbfplain.h> +SWORD_NAMESPACE_START GBFPlain::GBFPlain() { } -char GBFPlain::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module) +char GBFPlain::processText (SWBuf &text, const SWKey *key, const SWModule *module) { - char *to, *from, token[2048]; + char token[2048]; int tokpos = 0; bool intoken = false; - int len; - - len = strlen(text) + 1; // shift string to right of buffer - if (len < maxlen) { - memmove(&text[maxlen - len], text, len); - from = &text[maxlen - len]; - } - else from = text; // ------------------------------- - - for (to = text; *from; from++) { + const char *from; + SWBuf orig = text; + from = orig.c_str(); + for (text = ""; *from; from++) { if (*from == '<') { intoken = true; tokpos = 0; @@ -46,34 +40,30 @@ char GBFPlain::ProcessText(char *text, int maxlen, const SWKey *key, const SWMod case 'G': // Greek case 'H': // Hebrew case 'T': // Tense - *to++ = ' '; - *to++ = '<'; + text += " <"; for (char *tok = token + 2; *tok; tok++) - *to++ = *tok; - *to++ = '>'; - *to++ = ' '; + text += *tok; + text += "> "; continue; } break; case 'R': switch(token[1]) { case 'F': // footnote begin - *to++ = ' '; - *to++ = '['; + text += " ["; continue; case 'f': // footnote end - *to++ = ']'; - *to++ = ' '; + text += "] "; continue; } break; case 'C': switch(token[1]) { case 'A': // ASCII value - *to++ = (char)atoi(&token[2]); + text += (char)atoi(&token[2]); continue; case 'G': - *to++ = '>'; + text += ">"; continue; /* Bug in WEB case 'L': @@ -82,11 +72,10 @@ char GBFPlain::ProcessText(char *text, int maxlen, const SWKey *key, const SWMod */ case 'L': // Bug in WEB. Use above entry when fixed case 'N': // new line - *to++ = '\n'; + text += '\n'; continue; case 'M': // new paragraph - *to++ = '\n'; - *to++ = '\n'; + text += "\n\n"; continue; } break; @@ -98,9 +87,9 @@ char GBFPlain::ProcessText(char *text, int maxlen, const SWKey *key, const SWMod token[tokpos++] = *from; token[tokpos+2] = 0; } - else *to++ = *from; + else text += *from; } - *to++ = 0; - *to = 0; return 0; } + +SWORD_NAMESPACE_END |