diff options
-rw-r--r-- | share/txr/stdlib/match.tl | 12 | ||||
-rw-r--r-- | tests/011/patmatch.tl | 10 |
2 files changed, 15 insertions, 7 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 64f53357..0c10dfb1 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -907,9 +907,8 @@ ;; `@{var}txt` (new binding) (((@(eq 'sys:var) @sym) @(stringp @txt) . @rest) (with-gensyms (len end npos) - (list* ^@(require @(with ,len (search-str ,str ,txt ,pos)) - ,len) - ^@(with ,end (+ ,pos ,len)) + (list* ^@(require @(with ,end (search-str ,str ,txt ,pos)) + ,end) ^@(with ,npos (+ ,end ,(len txt))) ^@(with ,sym (sub-str ,str ,pos ,end)) (quasi-match vlist (cdr rest) (cons sym vars) @@ -918,11 +917,10 @@ (((@(eq 'sys:var) @sym) (@(eq 'sys:var) @(bound-p vlist vars @bsym) . @mods) . @rest) - (with-gensyms (txt len end npos) + (with-gensyms (txt end npos) (list* ^@(with ,txt (sys:quasi ,(cadr args))) - ^@(require @(with ,len (search-str ,str ,txt ,pos)) - ,len) - ^@(with ,end (+ ,pos ,len)) + ^@(require @(with ,end (search-str ,str ,txt ,pos)) + ,end) ^@(with ,npos (+ ,end (len ,txt))) ^@(with ,sym (sub-str ,str ,pos ,end)) (quasi-match vlist (cdr rest) (cons sym vars) diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 09395eba..ad9015db 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -339,6 +339,16 @@ (test (when-match (@(var= a) @(var= a)) '(1 1.0) a) 1) +(test (when-match `` "" t) t) +(test (when-match `abc` "abc" t) t) +(test (when-match `@a` "abc" a) "abc") + +(macro-time-let ((*stderr* *stdnull*)) + (test (when-match `@a@b` "abc" a) :error)) + +(test (when-match `@a-$` "a-$" a) "a") +(test (when-match `#@a-$` "#a-$" a) "a") + (compile-only (eval-only (compile-file (base-name *load-path*) "temp.tlo") |