From c92fde0bc75ade9d06c0d843c4693b9e2e338938 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 23 Apr 2007 15:45:55 -0400 Subject: Add sync and an incomplete version of mdev. --- lib/xregcomp.c | 23 +++++++++++++++++++++++ lib/xregcomp.h | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 lib/xregcomp.c create mode 100644 lib/xregcomp.h (limited to 'lib') diff --git a/lib/xregcomp.c b/lib/xregcomp.c new file mode 100644 index 00000000..60446ef8 --- /dev/null +++ b/lib/xregcomp.c @@ -0,0 +1,23 @@ +/* vi: set ts=4: + * Call regcomp() and handle errors. + * + * Copyright 2007 Rob Landley + * + * This is a separate file so environments that haven't got regular expression + * support can configure this out and avoid a build break. + */ + +#include "toys.h" +#include "xregcomp.h" + +void xregcomp(regex_t *preg, char *rexec, int cflags) +{ + int rc = regcomp(preg, rexec, cflags); + + if (rc) { + char msg[256]; + regerror(rc, preg, msg, 255); + msg[255]=0; + error_exit("xregcomp: %s", msg); + } +} diff --git a/lib/xregcomp.h b/lib/xregcomp.h new file mode 100644 index 00000000..fa929fa3 --- /dev/null +++ b/lib/xregcomp.h @@ -0,0 +1,6 @@ +/* This is a separate file so libc doesn't always need regex support. */ + +#include +#include + +void xregcomp(regex_t *preg, char *rexec, int cflags); -- cgit v1.2.3