1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

sxml-match: Handle multiple-value returns.

* module/sxml/sxml-match.ss (sxml-match1): Invoke ESCAPE via
  `call-with-values'.

* test-suite/tests/sxml-match-tests.ss ("test multiple value returns"):
  New test.

* module/sxml/match.scm: Mention the modification.
This commit is contained in:
Ludovic Courtès 2010-05-26 22:49:09 +02:00
parent 40b19fda5c
commit 01fded8c77
3 changed files with 17 additions and 2 deletions

View file

@ -81,11 +81,14 @@
;;; Include upstream source file. ;;; Include upstream source file.
;;; ;;;
;; This file was taken unmodified from ;; This file was taken from
;; <http://planet.plt-scheme.org/package-source/jim/sxml-match.plt/1/1/> on ;; <http://planet.plt-scheme.org/package-source/jim/sxml-match.plt/1/1/> on
;; 2010-05-24. It was written by Jim Bender <benderjg2@aol.com> and released ;; 2010-05-24. It was written by Jim Bender <benderjg2@aol.com> and released
;; under the MIT/X11 license ;; under the MIT/X11 license
;; <http://www.gnu.org/licenses/license-list.html#X11License>. ;; <http://www.gnu.org/licenses/license-list.html#X11License>.
;;
;; Modified the `sxml-match1' macro to allow multiple-value returns (upstream
;; was notified.)
(include-from-path "sxml/sxml-match.ss") (include-from-path "sxml/sxml-match.ss")

View file

@ -1124,7 +1124,10 @@
[(sxml-match1 exp cata-fun clause0 clause ...) [(sxml-match1 exp cata-fun clause0 clause ...)
(let/ec escape (let/ec escape
(compile-clause clause0 exp cata-fun (compile-clause clause0 exp cata-fun
(lambda () (escape (sxml-match1 exp cata-fun clause ...)))))])) (lambda () (call-with-values
(lambda () (sxml-match1 exp cata-fun
clause ...))
escape))))]))
(define-syntax sxml-match (define-syntax sxml-match
(syntax-rules () (syntax-rules ()

View file

@ -299,3 +299,12 @@
[(a (@ . ,qqq) ,t ...) [(a (@ . ,qqq) ,t ...)
(list qqq t ...)]) (list qqq t ...)])
'(((z 1) (y 2) (x 3)) 4 5 6)) '(((z 1) (y 2) (x 3)) 4 5 6))
(run-test "test multiple value returns"
(call-with-values
(lambda ()
(sxml-match '(foo)
((foo) (values 'x 'y))))
(lambda (x y)
(cons x y)))
'(x . y))