[sword-cvs] sword/src/modules/filters gbfhtml.cpp,1.24,1.25 swbasicfilter.cpp,1.20,1.21

sword@www.crosswire.org sword@www.crosswire.org
Thu, 20 Feb 2003 00:25:22 -0700


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

Modified Files:
	gbfhtml.cpp swbasicfilter.cpp 
Log Message:
Started HUGE task of moving all char **buf over to SWBuf &buf

NEED YOUR HELP



Index: gbfhtml.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbfhtml.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** gbfhtml.cpp	26 Jan 2003 07:50:26 -0000	1.24
--- gbfhtml.cpp	20 Feb 2003 07:25:20 -0000	1.25
***************
*** 63,67 ****
  
  
! bool GBFHTML::handleToken(char **buf, const char *token, DualStringMap &userData) {
  	const char *tok;
  	char val[128];
--- 63,67 ----
  
  
! bool GBFHTML::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
  	const char *tok;
  	char val[128];
***************
*** 89,96 ****
  				*valto = 0;
  				if (atoi((!isdigit(*val))?val+1:val) < 5627) {
! 					pushString(buf, " <small><em>&lt;");
  					for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
! 							*(*buf)++ = *tok;
! 					pushString(buf, "&gt;</em></small> ");					
  				}
  			}
--- 89,96 ----
  				*valto = 0;
  				if (atoi((!isdigit(*val))?val+1:val) < 5627) {
! 					buf += " <small><em>&lt;";
  					for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
! 							buf += *tok;
! 					buf += "&gt;</em></small> ";					
  				}
  			}
***************
*** 101,132 ****
  					*valto++ = *num;
  				*valto = 0;
- 				pushString(buf, " <small><em>(");
- 				for (tok = val; *tok; tok++)
  				// normal robinsons tense
! 						*(*buf)++ = *tok;		
! 				pushString(buf, ")</em></small> ");					
  			}
  		}
  		
  		else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
! 			pushString(buf, " <small><em>&lt;");
  			for (tok = token + 2; *tok; tok++)
! 					*(*buf)++ = *tok;
! 			pushString(buf, "&gt;</em></small> ");
  		}
  
  		else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
! 			pushString(buf, " <small><em>&lt;");
  			for (tok = token + 3; *tok; tok++)
  				if(*tok != '\"')
! 					*(*buf)++ = *tok;
! 			pushString(buf, ")</em></small> ");
  		}
  
  		else if (!strncmp(token, "RX", 2)) {
! 			pushString(buf, "<i>");
  			for (tok = token + 3; *tok; tok++) {
  			  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
! 			    *(*buf)++ = *tok;
  			  }
  			  else {
--- 101,132 ----
  					*valto++ = *num;
  				*valto = 0;
  				// normal robinsons tense
! 				buf += " <small><em>(";
! 				for (tok = val; *tok; tok++)
! 						buf += *tok;		
! 				buf += ")</em></small> ";					
  			}
  		}
  		
  		else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
! 			buf += " <small><em>&lt;";
  			for (tok = token + 2; *tok; tok++)
! 					buf += *tok;
! 			buf += "&gt;</em></small> ";
  		}
  
  		else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
! 			buf += " <small><em>&lt;";
  			for (tok = token + 3; *tok; tok++)
  				if(*tok != '\"')
! 					buf += *tok;
! 			buf += ")</em></small> ";
  		}
  
  		else if (!strncmp(token, "RX", 2)) {
! 			buf += "<i>";
  			for (tok = token + 3; *tok; tok++) {
  			  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
! 			    buf += *tok;
  			  }
  			  else {
***************
*** 134,142 ****
  			  }
  			}
! 			pushString(buf, "</i>");
  		}
  
  		else if (!strncmp(token, "RB", 2)) {
! 			pushString(buf, "<i>");
  			userData["hasFootnotePreTag"] = "true";
  		}
--- 134,142 ----
  			  }
  			}
! 			buf += "</i>";
  		}
  
  		else if (!strncmp(token, "RB", 2)) {
! 			buf += "<i>";
  			userData["hasFootnotePreTag"] = "true";
  		}
***************
*** 145,164 ****
  			if(userData["hasFootnotePreTag"] == "true") {
  				userData["hasFootnotePreTag"] = "false";
! 				pushString(buf, "</i> ");
  			}
! 			pushString(buf, "<font color=\"#800000\"><small> (");
  		}
  
  		else if (!strncmp(token, "FN", 2)) {
! 			pushString(buf, "<font face=\"");
  			for (tok = token + 2; *tok; tok++)				
  				if(*tok != '\"') 			
! 					*(*buf)++ = *tok;
! 			*(*buf)++ = '\"';
! 			*(*buf)++ = '>';
  		}
  
  		else if (!strncmp(token, "CA", 2)) {	// ASCII value
! 			*(*buf)++ = (char)atoi(&token[2]);
  		}
  		
--- 145,163 ----
  			if(userData["hasFootnotePreTag"] == "true") {
  				userData["hasFootnotePreTag"] = "false";
! 				buf += "</i> ";
  			}
! 			buf += "<font color=\"#800000\"><small> (";
  		}
  
  		else if (!strncmp(token, "FN", 2)) {
! 			buf += "<font face=\"";
  			for (tok = token + 2; *tok; tok++)				
  				if(*tok != '\"') 			
! 					buf += *tok;
! 			buf += "\">";
  		}
  
  		else if (!strncmp(token, "CA", 2)) {	// ASCII value
! 			buf += (char)atoi(&token[2]);
  		}
  		

Index: swbasicfilter.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/swbasicfilter.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** swbasicfilter.cpp	1 Oct 2002 22:04:59 -0000	1.20
--- swbasicfilter.cpp	20 Feb 2003 07:25:20 -0000	1.21
***************
*** 121,125 ****
  
  
! bool SWBasicFilter::substituteToken(char **buf, const char *token) {
  	DualStringMap::iterator it;
  
--- 121,125 ----
  
  
! bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
  	DualStringMap::iterator it;
  
***************
*** 134,138 ****
  
  	if (it != tokenSubMap.end()) {
! 		pushString(buf, it->second.c_str());
  		return true;
  	}
--- 134,138 ----
  
  	if (it != tokenSubMap.end()) {
! 		buf += it->second.c_str();
  		return true;
  	}
***************
*** 141,145 ****
  
  
! bool SWBasicFilter::substituteEscapeString(char **buf, const char *escString) {
  	DualStringMap::iterator it;
  
--- 141,145 ----
  
  
! bool SWBasicFilter::substituteEscapeString(SWBuf &buf, const char *escString) {
  	DualStringMap::iterator it;
  
***************
*** 154,158 ****
  
  	if (it != escSubMap.end()) {
! 		pushString(buf, it->second.c_str());
  		return true;
  	}
--- 154,158 ----
  
  	if (it != escSubMap.end()) {
! 		buf += it->second.c_str();
  		return true;
  	}
***************
*** 161,170 ****
  
  
! bool SWBasicFilter::handleToken(char **buf, const char *token, DualStringMap &userData) {
  	return substituteToken(buf, token);
  }
  
  
! bool SWBasicFilter::handleEscapeString(char **buf, const char *escString, DualStringMap &userData) {
  	return substituteEscapeString(buf, escString);
  }
--- 161,170 ----
  
  
! bool SWBasicFilter::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
  	return substituteToken(buf, token);
  }
  
  
! bool SWBasicFilter::handleEscapeString(SWBuf &buf, const char *escString, DualStringMap &userData) {
  	return substituteEscapeString(buf, escString);
  }
***************
*** 191,201 ****
  
  
! char SWBasicFilter::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module) {
  	this->key = key;
  	this->module = module;
! 	char *to, *from, token[4096];
  	int tokpos = 0;
  	bool intoken 	= false;
- 	int len;
  	bool inEsc = false;
  	char escStartLen = strlen(escStart);
--- 191,201 ----
  
  
! char SWBasicFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
  	this->key = key;
  	this->module = module;
!         const char *from;
!         char token[4096];
  	int tokpos = 0;
  	bool intoken 	= false;
  	bool inEsc = false;
  	char escStartLen = strlen(escStart);
***************
*** 211,224 ****
  	userData["suspendTextPassThru"] = "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;			// -------------------------------
! 
! 	resultBuffer = text;
! 
! 	for (to = text; *from; from++) {
  		if (*from == tokenStart[tokenStartPos]) {
  			if (tokenStartPos == (tokenStartLen - 1)) {
--- 211,217 ----
  	userData["suspendTextPassThru"] = "false";
  
! 	SWBuf orig = text;
! 	from = orig.c_str();
! 	for (text = ""; *from; from++) {
  		if (*from == tokenStart[tokenStartPos]) {
  			if (tokenStartPos == (tokenStartLen - 1)) {
***************
*** 252,259 ****
  					intoken = false;
  					userData["lastTextNode"] = lastTextNode;
! 					if ((!handleEscapeString(&to, token, userData)) && (passThruUnknownEsc)) {
! 						pushString(&to, escStart);
! 						pushString(&to, token);
! 						pushString(&to, escEnd);
  					}
  					escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
--- 245,252 ----
  					intoken = false;
  					userData["lastTextNode"] = lastTextNode;
! 					if ((!handleEscapeString(text, token, userData)) && (passThruUnknownEsc)) {
! 						text += escStart;
! 						text += token;
! 						text += escEnd;
  					}
  					escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
***************
*** 270,277 ****
  					intoken = false;
  					userData["lastTextNode"] = lastTextNode;
! 					if ((!handleToken(&to, token, userData)) && (passThruUnknownToken)) {
! 						pushString(&to, tokenStart);
! 						pushString(&to, token);
! 						pushString(&to, tokenEnd);
  					}
  					escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
--- 263,270 ----
  					intoken = false;
  					userData["lastTextNode"] = lastTextNode;
! 					if ((!handleToken(text, token, userData)) && (passThruUnknownToken)) {
! 						text += tokenStart;
! 						text += token;
! 						text += tokenEnd;
  					}
  					escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
***************
*** 290,302 ****
  		else {
  			if (!suspendTextPassThru)
! 				*to++ = *from;
  			lastTextNode += *from;
  		}
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
- 
  
  SWORD_NAMESPACE_END
--- 283,292 ----
  		else {
  			if (!suspendTextPassThru)
! 				text += *from;
  			lastTextNode += *from;
  		}
  	}
  	return 0;
  }
  
  SWORD_NAMESPACE_END