> From: Mark H Weaver <m...@netris.org> > Cc: Eli Zaretskii <e...@gnu.org>, guile-user@gnu.org > Date: Tue, 18 Jun 2013 18:28:13 -0400 > > I think this is a bad idea for multiple reasons: > > * Handling of alternate line endings does not belong here; it belongs in > a transcoder of some sort. > > * This solution partially hides a problem (the user reading text without > a proper transcoder), but does not solve the problem adequately. It > will behave badly on files with CRLF line endings. There's no way to > fix that in 'read-line' because its API does not allow for a > multi-character delimiter. > > * It potentially breaks existing code. Making the change only on mingw > would seem to mitigate that problem, but that just muddies the waters > by introducing a difference in behavior that is not necessarily > warranted. > > * It hard codes the assumption that the line ending style of the file > being read is determined by the platform you're running on.
I agree. > To my mind, this is a bug in those tests. Right. > So how about the following patch instead? > > What do you think? > > Mark > > > diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test > index 9b1c6c0..758f8f6 100644 > --- a/test-suite/tests/ports.test > +++ b/test-suite/tests/ports.test > @@ -238,7 +238,7 @@ > (pass-if "file: binary mode ignores port encoding" > (with-fluids ((%default-port-encoding "UTF-8")) > (let* ((filename (test-file)) > - (port (open-file filename "w")) > + (port (open-file filename "wb")) > (test-string "一二三") > (binary-test-string > (apply string > @@ -257,7 +257,7 @@ > (pass-if "file: binary mode ignores file coding declaration" > (with-fluids ((%default-port-encoding "UTF-8")) > (let* ((filename (test-file)) > - (port (open-file filename "w")) > + (port (open-file filename "wb")) > (test-string "一二三") > (binary-test-string > (apply string I already tried that, and it doesn't work. You cannot have a port that is both UTF-8 encoded and open in binary mode, because Guile will try to encode characters in 8859-1, and fail (because the characters used here are not Latin-1 characters). IOW, binary I/O cannot be encoded.