Arc Forumnew | comments | leaders | submitlogin
Bug in readline
2 points by aw 4159 days ago | 8 comments
Contents of file "foo":

Calling readline in Arc 3.1:

  arc> (w/infile s "foo" (drain (readline s)))
  ("one" "two" "\nthree")

2 points by rocketnia 4158 days ago | link

Well, this behavior at least guarantees that any string readline returns will be at least one character long. You can [coerce _ 'cons] the result without worrying that you'll confuse the EOF nil with an empty line.

Maybe readline was designed under the idea that Arc strings would be indistinguishable from lists of characters?


1 point by aw 4158 days ago | link

Check for nil before coercing to cons.


1 point by rocketnia 4158 days ago | link

With the fix, I have to do that. Without the fix, I can keep my code brief. For what it's worth, I like the fix better, but then I don't expect to write (aif (coerce (readline) 'cons) ...) much either.


2 points by aw 4158 days ago | link

And a fix:


3 points by aw 4133 days ago | link

Updated to accept both LF and CRLF line endings, useful for Internet protocols like HTTP which use CRLF.


1 point by akkartik 4159 days ago | link

It seems documented at least.

"An initial newline does not terminate the input and appears in the output."


3 points by aw 4158 days ago | link

Better to fix bugs than document them.


1 point by akkartik 4158 days ago | link