[sword-cvs] sword/src/modules/filters thmlscripref.cpp,1.5,1.6

sword@www.crosswire.org sword@www.crosswire.org
Fri, 21 Feb 2003 13:51:33 -0700


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

Modified Files:
	thmlscripref.cpp 
Log Message:
converted thmlscripref filter

Index: thmlscripref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlscripref.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** thmlscripref.cpp	1 Oct 2002 19:52:40 -0000	1.5
--- thmlscripref.cpp	21 Feb 2003 20:51:31 -0000	1.6
***************
*** 45,77 ****
  {
  	if (!option) {	// if we don't want scriprefs
- 		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;
  			}
! 			if (*from == '>') {	// process tokens
  				intoken = false;
! 				if (!strnicmp(token, "scripRef", 8)) {
  				  hide = true;
                                    continue;
  				}
! 				else if (!strnicmp(token, "/scripRef", 9)) {
  				  hide = false;
                                    continue;
--- 45,67 ----
  {
  	if (!option) {	// if we don't want scriprefs
  		bool intoken = false;
  		bool hide = false;
  
! 		SWBuf token;
! 		SWBuf orig = text;
!  	 	const char *from = orig.c_str();
! 		for (text = ""; *from; from++) {
! 			if (*from == '<') { //new token was found
  				intoken = true;
! 				token = "";
  				continue;
  			}
! 			else if (*from == '>') {	// process tokens
  				intoken = false;
! 				if (!strnicmp(token.c_str(), "scripRef", 8)) {
  				  hide = true;
                                    continue;
  				}
! 				else if (!strnicmp(token.c_str(), "/scripRef", 9)) {
  				  hide = false;
                                    continue;
***************
*** 80,99 ****
  				// if not a scripref 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;
! 				}
  			}
  		}
--- 70,84 ----
  				// if not a scripref 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;
  			}
  		}