0.9.0.17: minor tweaks
[sbcl.git] / contrib / sb-simple-streams / internal.lisp
index 1df77e9..a74aabb 100644 (file)
@@ -28,8 +28,8 @@
   (declare (type simple-stream-buffer buffer)
           (type (integer 0 #.most-positive-fixnum) index))
   (if (vectorp buffer)
-      (sb-sys:sap-ref-8 (sb-sys:vector-sap buffer) index))
-      (sb-sys:sap-ref-8 buffer index))
+      (sb-sys:sap-ref-8 (sb-sys:vector-sap buffer) index)
+      (sb-sys:sap-ref-8 buffer index)))
 
 (defun (setf bref) (octet buffer index)
   (declare (type (unsigned-byte 8) octet)
@@ -43,9 +43,9 @@
   (declare (type simple-stream-buffer src dst)
           (type fixnum soff doff length))
   (sb-sys:without-gcing ;; is this necessary??
-   (sb-kernel:system-area-copy (buffer-sap src) (* soff 8)
-                               (buffer-sap dst) (* doff 8)
-                               (* length 8))))
+   (sb-kernel:system-area-ub8-copy (buffer-sap src) soff
+                                   (buffer-sap dst) doff
+                                   length)))
 
 (defun allocate-buffer (size)
   (if (= size sb-impl::bytes-per-buffer)
 
 (defun std-dc-newline-in-handler (stream character)
   (with-stream-class (dual-channel-simple-stream stream)
-    (setf (sm charpos stream) -1) ;; set to 0 "if reading" ???
+    ;; FIXME: Currently, -1 is wrong, since callers of CHARPOS expect
+    ;; a result in (or null (and fixnum unsigned-byte)), so they must
+    ;; never see this temporary value.  Note that in
+    ;; STD-NEWLINE-OUT-HANDLER it is correct to use -1, since CHARPOS
+    ;; is incremented to zero before WRITE-CHAR returns.  Perhaps the
+    ;; same should happen for input?
+    (setf (sm charpos stream) 0) ; was -1
     character))
 
 (defvar *std-control-out-table*
     (declare (type sb-int:index mask))
     (let ((name (cond ((sb-int:unix-namestring pathname input))
                      ((and input (eq if-does-not-exist :create))
+                      (sb-int:unix-namestring pathname nil))
+                     ((and (eq direction :io) (not if-does-not-exist-given))
                       (sb-int:unix-namestring pathname nil)))))
       ;; Process if-exists argument if we are doing any output.
       (cond (output
                         :new-version
                         :error)))
             (case if-exists
-              ((:error nil)
+              ((:error nil :new-version)
                (setf mask (logior mask sb-unix:o_excl)))
               ((:rename :rename-and-delete)
                (setf mask (logior mask sb-unix:o_creat)))
-              ((:new-version :supersede)
+              ((:supersede)
                (setf mask (logior mask sb-unix:o_trunc)))))
            (t
             (setf if-exists nil)))     ; :ignore-this-arg