Changeset 10125


Ignore:
Timestamp:
10/16/05 12:35:45 (16 years ago)
Author:
piso
Message:

PEEK-CHAR.17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/peek_char.java

    r6221 r10125  
    22 * peek_char.java
    33 *
    4  * Copyright (C) 2004 Peter Graves
    5  * $Id: peek_char.java,v 1.4 2004-03-12 18:48:03 piso Exp $
     4 * Copyright (C) 2004-2005 Peter Graves
     5 * $Id: peek_char.java,v 1.5 2005-10-16 12:35:45 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    4040        boolean eofError = length > 2 ? (args[2] != NIL) : true;
    4141        LispObject eofValue = length > 3 ? args[3] : NIL;
    42         boolean recursive = length > 4 ? (args[4] != NIL) : false;
     42        // recursive-p is ignored
     43        // boolean recursive = length > 4 ? (args[4] != NIL) : false;
    4344        if (peekType == NIL) {
    44             LispObject result = stream.readChar(eofError, eofValue);
     45            // "If PEEK-TYPE is not supplied or NIL, PEEK-CHAR returns the next
     46            // character to be read from INPUT-STREAM, without actually
     47            // removing it from INPUT-STREAM."
     48            final Stream in;
     49            if (stream instanceof EchoStream)
     50                // "When INPUT-STREAM is an echo stream, characters that are
     51                // only peeked at are not echoed." Read from the echo stream's
     52                // input stream to bypass the echo.
     53                in = ((EchoStream)stream).getInputStream();
     54            else
     55                in = stream;
     56            final LispObject result = in.readChar(eofError, eofValue);
    4557            if (result instanceof LispCharacter)
    46                 stream.unreadChar((LispCharacter)result);
     58                in.unreadChar((LispCharacter)result);
    4759            return result;
    4860        }
    4961        if (peekType == T) {
     62            // "If PEEK-TYPE is T, then PEEK-CHAR skips over whitespace[2]
     63            // characters, but not comments, and then performs the peeking
     64            // operation on the next character."
    5065            Readtable rt = currentReadtable();
    5166            while (true) {
     
    6277        }
    6378        if (peekType instanceof LispCharacter) {
     79            // "If PEEK-TYPE is a character, then PEEK-CHAR skips over input
     80            // characters until a character that is CHAR= to that character is
     81            // found; that character is left in INPUT-STREAM."
    6482            char c = ((LispCharacter)peekType).value;
    6583            while (true) {
Note: See TracChangeset for help on using the changeset viewer.