From e39606c411bad57de5891965628f6ac278df42ee Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 25 Oct 2014 23:06:18 +0100 Subject: make regex wrapper return errors instead of just aborting --- utils/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 6199a8451..6730c9fa1 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -33,6 +33,7 @@ #include #include "utils/config.h" +#include "utils/log.h" #include "utils/messages.h" #include "utils/utf8.h" #include "utils/time.h" @@ -207,18 +208,20 @@ nserror snstrjoin(char **str, size_t *size, char sep, size_t nelm, ...) /* exported interface documented in utils/utils.h */ -void regcomp_wrapper(regex_t *preg, const char *regex, int cflags) +nserror regcomp_wrapper(regex_t *preg, const char *regex, int cflags) { int r; r = regcomp(preg, regex, cflags); if (r) { char errbuf[200]; regerror(r, preg, errbuf, sizeof errbuf); - fprintf(stderr, "Failed to compile regexp '%s'\n", regex); - die(errbuf); + LOG(("Failed to compile regexp '%s': %s\n", regex, errbuf)); + return NSERROR_INIT_FAILED; } + return NSERROR_OK; } + /** * The size of buffers within human_friendly_bytesize. * -- cgit v1.2.3