[sword-svn] r2806 - trunk/src/modules

scribe at crosswire.org scribe at crosswire.org
Fri Jun 7 06:32:17 MST 2013


Author: scribe
Date: 2013-06-07 06:32:16 -0700 (Fri, 07 Jun 2013)
New Revision: 2806

Modified:
   trunk/src/modules/swmodule.cpp
Log:
added ability for regex searches to cross verse boundaries.


Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2013-06-04 03:39:11 UTC (rev 2805)
+++ trunk/src/modules/swmodule.cpp	2013-06-07 13:32:16 UTC (rev 2806)
@@ -386,9 +386,11 @@
 		return listKey;
 	}
 	
-	SWKey *saveKey = 0;
+	SWKey *saveKey   = 0;
 	SWKey *searchKey = 0;
 	SWKey *resultKey = createKey();
+	SWKey *lastKey   = createKey();
+	SWBuf lastBuf = "";
 	regex_t preg;
 	vector<SWBuf> words;
 	vector<SWBuf> window;
@@ -559,11 +561,21 @@
 #endif
 		}
 		if (searchType >= 0) {
-			if (!regexec(&preg,  stripText(), 0, 0, 0)) {
+			SWBuf textBuf = stripText();
+			if (!regexec(&preg, textBuf, 0, 0, 0)) {
 				*resultKey = *getKey();
 				resultKey->clearBound();
 				listKey << *resultKey;
+				lastBuf = "";
 			}
+			else if (!regexec(&preg, lastBuf + ' ' + textBuf, 0, 0, 0)) {
+				lastKey->clearBound();
+				listKey << *lastKey;
+				lastBuf = textBuf;
+			}
+			else {
+				lastBuf = textBuf;
+			}
 		}
 
 		// phrase
@@ -737,6 +749,7 @@
 				break;
 			} // end switch
 		}
+		*lastKey = *getKey();
 		(*this)++;
 	}
 	
@@ -753,6 +766,7 @@
 	if (searchKey)
 		delete searchKey;
 	delete resultKey;
+	delete lastKey;
 
 	listKey = TOP;
 	setProcessEntryAttributes(savePEA);




More information about the sword-cvs mailing list