From d228557c3c400ba7a81ba0b0fd867ec78bb35015 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 10 Apr 2012 03:11:09 -0700 Subject: * eval.c (eval_init): Expose regex-compile and regexp as intrinsics. * lib.c (obj_init): Change spelling of nongreedy operator and put it into the user package so that it is available for use with regex-compile. * regex.c (match_regex, search_regex): Bugfix: optional start position argument argument not defaulting to zero. * txr.1: Documented regex-compile and regexp. * txr.vim: Highlighting regex-compile and regexp. --- regex.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'regex.c') diff --git a/regex.c b/regex.c index 2fc08c64..eddb3b0e 100644 --- a/regex.c +++ b/regex.c @@ -1644,6 +1644,9 @@ static regm_result_t regex_machine_feed(regex_machine_t *regm, wchar_t ch) val search_regex(val haystack, val needle_regex, val start, val from_end) { + if (!start) + start = zero; + if (length_str_lt(haystack, start)) { return nil; } else { @@ -1698,6 +1701,8 @@ val match_regex(val str, val reg, val pos) regex_machine_t regm; val i, retval; regm_result_t last_res = REGM_INCOMPLETE; + if (!pos) + pos = zero; regex_machine_init(®m, reg); -- cgit v1.2.3