aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog11
-rw-r--r--libstdc++-v3/config/os/mingw32/os_defines.h5
-rw-r--r--libstdc++-v3/config/os/newlib/os_defines.h5
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc19
4 files changed, 36 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d42c83e..e92b927 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-08 Danny Smith <dannysmith@users.sourceforge.net>
+ Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/20806
+ * config/os/mingw32/os_defines.h: Define
+ _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM.
+ * config/os/newlib/os_defines.h: Likewise, for __CYGWIN__.
+ * include/bits/fstream.tcc (basic_filebuf<>::showmanyc()):
+ Use it.
+ (basic_filebuf<>::xsgetn(_CharT*, streamsize)): Likewise.
+
2005-04-08 Kelley Cook <kcook@gcc.gnu.org>
* acconfig.h: Sort the bottom section.
diff --git a/libstdc++-v3/config/os/mingw32/os_defines.h b/libstdc++-v3/config/os/mingw32/os_defines.h
index 38fd3c7..2008886 100644
--- a/libstdc++-v3/config/os/mingw32/os_defines.h
+++ b/libstdc++-v3/config/os/mingw32/os_defines.h
@@ -1,6 +1,6 @@
// Specific definitions for generic platforms -*- C++ -*-
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -45,4 +45,7 @@
#undef NOMINMAX
#define NOMINMAX 1
+// See libstdc++/20806.
+#define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
+
#endif
diff --git a/libstdc++-v3/config/os/newlib/os_defines.h b/libstdc++-v3/config/os/newlib/os_defines.h
index ff33461..0b0a629 100644
--- a/libstdc++-v3/config/os/newlib/os_defines.h
+++ b/libstdc++-v3/config/os/newlib/os_defines.h
@@ -1,6 +1,6 @@
// Specific definitions for newlib -*- C++ -*-
-// Copyright (C) 2000 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2005 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -35,6 +35,9 @@
#ifdef __CYGWIN__
#define _GLIBCXX_GTHREAD_USE_WEAK 0
+
+// See libstdc++/20806.
+#define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
#endif
#endif
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index a9d1574..6915ea9 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -171,7 +171,15 @@ namespace std
// For a stateful encoding (-1) the pending sequence might be just
// shift and unshift prefixes with no actual character.
__ret = this->egptr() - this->gptr();
+
+#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM
+ // About this workaround, see libstdc++/20806.
+ const bool __testbinary = _M_mode & ios_base::binary;
+ if (__check_facet(_M_codecvt).encoding() >= 0
+ && __testbinary)
+#else
if (__check_facet(_M_codecvt).encoding() >= 0)
+#endif
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
return __ret;
@@ -521,10 +529,17 @@ namespace std
// future: when __n > __buflen we read directly instead of using the
// buffer repeatedly.
const bool __testin = _M_mode & ios_base::in;
- const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1
- : 1;
+ const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
+
+#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM
+ // About this workaround, see libstdc++/20806.
+ const bool __testbinary = _M_mode & ios_base::binary;
+ if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
+ && __testin && __testbinary && !_M_writing)
+#else
if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
&& __testin && !_M_writing)
+#endif
{
// First, copy the chars already present in the buffer.
const streamsize __avail = this->egptr() - this->gptr();