2015-09-06 20:33:41 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2014-11-16 14:16:14 +00:00
|
|
|
#include <regex.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
enregcomp(int status, regex_t *preg, const char *regex, int cflags)
|
|
|
|
{
|
2015-09-06 20:33:41 +00:00
|
|
|
char errbuf[BUFSIZ] = "";
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if ((r = regcomp(preg, regex, cflags)) == 0)
|
|
|
|
return r;
|
2014-11-16 14:16:14 +00:00
|
|
|
|
2015-09-06 20:33:41 +00:00
|
|
|
regerror(r, preg, errbuf, sizeof(errbuf));
|
|
|
|
enprintf(status, "invalid regex: %s\n", errbuf);
|
2014-11-16 14:16:14 +00:00
|
|
|
|
2015-09-06 20:33:41 +00:00
|
|
|
return r;
|
2014-11-16 14:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
eregcomp(regex_t *preg, const char *regex, int cflags)
|
|
|
|
{
|
|
|
|
return enregcomp(1, preg, regex, cflags);
|
|
|
|
}
|