;;;;
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-socket-api.cl,v 1.10 2002/03/27 10:48:12 kevin Exp $
+;;;; $Id: postgresql-socket-api.cl,v 1.12 2002/03/27 12:09:39 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
(defun read-field (socket type)
(let ((length (- (read-socket-value 'int32 socket) 4)))
(case type
- ((:int :long :longlong)
+ ((:int32 :int64)
(read-integer-from-socket socket length))
(:double
(read-double-from-socket socket length))
(unless before-decimal
(error "Unexpected value"))))
- (dotimes (i length)
- (setq char (read-byte socket))
-;; (format t "~&len:~D, i:~D, char:~D, minusp:~A, decimalp:~A" length i char minusp decimalp)
- (let ((weight (ascii-digit char)))
- (cond
- ((and weight (not decimalp)) ;; before decimal point
- (setq before-decimal (+ weight (* 10 before-decimal))))
- ((and weight decimalp) ;; after decimal point
- (setq after-decimal (+ weight (* 10 after-decimal)))
- (incf decimal-count))
- ((and (= char +char-code-period+))
- (setq decimalp t))
- ((or (= char +char-code-lower-e+) ;; E is for exponent
- (= char +char-code-upper-e+))
- (setq exponent (read-integer-from-socket socket (- length i 1)))
- (setq exponent (or exponent 0))
- (setq i length))
+ (block loop
+ (dotimes (i length)
+ (setq char (read-byte socket))
+ ;; (format t "~&len:~D, i:~D, char:~D, minusp:~A, decimalp:~A" length i char minusp decimalp)
+ (let ((weight (ascii-digit char)))
+ (cond
+ ((and weight (not decimalp)) ;; before decimal point
+ (setq before-decimal (+ weight (* 10 before-decimal))))
+ ((and weight decimalp) ;; after decimal point
+ (setq after-decimal (+ weight (* 10 after-decimal)))
+ (incf decimal-count))
+ ((and (= char +char-code-period+))
+ (setq decimalp t))
+ ((or (= char +char-code-lower-e+) ;; E is for exponent
+ (= char +char-code-upper-e+))
+ (setq exponent (read-integer-from-socket socket (- length i 1)))
+ (setq exponent (or exponent 0))
+ (return-from loop))
(t
(break "Unexpected value"))
)
- ))
+ )))
(setq result (* (+ (coerce before-decimal 'double-float)
(* after-decimal
(expt 10 (- decimal-count))))