Changeset 15292


Ignore:
Timestamp:
Apr 4, 2012, 7:05:20 AM (7 years ago)
Author:
gb
Message:

%ioblock-peek-char (the ISO-8859-1 version): if we don't get EOF,
we can safely decrement the input buffer idx by 1 (it'll always be

1 after reading an octet.)

%encoded-ioblock-peek-char: (all other encodings): let the ioblock's
unread-char function decide how to handle unreading the character.
(FILE-STREAMs generally adjust the file's position, other kinds
of streams use IOBLOCK-UNTYI-CHAR, which confuses FILE-POSITION on
FILE-STREAMs.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-streams.lisp

    r15177 r15292  
    13781378(defun %ioblock-peek-char (ioblock)
    13791379  (or (ioblock-untyi-char ioblock)
    1380       (let* ((buf (ioblock-inbuf ioblock))
    1381              (idx (io-buffer-idx buf))
    1382              (limit (io-buffer-count buf)))
    1383         (declare (fixnum idx limit))
    1384         (when (= idx limit)
    1385           (unless (%ioblock-advance ioblock t)
    1386             (return-from %ioblock-peek-char :eof))
    1387           (setq idx (io-buffer-idx buf)
    1388                 limit (io-buffer-count buf)))
    1389         (%code-char (aref (the (simple-array (unsigned-byte 8) (*)) (io-buffer-buffer buf)) idx)))))
     1380      (let* ((b (%ioblock-read-u8-byte ioblock)))
     1381        (if (eq b :eof)
     1382          b
     1383          (let* ((ch (%code-char b))
     1384                 (buf (ioblock-inbuf ioblock))
     1385                 (idx (io-buffer-idx buf)))
     1386            (declare (fixnum idx))
     1387            (setf (io-buffer-idx buf) (the fixnum (1- idx)))
     1388            ch)))))
    13901389
    13911390(defun %encoded-ioblock-peek-char (ioblock)
     
    13931392      (let* ((ch (funcall (ioblock-read-char-when-locked-function ioblock) ioblock)))
    13941393        (unless (eq ch :eof)
    1395           (setf (ioblock-untyi-char ioblock) ch))
     1394          (funcall (ioblock-unread-char-function ioblock) ioblock ch))
    13961395        ch)))
    13971396
Note: See TracChangeset for help on using the changeset viewer.