From: Jamie Zawinski
Subject: Re: Communicating with foreign hosts from MACL
Date:
Message-ID: <22133@pasteur.Berkeley.EDU>
In article <····@zipeecs.umich.edu> ····@dip.eecs.umich.edu (Arie Covrigaru) writes:
>
> The TI Explorer I am using for the same project doesn't have this problem,
> yet it must follow the same definition of read-line. On the Mac, I had to
> add a form to take care of the #\Linefeed character after a read-line, but
> this makes the code incompatible with the TI version.
The issue of "what read-line should do" aside, there is no reason that such
an implementation difference should make your code non-portable. The
read-macros #+ and #- let you conditionally compile things into your code,
much like C's #ifdef form.
(let ((line (read-line stream)))
#-EXPLORER (read-char stream) ; if not a TI, discard a newline.
line)
Or, a more general solution:
(let ((line (read-line stream)))
;; If the next character is LF, ditch it.
(when (char= #\Linefeed (peek-char nil stream nil #\Null))
(read-char stream))
line)
-- Jamie