[sword-cvs] sword/src/modules/filters gbfmorph.cpp,1.7,1.8 thmlstrongs.cpp,1.12,1.13

sword@www.crosswire.org sword@www.crosswire.org
Tue, 25 Feb 2003 18:31:52 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv27221

Modified Files:
	gbfmorph.cpp thmlstrongs.cpp 
Log Message:


Index: gbfmorph.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbfmorph.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** gbfmorph.cpp	1 Oct 2002 19:52:40 -0000	1.7
--- gbfmorph.cpp	26 Feb 2003 01:31:49 -0000	1.8
***************
*** 42,49 ****
  }
  
! char GBFMorph::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;
--- 42,49 ----
  }
  
! char GBFMorph::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
  	if (!option) {	// if we don't want morph tags
! 		const char *from;
! 		char token[2048]; // cheese.  Fix.
  		int tokpos = 0;
  		bool intoken = false;
***************
*** 51,62 ****
  		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;
--- 51,58 ----
  		bool lastspace = false;
  
! 		SWBuf orig = text;
! 		from = orig.c_str();
  
! 		for (text = ""; *from; from++) {
  			if (*from == '<') {
  				intoken = true;
***************
*** 72,84 ****
  				  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;
  			}
--- 68,79 ----
  				  if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
  				    if (lastspace)
! 				      text--;
  				  }
  				  continue;
  				}
  				// if not a morph tag token, keep token in text
! 				text += '<';
! 				text += token;
! 				text += '>';
  				continue;
  			}
***************
*** 89,98 ****
  			}
  			else	{
! 				*to++ = *from;
  				lastspace = (*from == ' ');
  			}
  		}
- 		*to++ = 0;
- 		*to = 0;
  	}
  	return 0;
--- 84,91 ----
  			}
  			else	{
! 				text += *from;
  				lastspace = (*from == ' ');
  			}
  		}
  	}
  	return 0;

Index: thmlstrongs.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlstrongs.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** thmlstrongs.cpp	1 Oct 2002 22:04:59 -0000	1.12
--- thmlstrongs.cpp	26 Feb 2003 01:31:49 -0000	1.13
***************
*** 45,51 ****
  }
  
! char ThMLStrongs::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
! {
! 	char *to, *from, token[2048]; // cheese.  Fix.
  	int tokpos = 0;
  	bool intoken = false;
--- 45,51 ----
  }
  
! char ThMLStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
! 	char token[2048]; // cheese.  Fix.
! 	const char *from;
  	int tokpos = 0;
  	bool intoken = false;
***************
*** 57,74 ****
  	char *valto;
  	char *ch;
! 	char *textStart = text, *textEnd = 0;
  	std::string tmp;
  	bool newText = 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;
--- 57,68 ----
  	char *valto;
  	char *ch;
! 	unsigned int textStart = 0, textEnd = 0;
  	std::string tmp;
  	bool newText = false;
  
! 		SWBuf orig = text;
! 		from = orig.c_str();
  
! 		for (text = ""; *from; from++) {
  		if (*from == '<') {
  			intoken = true;
***************
*** 77,81 ****
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = to;
  			continue;
  		}
--- 71,75 ----
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = text.length();
  			continue;
  		}
***************
*** 93,97 ****
  						module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
  						tmp = "";
! 						tmp.append(textStart, (int)(textEnd - textStart));
  						module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
  						newText = true;
--- 87,91 ----
  						module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
  						tmp = "";
! 						tmp.append(text.c_str()+textStart, text.c_str()+((int)(textEnd - textStart)));
  						module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
  						newText = true;
***************
*** 107,113 ****
  					if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
  						if (lastspace)
! 							to--;
  					}
! 					if (newText) {textStart = to; newText = false; }
  					continue;
  				}
--- 101,107 ----
  					if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
  						if (lastspace)
! 							text--;
  					}
! 					if (newText) {textStart = text.length(); newText = false; }
  					continue;
  				}
***************
*** 136,144 ****
  			}
  			// if not a strongs token, keep token in text
! 			*to++ = '<';
! 			for (char *tok = token; *tok; tok++)
! 				*to++ = *tok;
! 			*to++ = '>';
! 			if (newText) {textStart = to; newText = false; }
  			continue;
  		}
--- 130,137 ----
  			}
  			// if not a strongs token, keep token in text
! 			text += '<';
! 			text += token;
! 			text += '>';
! 			if (newText) {textStart = text.length(); newText = false; }
  			continue;
  		}
***************
*** 149,158 ****
  		}
  		else	{
! 			*to++ = *from;
  			lastspace = (*from == ' ');
  		}
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
--- 142,149 ----
  		}
  		else	{
! 			text += *from;
  			lastspace = (*from == ' ');
  		}
  	}
  	return 0;
  }