0.8.13.70: MORE DOCUMENTATION
[sbcl.git] / contrib / sb-simple-streams / internal.lisp
index 154abdc..e5e926e 100644 (file)
 
 (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