aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-21 13:24:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-21 13:24:58 +0000
commite865e81d34efb96417c549e9c326fb1c46dafbc7 (patch)
tree33ba50881b34dcb0732763d0359ca9a50bdef99a /libbb
parentbf66fbc8e2380717c1fab860cfc60c78582839dd (diff)
downloadbusybox-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.c11
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);
}
}