diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; +} |