From 52715b72cd4959569ad021b69bf9cf1b26ec55fb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 24 Mar 2012 01:13:55 -0700 Subject: * eval.c (eval_init): Register match-str and match-str-tree intrinsics. * lib.c (match_str, match_str_tree): Default position to zero. * txr.1: Doc stubs created. * txr.vim: Highlighting for match-str and match-str-tree. --- ChangeLog | 11 +++++++++++ eval.c | 2 ++ lib.c | 6 ++++++ txr.1 | 4 ++++ txr.vim | 1 + 5 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index a1e0a386..67c086e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2012-03-24 Kaz Kylheku + + * eval.c (eval_init): Register match-str and match-str-tree + intrinsics. + + * lib.c (match_str, match_str_tree): Default position to zero. + + * txr.1: Doc stubs created. + + * txr.vim: Highlighting for match-str and match-str-tree. + 2012-03-24 Kaz Kylheku Bugfix: code like @(skip)@{var /partial/} where diff --git a/eval.c b/eval.c index fbe63d3a..644998f0 100644 --- a/eval.c +++ b/eval.c @@ -2290,6 +2290,8 @@ void eval_init(void) reg_fun(intern(lit("length-str"), user_package), func_n1(length_str)); reg_fun(intern(lit("search-str"), user_package), func_n4o(search_str, 2)); reg_fun(intern(lit("search-str-tree"), user_package), func_n4o(search_str_tree, 2)); + reg_fun(intern(lit("match-str"), user_package), func_n3o(match_str, 2)); + reg_fun(intern(lit("match-str-tree"), user_package), func_n3o(match_str_tree, 2)); reg_fun(intern(lit("sub-str"), user_package), func_n3o(sub_str, 1)); reg_fun(intern(lit("replace-str"), user_package), func_n4o(replace_str, 2)); reg_fun(intern(lit("cat-str"), user_package), func_n2o(cat_str, 1)); diff --git a/lib.c b/lib.c index 6cbff8ba..2449cf4b 100644 --- a/lib.c +++ b/lib.c @@ -1560,6 +1560,9 @@ val match_str(val bigstr, val str, val pos) { val i, p; + if (pos == nil) + pos = zero; + for (i = zero; length_str_gt(bigstr, p = plus(pos, i)) && length_str_gt(str, i); i = plus(i, one)) @@ -1573,6 +1576,9 @@ val match_str(val bigstr, val str, val pos) val match_str_tree(val bigstr, val tree, val pos) { + if (pos == nil) + pos = zero; + if (stringp(tree)) { if (match_str(bigstr, tree, pos)) return length_str(tree); diff --git a/txr.1 b/txr.1 index 6bf7fcbf..5e606874 100644 --- a/txr.1 +++ b/txr.1 @@ -6807,6 +6807,10 @@ Certain object types have a custom equal function. .SS Function search-str-tree +.SS Function match-str + +.SS Function match-str-tree + .SS Function sub-str .SS Function replace-str diff --git a/txr.vim b/txr.vim index 88313eb8..e6ef2b3f 100644 --- a/txr.vim +++ b/txr.vim @@ -65,6 +65,7 @@ syn keyword txl_keyword contained make-sym gensym *gensym-counter* make-package syn keyword txl_keyword contained intern symbolp symbol-name symbol-package keywordp syn keyword txl_keyword contained mkstring copy-str upcase-str downcase-str string-extend syn keyword txl_keyword contained stringp lazy-stringp length-str search-str search-str-tree +syn keyword txl_keyword contained match-str match-str-tree syn keyword txl_keyword contained sub-str cat-str split-str replace-str syn keyword txl_keyword contained split-str-set list-str trim-str syn keyword txl_keyword contained string-lt int-str flo-str int-flo flo-int -- cgit v1.2.3