xregcomp.c 592 B

1234567891011121314151617181920212223242526
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Utility routines.
  4. *
  5. * Copyright (C) many different people.
  6. * If you wrote this, please acknowledge your work.
  7. *
  8. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  9. */
  10. #include <stdio.h>
  11. #include "libbb.h"
  12. #include "xregex.h"
  13. void xregcomp(regex_t *preg, const char *regex, int cflags)
  14. {
  15. int ret;
  16. if ((ret = regcomp(preg, regex, cflags)) != 0) {
  17. int errmsgsz = regerror(ret, preg, NULL, 0);
  18. char *errmsg = xmalloc(errmsgsz);
  19. regerror(ret, preg, errmsg, errmsgsz);
  20. bb_error_msg_and_die("xregcomp: %s", errmsg);
  21. }
  22. }