[cl-irc-cvs] r188 - trunk
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Sat Apr 21 22:50:12 UTC 2007
Author: ehuelsmann
Date: Sat Apr 21 18:50:10 2007
New Revision: 188
Modified:
trunk/protocol.lisp
trunk/utility.lisp
Log:
Fix off-by-one error and make sure we don't keep looping when the network stream is lost.
Modified: trunk/protocol.lisp
==============================================================================
--- trunk/protocol.lisp (original)
+++ trunk/protocol.lisp Sat Apr 21 18:50:10 2007
@@ -365,21 +365,22 @@
:element-type '(unsigned-byte 8)
:fill-pointer t)
'(10))
- (setf (fill-pointer buf)
- ;; remove all trailing CR and LF characters
- ;; (This allows non-conforming clients to send CRCRLF
- ;; as a line separator too).
- (or (position-if #'(lambda (x) (member x '(10 13)))
- buf :from-end t :end buf-len)
- buf-len))
- (try-decode-line buf *default-incoming-external-formats*)))
+ (when (< 0 buf-len)
+ (setf (fill-pointer buf)
+ ;; remove all trailing CR and LF characters
+ ;; (This allows non-conforming clients to send CRCRLF
+ ;; as a line separator too).
+ (or (position-if #'(lambda (x) (member x '(10 13)))
+ buf :from-end t :end buf-len)
+ buf-len))
+ (try-decode-line buf *default-incoming-external-formats*))))
(defmethod read-irc-message ((connection connection))
"Read and parse an IRC-message from the `connection'."
(handler-case
(let* ((msg-string (read-protocol-line connection))
- (message (create-irc-message msg-string)))
- (setf (connection message) connection)
+ (message (when msg-string (create-irc-message msg-string))))
+ (when message (setf (connection message) connection))
message)
(end-of-file
;; satisfy read-message-loop assumption of nil when no more messages
Modified: trunk/utility.lisp
==============================================================================
--- trunk/utility.lisp (original)
+++ trunk/utility.lisp Sat Apr 21 18:50:10 2007
@@ -129,7 +129,7 @@
;; For others, if this becomes an efficiency problem, please report...
(loop for next-elt = (funcall read-fun stream nil nil)
if (null next-elt)
- do (return (values target targ-cur t))
+ do (return (values target (1+ targ-cur) t))
else do
(setf (elt target (incf targ-cur)) next-elt)
(if (eql next-elt (aref limit-vector limit-cur))
More information about the cl-irc-cvs
mailing list