[pulseaudio-discuss] [PATCH 06/10] Use PCRE if POSIX regex.h is not available

Maarten Bosmans mkbosmans at gmail.com
Wed Jan 5 17:39:53 PST 2011


---
 configure.ac               |    7 ++++---
 src/modules/module-match.c |    7 ++++++-
 src/pulsecore/core-util.c  |    7 ++++++-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index df96cd3..5fddd28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,10 +362,7 @@ AC_CHECK_HEADERS([netinet/ip.h], [], [],
                   # include <netinet/in_systm.h>
                   #endif
                  ])
-AC_CHECK_HEADERS([regex.h], [HAVE_REGEX=1], [HAVE_REGEX=0])
 AC_CHECK_HEADERS([sys/un.h], [HAVE_AF_UNIX=1], [HAVE_AF_UNIX=0])
-
-AM_CONDITIONAL(HAVE_REGEX, test "x$HAVE_REGEX" = "x1")
 AM_CONDITIONAL(HAVE_AF_UNIX, test "x$HAVE_AF_UNIX" = "x1")
 
 # Linux
@@ -392,6 +389,10 @@ AC_CHECK_HEADERS_ONCE([sys/eventfd.h])
 AC_CHECK_HEADERS_ONCE([execinfo.h])
 AC_CHECK_HEADERS_ONCE([langinfo.h])
 
+AC_CHECK_HEADERS([regex.h], [HAVE_REGEX_H=1], [HAVE_REGEX_H=0])
+AC_CHECK_HEADERS([pcre.h], [HAVE_PCRE_H=1], [HAVE_PCRE_H=0])
+AM_CONDITIONAL(HAVE_REGEX, [test "x$HAVE_REGEX_H" = "x1" || test "x$HAVE_PCRE_H" = "x1"])
+
 #### Typdefs, structures, etc. ####
 
 AC_C_CONST
diff --git a/src/modules/module-match.c b/src/modules/module-match.c
index d83c86c..5976f03 100644
--- a/src/modules/module-match.c
+++ b/src/modules/module-match.c
@@ -27,10 +27,15 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#if defined(HAVE_REGEX_H)
+#include <regex.h>
+#elif defined(HAVE_PCRE_H)
+#include <pcreposix.h>
+#endif
+
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-error.h>
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 335140f..513b68c 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -40,7 +40,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <dirent.h>
-#include <regex.h>
 
 #ifdef HAVE_LANGINFO_H
 #include <langinfo.h>
@@ -50,6 +49,12 @@
 #include <sys/utsname.h>
 #endif
 
+#if defined(HAVE_REGEX_H)
+#include <regex.h>
+#elif defined(HAVE_PCRE_H)
+#include <pcreposix.h>
+#endif
+
 #ifdef HAVE_STRTOF_L
 #include <locale.h>
 #endif
-- 
1.7.1




More information about the pulseaudio-discuss mailing list