From 131d26ffeca06e98b50191703baf7683f8b47e30 Mon Sep 17 00:00:00 2001 From: rekado Date: Tue, 16 Dec 2014 18:35:29 +0100 Subject: rewrite stanza-find-property with sxpath --- xmpp.scm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xmpp.scm b/xmpp.scm index bade3c1..936013f 100644 --- a/xmpp.scm +++ b/xmpp.scm @@ -124,14 +124,12 @@ handlers." (define (stanza-find-property property-name stanza) - "Return the given property of a stanza or #f if there is none." - (let ((properties (cadr stanza))) - (if (equal? '@ (car properties)) - (let ((res (find (lambda (prop) (eq? property-name (car prop))) - (cdr properties)))) - (if res - (cadr res) - #f))))) + "Return the value of a given stanza property or #f if there is +none." + (let ((property ((sxpath `(* @ ,property-name)) stanza))) + (if (null? property) + #f + (cadar property)))) ;; generate accessor functions for various stanza attributes (for-each -- cgit v1.2.3