basic_file_stdio.cc (fopen_mode): Add modes missing per DR 596.
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. From-SVN: r130004
This commit is contained in:
parent
8dc9f613ea
commit
ec01f29236
@ -1,3 +1,11 @@
|
||||
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>):
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -626,6 +626,12 @@
|
||||
<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>
|
||||
|
@ -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*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user