lineedit: fix completion with applet names. closes 9361
[oweals/busybox.git] / libbb / xregcomp.c
index c28ca659d5afd86804d6b608d6cf2c14aa8d1769..344028f44d3b63d21fa0a5932bea4cc4b6bc3159 100644 (file)
@@ -5,45 +5,28 @@
  * Copyright (C) many different people.
  * If you wrote this, please acknowledge your work.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * 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;
 }
 
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
+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);
+       }
+}