[sword-svn] r3454 - in trunk: include src/modules

scribe at crosswire.org scribe at crosswire.org
Sun Apr 23 16:00:12 MST 2017


Author: scribe
Date: 2017-04-23 16:00:11 -0700 (Sun, 23 Apr 2017)
New Revision: 3454

Modified:
   trunk/include/swmodule.h
   trunk/src/modules/swmodule.cpp
Log:
fixed search flag OR bug for c++11regex support
catch prepare error for regex, in the case of bad user input


Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2017-04-23 01:26:51 UTC (rev 3453)
+++ trunk/include/swmodule.h	2017-04-23 23:00:11 UTC (rev 3454)
@@ -386,7 +386,7 @@
 	 *
 	 * @param istr string for which to search
 	 * @param searchType type of search to perform
-	 *			>=0 - regex
+	 *			>=0 - regex; (for backward compat, if > 0 then used as additional REGEX FLAGS)
 	 *			-1  - phrase
 	 *			-2  - multiword
 	 *			-3  - entryAttrib (eg. Word//Lemma./G1234/)	 (Lemma with dot means check components (Lemma.[1-9]) also)

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2017-04-23 01:26:51 UTC (rev 3453)
+++ trunk/src/modules/swmodule.cpp	2017-04-23 23:00:11 UTC (rev 3454)
@@ -365,7 +365,7 @@
  *
  * ENT:	istr		- string for which to search
  * 	searchType	- type of search to perform
- *				>=0 - regex
+ *				>=0 - regex; (for backward compat, if > 0 then used as additional REGEX FLAGS)
  *				-1  - phrase
  *				-2  - multiword
  *				-3  - entryAttrib (eg. Word//Lemma./G1234/)	 (Lemma with dot means check components (Lemma.[1-9]) also)
@@ -460,10 +460,14 @@
 	*this = TOP;
 	if (searchType >= 0) {
 #ifdef USECXX11REGEX
-		preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended & flags);
+		preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended | searchType | flags);
 #else
 		flags |=searchType|REG_NOSUB|REG_EXTENDED;
-		regcomp(&preg, istr, flags);
+		int err = regcomp(&preg, istr, flags);
+		if (err) {
+			SWLog::getSystemLog()->logError("Error compiling Regex: %d", err);
+			return listKey;
+		}
 #endif
 	}
 




More information about the sword-cvs mailing list