diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0dc8222b7cf..7abb3c281c1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2007-11-08 Paolo Carlini + + * config/io/basic_file_stdio.cc (fopen_mode): Add modes missing + per DR 596. + * testsuite/27_io/basic_filebuf/open/char/4.cc: Extend. + * include/std/fstream: Update comment preceding open. + * docs/html/ext/howto.html: Update. + 2007-11-08 Paolo Carlini * include/std/type_traits (__decay_selector<_Up, false, false>): diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc index 41d914ad859..104f88c96f7 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.cc +++ b/libstdc++-v3/config/io/basic_file_stdio.cc @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -86,27 +86,31 @@ namespace app = std::ios_base::app, binary = std::ios_base::binary }; - + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 596. 27.8.1.3 Table 112 omits "a+" and "a+b" modes. 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+"; - // Extension to Table 92. - case (in|out |app ): return "a+"; - - case ( out |binary): return "wb"; - case ( out |app|binary): return "ab"; - case ( out|trunc |binary): return "wb"; - case (in |binary): return "rb"; + case ( out ): return "w"; + case ( out |app ): return "a"; + case ( app ): return "a"; + case ( out|trunc ): return "w"; + case (in ): return "r"; + case (in|out ): return "r+"; + case (in|out|trunc ): return "w+"; + case (in|out |app ): return "a+"; + case (in |app ): return "a+"; + + case ( out |binary): return "wb"; + case ( out |app|binary): return "ab"; + case ( 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"; - // Extension to Table 92. case (in|out |app|binary): return "a+b"; - + case (in |app|binary): return "a+b"; + default: return 0; // invalid } } diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html index f67b25171c2..54dffbac573 100644 --- a/libstdc++-v3/docs/html/ext/howto.html +++ b/libstdc++-v3/docs/html/ext/howto.html @@ -626,6 +626,12 @@
Change it to be a formatted output function (i.e. catch exceptions).
+
596: + 27.8.1.3 Table 112 omits "a+" and "a+b" modes +
+
Add the missing modes to fopen_mode. +
+
660: Missing bitwise operations
diff --git a/libstdc++-v3/include/std/fstream b/libstdc++-v3/include/std/fstream index fb56412b212..af7635e9145 100644 --- a/libstdc++-v3/include/std/fstream +++ b/libstdc++-v3/include/std/fstream @@ -259,26 +259,31 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * * Table 92, adapted here, gives the relation between openmode * combinations and the equivalent fopen() flags. - * (NB: lines in|out|app and binary|in|out|app per DR 596) + * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, + * and binary|in|app per DR 596) * +---------------------------------------------------------+ * | ios_base Flag combination stdio equivalent | * |binary in out trunc app | * +---------------------------------------------------------+ * | + "w" | * | + + "a" | + * | + "a" | * | + + "w" | * | + "r" | * | + + "r+" | * | + + + "w+" | * | + + + "a+" | + * | + + "a+" | * +---------------------------------------------------------+ * | + + "wb" | * | + + + "ab" | + * | + + "ab" | * | + + + "wb" | * | + + "rb" | * | + + + "r+b" | * | + + + + "w+b" | * | + + + + "a+b" | + * | + + + "a+b" | * +---------------------------------------------------------+ */ __filebuf_type* diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc index 97200a68f7d..1c8d9ea21f1 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc @@ -1,6 +1,6 @@ // 2006-10-01 Paolo Carlini -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007 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 @@ -23,8 +23,7 @@ #include #include -// As an extension to Table 92, consistently with the C standards, we also -// allow in|out|app and in|out|app|binary. +// DR 596. void test01() { bool test __attribute__((unused)) = true; @@ -32,17 +31,38 @@ void test01() std::fstream scratch_file; + scratch_file.open(name, std::ios_base::app); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + scratch_file.open(name, std::ios_base::in | std::ios_base::out | std::ios_base::app); VERIFY( scratch_file ); VERIFY( scratch_file.is_open() ); scratch_file.close(); + scratch_file.open(name, std::ios_base::in | std::ios_base::app); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::app | std::ios_base::binary); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + scratch_file.open(name, std::ios_base::in | std::ios_base::out | std::ios_base::app | std::ios_base::binary); VERIFY( scratch_file ); VERIFY( scratch_file.is_open() ); scratch_file.close(); + + scratch_file.open(name, std::ios_base::in | std::ios_base::app + | std::ios_base::binary); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); } int