2007-11-08 Paolo Carlini <pcarlini@suse.de>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Nov 2007 16:22:21 +0000 (16:22 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Nov 2007 16:22:21 +0000 (16:22 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130004 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/config/io/basic_file_stdio.cc
libstdc++-v3/docs/html/ext/howto.html
libstdc++-v3/include/std/fstream
libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc

index 0dc8222..7abb3c2 100644 (file)
@@ -1,5 +1,13 @@
 2007-11-08  Paolo Carlini  <pcarlini@suse.de>
 
+       * 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  <pcarlini@suse.de>
+
        * include/std/type_traits (__decay_selector<_Up, false, false>):
        Change according to DR 705.
        * include/bits/stl_pair.h (make_pair(_T1&&, _T2&&)): Change
index 41d914a..104f88c 100644 (file)
@@ -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
       }
   }
index f67b251..54dffba 100644 (file)
     <dd>Change it to be a formatted output function (i.e. catch exceptions).
     </dd>
 
+    <dt><a href="lwg-active.html#596">596</a>:
+        <em>27.8.1.3 Table 112 omits "a+" and "a+b" modes</em>
+    </dt>
+    <dd>Add the missing modes to fopen_mode.
+    </dd>
+
     <dt><a href="lwg-defects.html#660">660</a>:
         <em>Missing bitwise operations</em>
     </dt>
index fb56412..af7635e 100644 (file)
@@ -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*
index 97200a6..1c8d9ea 100644 (file)
@@ -1,6 +1,6 @@
 // 2006-10-01  Paolo Carlini  <pcarlini@suse.de>
 
-// 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 <fstream>
 #include <testsuite_hooks.h>
 
-// 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