[sword-svn] r2436 - in trunk: src/keys tests utilities

scribe at crosswire.org scribe at crosswire.org
Sun Jun 14 12:40:02 MST 2009


Author: scribe
Date: 2009-06-14 12:40:02 -0700 (Sun, 14 Jun 2009)
New Revision: 2436

Modified:
   trunk/src/keys/listkey.cpp
   trunk/tests/filtertest.cpp
   trunk/tests/localetest.cpp
   trunk/tests/parsekey.cpp
   trunk/tests/rawldidxtest.cpp
   trunk/utilities/installmgr.cpp
Log:
Fixed error where empty listkey would segv
normalized output methods in utilities and added included where necessary
fixed usage wording on installmgr which was messed up by inserting a new option between 2 lines of the same option


Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/src/keys/listkey.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -165,7 +165,7 @@
 	}
 	Error();		// clear error
 	for(; step && !Error(); step--) {
-		if (arraypos < arraycnt) {
+		if (arraypos < arraycnt && arraycnt) {
 			if (array[arraypos]->isBoundSet())
 				(*(array[arraypos]))++;
 			if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
@@ -189,7 +189,7 @@
 	}
 	Error();		// clear error
 	for(; step && !Error(); step--) {
-		if (arraypos > -1) {
+		if (arraypos > -1 && arraycnt) {
 			if (array[arraypos]->isBoundSet())
 				(*(array[arraypos]))--;
 			if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
@@ -323,7 +323,7 @@
 
 const char *ListKey::getText() const {
 	int pos = arraypos;
-	SWKey *key = (pos >= arraycnt) ? 0:array[pos];
+	SWKey *key = (pos >= arraycnt || !arraycnt) ? 0:array[pos];
 	return (key) ? key->getText() : keytext;
 }
 

Modified: trunk/tests/filtertest.cpp
===================================================================
--- trunk/tests/filtertest.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/tests/filtertest.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -52,7 +52,7 @@
 	while (!fd || FileMgr::getLine(fd, lineBuffer)) {
 		filter.processText(lineBuffer);
 		for (unsigned int i = 0; i < lineBuffer.size(); i++) {
-			printf("%c", lineBuffer[i]);
+			std::cout << lineBuffer[i];
 		}
 		cout << "\n";
 		if (!fd) break;

Modified: trunk/tests/localetest.cpp
===================================================================
--- trunk/tests/localetest.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/tests/localetest.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -24,13 +24,13 @@
 
 int main(int argc, char **argv) {
 	if (argc != 3) {
-		fprintf(stderr, "usage: %s <locale_name> <text>\n", *argv);
+		std::cerr <<  "usage: " << *argv << " <locale_name> <text>\n";
 		exit(-1);
 	}
 
 	LocaleMgr lm;
 
-	printf("%s\n", lm.translate(argv[1], argv[2]));
+	std::cout << lm.translate(argv[1], argv[2]) << "\n";
 
 	VerseKey bla;
 	bla = "James 1:19";

Modified: trunk/tests/parsekey.cpp
===================================================================
--- trunk/tests/parsekey.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/tests/parsekey.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -27,7 +27,7 @@
 
 int main(int argc, char **argv) {
 	if ((argc < 2) || (argc > 4)) {
-		fprintf(stderr, "usage: %s <\"string to parse\"> [locale_name] [v11n] [test-in-set-verse]\n", *argv);
+		std::cerr << "usage: " << *argv << " <\"string to parse\"> [locale_name] [v11n] [test-in-set-verse]\n";
 		exit(-1);
 	}
 

Modified: trunk/tests/rawldidxtest.cpp
===================================================================
--- trunk/tests/rawldidxtest.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/tests/rawldidxtest.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -15,7 +15,7 @@
  *
  */
 
-#include <iostream>
+#include <stdio.h>
 #include <rawstr.h>
 #include <swmgr.h>
 #include <filemgr.h>

Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp	2009-06-06 14:32:13 UTC (rev 2435)
+++ trunk/utilities/installmgr.cpp	2009-06-14 19:40:02 UTC (rev 2436)
@@ -96,8 +96,8 @@
 void usage(const char *progName) {
 	fprintf(stderr, "usage: %s <option>\nOptions:\n"
 		"\t-init\t\t\t\tcreate a basic user config file.\n"
+		"\t\t\t\t\t\tWARNING: overwrites existing.\n"
 		"\t-sc\t\t\t\tsync config with known remote repo list\n"
-		"\t\t\t\t\t\tWARNING: overwrites existing.\n"
 		"\t-l\t\t\t\tlist installed modules\n"
 		"\t-u <modName>\t\t\tuninstall module\n"
 		"\t-s\t\t\t\tlist remote sources\n"
@@ -149,6 +149,7 @@
 		return;
 	}
 
+	// be sure we have at least some config file already out there
 	if (!FileMgr::existsFile(confPath.c_str())) {
 		createBasicConfig(true, false);
 		finish(1); // cleanup and don't exit




More information about the sword-cvs mailing list