mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-30 07:14:09 +08:00
howto.html ('LWG Issues'): Add issue 60, partial implementation only.
2003-04-23 Phil Edwards <pme@gcc.gnu.org> * docs/html/ext/howto.html ('LWG Issues'): Add issue 60, partial implementation only. * include/bits/istream.tcc (putback, unget, sync, tellg, seekg): Comment and change to comply with DR 60 and the effect on gcount(). * include/std/std_istream.h: Update comments. * testsuite/27_io/basic_istream/putback/char/1.cc (test01): Add comments about reasons for tests. Test sync() against gcount(). * testsuite/27_io/basic_istream/seekg/char/2.cc: New file, test for effect on gcount(). * testsuite/27_io/basic_istream/tellg/char/2.cc: New file, test for effect on gcount(). From-SVN: r65983
This commit is contained in:
parent
c57ddcf1b4
commit
6894ddcf3d
@ -1,3 +1,17 @@
|
|||||||
|
2003-04-23 Phil Edwards <pme@gcc.gnu.org>
|
||||||
|
|
||||||
|
* docs/html/ext/howto.html ('LWG Issues'): Add issue 60, partial
|
||||||
|
implementation only.
|
||||||
|
* include/bits/istream.tcc (putback, unget, sync, tellg, seekg):
|
||||||
|
Comment and change to comply with DR 60 and the effect on gcount().
|
||||||
|
* include/std/std_istream.h: Update comments.
|
||||||
|
* testsuite/27_io/basic_istream/putback/char/1.cc (test01): Add
|
||||||
|
comments about reasons for tests. Test sync() against gcount().
|
||||||
|
* testsuite/27_io/basic_istream/seekg/char/2.cc: New file, test
|
||||||
|
for effect on gcount().
|
||||||
|
* testsuite/27_io/basic_istream/tellg/char/2.cc: New file, test
|
||||||
|
for effect on gcount().
|
||||||
|
|
||||||
2003-04-22 Loren J. Rittle <ljrittle@acm.org>
|
2003-04-22 Loren J. Rittle <ljrittle@acm.org>
|
||||||
|
|
||||||
* testsuite/27_io/basic_filebuf/close/char/9964.cc (test_07):
|
* testsuite/27_io/basic_filebuf/close/char/9964.cc (test_07):
|
||||||
|
@ -464,6 +464,13 @@
|
|||||||
"copying stream state" was deemed too complicated.
|
"copying stream state" was deemed too complicated.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><a href="lwg-defects.html#60">60</a>:
|
||||||
|
<em>What is a formatted input function?</em>
|
||||||
|
</dt>
|
||||||
|
<dd>This DR made many widespread changes to <code>basic_istream</code>,
|
||||||
|
not all of which have been implemented.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt><a href="lwg-defects.html#68">68</a>:
|
<dt><a href="lwg-defects.html#68">68</a>:
|
||||||
<em>Extractors for char* should store null at end</em>
|
<em>Extractors for char* should store null at end</em>
|
||||||
</dt>
|
</dt>
|
||||||
|
@ -841,7 +841,10 @@ namespace std
|
|||||||
basic_istream<_CharT, _Traits>::
|
basic_istream<_CharT, _Traits>::
|
||||||
putback(char_type __c)
|
putback(char_type __c)
|
||||||
{
|
{
|
||||||
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||||
|
// 60. What is a formatted input function?
|
||||||
_M_gcount = 0;
|
_M_gcount = 0;
|
||||||
|
#endif
|
||||||
sentry __cerb(*this, true);
|
sentry __cerb(*this, true);
|
||||||
if (__cerb)
|
if (__cerb)
|
||||||
{
|
{
|
||||||
@ -872,7 +875,10 @@ namespace std
|
|||||||
basic_istream<_CharT, _Traits>::
|
basic_istream<_CharT, _Traits>::
|
||||||
unget(void)
|
unget(void)
|
||||||
{
|
{
|
||||||
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||||
|
// 60. What is a formatted input function?
|
||||||
_M_gcount = 0;
|
_M_gcount = 0;
|
||||||
|
#endif
|
||||||
sentry __cerb(*this, true);
|
sentry __cerb(*this, true);
|
||||||
if (__cerb)
|
if (__cerb)
|
||||||
{
|
{
|
||||||
@ -903,8 +909,8 @@ namespace std
|
|||||||
basic_istream<_CharT, _Traits>::
|
basic_istream<_CharT, _Traits>::
|
||||||
sync(void)
|
sync(void)
|
||||||
{
|
{
|
||||||
|
// DR60. Do not change _M_gcount.
|
||||||
int __ret = -1;
|
int __ret = -1;
|
||||||
_M_gcount = 0;
|
|
||||||
sentry __cerb(*this, true);
|
sentry __cerb(*this, true);
|
||||||
if (__cerb)
|
if (__cerb)
|
||||||
{
|
{
|
||||||
@ -948,7 +954,7 @@ namespace std
|
|||||||
basic_istream<_CharT, _Traits>::
|
basic_istream<_CharT, _Traits>::
|
||||||
seekg(pos_type __pos)
|
seekg(pos_type __pos)
|
||||||
{
|
{
|
||||||
_M_gcount = 0;
|
// DR60. Do not change _M_gcount.
|
||||||
if (!this->fail())
|
if (!this->fail())
|
||||||
{
|
{
|
||||||
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||||
@ -968,7 +974,7 @@ namespace std
|
|||||||
basic_istream<_CharT, _Traits>::
|
basic_istream<_CharT, _Traits>::
|
||||||
seekg(off_type __off, ios_base::seekdir __dir)
|
seekg(off_type __off, ios_base::seekdir __dir)
|
||||||
{
|
{
|
||||||
_M_gcount = 0;
|
// DR60. Do not change _M_gcount.
|
||||||
if (!this->fail())
|
if (!this->fail())
|
||||||
{
|
{
|
||||||
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||||
|
@ -476,10 +476,6 @@ namespace std
|
|||||||
*
|
*
|
||||||
* @note Since no characters are extracted, the next call to
|
* @note Since no characters are extracted, the next call to
|
||||||
* @c gcount() will return 0, as required by DR 60.
|
* @c gcount() will return 0, as required by DR 60.
|
||||||
*
|
|
||||||
* @if maint
|
|
||||||
* FIXME We don't comply with DR 60 here, _M_gcount is untouched.
|
|
||||||
* @endif
|
|
||||||
*/
|
*/
|
||||||
__istream_type&
|
__istream_type&
|
||||||
putback(char_type __c);
|
putback(char_type __c);
|
||||||
@ -513,9 +509,6 @@ namespace std
|
|||||||
* @note This function does not count the number of characters
|
* @note This function does not count the number of characters
|
||||||
* extracted, if any, and therefore does not affect the next
|
* extracted, if any, and therefore does not affect the next
|
||||||
* call to @c gcount().
|
* call to @c gcount().
|
||||||
* @if maint
|
|
||||||
* FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
|
|
||||||
* @endif
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sync();
|
sync();
|
||||||
@ -545,9 +538,6 @@ namespace std
|
|||||||
* @note This function does not count the number of characters
|
* @note This function does not count the number of characters
|
||||||
* extracted, if any, and therefore does not affect the next
|
* extracted, if any, and therefore does not affect the next
|
||||||
* call to @c gcount().
|
* call to @c gcount().
|
||||||
* @if maint
|
|
||||||
* FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
|
|
||||||
* @endif
|
|
||||||
*/
|
*/
|
||||||
__istream_type&
|
__istream_type&
|
||||||
seekg(pos_type);
|
seekg(pos_type);
|
||||||
@ -564,9 +554,6 @@ namespace std
|
|||||||
* @note This function does not count the number of characters
|
* @note This function does not count the number of characters
|
||||||
* extracted, if any, and therefore does not affect the next
|
* extracted, if any, and therefore does not affect the next
|
||||||
* call to @c gcount().
|
* call to @c gcount().
|
||||||
* @if maint
|
|
||||||
* FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
|
|
||||||
* @endif
|
|
||||||
*/
|
*/
|
||||||
__istream_type&
|
__istream_type&
|
||||||
seekg(off_type, ios_base::seekdir);
|
seekg(off_type, ios_base::seekdir);
|
||||||
|
@ -39,8 +39,9 @@ test01()
|
|||||||
|
|
||||||
std::stringbuf isbuf_03(str_02, std::ios_base::in);
|
std::stringbuf isbuf_03(str_02, std::ios_base::in);
|
||||||
std::stringbuf isbuf_04(str_02, std::ios_base::in);
|
std::stringbuf isbuf_04(str_02, std::ios_base::in);
|
||||||
|
std::stringbuf isbuf_05(str_02, std::ios_base::in);
|
||||||
|
|
||||||
std::istream is_00(NULL);
|
std::istream is_00(&isbuf_05);
|
||||||
std::istream is_03(&isbuf_03);
|
std::istream is_03(&isbuf_03);
|
||||||
std::istream is_04(&isbuf_04);
|
std::istream is_04(&isbuf_04);
|
||||||
std::ios_base::iostate state1, state2, statefail, stateeof;
|
std::ios_base::iostate state1, state2, statefail, stateeof;
|
||||||
@ -54,7 +55,7 @@ test01()
|
|||||||
is_04.clear();
|
is_04.clear();
|
||||||
state1 = is_04.rdstate();
|
state1 = is_04.rdstate();
|
||||||
is_04.putback('|');
|
is_04.putback('|');
|
||||||
VERIFY( is_04.gcount() == 0 );
|
VERIFY( is_04.gcount() == 0 ); // DR 60
|
||||||
state2 = is_04.rdstate();
|
state2 = is_04.rdstate();
|
||||||
VERIFY( state1 == state2 );
|
VERIFY( state1 == state2 );
|
||||||
VERIFY( is_04.peek() == '|' );
|
VERIFY( is_04.peek() == '|' );
|
||||||
@ -63,13 +64,17 @@ test01()
|
|||||||
is_04.clear();
|
is_04.clear();
|
||||||
state1 = is_04.rdstate();
|
state1 = is_04.rdstate();
|
||||||
is_04.unget();
|
is_04.unget();
|
||||||
VERIFY( is_04.gcount() == 0 );
|
VERIFY( is_04.gcount() == 0 ); // DR 60
|
||||||
state2 = is_04.rdstate();
|
state2 = is_04.rdstate();
|
||||||
VERIFY( state1 == state2 );
|
VERIFY( state1 == state2 );
|
||||||
VERIFY( is_04.peek() == 'r' );
|
VERIFY( is_04.peek() == 'r' );
|
||||||
|
|
||||||
// int sync()
|
// int sync()
|
||||||
|
is_00.ignore(10);
|
||||||
|
int count1 = is_00.gcount();
|
||||||
int i = is_00.sync();
|
int i = is_00.sync();
|
||||||
|
int count2 = is_00.gcount();
|
||||||
|
VERIFY (count1 == count2 ); // DR 60
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
48
libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc
Normal file
48
libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 2003-04-22 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2003 Free Software Foundation
|
||||||
|
//
|
||||||
|
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 27.6.1.3 unformatted input functions
|
||||||
|
// DR 60 -- seekg does not effect calls to gcount
|
||||||
|
|
||||||
|
#include <istream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
istringstream ist("the lamb lies down on broadway");
|
||||||
|
ios::pos_type pos = ist.tellg();
|
||||||
|
ist.ignore(4);
|
||||||
|
int count1 = ist.gcount();
|
||||||
|
ist.seekg(pos);
|
||||||
|
int count2 = ist.gcount();
|
||||||
|
ist.seekg(pos, ios::beg);
|
||||||
|
count2 = ist.gcount();
|
||||||
|
VERIFY( count1 == count2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
45
libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc
Normal file
45
libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// 2003-04-22 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2003 Free Software Foundation
|
||||||
|
//
|
||||||
|
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 27.6.1.3 unformatted input functions
|
||||||
|
// DR 60 -- tellg does not effect calls to gcount
|
||||||
|
|
||||||
|
#include <istream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
istringstream ist("three sides live");
|
||||||
|
ist.ignore(4);
|
||||||
|
int count1 = ist.gcount();
|
||||||
|
ist.tellg();
|
||||||
|
int count2 = ist.gcount();
|
||||||
|
VERIFY( count1 == count2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user