blob: 4bcb9aedf548301086dda4c90492a5e6aaca16cf [file] [log] [blame]
Eric Andersenaad1a882001-03-16 22:47:14 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) many different people.
Eric Andersencb81e642003-07-14 21:21:08 +00006 * If you wrote this, please acknowledge your work.
Eric Andersenaad1a882001-03-16 22:47:14 +00007 *
Bernhard Reutner-Fischerb1629b12006-05-19 19:29:19 +00008 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersenaad1a882001-03-16 22:47:14 +00009 */
10
11#include <stdio.h>
12#include "libbb.h"
"Vladimir N. Oleynik"23f62fc2005-09-14 16:59:11 +000013#include "xregex.h"
Eric Andersenaad1a882001-03-16 22:47:14 +000014
15
16
17void xregcomp(regex_t *preg, const char *regex, int cflags)
18{
19 int ret;
20 if ((ret = regcomp(preg, regex, cflags)) != 0) {
21 int errmsgsz = regerror(ret, preg, NULL, 0);
22 char *errmsg = xmalloc(errmsgsz);
23 regerror(ret, preg, errmsg, errmsgsz);
Manuel Novoa III cad53642003-03-19 09:13:01 +000024 bb_error_msg_and_die("xregcomp: %s", errmsg);
Eric Andersenaad1a882001-03-16 22:47:14 +000025 }
26}