aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-12-21 13:24:58 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-12-21 13:24:58 +0000
commit9c69d76608d1689460671e7feac3f34917728a85 (patch)
tree33ba50881b34dcb0732763d0359ca9a50bdef99a /libbb
parente99be6e4a58561eb7521c57148ec65ba0d87dd7b (diff)
downloadbusybox-w32-9c69d76608d1689460671e7feac3f34917728a85.tar.gz
busybox-w32-9c69d76608d1689460671e7feac3f34917728a85.tar.bz2
busybox-w32-9c69d76608d1689460671e7feac3f34917728a85.zip
less: stop dying on bad regexps, quietly pipe data w/o
user interaction if stdout is not a tty. size optimizations git-svn-id: svn://busybox.net/trunk/busybox@17028 69ca8d6d-28ef-0310-b511-8ec308f3f277
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 @@
11#include "libbb.h" 11#include "libbb.h"
12#include "xregex.h" 12#include "xregex.h"
13 13
14void xregcomp(regex_t *preg, const char *regex, int cflags) 14char* regcomp_or_errmsg(regex_t *preg, const char *regex, int cflags)
15{ 15{
16 int ret = regcomp(preg, regex, cflags); 16 int ret = regcomp(preg, regex, cflags);
17 if (ret) { 17 if (ret) {
18 int errmsgsz = regerror(ret, preg, NULL, 0); 18 int errmsgsz = regerror(ret, preg, NULL, 0);
19 char *errmsg = xmalloc(errmsgsz); 19 char *errmsg = xmalloc(errmsgsz);
20 regerror(ret, preg, errmsg, errmsgsz); 20 regerror(ret, preg, errmsg, errmsgsz);
21 return errmsg;
22 }
23 return NULL;
24}
25
26void xregcomp(regex_t *preg, const char *regex, int cflags)
27{
28 char *errmsg = regcomp_or_errmsg(preg, regex, cflags);
29 if (errmsg) {
21 bb_error_msg_and_die("xregcomp: %s", errmsg); 30 bb_error_msg_and_die("xregcomp: %s", errmsg);
22 } 31 }
23} 32}