[sword-cvs] sword/src/modules/filters gbfstrongs.cpp,1.18,1.19

sword@www.crosswire.org sword@www.crosswire.org
Mon, 24 Feb 2003 22:01:17 -0700


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

Modified Files:
	gbfstrongs.cpp 
Log Message:


Index: gbfstrongs.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbfstrongs.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** gbfstrongs.cpp	8 Jan 2003 23:31:48 -0000	1.18
--- gbfstrongs.cpp	25 Feb 2003 05:01:15 -0000	1.19
***************
*** 44,50 ****
  }
  
! char GBFStrongs::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
! 	char *to, *from, token[2048]; // cheese.  Fix.
  	int tokpos = 0;
  	bool intoken = false;
--- 44,50 ----
  }
  
! char GBFStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
! 	char token[2048]; // cheese.  Fix.
  	int tokpos = 0;
  	bool intoken = false;
***************
*** 56,71 ****
  	char *valto;
  	char *ch;
! 	char *textStart = text, *textEnd = 0;
  	bool newText = false;
  	std::string tmp;
  
! 	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;
--- 56,68 ----
  	char *valto;
  	char *ch;
! 	unsigned int textStart = 0, textEnd = 0;
  	bool newText = false;
  	std::string tmp;
+ 	const char *from;
  
! 	SWBuf orig = text;
! 	from = orig.c_str();
  
! 	for (text = ""; *from; from++) {
  		if (*from == '<') {
  			intoken = true;
***************
*** 74,78 ****
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = to;
  			continue;
  		}
--- 71,75 ----
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = text.size();
  			continue;
  		}
***************
*** 91,95 ****
  						module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
  						tmp = "";
! 						tmp.append(textStart, (int)(textEnd - textStart));
  						module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
  						newText = true;
--- 88,92 ----
  						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;
***************
*** 104,119 ****
  					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;
  				}
  			}
  			// 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;
  		}
--- 101,115 ----
  					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.size(); newText = false; }
  					continue;
  				}
  			}
  			// if not a strongs token, keep token in text
! 			text += '<';
! 			text += token;
! 			text += '>';
! 			if (newText) {textStart = text.size(); newText = false; }
  			continue;
  		}
***************
*** 124,133 ****
  		}
  		else	{
! 			*to++ = *from;
  			lastspace = (*from == ' ');
  		}
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
--- 120,127 ----
  		}
  		else	{
! 			text += *from;
  			lastspace = (*from == ' ');
  		}
  	}
  	return 0;
  }