summaryrefslogtreecommitdiff
path: root/src/rexp.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2004-01-01 01:25:04 +0000
committerIan C <ianc@noddybox.co.uk>2004-01-01 01:25:04 +0000
commitf3a485b283141787667ea98b8e0a8687f07d9062 (patch)
tree2c5234cb3408979109e987737a6197ec2085ec7e /src/rexp.c
parent9d6402a5215920987fb10e5b35f35b93f1c6f725 (diff)
A few tweaks and added an extra variable (showmatch)
Diffstat (limited to 'src/rexp.c')
-rw-r--r--src/rexp.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/rexp.c b/src/rexp.c
index 3e51aa6..effa882 100644
--- a/src/rexp.c
+++ b/src/rexp.c
@@ -33,13 +33,23 @@ static const char id[]="$Id$";
#include "config.h"
#include "util.h"
+static const char header_id[]=KBS_REXP_H;
+
+
+/* ---------------------------------------- TYPES
+*/
+struct RE_Expression
+{
+ regex_t re;
+ char *expr;
+};
/* ---------------------------------------- INTERFACES
*/
RE_Expression RECompile(const char *regexpr)
{
- regex_t *re;
+ RE_Expression re;
int flags;
re=Malloc(sizeof *re);
@@ -49,11 +59,15 @@ RE_Expression RECompile(const char *regexpr)
if (!ConfigInt(CONFIG_CASESENSE))
flags|=REG_ICASE;
- if (regcomp(re,regexpr,flags))
+ if (regcomp(&re->re,regexpr,flags))
{
free(re);
re=NULL;
}
+ else
+ {
+ re->expr=CopyStr(regexpr);
+ }
return re;
}
@@ -61,7 +75,17 @@ RE_Expression RECompile(const char *regexpr)
int RESearch(const RE_Expression re, const char *string)
{
- return !regexec(re,string,0,NULL,0);
+ int ret;
+
+ ret=regexec(&re->re,string,0,NULL,0);
+
+ return !ret;
+}
+
+
+const char *REGetExpression(const RE_Expression re)
+{
+ return re->expr;
}
@@ -69,7 +93,8 @@ void REFree(RE_Expression re)
{
if (re)
{
- regfree(re);
+ regfree(&re->re);
+ free(re->expr);
free(re);
}
}