[sword-devel] indexed search discrepancy (minor search.cpp patch)

Jonathan Marsden jmarsden at fastmail.fm
Sat Aug 29 21:11:24 MST 2009

Matthew Talbert wrote:

> If this gets fixed, I think searching and results should be added to
> the test suite. It would be simple to add; just run mkfastmod, then
> the search program (it would be nice to be able to change the search
> type without re-compiling so that different search types could be
> done).

Seems reasonable.  I just created a trivially enhanced search.cpp which
checks for the existence of SEARCH_TYPE as an enviroment variable and
uses it if present.  svn diff attached.  So now you can do

  SEARCH_TYPE=-4 ./search KJV "swift hear slow speak"

and so on and so forth.  Patch is below.


Index: search.cpp
--- search.cpp	(revision 2449)
+++ search.cpp	(working copy)
@@ -26,6 +26,7 @@
 #include <markupfiltmgr.h>
 #include <regex.h> // GNU
 #include <iostream>
+#include <cstdlib> // For getenv() and atoi()

 using namespace sword;
@@ -72,6 +73,13 @@

+	// Override compiled in SEARCH_TYPE from environment variable.
+	char *envpointer;
+	std::string envstring = "SEARCH_TYPE";
+	if ((envpointer = getenv(envstring.c_str()))) {
+	  SEARCH_TYPE = atoi(envpointer);
+	  std::cout << "SEARCH_TYPE is : " << envpointer << std::endl ;
+	}

 	SWBuf searchTerm = argv[2];
 	manager.setGlobalOption("Greek Accents", "Off");

More information about the sword-devel mailing list