diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-21 13:24:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-21 13:24:58 +0000 |
commit | e865e81d34efb96417c549e9c326fb1c46dafbc7 (patch) | |
tree | 33ba50881b34dcb0732763d0359ca9a50bdef99a /libbb | |
parent | bf66fbc8e2380717c1fab860cfc60c78582839dd (diff) | |
download | busybox-e865e81d34efb96417c549e9c326fb1c46dafbc7.tar.gz |
less: stop dying on bad regexps, quietly pipe data w/o
user interaction if stdout is not a tty.
size optimizations
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xregcomp.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libbb/xregcomp.c b/libbb/xregcomp.c index 6e9a29f49..157132c1f 100644 --- a/libbb/xregcomp.c +++ b/libbb/xregcomp.c @@ -11,13 +11,22 @@ #include "libbb.h" #include "xregex.h" -void xregcomp(regex_t *preg, const char *regex, int cflags) +char* regcomp_or_errmsg(regex_t *preg, const char *regex, int cflags) { int ret = regcomp(preg, regex, cflags); if (ret) { int errmsgsz = regerror(ret, preg, NULL, 0); char *errmsg = xmalloc(errmsgsz); regerror(ret, preg, errmsg, errmsgsz); + return errmsg; + } + return NULL; +} + +void xregcomp(regex_t *preg, const char *regex, int cflags) +{ + char *errmsg = regcomp_or_errmsg(preg, regex, cflags); + if (errmsg) { bb_error_msg_and_die("xregcomp: %s", errmsg); } } |