sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

eregcomp.c (469B)


      1 #include <sys/types.h>
      2 
      3 #include <regex.h>
      4 #include <stdio.h>
      5 
      6 #include "../util.h"
      7 
      8 int
      9 enregcomp(int status, regex_t *preg, const char *regex, int cflags)
     10 {
     11 	char errbuf[BUFSIZ] = "";
     12 	int r;
     13 
     14 	if ((r = regcomp(preg, regex, cflags)) == 0)
     15 		return r;
     16 
     17 	regerror(r, preg, errbuf, sizeof(errbuf));
     18 	enprintf(status, "invalid regex: %s\n", errbuf);
     19 
     20 	return r;
     21 }
     22 
     23 int
     24 eregcomp(regex_t *preg, const char *regex, int cflags)
     25 {
     26 	return enregcomp(1, preg, regex, cflags);
     27 }