From: Guy Ellis <···········@CompuServe.COM>
Date: 8 May 1996 14:16:35 GMT
I'm using Allegro Common Lisp 3.0 for windows and get the
following error message when trying to use read-line with a large
file:
Subscript given to array function in CONCATENTATE-STRINGS is out
of bounds.
The file is about 200k in size but about every 80 characters are
separated by a newline character. The functionality works fine if
I cut the file down to 10k. I was under the impression that
read-line just read characters up to the first newline. Is this
correct? Does anybody know what is happening here?
The problem is that ACL/Win uses #\Newline := #\Return (perhaps
due to its Procyon/MAC heritage). Thus \Linefeed is not an end-of-line
sequence so your entire file is being read as a single line, overflowing
the current 16-bit limit on string length.
Its easy enough to verify this. Here's an Editi transcript:
(labels ((doit (char1 &optional char2 &aux (str (copy "0123")) stream)
(setf (aref str 1) char1)
(when char2 (setf (aref str 2) char2))
(list (read-line (setq stream (make-string-input-stream str)))
(read-line stream nil))))
(values (doit #\Linefeed)
(doit #\Return)
(doit #\Return #\Linefeed)
(doit #\Linefeed #\Return)))
=>
("0
23" NIL) ; so LF != NL
("0" "23") ; so CR = NL
("0" "3") ; so CR LF = NL
("0 ; so LF CR = LF NL
" "3")