summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/util.c b/util.c
index bc611a8..ce0b458 100644
--- a/util.c
+++ b/util.c
@@ -12,7 +12,9 @@
#include "util.h"
#include <errno.h>
#include <fcntl.h>
+#include <regex.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -76,3 +78,12 @@ int dup_cloexec(int fd) {
return ret;
#endif
}
+
+char *xregerror(int err, const regex_t *regex) {
+ size_t len = regerror(err, regex, NULL, 0);
+ char *str = malloc(len);
+ if (str) {
+ regerror(err, regex, str, len);
+ }
+ return str;
+}