-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Simon Josefsson on 11/9/2005 7:17 PM: > Is this right? I'm not sure what a portable way to remove EOL is. > Anyway, I installed this because it work on known platforms.
The concept is correct (the full-blown readline library does indeed strip the trailing newline), but whether you should also strip \r is a different matter. > > > + if (out[strlen (out) - 1] == '\r') > + out[strlen (out) - 1] = '\0'; > + if (out[strlen (out) - 1] == '\n') > + out[strlen (out) - 1] = '\0'; This is backwards: Windows text files have \r\n, so you should strip \n before \r if you are working from the end (and if others agree that stripping \r is the right thing to do). Also, it ignores the fact that getline() can return embedded NULs, so that a) strlen() may be inaccurate, and b) it is a waste of computation since the return value of getline() is already the full length rather than walking the string multiple times. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDctTC84KuGfSFAYARAoDAAJ9ZGEiQrUJCICFIXbG3fX31Kwh5KACgupxq /JDFkoRVihv/v69Kb0gMR2A= =6qMR -----END PGP SIGNATURE----- _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib