+2004-02-04 Benjamin Kosnik <bkoz@redhat.com>
+ Zack Weinberg <zack@codesourcery.com>
+
+ * config/io/basic_file_stdio.cc (__gnu_internal::fopen_mode):
+ New function.
+ (__basic_file<char>::sys_open, __basic_file<char>::open): Use it.
+ (__basic_file<char>::_M_open_mode): Use it. Mark deprecated.
+
+ * testsuite/27_io/filebuf_members.cc (test_06, test_07):
+ Correct flags to filebuf::open calls.
+
2004-01-29 Paolo Carlini <pcarlini@suse.de>
-
+
PR libstdc++/12657
* include/bits/basic_ios.tcc (copyfmt(const basic_ios&)):
Implement resolution of DR 292 (WP).
PR libstdc++/12540
* config/locale/gnu/monetary_members.cc: Don't leak memory
on exception.
-
+
2004-01-26 Andreas Schwab <schwab@suse.de>
* config/locale/gnu/monetary_members.cc: Restore locale before
2004-01-07 Paolo Carlini <pcarlini@suse.de>
Petur Runolfsson <peturr02@ru.is>
-
+
PR libstdc++/13007
* include/bits/fstream.tcc (imbue): Don't touch the stored
locale.
LD_LIBRARY_PATH to both. Based on libjava.exp.
2003-12-10 Benjamin Kosnik <bkoz@redhat.com>
- Alexandre Oliva <aoliva@redhat.com>
-
+ Alexandre Oliva <aoliva@redhat.com>
+
PR libstdc++/11612
* testsuite/Makefile.am (GLIBCXX_DIR): New.
(GLIBGCC_DIR): New.
* include/bits/basic_ios.tcc: Tweak.
* include/bits/fstream.tcc: Tweak.
* include/bits/istream.tcc: Use _M_setstate for common exception
- handling. Move setstate calls after catch.
+ handling. Move setstate calls after catch.
(basic_istream::tellg): Check for exceptions thrown by streambuf
virtual functions.
(basic_istream::seekg): Same.
* include/bits/ostream.tcc: Same, but for ostream.
(basic_ostream::flush): Check for exceptions thrown by streambuf
virtual functions.
- (basic_istream::tellp): Same.
+ (basic_istream::tellp): Same.
(basic_istream::seekp): Same.
* include/bits/locale_facets.tcc: Tweak.
* include/bits/streambuf.tcc: Tweak.
PR libstdc++/12451
* libsupc++/cxxabi.h: Move forward declaration of __class_type_info.
-
+
2003-10-01 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* configure.target: Handle Solaris 2.5 micro releases explicitly.
returns eof.
2003-09-30 Nathan Myers <ncm@cantrip.org>
- Paolo Carlini <pcarlini@unitus.it>
+ Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/11400
* include/bits/stl_algo.h (search_n):
// Wrapper of C-language FILE struct -*- C++ -*-
-// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 2004 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
# endif
#endif
+namespace __gnu_internal
+{
+ // Map ios_base::openmode flags to a string for use in fopen().
+ // Table of valid combinations as given in [lib.filebuf.members]/2.
+ static const char*
+ fopen_mode(std::ios_base::openmode mode)
+ {
+ enum
+ {
+ in = std::ios_base::in,
+ out = std::ios_base::out,
+ trunc = std::ios_base::trunc,
+ app = std::ios_base::app,
+ binary = std::ios_base::binary
+ };
+
+ switch (mode & (in|out|trunc|app|binary))
+ {
+ case ( out ): return "w";
+ case ( out |app ): return "a";
+ case ( out|trunc ): return "w";
+ case (in ): return "r";
+ case (in|out ): return "r+";
+ case (in|out|trunc ): return "w+";
+
+ case ( out |binary): return "wb";
+ case ( out |app|binary): return "ab";
+ case ( out|trunc |binary): return "wb";
+ case (in |binary): return "rb";
+ case (in|out |binary): return "r+b";
+ case (in|out|trunc |binary): return "w+b";
+
+ default: return 0; // invalid
+ }
+ }
+} // namespace __gnu_internal
+
namespace std
{
// Definitions for __basic_file<char>.
__basic_file<char>::~__basic_file()
{ this->close(); }
-
- void
- __basic_file<char>::_M_open_mode(ios_base::openmode __mode, int& __p_mode,
- int&, char* __c_mode)
- {
- bool __testb = __mode & ios_base::binary;
- bool __testi = __mode & ios_base::in;
- bool __testo = __mode & ios_base::out;
- bool __testt = __mode & ios_base::trunc;
- bool __testa = __mode & ios_base::app;
-
- // Set __c_mode for use in fopen.
- // Set __p_mode for use in open.
- if (!__testi && __testo && !__testt && !__testa)
- {
- strcpy(__c_mode, "w");
- __p_mode = (O_WRONLY | O_CREAT);
- }
- if (!__testi && __testo && !__testt && __testa)
- {
- strcpy(__c_mode, "a");
- __p_mode |= O_WRONLY | O_CREAT | O_APPEND;
- }
- if (!__testi && __testo && __testt && !__testa)
- {
- strcpy(__c_mode, "w");
- __p_mode |= O_WRONLY | O_CREAT | O_TRUNC;
- }
- if (__testi && !__testo && !__testt && !__testa)
- {
- strcpy(__c_mode, "r");
- __p_mode |= O_RDONLY;
- }
- if (__testi && __testo && !__testt && !__testa)
- {
- strcpy(__c_mode, "r+");
- __p_mode |= O_RDWR | O_CREAT;
- }
- if (__testi && __testo && __testt && !__testa)
- {
- strcpy(__c_mode, "w+");
- __p_mode |= O_RDWR | O_CREAT | O_TRUNC;
- }
- if (__testb)
- strcat(__c_mode, "b");
+ // Preserved for binary compatibility only.
+ // Do not use. Gone in 3.4.
+ void
+ __basic_file<char>::_M_open_mode(ios_base::openmode __mode, int&, int&,
+ char* __c_mode)
+ {
+ const char* r = __gnu_internal::fopen_mode(__mode);
+ if (r)
+ strcpy(__c_mode, r);
}
__basic_file<char>*
bool __del)
{
__basic_file* __ret = NULL;
- int __p_mode = 0;
- int __rw_mode = 0;
- char __c_mode[4];
-
- _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode);
- if (!this->is_open() && (_M_cfile = fdopen(__fd, __c_mode)))
+ const char* __c_mode = __gnu_internal::fopen_mode(__mode);
+ if (__c_mode && !this->is_open()
+ && (_M_cfile = fdopen(__fd, __c_mode)))
{
// Iff __del is true, then close will fclose the fd.
_M_cfile_created = __del;
int /*__prot*/)
{
__basic_file* __ret = NULL;
- int __p_mode = 0;
- int __rw_mode = 0;
- char __c_mode[4];
-
- _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode);
-
- if (!this->is_open())
+ const char* __c_mode = __gnu_internal::fopen_mode(__mode);
+ if (__c_mode && !this->is_open())
{
if ((_M_cfile = fopen(__name, __c_mode)))
{