1.0.1.23:
authorJuho Snellman <jsnell@iki.fi>
Thu, 11 Jan 2007 21:41:59 +0000 (21:41 +0000)
committerJuho Snellman <jsnell@iki.fi>
Thu, 11 Jan 2007 21:41:59 +0000 (21:41 +0000)
        Add generic function STREAM-FILE-POSITION, used to provide an
        implementation of FILE-POSITION for Gray streams (thanks to Eric
        Marsden).

NEWS
doc/manual/streams.texinfo
package-data-list.lisp-expr
src/code/stream.lisp
src/pcl/gray-streams.lisp
tests/gray-streams.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index bdde696..5fe4cfd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ changes in sbcl-1.0.2 relative to sbcl-1.0.1:
   * improvement: support for executable cores on NetBSD (thanks to 
     Richard Kreuter)
   * new feature: added a RESTART-FRAME debugger command
+  * new feature: new generic function SB-GRAY:STREAM-FILE-POSITION can 
+    be used to provide an implementation for FILE-POSITION on Gray streams
+    (thanks to Eric Marsden)
   * optimization: the function call overhead in code compiled with 
     a high DEBUG optimization setting is significantly 
   * bug fix: an error is signaled for attempts to use READ-SEQUENCE
index ddb0003..243ccf4 100644 (file)
@@ -105,7 +105,7 @@ of fundamental-stream.
 
 @include fun-common-lisp-stream-element-type.texinfo
 @include fun-common-lisp-close.texinfo
-
+@include fun-sb-gray-stream-file-position.texinfo
 
 
 
index 1fd8ae0..580b77f 100644 (file)
@@ -763,7 +763,7 @@ Lisp extension proposal by David N. Gray"
                "FUNDAMENTAL-INPUT-STREAM" "FUNDAMENTAL-OUTPUT-STREAM"
                "FUNDAMENTAL-STREAM"
                "STREAM-ADVANCE-TO-COLUMN" "STREAM-CLEAR-INPUT"
-               "STREAM-CLEAR-OUTPUT" "STREAM-FINISH-OUTPUT" "STREAM-FORCE-OUTPUT"
+               "STREAM-CLEAR-OUTPUT" "STREAM-FILE-POSITION" "STREAM-FINISH-OUTPUT" "STREAM-FORCE-OUTPUT"
                "STREAM-FRESH-LINE" "STREAM-LINE-COLUMN" "STREAM-LINE-LENGTH"
                "STREAM-LISTEN" "STREAM-PEEK-CHAR" "STREAM-READ-BYTE"
                "STREAM-READ-CHAR" "STREAM-READ-CHAR-NO-HANG" "STREAM-READ-LINE"
index 609df65..61e786c 100644 (file)
                      (- +ansi-stream-in-buffer-length+
                         (ansi-stream-in-index stream)))))))))))
 
-
 (defun file-position (stream &optional position)
-  (ansi-stream-file-position stream position))
+  (if (ansi-stream-p stream)
+      (ansi-stream-file-position stream position)
+      (stream-file-position stream position)))
 
 ;;; This is a literal translation of the ANSI glossary entry "stream
 ;;; associated with a file".
index 28ed0f1..7498eea 100644 (file)
   (error 'type-error :datum non-stream :expected-type 'stream))
 
 (defgeneric stream-read-sequence (stream seq &optional start end)
+  #+sb-doc
   (:documentation
    "This is like CL:READ-SEQUENCE, but for Gray streams."))
 
       T)))
 
 (defgeneric stream-write-sequence (stream seq &optional start end)
+  #+sb-doc
   (:documentation
    "This is like CL:WRITE-SEQUENCE, but for Gray streams."))
 
   (basic-io-type-stream-write-sequence stream seq start end
                                        #'stream-write-byte))
 
+(defgeneric stream-file-position (stream &optional position-spec)
+  #+sb-doc
+  (:documentation
+   "Used by FILE-POSITION. Returns or changes the current position within STREAM."))
+
+(defmethod stream-file-position ((stream ansi-stream) &optional position-spec)
+  (ansi-stream-file-position stream position-spec))
+
+(defmethod stream-file-position ((stream t) &optional position-spec)
+  (declare (ignore stream position-spec))
+  nil)
+
 \f
 ;;; This is not in the Gray stream proposal, so it is left here
 ;;; as example code.
index f20c68b..181e0c1 100644 (file)
@@ -60,7 +60,8 @@
 
 (defclass character-output-stream (fundamental-character-output-stream)
   ((lisp-stream :initarg :lisp-stream
-                :accessor character-output-stream-lisp-stream)))
+                :accessor character-output-stream-lisp-stream)
+   (position :initform 42 :accessor character-output-stream-position)))
 
 (defclass character-input-stream (fundamental-character-input-stream)
   ((lisp-stream :initarg :lisp-stream
 
 (defmethod stream-clear-output ((stream character-output-stream))
   (clear-output (character-output-stream-lisp-stream stream)))
+
+(defmethod stream-file-position ((stream character-output-stream) &optional new-value)
+  (if new-value
+      (setf (character-output-stream-position stream) new-value)
+      (character-output-stream-position stream)))
 \f
 ;;;; example character input stream encapsulating a lisp-stream
 
                      ((eq byte :eof))
                    (write-byte byte our-bin-to-char-output))))
              test-string))))
+
+\f
+
+;;; Minimal test of file-position
+(let ((stream (make-instance 'character-output-stream)))
+  (assert (= (file-position stream) 42))
+  (assert (file-position stream 50))
+  (assert (= (file-position stream) 50)))
index 82304ff..611eb22 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.1.22"
+"1.0.1.23"