Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

READ-LINE

3 views
Skip to first unread message

J.L. Perez-de-la-Cruz

unread,
May 5, 1999, 3:00:00 AM5/5/99
to
In the CLHS it can be read:
Function READ-LINE
read-line &optional input-stream eof-error-p eof-value recursive-p
=> line, missing-newline-p
...
The secondary value, missing-newline-p, is a generalized boolean
that is false if the line was terminated by a newline, or true
if the line was terminated by the end of file for input-stream
(or if the line IS the EOF-value) (my emphasis)

However, the following program loops forever in CLISP for Windows:
(DEFUN LEER-TEXTO ()
(WITH-OPEN-FILE (F1 "kk.txt" :DIRECTION :INPUT)
(LOOP
(MULTIPLE-VALUE-BIND (LINEA FINAL)
(READ-LINE F1 NIL)
(TERPRI)
(PRINC LINEA)
(WHEN FINAL (RETURN))))))
(LEER-TEXTO)
when "kk.txt" contains the two lines
asdf
<EOF>
but behaves properly when "kk.txt" contains a space in the second line
asdf
<EOF>
Is this a little bug in CLISP or am I misunderstanding the
specification?
Thanks.

---------------------
Jose-Luis Perez-de-la-Cruz
ETSI Informatica
POB 4114
MALAGA 29080 SPAIN
Tlf +34 952 132801
Fax +34 952 131396
--------------------

Erik Naggum

unread,
May 5, 1999, 3:00:00 AM5/5/99
to
* "J.L. Perez-de-la-Cruz" <cr...@apolo.lcc.uma.es>

| Is this a little bug in CLISP or am I misunderstanding the
| specification?

since you return whatever object CLISP elects to mean end-of-file when
you hit the end of file, I suppose you get a lot of that object printed
while READ-LINE continues to hit its head at the end of the file when the
last line was properly terminated.

#:Erik

J.L. Perez-de-la-Cruz

unread,
May 5, 1999, 3:00:00 AM5/5/99
to

That's exactly what happens.

Erik Naggum

unread,
May 5, 1999, 3:00:00 AM5/5/99
to
* "J.L. Perez-de-la-Cruz" <cr...@apolo.lcc.uma.es>

| That's exactly what happens.

then that's the expected and correct behavior.

if you don't want this behavior, supply READ-LINE with a value that you
can check against to see that you have hit the end of the file. I tend
to use the keywof :EOF when dealing with characters or strings.

#:Erik

0 new messages