[sword-cvs] sword/src/modules/filters thmlfootnotes.cpp,1.5,1.6 thmllemma.cpp,1.4,1.5 thmlmorph.cpp,1.4,1.5
sword@www.crosswire.org
sword@www.crosswire.org
Sat, 22 Feb 2003 03:52:09 -0700
Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv26953/modules/filters
Modified Files:
thmlfootnotes.cpp thmllemma.cpp thmlmorph.cpp
Log Message:
SWBuf update
Index: thmlfootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlfootnotes.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** thmlfootnotes.cpp 1 Oct 2002 19:52:40 -0000 1.5
--- thmlfootnotes.cpp 22 Feb 2003 10:52:06 -0000 1.6
***************
*** 42,68 ****
}
! char ThMLFootnotes::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want footnotes
- char *to, *from, token[2048]; // cheese. Fix.
- int tokpos = 0;
bool intoken = false;
- int len;
bool hide = false;
! 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++) {
if (*from == '<') {
intoken = true;
! tokpos = 0;
! token[0] = 0;
! token[1] = 0;
! token[2] = 0;
continue;
}
--- 42,58 ----
}
! char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want footnotes
bool intoken = false;
bool hide = false;
! SWBuf token;
! SWBuf orig = text;
! const char *from = orig.c_str();
! for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
! token = "";
continue;
}
***************
*** 80,103 ****
// if not a footnote token, keep token in text
if (!hide) {
! *to++ = '<';
! for (char *tok = token; *tok; tok++)
! *to++ = *tok;
! *to++ = '>';
}
continue;
}
if (intoken) {
! if (tokpos < 2045)
! token[tokpos++] = *from;
! token[tokpos+2] = 0;
}
! else {
! if (!hide) {
! *to++ = *from;
! }
}
}
- *to++ = 0;
- *to = 0;
}
return 0;
--- 70,86 ----
// if not a footnote token, keep token in text
if (!hide) {
! text += '<';
! text.append(token);
! text += '>';
}
continue;
}
if (intoken) {
! token += *from; //copy chars of found token
}
! else if (!hide) {
! text += *from;
}
}
}
return 0;
Index: thmllemma.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmllemma.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** thmllemma.cpp 1 Oct 2002 19:52:40 -0000 1.4
--- thmllemma.cpp 22 Feb 2003 10:52:06 -0000 1.5
***************
*** 41,97 ****
}
! char ThMLLemma::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want lemmas
- char *to, *from, token[2048]; // cheese. Fix.
- int tokpos = 0;
bool intoken = false;
- int len;
- bool lastspace = false;
-
- 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++) {
if (*from == '<') {
intoken = true;
! tokpos = 0;
! token[0] = 0;
! token[1] = 0;
! token[2] = 0;
continue;
}
if (*from == '>') { // process tokens
intoken = false;
! if (!strnicmp(token, "sync type=\"lemma\" ", 18)) { // Lemma
! if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
! if (lastspace)
! to--;
! }
! continue;
}
// if not a lemma token, keep token in text
! *to++ = '<';
! for (char *tok = token; *tok; tok++)
! *to++ = *tok;
! *to++ = '>';
continue;
}
if (intoken) {
! if (tokpos < 2045)
! token[tokpos++] = *from;
! token[tokpos+2] = 0;
! }
! else {
! *to++ = *from;
! lastspace = (*from == ' ');
}
}
- *to++ = 0;
- *to = 0;
}
return 0;
--- 41,76 ----
}
! char ThMLLemma::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want lemmas
bool intoken = false;
! SWBuf token;
! SWBuf orig = text;
! const char *from = orig.c_str();
! for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
! token = "";
continue;
}
if (*from == '>') { // process tokens
intoken = false;
! if (!strnicmp(token, "sync", 4) && strstr(token, "type=\"lemma\" ")) { // Lemma
! continue;
}
// if not a lemma token, keep token in text
! text = '<';
! text.append(token);
! text += '>';
continue;
}
if (intoken) {
! token += *from;
}
+ else {
+ text += *from;
+ }
}
}
return 0;
Index: thmlmorph.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlmorph.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** thmlmorph.cpp 1 Oct 2002 19:52:40 -0000 1.4
--- thmlmorph.cpp 22 Feb 2003 10:52:06 -0000 1.5
***************
*** 42,98 ****
}
! char ThMLMorph::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want morph tags
- char *to, *from, token[2048]; // cheese. Fix.
- int tokpos = 0;
bool intoken = false;
- int len;
- bool lastspace = false;
! 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++) {
if (*from == '<') {
intoken = true;
! tokpos = 0;
! token[0] = 0;
! token[1] = 0;
! token[2] = 0;
continue;
}
if (*from == '>') { // process tokens
intoken = false;
! if (!strnicmp(token, "sync type=\"morph\" ", 18)) { // Morph
! if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
! if (lastspace)
! to--;
! }
continue;
}
// if not a morph tag token, keep token in text
! *to++ = '<';
! for (char *tok = token; *tok; tok++)
! *to++ = *tok;
! *to++ = '>';
continue;
}
if (intoken) {
! if (tokpos < 2045)
! token[tokpos++] = *from;
! token[tokpos+2] = 0;
}
else {
! *to++ = *from;
! lastspace = (*from == ' ');
}
}
- *to++ = 0;
- *to = 0;
}
return 0;
--- 42,77 ----
}
! char ThMLMorph::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!option) { // if we don't want morph tags
bool intoken = false;
! SWBuf token;
! SWBuf orig = text;
! const char *from = orig.c_str();
! for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
! token = "";
continue;
}
if (*from == '>') { // process tokens
intoken = false;
! if (!strnicmp(token, "sync", 4) && strstr(token, "type=\"morph\"")) { // Morph
continue;
}
// if not a morph tag token, keep token in text
! text += '<';
! text.append(token);
! text += '>';
continue;
}
if (intoken) {
! token += *from
}
else {
! text += *from;
}
}
}
return 0;