re PR libstdc++/11095 (C++ iostream manipulator causes segfault when called iwth negative argument)
2003-06-05 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/11095 * include/bits/istream.tcc (operator>>(basic_istream&, _CharT*)): Deal with width() smaller than zero. * include/bits/ostream.tcc (operator<<(basic_ostream&, _CharT), operator<<(basic_ostream&, char), operator<<(basic_ostream&, const _CharT*), operator<<(basic_ostream<_CharT, _Traits>&, const char*), operator<<(basic_ostream<char, _Traits>&, const char*), operator<<(basic_ostream, const basic_string&)): Likewise. * testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc: * testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc: * testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc: * testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc: * testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-od.cc: * testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-oe.cc: * testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-of.cc: New. From-SVN: r67518
This commit is contained in:
parent
49c72d225b
commit
1e64c2fc32
|
@ -1,3 +1,22 @@
|
|||
2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/11095
|
||||
* include/bits/istream.tcc (operator>>(basic_istream&, _CharT*)):
|
||||
Deal with width() smaller than zero.
|
||||
* include/bits/ostream.tcc (operator<<(basic_ostream&, _CharT),
|
||||
operator<<(basic_ostream&, char), operator<<(basic_ostream&,
|
||||
const _CharT*), operator<<(basic_ostream<_CharT, _Traits>&,
|
||||
const char*), operator<<(basic_ostream<char, _Traits>&,
|
||||
const char*), operator<<(basic_ostream, const basic_string&)): Likewise.
|
||||
* testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-od.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-oe.cc:
|
||||
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/11095-of.cc:
|
||||
New.
|
||||
|
||||
2003-06-05 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||
|
||||
* acinclude.m4 (GLIBCPP_CHECK_PCH): Only set glibcpp_PCHFLAGS if
|
||||
|
|
|
@ -1021,7 +1021,7 @@ namespace std
|
|||
{
|
||||
// Figure out how many characters to extract.
|
||||
streamsize __num = __in.width();
|
||||
if (__num == 0)
|
||||
if (__num <= 0)
|
||||
__num = numeric_limits<streamsize>::max();
|
||||
|
||||
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
|
||||
|
|
|
@ -474,7 +474,7 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__w + 1)));
|
||||
__pads[0] = __c;
|
||||
streamsize __len = 1;
|
||||
|
@ -510,7 +510,7 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
char* __pads = static_cast<char*>(__builtin_alloca(__w + 1));
|
||||
__pads[0] = __c;
|
||||
streamsize __len = 1;
|
||||
|
@ -545,7 +545,7 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
|
||||
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
|
||||
if (__w > __len)
|
||||
|
@ -594,7 +594,7 @@ namespace std
|
|||
try
|
||||
{
|
||||
streamsize __len = static_cast<streamsize>(__clen);
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
|
||||
|
||||
if (__w > __len)
|
||||
|
@ -632,7 +632,7 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
char* __pads = static_cast<char*>(__builtin_alloca(__w));
|
||||
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
|
||||
|
||||
|
@ -671,7 +671,7 @@ namespace std
|
|||
if (__cerb)
|
||||
{
|
||||
const _CharT* __s = __str.data();
|
||||
streamsize __w = __out.width();
|
||||
const streamsize __w = __out.width() > 0 ? __out.width() : 0;
|
||||
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
|
||||
streamsize __len = static_cast<streamsize>(__str.size());
|
||||
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.3 character extractors
|
||||
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator>>(basic_istream&, _CharT*)
|
||||
void test01()
|
||||
{
|
||||
bool test = true;
|
||||
const std::string str_01("Consoli ");
|
||||
|
||||
std::stringbuf isbuf_01(str_01, std::ios_base::in);
|
||||
std::istream is_01(&isbuf_01);
|
||||
|
||||
std::ios_base::iostate state1, state2;
|
||||
|
||||
char array1[10];
|
||||
typedef std::ios::traits_type ctraits_type;
|
||||
|
||||
is_01.width(-60);
|
||||
state1 = is_01.rdstate();
|
||||
is_01 >> array1;
|
||||
state2 = is_01.rdstate();
|
||||
VERIFY( state1 == state2 );
|
||||
VERIFY( !ctraits_type::compare(array1, "Consoli", 7) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream&, char)
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::ostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << 'C';
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == "C" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream<char, _Traits>&, const char*)
|
||||
void
|
||||
test02()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::ostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << "Consoli";
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == "Consoli" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test02();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream&, const basic_string&)
|
||||
void
|
||||
test03()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::ostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << std::string("Consoli");
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == "Consoli" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test03();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream&, _CharT)
|
||||
void
|
||||
test01()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::wostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << L'C';
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == L"C" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream&, const _CharT*)
|
||||
void
|
||||
test02()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::wostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << L"Consoli";
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == L"Consoli" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test02();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
// 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.2.5.4 basic_ostream character inserters
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11095
|
||||
// operator<<(basic_ostream<_CharT, _Traits>&, const char*)
|
||||
void
|
||||
test03()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
std::wostringstream oss_01;
|
||||
|
||||
oss_01.width(-60);
|
||||
oss_01 << "Consoli";
|
||||
VERIFY( oss_01.good() );
|
||||
VERIFY( oss_01.str() == L"Consoli" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test03();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue