summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordata-man <dataman@tutanota.com>2022-01-24 07:34:59 +0500
committerdata-man <dataman@tutanota.com>2022-01-24 07:34:59 +0500
commit475bc25800451c76d9a721fb35628693758a15e0 (patch)
treeaa46e0fc0be368d98f1fc34853b70b1e6619eedb
parent8199f5c1c599a39ba0a9c4ace0bacde95b4bb483 (diff)
downloadbfs-475bc25800451c76d9a721fb35628693758a15e0.tar.xz
Using Oniguruma library (optionally)
-rw-r--r--Makefile10
-rw-r--r--eval.c7
-rw-r--r--expr.h7
-rw-r--r--parse.c7
-rw-r--r--util.c7
-rw-r--r--util.h7
6 files changed, 40 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 18a51d3..77de641 100644
--- a/Makefile
+++ b/Makefile
@@ -72,6 +72,11 @@ ifeq ($(OS),Linux)
LOCAL_LDFLAGS += -Wl,--as-needed
LOCAL_LDLIBS += -lacl -lcap -lattr -lrt
+ifdef USE_ONIGURUMA
+LOCAL_LDLIBS += -lonig
+LOCAL_CFLAGS += -DUSE_ONIGURUMA
+endif
+
# These libraries are not built with msan, so disable them
MSAN_CFLAGS += -DBFS_HAS_SYS_ACL=0 -DBFS_HAS_SYS_CAPABILITY=0 -DBFS_HAS_SYS_XATTR=0
@@ -82,6 +87,11 @@ endif
ifeq ($(OS),NetBSD)
LOCAL_LDLIBS += -lutil
+
+ifdef USE_ONIGURUMA
+LOCAL_LDLIBS += -lonig
+LOCAL_CFLAGS += -DUSE_ONIGURUMA
+endif
endif
ifneq ($(filter asan,$(MAKECMDGOALS)),)
diff --git a/eval.c b/eval.c
index ec2701b..8dd8f75 100644
--- a/eval.c
+++ b/eval.c
@@ -43,7 +43,6 @@
#include <fnmatch.h>
#include <grp.h>
#include <pwd.h>
-#include <regex.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
@@ -55,6 +54,12 @@
#include <unistd.h>
#include <wchar.h>
+#ifdef USE_ONIGURUMA
+ #include <onigposix.h>
+#else
+ #include <regex.h>
+#endif
+
struct eval_state {
/** Data about the current file. */
const struct BFTW *ftwbuf;
diff --git a/expr.h b/expr.h
index c25d1ca..82df7bf 100644
--- a/expr.h
+++ b/expr.h
@@ -26,12 +26,17 @@
#include "exec.h"
#include "printf.h"
#include "stat.h"
-#include <regex.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include <time.h>
+#ifdef USE_ONIGURUMA
+ #include <onigposix.h>
+#else
+ #include <regex.h>
+#endif
+
/**
* Possible types of numeric comparison.
*/
diff --git a/parse.c b/parse.c
index 8ff47c2..9ff2c2a 100644
--- a/parse.c
+++ b/parse.c
@@ -48,7 +48,6 @@
#include <grp.h>
#include <limits.h>
#include <pwd.h>
-#include <regex.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
@@ -60,6 +59,12 @@
#include <time.h>
#include <unistd.h>
+#ifdef USE_ONIGURUMA
+ #include <onigposix.h>
+#else
+ #include <regex.h>
+#endif
+
// Strings printed by -D tree for "fake" expressions
static char *fake_and_arg = "-a";
static char *fake_false_arg = "-false";
diff --git a/util.c b/util.c
index 71b3c53..b5ef8f8 100644
--- a/util.c
+++ b/util.c
@@ -21,7 +21,6 @@
#include <fcntl.h>
#include <langinfo.h>
#include <nl_types.h>
-#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -30,6 +29,12 @@
#include <sys/types.h>
#include <unistd.h>
+#ifdef USE_ONIGURUMA
+ #include <onigposix.h>
+#else
+ #include <regex.h>
+#endif
+
#if BFS_HAS_SYS_PARAM
# include <sys/param.h>
#endif
diff --git a/util.h b/util.h
index 37c03fa..213d514 100644
--- a/util.h
+++ b/util.h
@@ -23,12 +23,17 @@
#include <fcntl.h>
#include <fnmatch.h>
-#include <regex.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
+#ifdef USE_ONIGURUMA
+ #include <onigposix.h>
+#else
+ #include <regex.h>
+#endif
+
// Some portability concerns
#ifdef __has_feature