+2003-12-05 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/13189
+ * include/ext/enc_filebuf.h: Fix.
+ * include/bits/fstream.tcc: Tweak formatting.
+ * include/bits/postypes.h: Same.
+ * include/bits/sstream.tcc: Same.
+ * include/bits/streambuf.tcc: Same.
+ * testsuite/ext/stdio_filebuf.cc: Split.
+ * testsuite/ext/stdio_filebuf_2.cc: Split.
+ * testsuite/ext/stdio_sync_filebuf_char.cc: Split.
+ * testsuite/ext/stdio_sync_filebuf_wchar_t.cc: Split.
+ * testsuite/ext/enc_filebuf/char/13189.cc: New.
+ * testsuite/ext/enc_filebuf/wchar_t/13189.cc: New.
+ * testsuite/ext/stdio_filebuf/char/1.cc: New.
+ * testsuite/ext/stdio_filebuf/char/2.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/char/1.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: New.
+ * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: New.
+
2003-12-05 Carlo Wood <carlo@alinoe.com>
PR libstdc++/13045
{
streamsize __ret = -1;
const bool __testin = this->_M_mode & ios_base::in;
-
if (__testin && this->is_open())
{
// For a stateful encoding (-1) the pending sequence might be just
if (__check_facet(_M_codecvt).encoding() >= 0)
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
-
return __ret;
}
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
-
if (__testin && !_M_writing)
{
// Check for pback madness, and if so swich back to the
{
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
-
if (__testin && !_M_writing)
{
// Remember whether the pback buffer is active, otherwise below
// we may try to store in it a second char (libstdc++/9761).
const bool __testpb = this->_M_pback_init;
const bool __testeof = traits_type::eq_int_type(__i, __ret);
-
int_type __tmp;
if (this->eback() < this->gptr())
{
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = this->_M_mode & ios_base::out;
-
if (__testout && !_M_reading)
{
if (this->pbase() < this->pptr())
}
// Convert pending sequence to external representation,
- // output.
+ // and output.
if (_M_convert_to_external(this->pbase(),
this->pptr() - this->pbase())
&& (!__testeof || (__testeof && !_M_file.sync())))
// Sizes of external and pending output.
streamsize __elen = 0;
streamsize __plen = 0;
-
if (__check_facet(_M_codecvt).always_noconv())
{
__elen += _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
basic_filebuf<_CharT, _Traits>::
xsputn(const _CharT* __s, streamsize __n)
{
- streamsize __ret = 0;
-
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n is sufficiently large we write directly instead of
// using the buffer.
+ streamsize __ret = 0;
const bool __testout = this->_M_mode & ios_base::out;
if (__testout && !_M_reading
&& __check_facet(_M_codecvt).always_noconv())
__ret = __streambuf_type::xsputn(__s, __n);
}
else
- __ret = __streambuf_type::xsputn(__s, __n);
-
+ __ret = __streambuf_type::xsputn(__s, __n);
return __ret;
}
basic_filebuf<_CharT, _Traits>::
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
{
- pos_type __ret = pos_type(off_type(-1));
-
int __width = 0;
if (_M_codecvt)
__width = _M_codecvt->encoding();
if (__width < 0)
__width = 0;
+ pos_type __ret = pos_type(off_type(-1));
const bool __testfail = __off != 0 && __width <= 0;
if (this->is_open() && !__testfail)
{
seekpos(pos_type __pos, ios_base::openmode)
{
pos_type __ret = pos_type(off_type(-1));
-
if (this->is_open())
{
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
-
__ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
}
return __ret;
if (_M_terminate_output())
{
// Returns pos_type(off_type(-1)) in case of failure.
- __ret = pos_type(_M_file.seekoff(__off, __way));
-
+ __ret = pos_type(_M_file.seekoff(__off, __way));
_M_reading = false;
_M_writing = false;
_M_ext_next = _M_ext_end = _M_ext_buf;
basic_filebuf<_CharT, _Traits>::
_M_terminate_output()
{
- bool __testvalid = true;
-
// Part one: update the output sequence.
+ bool __testvalid = true;
if (this->pbase() < this->pptr())
{
const int_type __tmp = this->overflow();
// get the length of the unshift sequence from codecvt,
// without calling unshift.
const size_t __blen = 128;
-
char __buf[__blen];
codecvt_base::result __r;
streamsize __ilen = 0;
else if (__r == codecvt_base::ok ||
__r == codecvt_base::partial)
{
- __ilen = __next - __buf;
-
+ __ilen = __next - __buf;
if (__ilen > 0)
{
const streamsize __elen = _M_file.xsputn(__buf, __ilen);
basic_filebuf<_CharT, _Traits>::
sync()
{
- int __ret = 0;
-
// Make sure that the internal buffer resyncs its idea of
// the file position with the external file.
// NB: _M_file.sync() will be called within.
+ int __ret = 0;
if (this->pbase() < this->pptr())
{
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
- }
-
+ }
return __ret;
}
imbue(const locale& __loc)
{
bool __testfail = false;
-
if (this->is_open())
{
const pos_type __ret = this->seekoff(0, ios_base::cur,
private:
friend class streamoff;
- __streamoff_base_type _M_off;
- _StateT _M_state;
+ __streamoff_base_type _M_off;
+ _StateT _M_state;
public:
// The standard doesn't require that fpos objects can be default
if (__builtin_expect(!__testout, false))
return traits_type::eof();
- const bool __testeof = traits_type::eq_int_type(__c,
- traits_type::eof());
+ const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c);
__tmp.assign(_M_string.data(), this->epptr() - this->pbase());
_M_string.swap(__tmp);
_M_sync(const_cast<char_type*>(_M_string.data()),
- this->gptr() - this->eback(),
- this->pptr() - this->pbase());
+ this->gptr() - this->eback(), this->pptr() - this->pbase());
}
return this->sputc(traits_type::to_char_type(__c));
}
{
// Update egptr() to match the actual string end.
_M_update_egptr();
-
if (this->gptr() < this->egptr())
__ret = traits_type::to_int_type(*this->gptr());
}
basic_stringbuf<_CharT, _Traits, _Alloc>::
seekpos(pos_type __sp, ios_base::openmode __mode)
{
- pos_type __ret = pos_type(off_type(-1));
-
+ pos_type __ret = pos_type(off_type(-1));
if (_M_string.capacity())
{
off_type __pos (__sp);
extern template class basic_streambuf<char>;
extern template
streamsize
- __copy_streambufs(basic_streambuf<char>*,
- basic_streambuf<char>*);
+ __copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*);
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_streambuf<wchar_t>;
extern template
streamsize
- __copy_streambufs(basic_streambuf<wchar_t>*,
- basic_streambuf<wchar_t>*);
+ __copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*);
#endif
#endif
} // namespace std
-// __enc_traits layer for filebuf -*- C++ -*-
+// filebuf with __enc_traits state type -*- C++ -*-
-// Copyright (C) 2002 Free Software Foundation, Inc.
+// Copyright (C) 2002, 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
namespace __gnu_cxx
{
- // Custom traits type with __enc_traits for state type, all other bits
- // equivalent to the required char_traits instantiations.
+ // Custom traits type with __enc_traits for the state type, and the
+ // associated fpos<__enc_traits> for the position type, all other
+ // bits equivalent to the required char_traits instantiations.
template<typename _CharT>
struct enc_char_traits: public std::char_traits<_CharT>
{
- typedef std::__enc_traits state_type;
+ typedef std::__enc_traits state_type;
+ typedef typename std::fpos<state_type> pos_type;
};
template<typename _CharT>
: public std::basic_filebuf<_CharT, enc_char_traits<_CharT> >
{
public:
- typedef typename enc_char_traits<_CharT>::state_type state_type;
+ typedef enc_char_traits<_CharT> traits_type;
+ typedef typename traits_type::state_type state_type;
+ typedef typename traits_type::pos_type pos_type;
enc_filebuf(state_type& __state)
: std::basic_filebuf<_CharT, enc_char_traits<_CharT> >()
{
// Set state type to something useful.
// Something more than copyconstructible is needed here, so
- // require copyconstructible + assignment operator.
+ // require default and copy constructible + assignment operator.
__glibcxx_class_requires(state_type, _SGIAssignableConcept);
- _M_state_cur = __state;
- _M_state_cur._M_init();
+ this->_M_state_beg = __state;
+ this->_M_state_beg._M_init();
};
};
} // namespace __gnu_cxx
--- /dev/null
+// 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.
+
+#include <ext/enc_filebuf.h>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ using namespace std;
+
+ typedef __enc_traits state_type;
+ typedef char char_type;
+ typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+ typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+ bool test __attribute__((unused)) = true;
+ ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+ try
+ {
+ state_type st;
+ filebuf_type fbuf(st);
+ locale loc(locale::classic(), new enc_codecvt);
+ fbuf.pubimbue(loc);
+ fbuf.open("tmp_13189c", mode);
+ fbuf.sputc('a');
+ fbuf.pubseekoff(0, ios_base::beg);
+ fbuf.sgetc();
+ fbuf.close();
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ return 0;
+}
--- /dev/null
+// 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.
+
+#include <ext/enc_filebuf.h>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ using namespace std;
+
+ typedef __enc_traits state_type;
+ typedef wchar_t char_type;
+ typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+ typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+ bool test __attribute__((unused)) = true;
+ ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+ try
+ {
+ state_type st;
+ filebuf_type fbuf(st);
+ locale loc(locale::classic(), new enc_codecvt);
+ fbuf.pubimbue(loc);
+ fbuf.open("tmp_13189w", mode);
+ fbuf.sputc(L'a');
+ fbuf.pubseekoff(0, ios_base::beg);
+ fbuf.sgetc();
+ fbuf.close();
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ return 0;
+}
+++ /dev/null
-// 2003-02-11 Paolo Carlini <pcarlini@unitus.it>
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// stdio_filebuf.h
-
-#include <ext/stdio_filebuf.h>
-#include <testsuite_hooks.h>
-
-// { dg-do compile }
-
-// libstdc++/9320
-namespace test
-{
- using namespace std;
- using __gnu_test::pod_char;
- typedef short type_t;
- template class __gnu_cxx::stdio_filebuf<type_t, char_traits<type_t> >;
- template class __gnu_cxx::stdio_filebuf<pod_char, char_traits<pod_char> >;
-} // test
--- /dev/null
+// 2003-02-11 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// stdio_filebuf.h
+
+#include <ext/stdio_filebuf.h>
+#include <testsuite_hooks.h>
+
+// { dg-do compile }
+
+// libstdc++/9320
+namespace test
+{
+ using namespace std;
+ using __gnu_test::pod_char;
+ typedef short type_t;
+ template class __gnu_cxx::stdio_filebuf<type_t, char_traits<type_t> >;
+ template class __gnu_cxx::stdio_filebuf<pod_char, char_traits<pod_char> >;
+} // test
--- /dev/null
+// 2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
+
+// Copyright (C) 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// stdio_filebuf.h
+
+#include <ext/stdio_filebuf.h>
+#include <cstdio>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// Small stack-based buffers (i.e., using _M_unbuf) were not flushed
+// out by _M_really_overflow upon overflow.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char* name = "tmp_file1";
+ FILE* file = fopen(name, "w");
+ {
+ using namespace __gnu_cxx;
+ stdio_filebuf<char> sbuf(file, ios_base::out, 2);
+ sbuf.sputc('T');
+ sbuf.sputc('S');
+ sbuf.sputc('P');
+ }
+ fclose(file);
+
+ filebuf fbuf;
+ fbuf.open(name, ios_base::in);
+ char buf[10];
+ streamsize n = fbuf.sgetn(buf, sizeof(buf));
+ fbuf.close();
+
+ VERIFY( n == 3 );
+ VERIFY( !memcmp(buf, "TSP", 3) );
+}
+
+int main()
+{
+ test01();
+}
+++ /dev/null
-// 2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
-
-// Copyright (C) 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// stdio_filebuf.h
-
-#include <ext/stdio_filebuf.h>
-#include <cstdio>
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// Small stack-based buffers (i.e., using _M_unbuf) were not flushed
-// out by _M_really_overflow upon overflow.
-void test01()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
-
- const char* name = "tmp_file1";
- FILE* file = fopen(name, "w");
- {
- using namespace __gnu_cxx;
- stdio_filebuf<char> sbuf(file, ios_base::out, 2);
- sbuf.sputc('T');
- sbuf.sputc('S');
- sbuf.sputc('P');
- }
- fclose(file);
-
- filebuf fbuf;
- fbuf.open(name, ios_base::in);
- char buf[10];
- streamsize n = fbuf.sgetn(buf, sizeof(buf));
- fbuf.close();
-
- VERIFY( n == 3 );
- VERIFY( !memcmp(buf, "TSP", 3) );
-}
-
-int main()
-{
- test01();
-}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ const char* c_lit = "black pearl jasmine tea";
+ int size = strlen(c_lit);
+ const char* name = "stdiobuf-1.txt";
+
+ FILE* fout = fopen(name, "w");
+ fwrite(c_lit, 1, size, fout);
+ fclose(fout);
+
+ FILE* fin = fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(fin);
+
+ VERIFY( sbuf.sgetc() == c_lit[0] );
+ VERIFY( getc(fin) == c_lit[0] );
+ VERIFY( sbuf.sgetc() == c_lit[1] );
+ VERIFY( sbuf.sbumpc() == c_lit[1] );
+ VERIFY( ungetc('Z', fin) == 'Z' );
+ VERIFY( sbuf.sbumpc() == 'Z' );
+ VERIFY( getc(fin) == c_lit[2] );
+ VERIFY( sbuf.sputbackc('X') == 'X' );
+ VERIFY( getc(fin) == 'X' );
+
+ char buf[5];
+ memset(buf, 'x', 5);
+ VERIFY( sbuf.sgetn(buf, 5) == 5 );
+ VERIFY( !memcmp(buf, c_lit + 3, 5) );
+ VERIFY( getc(fin) == c_lit[8] );
+
+ fclose(fin);
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef char_traits<wchar_t> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const char* c_lit = "black pearl jasmine tea";
+ const wchar_t* w_lit = L"black pearl jasmine tea";
+ int size = strlen(c_lit);
+ const char* name = "stdiobuf-1.txt";
+
+ FILE* fout = fopen(name, "w");
+ fwrite(c_lit, 1, size, fout);
+ fclose(fout);
+
+ FILE* fin = fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> wsbuf(fin);
+
+ VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[0] );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[0] );
+ VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[1] );
+ VERIFY( traits_type::to_char_type(wsbuf.sbumpc()) == w_lit[1] );
+ VERIFY( ungetwc(L'Z', fin) == L'Z' );
+ VERIFY( wsbuf.sbumpc() == L'Z' );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[2] );
+ VERIFY( wsbuf.sputbackc(L'X') == L'X' );
+ VERIFY( getwc(fin) == L'X' );
+
+ wchar_t buf[5];
+ wmemset(buf, 0xdeadbeef, 5);
+ VERIFY( wsbuf.sgetn(buf, 5) == 5 );
+ VERIFY( !wmemcmp(buf, w_lit + 3, 5) );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[8] );
+
+ fclose(fin);
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// 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.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test05();
+ return 0;
+}
+++ /dev/null
-// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
-
-// 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.
-
-#include <ext/stdio_sync_filebuf.h>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- using namespace std;
-
- bool test __attribute__((unused)) = true;
- const char* c_lit = "black pearl jasmine tea";
- int size = strlen(c_lit);
- const char* name = "stdiobuf-1.txt";
-
- FILE* fout = fopen(name, "w");
- fwrite(c_lit, 1, size, fout);
- fclose(fout);
-
- FILE* fin = fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<char> sbuf(fin);
-
- VERIFY( sbuf.sgetc() == c_lit[0] );
- VERIFY( getc(fin) == c_lit[0] );
- VERIFY( sbuf.sgetc() == c_lit[1] );
- VERIFY( sbuf.sbumpc() == c_lit[1] );
- VERIFY( ungetc('Z', fin) == 'Z' );
- VERIFY( sbuf.sbumpc() == 'Z' );
- VERIFY( getc(fin) == c_lit[2] );
- VERIFY( sbuf.sputbackc('X') == 'X' );
- VERIFY( getc(fin) == 'X' );
-
- char buf[5];
- memset(buf, 'x', 5);
- VERIFY( sbuf.sgetn(buf, 5) == 5 );
- VERIFY( !memcmp(buf, c_lit + 3, 5) );
- VERIFY( getc(fin) == c_lit[8] );
-
- fclose(fin);
-}
-
-// libstdc++/12048
-void test02()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
- int c1 = sbuf.sbumpc();
- VERIFY( c1 != EOF );
- int c2 = sbuf.sungetc();
- VERIFY( c2 != EOF );
- int c3 = sbuf.sbumpc();
- VERIFY( c3 == c1 );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test03()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
- int c1 = sbuf.sbumpc();
- VERIFY( c1 != EOF );
- int c2 = sbuf.sungetc();
- VERIFY( c2 != EOF );
- int c3 = std::fgetc(file);
- VERIFY( c3 == c1 );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test04()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
- char buf[2];
- VERIFY( sbuf.sgetn(buf, 2) == 2 );
- int c2 = sbuf.sungetc();
- VERIFY( c2 != EOF );
- int c3 = sbuf.sbumpc();
- VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test05()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
- char buf[2];
- VERIFY( sbuf.sgetn(buf, 2) == 2 );
- int c2 = sbuf.sungetc();
- VERIFY( c2 != EOF );
- int c3 = std::fgetc(file);
- VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
-
- std::fclose(file);
-}
-
-int main ()
-{
- test01();
- test02();
- test03();
- test04();
- test05();
-
- return 0;
-}
+++ /dev/null
-// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
-
-// 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.
-
-#include <ext/stdio_sync_filebuf.h>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- using namespace std;
- typedef char_traits<wchar_t> traits_type;
-
- bool test __attribute__((unused)) = true;
- const char* c_lit = "black pearl jasmine tea";
- const wchar_t* w_lit = L"black pearl jasmine tea";
- int size = strlen(c_lit);
- const char* name = "stdiobuf-1.txt";
-
- FILE* fout = fopen(name, "w");
- fwrite(c_lit, 1, size, fout);
- fclose(fout);
-
- FILE* fin = fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<wchar_t> wsbuf(fin);
-
- VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[0] );
- VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[0] );
- VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[1] );
- VERIFY( traits_type::to_char_type(wsbuf.sbumpc()) == w_lit[1] );
- VERIFY( ungetwc(L'Z', fin) == L'Z' );
- VERIFY( wsbuf.sbumpc() == L'Z' );
- VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[2] );
- VERIFY( wsbuf.sputbackc(L'X') == L'X' );
- VERIFY( getwc(fin) == L'X' );
-
- wchar_t buf[5];
- wmemset(buf, 0xdeadbeef, 5);
- VERIFY( wsbuf.sgetn(buf, 5) == 5 );
- VERIFY( !wmemcmp(buf, w_lit + 3, 5) );
- VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[8] );
-
- fclose(fin);
-}
-
-// libstdc++/12048
-void test02()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
- std::wint_t c1 = sbuf.sbumpc();
- VERIFY( c1 != WEOF );
- std::wint_t c2 = sbuf.sungetc();
- VERIFY( c2 != WEOF );
- std::wint_t c3 = sbuf.sbumpc();
- VERIFY( c3 == c1 );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test03()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
- std::wint_t c1 = sbuf.sbumpc();
- VERIFY( c1 != WEOF );
- std::wint_t c2 = sbuf.sungetc();
- VERIFY( c2 != WEOF );
- std::wint_t c3 = std::fgetwc(file);
- VERIFY( c3 == c1 );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test04()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
- wchar_t buf[2];
- VERIFY( sbuf.sgetn(buf, 2) == 2 );
- std::wint_t c2 = sbuf.sungetc();
- VERIFY( c2 != WEOF );
- std::wint_t c3 = sbuf.sbumpc();
- VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
-
- std::fclose(file);
-}
-
-// libstdc++/12048
-void test05()
-{
- bool test __attribute__((unused)) = true;
- const char* name = "cin_unget-1.txt";
-
- std::FILE* file = std::fopen(name, "r");
- __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
- wchar_t buf[2];
- VERIFY( sbuf.sgetn(buf, 2) == 2 );
- std::wint_t c2 = sbuf.sungetc();
- VERIFY( c2 != WEOF );
- std::wint_t c3 = std::fgetwc(file);
- VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
-
- std::fclose(file);
-}
-
-int main ()
-{
- test01();
- test02();
- test03();
- test04();
- test05();
-
- return 0;
-}