Annotation of /tags/mkinitrd-6_2_0/libbb/xregcomp.c
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/libbb/xregcomp.c
File MIME type: text/plain
File size: 744 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/libbb/xregcomp.c
File MIME type: text/plain
File size: 744 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) many different people. | ||
6 | * If you wrote this, please acknowledge your work. | ||
7 | * | ||
8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
9 | */ | ||
10 | |||
11 | #include "libbb.h" | ||
12 | #include "xregex.h" | ||
13 | |||
14 | char* regcomp_or_errmsg(regex_t *preg, const char *regex, int cflags) | ||
15 | { | ||
16 | int ret = regcomp(preg, regex, cflags); | ||
17 | if (ret) { | ||
18 | int errmsgsz = regerror(ret, preg, NULL, 0); | ||
19 | char *errmsg = xmalloc(errmsgsz); | ||
20 | regerror(ret, preg, errmsg, errmsgsz); | ||
21 | return errmsg; | ||
22 | } | ||
23 | return NULL; | ||
24 | } | ||
25 | |||
26 | void xregcomp(regex_t *preg, const char *regex, int cflags) | ||
27 | { | ||
28 | char *errmsg = regcomp_or_errmsg(preg, regex, cflags); | ||
29 | if (errmsg) { | ||
30 | bb_error_msg_and_die("xregcomp: %s", errmsg); | ||
31 | } | ||
32 | } |