[sword-cvs] sword/src/modules/filters osismorph.cpp,1.1,1.2 osisstrongs.cpp,1.1,1.2

sword@www.crosswire.org sword@www.crosswire.org
Wed, 26 Feb 2003 12:21:54 -0700


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

Modified Files:
	osismorph.cpp osisstrongs.cpp 
Log Message:
converted to SWBuf. please review.


Index: osismorph.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osismorph.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** osismorph.cpp	8 Jan 2003 09:39:57 -0000	1.1
--- osismorph.cpp	26 Feb 2003 19:21:52 -0000	1.2
***************
*** 42,62 ****
  }
  
! char OSISMorph::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;
--- 42,60 ----
  }
  
! char OSISMorph::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;
  		int len;
  		bool lastspace = false;
+ 		SWBuf orig = text;
+ 		from = orig.c_str();
  
  		len = strlen(text) + 1;	// shift string to right of buffer
  
! 		for (text = ""; *from; from++) {
  			if (*from == '<') {
  				intoken = true;
***************
*** 81,88 ****
  				}
  				// if not a morph tag token, keep token in text
! 				*to++ = '<';
  				for (char *tok = token; *tok; tok++)
! 					*to++ = *tok;
! 				*to++ = '>';
  				continue;
  			}
--- 79,86 ----
  				}
  				// if not a morph tag token, keep token in text
! 				text += '<';
  				for (char *tok = token; *tok; tok++)
! 					text += *tok;
! 				text += '>';
  				continue;
  			}
***************
*** 93,102 ****
  			}
  			else	{
! 				*to++ = *from;
  				lastspace = (*from == ' ');
  			}
  		}
- 		*to++ = 0;
- 		*to = 0;
  	}
  	return 0;
--- 91,98 ----
  			}
  			else	{
! 				text += *from;
  				lastspace = (*from == ' ');
  			}
  		}
  	}
  	return 0;

Index: osisstrongs.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisstrongs.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** osisstrongs.cpp	8 Jan 2003 09:39:57 -0000	1.1
--- osisstrongs.cpp	26 Feb 2003 19:21:52 -0000	1.2
***************
*** 44,50 ****
  }
  
! char OSISStrongs::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,51 ----
  }
  
! char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
! 	const char *from;
! 	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;
--- 57,70 ----
  	char *valto;
  	char *ch;
! 	unsigned int textStart = 0, textEnd = 0;
  	bool newText = false;
  	std::string tmp;
  
+ 	SWBuf orig = text;
+ 	from = orig.c_str();
+ 
  	len = strlen(text) + 1;	// shift string to right of buffer
  
! 	for (text = ""; *from; from++) {
  		if (*from == '<') {
  			intoken = true;
***************
*** 74,78 ****
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = to;
  			continue;
  		}
--- 73,77 ----
  			token[1] = 0;
  			token[2] = 0;
! 			textEnd = text.size();
  			continue;
  		}
***************
*** 116,124 ****
  			}
  			// 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;
  		}
--- 115,123 ----
  			}
  			// if not a strongs token, keep token in text
! 			text += '<';
  			for (char *tok = token; *tok; tok++)
! 				text += *tok;
! 			text += '>';
! 			if (newText) {textStart = text.size(); newText = false; }
  			continue;
  		}
***************
*** 129,138 ****
  		}
  		else	{
! 			*to++ = *from;
  			lastspace = (*from == ' ');
  		}
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
--- 128,135 ----
  		}
  		else	{
! 			text += *from;
  			lastspace = (*from == ' ');
  		}
  	}
  	return 0;
  }