summaryrefslogtreecommitdiff
path: root/util/sbase/libutil/eregcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/sbase/libutil/eregcomp.c')
-rw-r--r--util/sbase/libutil/eregcomp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/util/sbase/libutil/eregcomp.c b/util/sbase/libutil/eregcomp.c
new file mode 100644
index 00000000..02c8698c
--- /dev/null
+++ b/util/sbase/libutil/eregcomp.c
@@ -0,0 +1,27 @@
+#include <sys/types.h>
+
+#include <regex.h>
+#include <stdio.h>
+
+#include "../util.h"
+
+int
+enregcomp(int status, regex_t *preg, const char *regex, int cflags)
+{
+ char errbuf[BUFSIZ] = "";
+ int r;
+
+ if ((r = regcomp(preg, regex, cflags)) == 0)
+ return r;
+
+ regerror(r, preg, errbuf, sizeof(errbuf));
+ enprintf(status, "invalid regex: %s\n", errbuf);
+
+ return r;
+}
+
+int
+eregcomp(regex_t *preg, const char *regex, int cflags)
+{
+ return enregcomp(1, preg, regex, cflags);
+}