summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2013-12-05 23:47:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2013-12-05 23:47:58 -0800
commit43fa874fd295b2c765cddd14939a60a47e190148 (patch)
tree19e9205efe84ec5b66e1b0b47f8bf732edde9909 /regex.c
parentf128b3e3f1ab9fb724d09486b59ae2a2b4cab29c (diff)
downloadtxr-43fa874fd295b2c765cddd14939a60a47e190148.tar.gz
txr-43fa874fd295b2c765cddd14939a60a47e190148.tar.bz2
txr-43fa874fd295b2c765cddd14939a60a47e190148.zip
* regex.c (regex_compile): Handle string input.
* regex.h (regex_compile): Don't call argument regex_sexp, since it can be a string. * txr.1: Updated.
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/regex.c b/regex.c
index 52a42b14..c589b0ca 100644
--- a/regex.c
+++ b/regex.c
@@ -35,6 +35,7 @@
#include <limits.h>
#include "config.h"
#include "lib.h"
+#include "parser.h"
#include "unwind.h"
#include "regex.h"
#include "txr.h"
@@ -1614,7 +1615,10 @@ static val regex_requires_dv(val exp)
val regex_compile(val regex_sexp)
{
- if (opt_derivative_regex || regex_requires_dv(regex_sexp)) {
+ if (stringp(regex_sexp)) {
+ regex_sexp = regex_parse(regex_sexp, nil);
+ return if2(regex_sexp, regex_compile(regex_sexp));
+ } else if (opt_derivative_regex || regex_requires_dv(regex_sexp)) {
return cons(compiled_regex_s, cons(dv_compile_regex(regex_sexp), nil));
} else {
nfa_t *pnfa = (nfa_t *) chk_malloc(sizeof *pnfa);