[sword-svn] r2931 - in trunk: include src/modules/filters tests utilities utilities/diatheke

scribe at crosswire.org scribe at crosswire.org
Wed Jul 31 06:07:27 MST 2013


Author: scribe
Date: 2013-07-31 06:07:26 -0700 (Wed, 31 Jul 2013)
New Revision: 2931

Modified:
   trunk/include/swmodule.h
   trunk/src/modules/filters/utf8arshaping.cpp
   trunk/src/modules/filters/utf8bidireorder.cpp
   trunk/tests/introtest.cpp
   trunk/tests/mgrtest.cpp
   trunk/utilities/diatheke/corediatheke.cpp
   trunk/utilities/emptyvss.cpp
   trunk/utilities/mod2vpl.cpp
Log:
Cleaned an unitialized valgrind report in the utf8 filters
Since we deprecated returning a const char * from renderText, we should not allow an undeprecated backdoor through SWModule::operator char *
Removed deprecation warning in the tests and utils


Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/include/swmodule.h	2013-07-31 13:07:26 UTC (rev 2931)
@@ -47,7 +47,8 @@
 #define SEARCHFLAG_MATCHWHOLEENTRY 4096
 
 #define SWMODULE_OPERATORS \
-	operator const char *() { return renderText(); } \
+	SWDEPRECATED operator const char *() { static SWBuf unsafeTmp = renderText(); return unsafeTmp.c_str(); } \
+	operator SWBuf() { return renderText(); } \
 	operator SWKey &() { return *getKey(); } \
 	operator SWKey *() { return getKey(); } \
 	SWModule &operator <<(const char *inbuf) { setEntry(inbuf); return *this; } \
@@ -95,7 +96,7 @@
      char display(SWModule &imodule)
      {
      #ifndef	_WIN32_WCE
-          std::cout << (const char *)imodule;
+          std::cout << imodule.renderText();
      #endif
           return 0;
      }

Modified: trunk/src/modules/filters/utf8arshaping.cpp
===================================================================
--- trunk/src/modules/filters/utf8arshaping.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/src/modules/filters/utf8arshaping.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -32,7 +32,7 @@
 
 SWORD_NAMESPACE_START
 
-UTF8arShaping::UTF8arShaping() {
+UTF8arShaping::UTF8arShaping() : err(U_ZERO_ERROR) {
 	conv = ucnv_open("UTF-8", &err);
 }
 

Modified: trunk/src/modules/filters/utf8bidireorder.cpp
===================================================================
--- trunk/src/modules/filters/utf8bidireorder.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/src/modules/filters/utf8bidireorder.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -33,7 +33,7 @@
 
 SWORD_NAMESPACE_START
 
-UTF8BiDiReorder::UTF8BiDiReorder() {
+UTF8BiDiReorder::UTF8BiDiReorder() : err(U_ZERO_ERROR) {
 
         conv = ucnv_open("UTF-8", &err);
 

Modified: trunk/tests/introtest.cpp
===================================================================
--- trunk/tests/introtest.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/tests/introtest.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -81,35 +81,35 @@
 	vk.setChapter(0);
 	vk.setVerse(0);
 
-	std::cout << "Module heading text ?= " << (const char*)mod << std::endl;
+	std::cout << "Module heading text ?= " << mod.renderText() << std::endl;
 
 	vk.setTestament(1);
 	vk.setBook(0);
 	vk.setChapter(0);
 	vk.setVerse(0);
 
-	std::cout << "OT heading text ?= " << (const char*)mod << std::endl;
+	std::cout << "OT heading text ?= " << mod.renderText() << std::endl;
 
 	vk.setTestament(1);
 	vk.setBook(1);
 	vk.setChapter(0);
 	vk.setVerse(0);
 
-	std::cout << "Gen heading text ?= " << (const char*)mod << std::endl;
+	std::cout << "Gen heading text ?= " << mod.renderText() << std::endl;
 
 	vk.setTestament(1);
 	vk.setBook(1);
 	vk.setChapter(1);
 	vk.setVerse(0);
 
-	std::cout << "Gen 1 heading text ?= " << (const char*)mod << std::endl;
+	std::cout << "Gen 1 heading text ?= " << mod.renderText() << std::endl;
 
 	vk.setTestament(1);
 	vk.setBook(1);
 	vk.setChapter(1);
 	vk.setVerse(1);
 
-	std::cout << "Gen 1:1 text ?= " << (const char*)mod << std::endl;
+	std::cout << "Gen 1:1 text ?= " << mod.renderText() << std::endl;
 
 	  /* old introtest
 	SWModule *mhc = mymgr.Modules["MHC"];

Modified: trunk/tests/mgrtest.cpp
===================================================================
--- trunk/tests/mgrtest.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/tests/mgrtest.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -51,7 +51,7 @@
 		std::cout << "Has Feature HebrewDef = " << it->second->getConfig().has("Feature", "HebrewDef") << "\n";
 		if ((!strcmp((*it).second->getType(), "Biblical Texts")) || (!strcmp((*it).second->getType(), "Commentaries"))) {
 			it->second->setKey("James 1:19");
-			std::cout << (const char *) *(*it).second << "\n\n";
+			std::cout << (*it).second->renderText() << "\n\n";
 		}
 	}
 
@@ -60,7 +60,7 @@
 	if (mhc) {
 		std::cout << "MHC, Lang = " << mhc->getLanguage() << "\n\n";
 		for (mhc->setKey("Gen 1:1"); *mhc->getKey() < (VerseKey) "Gen 1:10"; (*mhc)++)
-			std::cout << (const char *) *mhc << "\n";
+			std::cout << mhc->renderText() << "\n";
 	}
 
 	if (sysConf)

Modified: trunk/utilities/diatheke/corediatheke.cpp
===================================================================
--- trunk/utilities/diatheke/corediatheke.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/utilities/diatheke/corediatheke.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -303,7 +303,7 @@
 
 		target->setKey(ref);
 
-		SWBuf text = (const char *) *target;
+		SWBuf text = target->renderText();
 
 		if (outputformat == FMT_RTF) {
 			*output << "{\\rtf1\\ansi{\\fonttbl{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}{\\f1\\fdecor\\fprq2 ";
@@ -392,7 +392,7 @@
 					else {
 						*output << ": ";
 					}
-					*output << (const char*)*target;
+					*output << target->renderText();
 					if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 						*output << "</font>";
 					}
@@ -431,7 +431,7 @@
 				else {
 					*output << ": ";
 				}
-				*output << (const char*)*target;
+				*output << target->renderText();
 				if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 					*output << "</font>";
 				}

Modified: trunk/utilities/emptyvss.cpp
===================================================================
--- trunk/utilities/emptyvss.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/utilities/emptyvss.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -73,9 +73,9 @@
 
 	while (!mod->popError()) {
 	  
-	  if (vkey->getVerse())
-	    if (!strlen ((const char *)(*mod)))
-	      std::cout << *vkey << std::endl;
-	  (*mod)++;
+	if (vkey->getVerse())
+		if (!mod->renderText().length())
+			std::cout << *vkey << std::endl;
+		(*mod)++;
 	}
 }

Modified: trunk/utilities/mod2vpl.cpp
===================================================================
--- trunk/utilities/mod2vpl.cpp	2013-07-31 12:09:08 UTC (rev 2930)
+++ trunk/utilities/mod2vpl.cpp	2013-07-31 13:07:26 UTC (rev 2931)
@@ -95,8 +95,8 @@
 	(*mod) = TOP;
 
 	while (!mod->popError()) {
-		buffer = new char [ strlen ((const char *)(*mod)) + 1 ];
-		strcpy(buffer, (const char *)(*mod));
+		buffer = new char [ mod->renderText().length() + 1 ];
+		strcpy(buffer, mod->renderText());
 		cleanbuf(buffer);
 		if (vref) {
 			if ((strlen(buffer) > 0) && (vref)) {




More information about the sword-cvs mailing list