aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2003-12-10 20:05:00 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2003-12-10 20:05:00 +0000
commit3090572ce2806c17059af0924390a7532467c2ef (patch)
tree8005bb5caef94bc1b2e5f178ff8f8917dd7473dd
parent35d6801ebe76223839d318e66696d28fe903c739 (diff)
downloadgcc-3090572ce2806c17059af0924390a7532467c2ef.zip
gcc-3090572ce2806c17059af0924390a7532467c2ef.tar.gz
gcc-3090572ce2806c17059af0924390a7532467c2ef.tar.bz2
re PR libstdc++/13217 (basic_filebuf::underflow doesn't deal gracefully with read errors)
2003-12-10 Paolo Carlini <pcarlini@suse.de> PR libstdc++/13217 * include/bits/fstream.tcc (underflow): Deal gracefully with read errors: throw ios_base::failure. From-SVN: r74506
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc7
2 files changed, 13 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 39dfb08..4af6d4e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2003-12-10 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/13217
+ * include/bits/fstream.tcc (underflow): Deal gracefully with
+ read errors: throw ios_base::failure.
+
2003-12-10 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/10063
@@ -358,7 +364,7 @@
PR libstdc++/11544
PR libstdc++/11603
- * include/bits/fstream.tcc (underflow): Throw ios_base:failure
+ * include/bits/fstream.tcc (underflow): Throw ios_base::failure
upon incomplete or invalid byte sequences in the file.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-1.cc: New.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-2.cc: New.
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 595d8bde..998e0c3 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -258,6 +258,8 @@ namespace std
streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
if (__elen == 0)
__got_eof = true;
+ else if (__elen == -1)
+ break;
_M_ext_end += __elen;
}
@@ -306,9 +308,12 @@ namespace std
__throw_ios_failure("basic_filebuf::underflow "
"incomplete character in file");
}
- else
+ else if (__r == codecvt_base::error)
__throw_ios_failure("basic_filebuf::underflow "
"invalid byte sequence in file");
+ else
+ __throw_ios_failure("basic_filebuf::underflow "
+ "error reading the file");
}
return __ret;
}