aboutsummaryrefslogtreecommitdiff
path: root/lib/xregcomp.c
blob: ec7d1b79b42dfeb9975b624d52b11ee71e58b2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Call regcomp() and handle errors.
 *
 * Copyright 2007 Rob Landley <rob@landley.net>
 *
 * This is a separate file so environments that haven't got regular expression
 * support can configure this out and avoid a build break.
 */

#include "toys.h"
#include "xregcomp.h"

void xregcomp(regex_t *preg, char *regex, int cflags)
{
  int rc = regcomp(preg, regex, cflags);

  if (rc) {
    char msg[256];
    regerror(rc, preg, msg, 255);
    msg[255]=0;
    error_exit("xregcomp: %s", msg);
  }
}