lineedit: fix completion with applet names. closes 9361
[oweals/busybox.git] / libbb / xregcomp.c
index 4bcb9aedf548301086dda4c90492a5e6aaca16cf..344028f44d3b63d21fa0a5932bea4cc4b6bc3159 100644 (file)
@@ -5,22 +5,28 @@
  * Copyright (C) many different people.
  * If you wrote this, please acknowledge your work.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
-#include <stdio.h>
 #include "libbb.h"
 #include "xregex.h"
 
-
-
-void xregcomp(regex_t *preg, const char *regex, int cflags)
+char* FAST_FUNC regcomp_or_errmsg(regex_t *preg, const char *regex, int cflags)
 {
-       int ret;
-       if ((ret = regcomp(preg, regex, cflags)) != 0) {
+       int ret = regcomp(preg, regex, cflags);
+       if (ret) {
                int errmsgsz = regerror(ret, preg, NULL, 0);
                char *errmsg = xmalloc(errmsgsz);
                regerror(ret, preg, errmsg, errmsgsz);
-               bb_error_msg_and_die("xregcomp: %s", errmsg);
+               return errmsg;
+       }
+       return NULL;
+}
+
+void FAST_FUNC xregcomp(regex_t *preg, const char *regex, int cflags)
+{
+       char *errmsg = regcomp_or_errmsg(preg, regex, cflags);
+       if (errmsg) {
+               bb_error_msg_and_die("bad regex '%s': %s", regex, errmsg);
        }
 }