[Box Backup-commit] COMMIT r1677 - in box/chris/general: . lib/common

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat May 26 13:25:26 BST 2007


Author: chris
Date: 2007-05-26 13:25:26 +0100 (Sat, 26 May 2007)
New Revision: 1677

Modified:
   box/chris/general/configure.ac
   box/chris/general/lib/common/BoxConfig-MSVC.h
   box/chris/general/lib/common/ExcludeList.cpp
   box/chris/general/lib/common/ExcludeList.h
Log:
Work around the fact that we may have regex support without having 
regex.h (e.g. from pcreposix.h/libpcreposix) and disabuse HAVE_REGEX_H, 
define and use HAVE_REGEX_SUPPORT instead, thanks Gary!


Modified: box/chris/general/configure.ac
===================================================================
--- box/chris/general/configure.ac	2007-05-25 18:41:43 UTC (rev 1676)
+++ box/chris/general/configure.ac	2007-05-26 12:25:26 UTC (rev 1677)
@@ -112,9 +112,26 @@
 
 if test "$have_regex_h" = "yes"; then
   AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if regex.h is available])
+else
+  AC_CHECK_HEADER([pcreposix.h], [have_pcreposix_h=yes])
+fi
+
+if test "$have_pcreposix_h" = "yes"; then
+  AC_SEARCH_LIBS([regcomp], ["pcreposix -lpcre"],,[have_pcreposix_h=no_regcomp])
+fi
+
+if test "$have_pcreposix_h" = "yes"; then
+  AC_DEFINE([HAVE_PCREPOSIX_H], [1], [Define to 1 if pcreposix.h is available])
   AC_SEARCH_LIBS([regcomp], ["pcreposix -lpcre"])
 fi
 
+if test "$have_regex_h" = "yes" -o "$have_pcreposix_h" = "yes"; then
+  have_regex_support=yes
+  AC_DEFINE([HAVE_REGEX_SUPPORT], [1], [Define to 1 if regular expressions are supported])
+else
+  have_regex_support=no
+fi
+
 AC_SEARCH_LIBS([dlsym], ["dl"])
 
 ### Checks for typedefs, structures, and compiler characteristics.
@@ -274,7 +291,7 @@
 without these features, but will work better where they are present. Refer
 to the documentation for more information on each feature.
 
-Regular expressions: $have_regex_h
+Regular expressions: $have_regex_support
 Large files:         $have_large_file_support
 Berkeley DB:         $ax_path_bdb_ok
 Readline:            $have_libreadline

Modified: box/chris/general/lib/common/BoxConfig-MSVC.h
===================================================================
--- box/chris/general/lib/common/BoxConfig-MSVC.h	2007-05-25 18:41:43 UTC (rev 1676)
+++ box/chris/general/lib/common/BoxConfig-MSVC.h	2007-05-26 12:25:26 UTC (rev 1677)
@@ -178,6 +178,7 @@
 /* Define to 1 if you have the <regex.h> header file. */
 /* #undef HAVE_REGEX_H */
 #define HAVE_PCREPOSIX_H 1
+#define HAVE_REGEX_SUPPORT 1
 
 /* Define to 1 if you have the `setproctitle' function. */
 /* #undef HAVE_SETPROCTITLE */

Modified: box/chris/general/lib/common/ExcludeList.cpp
===================================================================
--- box/chris/general/lib/common/ExcludeList.cpp	2007-05-25 18:41:43 UTC (rev 1676)
+++ box/chris/general/lib/common/ExcludeList.cpp	2007-05-26 12:25:26 UTC (rev 1677)
@@ -9,12 +9,13 @@
 
 #include "Box.h"
 
-#ifdef HAVE_PCREPOSIX_H
-	#include <pcreposix.h>
+#ifdef HAVE_REGEX_SUPPORT
+	#ifdef HAVE_PCREPOSIX_H
+		#include <pcreposix.h>
+	#else
+		#include <regex.h>
+	#endif
 	#define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED
-#elif defined HAVE_REGEX_H
-	#include <regex.h>
-	#define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED
 #endif
 
 #include "ExcludeList.h"
@@ -49,7 +50,7 @@
 // --------------------------------------------------------------------------
 ExcludeList::~ExcludeList()
 {
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	// free regex memory
 	while(mRegex.size() > 0)
 	{
@@ -167,7 +168,7 @@
 // --------------------------------------------------------------------------
 void ExcludeList::AddRegexEntries(const std::string &rEntries)
 {
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 
 	// Split strings up
 	std::vector<std::string> ens;
@@ -252,7 +253,7 @@
 	}
 	
 	// Check against regular expressions
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	for(std::vector<regex_t *>::const_iterator i(mRegex.begin()); i != mRegex.end(); ++i)
 	{
 		// Test against this expression
@@ -308,7 +309,7 @@
 	//
 	mDefinite.clear();
 
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	// free regex memory
 	while(mRegex.size() > 0)
 	{
@@ -349,7 +350,7 @@
 	//
 	//
 	//
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	rArchive.Read(iCount);
 
 	if (iCount > 0)
@@ -386,7 +387,7 @@
 			}
 		}
 	}
-#endif // HAVE_REGEX_H
+#endif // HAVE_REGEX_SUPPORT
 
 	//
 	//
@@ -441,7 +442,7 @@
 	//
 	//
 	//
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	// don't even try to save compiled regular expressions,
 	// use string copies instead.
 	ASSERT(mRegex.size() == mRegexStr.size()); 	
@@ -454,7 +455,7 @@
 	{
 		rArchive.Write(*i);
 	}
-#endif // HAVE_REGEX_H
+#endif // HAVE_REGEX_SUPPORT
 
 	//
 	//

Modified: box/chris/general/lib/common/ExcludeList.h
===================================================================
--- box/chris/general/lib/common/ExcludeList.h	2007-05-25 18:41:43 UTC (rev 1676)
+++ box/chris/general/lib/common/ExcludeList.h	2007-05-26 12:25:26 UTC (rev 1677)
@@ -50,7 +50,7 @@
 	// Mainly for tests
 	unsigned int SizeOfDefiniteList() const {return mDefinite.size();}
 	unsigned int SizeOfRegexList() const
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 		{return mRegex.size();}
 #else
 		{return 0;}
@@ -58,7 +58,7 @@
 
 private:
 	std::set<std::string> mDefinite;
-#ifdef HAVE_REGEX_H
+#ifdef HAVE_REGEX_SUPPORT
 	std::vector<regex_t *> mRegex;
 	std::vector<std::string> mRegexStr;	// save original regular expression string-based source for Serialize
 #endif




More information about the Boxbackup-commit mailing list