# HG changeset patch # User John W. Eaton # Date 1235419450 -3600 # Node ID 8bc4e0ae758cf555155f572f450fe59f1dc419ce # Parent 7518126401ac323c48921e22aeb8a110418950db handle CRLF and CR in fgetl/fgets diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-02-13 John W. Eaton + + * oct-stream.cc (octave_base_stream::do_gets): Handle CRLF and CR. + 2009-01-23 Jaroslav Hajek * DLD-FUNCTIONS/ranpd.cc: Use relative tolerance for randp tests. diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -982,7 +982,31 @@ { char_count++; - if (c == '\n') + // Handle CRLF, CR, or LF as line ending. + + if (c == '\r') + { + if (! strip_newline) + buf << static_cast (c); + + c = is.get (); + + if (c != EOF) + { + if (c == '\n') + { + char_count++; + + if (! strip_newline) + buf << static_cast (c); + } + else + is.putback (c); + } + + break; + } + else if (c == '\n') { if (! strip_newline) buf << static_cast (c);