From ce0d5294d5898b6100269bd39d38c0884d5fd4b4 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sat, 27 Dec 2003 20:15:23 +0000 Subject: [project @ 2003-12-27 20:15:22 by bursa] Use charset from Content-Type header. svn path=/import/netsurf/; revision=460 --- utils/utils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 2ebdf9e5d..cb331a55f 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "libxml/encoding.h" #include "libxml/uri.h" #include "netsurf/utils/log.h" @@ -256,3 +258,23 @@ bool is_dir(const char *path) return S_ISDIR(s.st_mode) ? true : false; } + + +/** + * Compile a regular expression, handling errors. + * + * Parameters as for regcomp(), see man regex. + */ + +void regcomp_wrapper(regex_t *preg, const char *regex, int cflags) +{ + char errbuf[200]; + int r; + r = regcomp(preg, regex, cflags); + if (r) { + regerror(r, preg, errbuf, sizeof errbuf); + fprintf(stderr, "Failed to compile regexp '%s'\n", regex); + die(errbuf); + } +} + -- cgit v1.2.3