mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-18 18:23:25 +03:00
move regex helper to be with teh single remaining call site
This commit is contained in:
parent
10ef7b3f1d
commit
7ba291037b
@ -1158,6 +1158,25 @@ static bool save_complete_inventory(save_complete_ctx *ctx)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile a regular expression, handling errors.
|
||||
*
|
||||
* Parameters as for regcomp(), see man regex.
|
||||
*/
|
||||
static 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);
|
||||
LOG("Failed to compile regexp '%s': %s\n", regex, errbuf);
|
||||
return NSERROR_INIT_FAILED;
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Documented in save_complete.h */
|
||||
void save_complete_init(void)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <strings.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <curl/curl.h>
|
||||
@ -217,21 +216,6 @@ nserror snstrjoin(char **str, size_t *size, char sep, size_t nelm, ...)
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in utils/utils.h */
|
||||
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);
|
||||
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.
|
||||
*
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -152,13 +151,6 @@ char *cnv_space2nbsp(const char *s);
|
||||
*/
|
||||
bool is_dir(const char *path);
|
||||
|
||||
/**
|
||||
* Compile a regular expression, handling errors.
|
||||
*
|
||||
* Parameters as for regcomp(), see man regex.
|
||||
*/
|
||||
nserror regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
|
||||
|
||||
/**
|
||||
* Create a human redable representation of a size in bytes.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user