From scaekenberghe at common-lisp.net Fri Feb 15 15:11:00 2008 From: scaekenberghe at common-lisp.net (scaekenberghe) Date: Fri, 15 Feb 2008 10:11:00 -0500 (EST) Subject: [s-xml-rpc-cvs] CVS s-xml-rpc/src Message-ID: <20080215151100.35BD823341@common-lisp.net> Update of /project/s-xml-rpc/cvsroot/s-xml-rpc/src In directory clnet:/tmp/cvs-serv6331/src Modified Files: xml-rpc.lisp Log Message: patch by jeff sapp: parse doubles as cl double-floats --- /project/s-xml-rpc/cvsroot/s-xml-rpc/src/xml-rpc.lisp 2006/04/19 10:22:30 1.9 +++ /project/s-xml-rpc/cvsroot/s-xml-rpc/src/xml-rpc.lisp 2008/02/15 15:11:00 1.10 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: xml-rpc.lisp,v 1.9 2006/04/19 10:22:30 scaekenberghe Exp $ +;;;; $Id: xml-rpc.lisp,v 1.10 2008/02/15 15:11:00 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of the XML-RPC protocol, ;;;; as documented on the website http://www.xmlrpc.com @@ -284,7 +284,8 @@ (declare (ignore attributes)) (cons (case name ((:|int| :|i4|) (parse-integer seed)) - (:|double| (let ((*read-eval* nil)) + (:|double| (let ((*read-eval* nil) + (*read-default-float-format* 'double-float)) (read-from-string seed))) (:|boolean| (= 1 (parse-integer seed))) (:|string| (if (null seed) "" seed)) @@ -523,7 +524,7 @@ (defun xml-rpc-implementation-version () "Identify ourselves" (concatenate 'string - "$Id: xml-rpc.lisp,v 1.9 2006/04/19 10:22:30 scaekenberghe Exp $" + "$Id: xml-rpc.lisp,v 1.10 2008/02/15 15:11:00 scaekenberghe Exp $" " " (lisp-implementation-type) " " From scaekenberghe at common-lisp.net Fri Feb 15 15:42:40 2008 From: scaekenberghe at common-lisp.net (scaekenberghe) Date: Fri, 15 Feb 2008 10:42:40 -0500 (EST) Subject: [s-xml-rpc-cvs] CVS s-xml-rpc/src Message-ID: <20080215154240.D0FBC5D172@common-lisp.net> Update of /project/s-xml-rpc/cvsroot/s-xml-rpc/src In directory clnet:/tmp/cvs-serv13386/src Modified Files: xml-rpc.lisp Log Message: fixed a bug reported by Evgeniy Zamriy: 0 was decoded incorrectly as an empty string instead of as nil fixed second clause in :|value| handling testing (null seed) instead of (null (car seed)) added more decoding tests to cope with regression, seems ok --- /project/s-xml-rpc/cvsroot/s-xml-rpc/src/xml-rpc.lisp 2008/02/15 15:11:00 1.10 +++ /project/s-xml-rpc/cvsroot/s-xml-rpc/src/xml-rpc.lisp 2008/02/15 15:42:40 1.11 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: xml-rpc.lisp,v 1.10 2008/02/15 15:11:00 scaekenberghe Exp $ +;;;; $Id: xml-rpc.lisp,v 1.11 2008/02/15 15:42:40 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of the XML-RPC protocol, ;;;; as documented on the website http://www.xmlrpc.com @@ -297,7 +297,7 @@ (:|array| (car seed)) (:|data| (unless (stringp seed) (nreverse seed))) (:|value| (cond ((stringp seed) seed) - ((null (car seed)) "") + ((null seed) "") (t (car seed)))) (:|struct| (make-xml-rpc-struct :alist seed)) (:|member| (cons (cadr seed) (car seed))) @@ -524,7 +524,7 @@ (defun xml-rpc-implementation-version () "Identify ourselves" (concatenate 'string - "$Id: xml-rpc.lisp,v 1.10 2008/02/15 15:11:00 scaekenberghe Exp $" + "$Id: xml-rpc.lisp,v 1.11 2008/02/15 15:42:40 scaekenberghe Exp $" " " (lisp-implementation-type) " " From scaekenberghe at common-lisp.net Fri Feb 15 15:42:41 2008 From: scaekenberghe at common-lisp.net (scaekenberghe) Date: Fri, 15 Feb 2008 10:42:41 -0500 (EST) Subject: [s-xml-rpc-cvs] CVS s-xml-rpc/test Message-ID: <20080215154241.10D465D172@common-lisp.net> Update of /project/s-xml-rpc/cvsroot/s-xml-rpc/test In directory clnet:/tmp/cvs-serv13386/test Modified Files: test-xml-rpc.lisp Log Message: fixed a bug reported by Evgeniy Zamriy: 0 was decoded incorrectly as an empty string instead of as nil fixed second clause in :|value| handling testing (null seed) instead of (null (car seed)) added more decoding tests to cope with regression, seems ok --- /project/s-xml-rpc/cvsroot/s-xml-rpc/test/test-xml-rpc.lisp 2006/04/19 10:22:31 1.3 +++ /project/s-xml-rpc/cvsroot/s-xml-rpc/test/test-xml-rpc.lisp 2008/02/15 15:42:40 1.4 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: test-xml-rpc.lisp,v 1.3 2006/04/19 10:22:31 scaekenberghe Exp $ +;;;; $Id: test-xml-rpc.lisp,v 1.4 2008/02/15 15:42:40 scaekenberghe Exp $ ;;;; ;;;; Unit and functional tests for xml-rpc.lisp ;;;; @@ -112,7 +112,7 @@ " fgo " -31 "" - -12.214 + -12.214D0 ,(xml-rpc-time (iso8601->universal-time "19980717T14:08:55")) #(121 111 117 32 99 97 110 39 116 32 114 101 97 100 32 116 104 105 115 33))))) @@ -134,6 +134,26 @@ ")) '("XYZ"))) +;; double decoding + +(assert (< (abs (- (decode-xml-rpc (make-string-input-stream "3.141592653589793")) + pi)) + 0.000000000001D0)) + +;; string decoding + +(assert (equal (decode-xml-rpc (make-string-input-stream "foo")) + "foo")) + +(assert (equal (decode-xml-rpc (make-string-input-stream "foo")) + "foo")) + +(assert (equal (decode-xml-rpc (make-string-input-stream "")) + "")) + +(assert (equal (decode-xml-rpc (make-string-input-stream "")) + "")) + ;; boolean encoding (assert (equal (with-output-to-string (out) @@ -144,4 +164,13 @@ (encode-xml-rpc-value nil out)) "0")) + +;; boolean decoding + +(assert (equal (decode-xml-rpc (make-string-input-stream "1")) + t)) + +(assert (equal (decode-xml-rpc (make-string-input-stream "0")) + nil)) + ;;;; eof