[multiple changes]
2009-03-25 Edward Smith-Rowland <3dw4rd@verizon.net> * include/std/fstream (basic_filebuf<>::open(const std::string&, ios_base::openmode), basic_ifstream<>::basic_ifstream(const std::string&, ios_base::openmode), basic_ifstream<>:: open(const std::string&, ios_base::openmode), basic_ofstream<>:: basic_ofstream(const std::string&, ios_base::openmode), basic_ofstream<>::open(const std::string&, ios_base::openmode), basic_fstream<>::basic_fstream(const std::string&, ios_base::openmode), basic_fstream<>::open(const std::string&, ios_base::openmode)): Add in C++0x mode. * testsuite/27_io/basic_ofstream/open/char/2.cc: New. * testsuite/27_io/basic_ofstream/cons/char/2.cc: Likewise. * testsuite/27_io/basic_fstream/open/char/1.cc: Likewise. * testsuite/27_io/basic_fstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_ifstream/open/char/1.cc: Likewise. * testsuite/27_io/basic_ifstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_filebuf/open/char/5.cc: Likewise. 2009-03-25 Paolo Carlini <paolo.carlini@oracle.com> * testsuite/27_io/basic_ofstream/cons/char/2.cc: Rename to... * testsuite/27_io/basic_ofstream/cons/char/1.cc: ... this. * testsuite/27_io/basic_fstream/cons/3.cc: Rename to... * testsuite/27_io/basic_fstream/cons/1.cc: ... this. From-SVN: r145078
This commit is contained in:
parent
9fdcdc749b
commit
13c4b87740
|
@ -1,3 +1,29 @@
|
|||
2009-03-25 Edward Smith-Rowland <3dw4rd@verizon.net>
|
||||
|
||||
* include/std/fstream (basic_filebuf<>::open(const std::string&,
|
||||
ios_base::openmode), basic_ifstream<>::basic_ifstream(const
|
||||
std::string&, ios_base::openmode), basic_ifstream<>::
|
||||
open(const std::string&, ios_base::openmode), basic_ofstream<>::
|
||||
basic_ofstream(const std::string&, ios_base::openmode),
|
||||
basic_ofstream<>::open(const std::string&, ios_base::openmode),
|
||||
basic_fstream<>::basic_fstream(const std::string&, ios_base::openmode),
|
||||
basic_fstream<>::open(const std::string&, ios_base::openmode)):
|
||||
Add in C++0x mode.
|
||||
* testsuite/27_io/basic_ofstream/open/char/2.cc: New.
|
||||
* testsuite/27_io/basic_ofstream/cons/char/2.cc: Likewise.
|
||||
* testsuite/27_io/basic_fstream/open/char/1.cc: Likewise.
|
||||
* testsuite/27_io/basic_fstream/cons/char/1.cc: Likewise.
|
||||
* testsuite/27_io/basic_ifstream/open/char/1.cc: Likewise.
|
||||
* testsuite/27_io/basic_ifstream/cons/char/1.cc: Likewise.
|
||||
* testsuite/27_io/basic_filebuf/open/char/5.cc: Likewise.
|
||||
|
||||
2009-03-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* testsuite/27_io/basic_ofstream/cons/char/2.cc: Rename to...
|
||||
* testsuite/27_io/basic_ofstream/cons/char/1.cc: ... this.
|
||||
* testsuite/27_io/basic_fstream/cons/3.cc: Rename to...
|
||||
* testsuite/27_io/basic_fstream/cons/1.cc: ... this.
|
||||
|
||||
2009-03-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/forward_list.h (_Fwd_list_node_base<>::
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
#include <bits/codecvt.h>
|
||||
#include <cstdio> // For BUFSIZ
|
||||
#include <bits/basic_file.h> // For __basic_file, __c_lock
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#include <string> // For std::string overloads.
|
||||
#endif
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
|
@ -266,6 +269,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
__filebuf_type*
|
||||
open(const char* __s, ios_base::openmode __mode);
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Opens an external file.
|
||||
* @param s The name of the file.
|
||||
* @param mode The open mode flags.
|
||||
* @return @c this on success, NULL on failure
|
||||
*/
|
||||
__filebuf_type*
|
||||
open(const std::string& __s, ios_base::openmode __mode)
|
||||
{ return open(__s.c_str(), __mode); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Closes the currently associated file.
|
||||
* @return @c this on success, NULL on failure
|
||||
|
@ -448,6 +463,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->open(__s, __mode);
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Create an input file stream.
|
||||
* @param s std::string specifying the filename.
|
||||
* @param mode Open file in specified mode (see std::ios_base).
|
||||
*
|
||||
* @c ios_base::in is automatically included in @a mode.
|
||||
*/
|
||||
explicit
|
||||
basic_ifstream(const std::string& __s,
|
||||
ios_base::openmode __mode = ios_base::in)
|
||||
: __istream_type(), _M_filebuf()
|
||||
{
|
||||
this->init(&_M_filebuf);
|
||||
this->open(__s, __mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The destructor does nothing.
|
||||
*
|
||||
|
@ -504,6 +537,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->clear();
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Opens an external file.
|
||||
* @param s The name of the file.
|
||||
* @param mode The open mode flags.
|
||||
*
|
||||
* Calls @c std::basic_filebuf::open(s,mode|in). If that function
|
||||
* fails, @c failbit is set in the stream's error state.
|
||||
*/
|
||||
void
|
||||
open(const std::string& __s, ios_base::openmode __mode = ios_base::in)
|
||||
{
|
||||
if (!_M_filebuf.open(__s, __mode | ios_base::in))
|
||||
this->setstate(ios_base::failbit);
|
||||
else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 409. Closing an fstream should clear error state
|
||||
this->clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Close the file.
|
||||
*
|
||||
|
@ -579,6 +633,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->open(__s, __mode);
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Create an output file stream.
|
||||
* @param s std::string specifying the filename.
|
||||
* @param mode Open file in specified mode (see std::ios_base).
|
||||
*
|
||||
* @c ios_base::out|ios_base::trunc is automatically included in
|
||||
* @a mode.
|
||||
*/
|
||||
explicit
|
||||
basic_ofstream(const std::string& __s,
|
||||
ios_base::openmode __mode = ios_base::out|ios_base::trunc)
|
||||
: __ostream_type(), _M_filebuf()
|
||||
{
|
||||
this->init(&_M_filebuf);
|
||||
this->open(__s, __mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The destructor does nothing.
|
||||
*
|
||||
|
@ -636,6 +709,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->clear();
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Opens an external file.
|
||||
* @param s The name of the file.
|
||||
* @param mode The open mode flags.
|
||||
*
|
||||
* Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that
|
||||
* function fails, @c failbit is set in the stream's error state.
|
||||
*/
|
||||
void
|
||||
open(const std::string& __s,
|
||||
ios_base::openmode __mode = ios_base::out | ios_base::trunc)
|
||||
{
|
||||
if (!_M_filebuf.open(__s, __mode | ios_base::out))
|
||||
this->setstate(ios_base::failbit);
|
||||
else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 409. Closing an fstream should clear error state
|
||||
this->clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Close the file.
|
||||
*
|
||||
|
@ -710,6 +805,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->open(__s, __mode);
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Create an input/output file stream.
|
||||
* @param s Null terminated string specifying the filename.
|
||||
* @param mode Open file in specified mode (see std::ios_base).
|
||||
*/
|
||||
explicit
|
||||
basic_fstream(const std::string& __s,
|
||||
ios_base::openmode __mode = ios_base::in | ios_base::out)
|
||||
: __iostream_type(NULL), _M_filebuf()
|
||||
{
|
||||
this->init(&_M_filebuf);
|
||||
this->open(__s, __mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The destructor does nothing.
|
||||
*
|
||||
|
@ -767,6 +878,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
this->clear();
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Opens an external file.
|
||||
* @param s The name of the file.
|
||||
* @param mode The open mode flags.
|
||||
*
|
||||
* Calls @c std::basic_filebuf::open(s,mode). If that
|
||||
* function fails, @c failbit is set in the stream's error state.
|
||||
*/
|
||||
void
|
||||
open(const std::string& __s,
|
||||
ios_base::openmode __mode = ios_base::in | ios_base::out)
|
||||
{
|
||||
if (!_M_filebuf.open(__s, __mode))
|
||||
this->setstate(ios_base::failbit);
|
||||
else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 409. Closing an fstream should clear error state
|
||||
this->clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Close the file.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// Test member functions.
|
||||
void test01()
|
||||
{
|
||||
std::filebuf fb;
|
||||
|
||||
const std::string name = "filebuf_name.txt";
|
||||
fb.open(name, std::ios_base::in | std::ios_base::ate);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void test01()
|
||||
{
|
||||
const std::string name = "fstream_name.txt";
|
||||
std::fstream fs(name);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void test01()
|
||||
{
|
||||
std::fstream fs;
|
||||
|
||||
const std::string name = "fstream_name.txt";
|
||||
fs.open(name);
|
||||
|
||||
fs.close();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void test01()
|
||||
{
|
||||
const std::string name = "ifstream_name.txt";
|
||||
std::ifstream ifs(name);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void test01()
|
||||
{
|
||||
std::ifstream ifs;
|
||||
|
||||
const std::string name = "ifstream_name.txt";
|
||||
ifs.open(name);
|
||||
|
||||
ifs.close();
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (C) 2000, 2001, 2003 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 27.8.1.10 ofstream member functions
|
||||
// @require@ %-*.tst
|
||||
// @diff@ %-*.tst %-*.txt
|
||||
|
||||
// { dg-require-fileio "" }
|
||||
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
const char name_02[] = "ofstream_members-1.txt";
|
||||
|
||||
// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
|
||||
void test02()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
const int more_than_max_open_files = 8200;
|
||||
|
||||
for(int i = 0; ++i < more_than_max_open_files;)
|
||||
{
|
||||
std::ofstream ifs(name_02);
|
||||
VERIFY( static_cast<bool>(ifs) );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2009 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
|
||||
|
@ -16,36 +16,13 @@
|
|||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 27.8.1.10 ofstream member functions
|
||||
// @require@ %-*.tst
|
||||
// @diff@ %-*.tst %-*.txt
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// { dg-require-fileio "" }
|
||||
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
const char name_02[] = "ofstream_members-1.txt";
|
||||
|
||||
// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
|
||||
void test02()
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
const int more_than_max_open_files = 8200;
|
||||
|
||||
for(int i = 0; ++i < more_than_max_open_files;)
|
||||
{
|
||||
std::ofstream ifs(name_02);
|
||||
VERIFY( static_cast<bool>(ifs) );
|
||||
}
|
||||
const std::string name = "ofstream_name.txt";
|
||||
std::ofstream ofs(name);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2009 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void test01()
|
||||
{
|
||||
std::ofstream ofs;
|
||||
|
||||
const std::string name = "ofstream_name.txt";
|
||||
ofs.open(name);
|
||||
|
||||
ofs.close();
|
||||
}
|
Loading…
Reference in New Issue