# HG changeset patch # User John W. Eaton # Date 1454537715 18000 # Node ID 3db899f1d54cd89e8041ce69627ebbd0757d65e3 # Parent e7fda94aec6b967aa2756bc9b6c15da42ca36d01 use istream::traits_type::eof () instead of EOF * c-file-ptr-stream.cc, oct-stream.cc, lo-utils.cc: Use istream::traits_type::eof () instead of EOF. diff -r e7fda94aec6b -r 3db899f1d54c libinterp/corefcn/c-file-ptr-stream.cc --- a/libinterp/corefcn/c-file-ptr-stream.cc Wed Feb 03 16:50:38 2016 -0500 +++ b/libinterp/corefcn/c-file-ptr-stream.cc Wed Feb 03 17:15:15 2016 -0500 @@ -153,7 +153,7 @@ int c_file_ptr_buf::flush (void) { - return f ? gnulib::fflush (f) : EOF; + return f ? gnulib::fflush (f) : traits_type::eof (); } int @@ -300,7 +300,7 @@ // something other than 0 for the second argument to gzflush and // checking the return value, etc.? - return f ? gzflush (f, 0) : EOF; + return f ? gzflush (f, 0) : traits_type::eof (); } int diff -r e7fda94aec6b -r 3db899f1d54c libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Wed Feb 03 16:50:38 2016 -0500 +++ b/libinterp/corefcn/oct-stream.cc Wed Feb 03 17:15:15 2016 -0500 @@ -970,7 +970,7 @@ if (max_len != 0) { - while (is && (c = is.get ()) != EOF) + while (is && (c = is.get ()) != std::istream::traits_type::eof ()) { char_count++; @@ -982,7 +982,7 @@ c = is.get (); - if (c != EOF) + if (c != std::istream::traits_type::eof ()) { if (c == '\n') { @@ -1078,7 +1078,7 @@ int lastc = -1; cnt = 0; - while (is && (c = is.get ()) != EOF) + while (is && (c = is.get ()) != std::istream::traits_type::eof ()) { // Handle CRLF, CR, or LF as line ending. if (c == '\r' || (c == '\n' && lastc != '\r')) @@ -1125,12 +1125,13 @@ case 'i': { - int c1 = EOF; - - while (is && (c1 = is.get ()) != EOF && isspace (c1)) + int c1 = std::istream::traits_type::eof (); + + while (is && (c1 = is.get ()) != std::istream::traits_type::eof () + && isspace (c1)) ; // skip whitespace - if (c1 != EOF) + if (c1 != std::istream::traits_type::eof ()) { if (c1 == '0') { @@ -1225,12 +1226,13 @@ case 'f': case 'g': { - int c1 = EOF; - - while (is && (c1 = is.get ()) != EOF && isspace (c1)) + int c1 = std::istream::traits_type::eof (); + + while (is && (c1 = is.get ()) != std::istream::traits_type::eof () + && isspace (c1)) ; // skip whitespace - if (c1 != EOF) + if (c1 != std::istream::traits_type::eof ()) { is.putback (c1); @@ -1286,12 +1288,13 @@ #define DO_WHITESPACE_CONVERSION() \ do \ { \ - int c = EOF; \ + int c = std::istream::traits_type::eof (); \ \ - while (is && (c = is.get ()) != EOF && isspace (c)) \ + while (is && (c = is.get ()) != std::istream::traits_type::eof () \ + && isspace (c)) \ { /* skip whitespace */ } \ \ - if (c != EOF) \ + if (c != std::istream::traits_type::eof ()) \ is.putback (c); \ } \ while (0) @@ -1299,12 +1302,12 @@ #define DO_LITERAL_CONVERSION() \ do \ { \ - int c = EOF; \ + int c = std::istream::traits_type::eof (); \ \ int n = strlen (fmt); \ int i = 0; \ \ - while (i < n && is && (c = is.get ()) != EOF) \ + while (i < n && is && (c = is.get ()) != std::istream::traits_type::eof ()) \ { \ if (c == static_cast (fmt[i])) \ { \ @@ -1328,7 +1331,7 @@ { \ int c = is.get (); \ \ - if (c != EOF) \ + if (c != std::istream::traits_type::eof ()) \ { \ if (c != '%') \ { \ @@ -1348,13 +1351,13 @@ \ std::string tmp (width, '\0'); \ \ - int c = EOF; \ + int c = std::istream::traits_type::eof (); \ int n = 0; \ \ - while (is && n < width && (c = is.get ()) != EOF) \ + while (is && n < width && (c = is.get ()) != std::istream::traits_type::eof ()) \ tmp[n++] = static_cast (c); \ \ - if (n > 0 && c == EOF) \ + if (n > 0 && c == std::istream::traits_type::eof ()) \ is.clear (); \ \ tmp.resize (n) @@ -1372,11 +1375,11 @@ { \ tmp = std::string (width, '\0'); \ \ - int c = EOF; \ + int c = std::istream::traits_type::eof (); \ \ int n = 0; \ \ - while (is && (c = is.get ()) != EOF) \ + while (is && (c = is.get ()) != std::istream::traits_type::eof ()) \ { \ if (! isspace (c)) \ { \ @@ -1385,7 +1388,8 @@ } \ } \ \ - while (is && n < width && (c = is.get ()) != EOF) \ + while (is && n < width \ + && (c = is.get ()) != std::istream::traits_type::eof ()) \ { \ if (isspace (c)) \ { \ @@ -1396,7 +1400,7 @@ tmp[n++] = static_cast (c); \ } \ \ - if (n > 0 && c == EOF) \ + if (n > 0 && c == std::istream::traits_type::eof ()) \ is.clear (); \ \ tmp.resize (n); \ @@ -1423,31 +1427,34 @@ \ std::string char_class = elt->char_class; \ \ - int c = EOF; \ + int c = std::istream::traits_type::eof (); \ \ if (elt->type == '[') \ { \ int chars_read = 0; \ - while (is && chars_read++ < width && (c = is.get ()) != EOF \ + while (is && chars_read++ < width \ + && (c = is.get ()) != std::istream::traits_type::eof () \ && char_class.find (c) != std::string::npos) \ buf << static_cast (c); \ } \ else \ { \ int chars_read = 0; \ - while (is && chars_read++ < width && (c = is.get ()) != EOF \ + while (is && chars_read++ < width \ + && (c = is.get ()) != std::istream::traits_type::eof () \ && char_class.find (c) == std::string::npos) \ buf << static_cast (c); \ } \ \ - if (width == std::numeric_limits::max () && c != EOF) \ + if (width == std::numeric_limits::max () \ + && c != std::istream::traits_type::eof ()) \ is.putback (c); \ \ tmp = buf.str (); \ \ if (tmp.empty ()) \ is.setstate (std::ios::failbit); \ - else if (c == EOF) \ + else if (c == std::istream::traits_type::eof ()) \ is.clear (); \ \ } \ diff -r e7fda94aec6b -r 3db899f1d54c liboctave/util/lo-utils.cc --- a/liboctave/util/lo-utils.cc Wed Feb 03 16:50:38 2016 -0500 +++ b/liboctave/util/lo-utils.cc Wed Feb 03 17:15:15 2016 -0500 @@ -239,7 +239,7 @@ else { val = octave_numeric_limits::NA (); - if (c2 != EOF) + if (c2 != std::istream::traits_type::eof ()) is.putback (c2); } }