diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-12-18 12:38:19 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-12-18 13:19:04 -0500 |
commit | 4b9592f93a68f88152b390898004e5e54b540cae (patch) | |
tree | 18930e6373e5e75aa2999f405971d7a29e4eebc8 /util.c | |
parent | 2ebbe75a8d272458cd3229b6033b2a5ce19b105b (diff) | |
download | bfs-4b9592f93a68f88152b390898004e5e54b540cae.tar.xz |
Implement -regex, -iregex, and -regextype/-E
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; +} |