diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-17 20:40:33 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-17 20:40:33 +0000 |
commit | be7004e483155fec9dc1404ce22b9bf05c193127 (patch) | |
tree | 324b7c12f3d62c06a7c4873e563b9c5491af99e4 | |
parent | bca5a28b4734025b47828589f2a0704cc7e1d9e9 (diff) |
next citrus step.
reviewed by millert, otto, kevlo, naddy, kettenis...
libc+libstdc++ bump
105 files changed, 1916 insertions, 473 deletions
diff --git a/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.cc b/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.cc index 60eb006a847..995dbeeabf2 100644 --- a/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.cc +++ b/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.cc @@ -42,7 +42,7 @@ namespace std _lock = __lock; #endif // Don't set the orientation of the stream when initializing. -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _IO_no_init(this, 0, 0, &_M_wfile, 0); #else /* !defined(_GLIBCPP_USE_WCHAR_T) */ _IO_no_init(this, 0, 0, NULL, 0); @@ -99,7 +99,7 @@ namespace std { return _IO_file_doallocate(this); } // __basic_file<wchar_t> definitions -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) __basic_file<wchar_t>::__basic_file(__c_lock* __lock) { #ifdef _IO_MTSAFE_IO @@ -180,7 +180,7 @@ namespace std // Need to instantiate base class here for type-info bits, etc template struct __basic_file_base<char>; template class __basic_file<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template struct __basic_file_base<wchar_t>; template class __basic_file<wchar_t>; #endif diff --git a/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.h b/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.h index 57d83c49d00..48e18216ba5 100644 --- a/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.h +++ b/gnu/lib/libstdc++/libstdc++/config/io/basic_file_libio.h @@ -122,7 +122,7 @@ namespace std template<typename _CharT> class __basic_file: public __basic_file_base<_CharT> { -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) __c_wfile_type _M_wfile; # endif @@ -292,7 +292,7 @@ namespace std __basic_file<char>::doallocate(); // __basic_file<wchar_t> specializations -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> __basic_file<wchar_t>::__basic_file(__c_lock* __lock); diff --git a/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio.h b/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio.h index acf65207f18..3a3a881eb19 100644 --- a/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio.h +++ b/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio.h @@ -57,8 +57,7 @@ namespace std // from basic_file.h typedef _IO_FILE __c_file_type; typedef _IO_wide_data __c_wfile_type; - -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern "C" _IO_codecvt __c_libio_codecvt; #endif diff --git a/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio_codecvt.c b/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio_codecvt.c index 38d8b55e0c2..b11a1fa6730 100644 --- a/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio_codecvt.c +++ b/gnu/lib/libstdc++/libstdc++/config/io/c_io_libio_codecvt.c @@ -23,11 +23,19 @@ other reasons why the executable file might be covered by the GNU General Public License. */ +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. /* Slightly modified from glibc/libio/iofwide.c */ #include <libio.h> -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) /* Prototypes of libio's codecvt functions. */ static enum __codecvt_result diff --git a/gnu/lib/libstdc++/libstdc++/config/io/c_io_stdio.h b/gnu/lib/libstdc++/libstdc++/config/io/c_io_stdio.h index a46e243cf9f..c7dad5b3a73 100644 --- a/gnu/lib/libstdc++/libstdc++/config/io/c_io_stdio.h +++ b/gnu/lib/libstdc++/libstdc++/config/io/c_io_stdio.h @@ -41,7 +41,7 @@ namespace std // for fpos.h typedef long streamoff; typedef ptrdiff_t streamsize; // Signed integral type -#if defined(_GLIBCPP_USE_WCHAR_T) +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef ptrdiff_t wstreamsize; #endif typedef fpos_t __c_streampos; diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/codecvt_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/codecvt_members.cc index ff65dffa1e9..c7b3b10f171 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/codecvt_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/codecvt_members.cc @@ -38,7 +38,7 @@ namespace std { // Specializations. -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) codecvt_base::result codecvt<wchar_t, char, mbstate_t>:: do_out(state_type& __state, const intern_type* __from, diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/collate_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/collate_members.cc index 93767d93e3b..349c7935fef 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/collate_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/collate_members.cc @@ -53,7 +53,7 @@ namespace std size_t __n) const { return strxfrm(__to, __from, __n); } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> int collate<wchar_t>::_M_compare(const wchar_t* __one, diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/ctype_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/ctype_members.cc index 71e810abef7..7a550ced53a 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/ctype_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/ctype_members.cc @@ -47,7 +47,7 @@ namespace std _S_create_c_locale(_M_c_locale_ctype, __s); } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) ctype<wchar_t>::__wmask_type ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const { diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/messages_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/messages_members.cc index f38f82beed2..d810dadb6fa 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/messages_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/messages_members.cc @@ -43,7 +43,7 @@ namespace std messages<char>::do_get(catalog, int, int, const string& __dfault) const { return __dfault; } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> wstring messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/monetary_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/monetary_members.cc index 1921f46e98c..1becc6d8edc 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/monetary_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/monetary_members.cc @@ -83,7 +83,7 @@ namespace std moneypunct<char, false>::~moneypunct() { } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> void moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/numeric_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/numeric_members.cc index f942e0415b0..fd324934de4 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/numeric_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/numeric_members.cc @@ -53,7 +53,7 @@ namespace std numpunct<char>::~numpunct() { } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> void numpunct<wchar_t>::_M_initialize_numpunct(__c_locale) diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/time_members.cc b/gnu/lib/libstdc++/libstdc++/config/locale/generic/time_members.cc index df43f03a53d..acdccd209f6 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/time_members.cc +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/time_members.cc @@ -113,7 +113,7 @@ namespace std _M_month_a12 = "Dec"; } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> void __timepunct<wchar_t>:: @@ -122,7 +122,9 @@ namespace std { char* __old = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, _M_name_timepunct); +# if defined(_GLIBCPP_USE_WCHAR_T) wcsftime(__s, __maxlen, __format, __tm); +# endif setlocale(LC_ALL, __old); free(__old); } diff --git a/gnu/lib/libstdc++/libstdc++/include/backward/fstream.h b/gnu/lib/libstdc++/libstdc++/include/backward/fstream.h index 44461f464dd..72a9eb3345e 100644 --- a/gnu/lib/libstdc++/libstdc++/include/backward/fstream.h +++ b/gnu/lib/libstdc++/libstdc++/include/backward/fstream.h @@ -37,7 +37,7 @@ using std::ofstream; using std::fstream; using std::streampos; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) using std::wfilebuf; using std::wifstream; using std::wofstream; diff --git a/gnu/lib/libstdc++/libstdc++/include/backward/iostream.h b/gnu/lib/libstdc++/libstdc++/include/backward/iostream.h index 5346d9d22e8..63b6040553f 100644 --- a/gnu/lib/libstdc++/libstdc++/include/backward/iostream.h +++ b/gnu/lib/libstdc++/libstdc++/include/backward/iostream.h @@ -41,7 +41,7 @@ using std::cout; using std::cin; using std::cerr; using std::clog; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) using std::wcout; using std::wcin; using std::wcerr; diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/basic_ios.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/basic_ios.tcc index 48e2f3fbf25..87e2c70d2ec 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/basic_ios.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/basic_ios.tcc @@ -214,7 +214,7 @@ namespace std #if defined(_GLIBCPP_EXTERN_TEMPLATE) extern template class basic_ios<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_ios<wchar_t>; #endif #endif diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/basic_string.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/basic_string.tcc index d76b55a370b..9aeeed9046e 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/basic_string.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/basic_string.tcc @@ -1072,7 +1072,7 @@ namespace std basic_istream<char>& getline(basic_istream<char>&, string&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_string<wchar_t>; extern template basic_istream<wchar_t>& diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/char_traits.h b/gnu/lib/libstdc++/libstdc++/include/bits/char_traits.h index 1cb982b4856..c42078344d4 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/char_traits.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/char_traits.h @@ -189,9 +189,7 @@ namespace std typedef wchar_t char_type; typedef wint_t int_type; typedef streamoff off_type; -#ifdef _GLIBCPP_USE_WCHAR_T typedef wstreampos pos_type; -#endif typedef mbstate_t state_type; static void diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/codecvt.h b/gnu/lib/libstdc++/libstdc++/include/bits/codecvt.h index 9ab9f94e71d..6ec5b68684a 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/codecvt.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/codecvt.h @@ -259,7 +259,7 @@ do_max_length() const throw(); }; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) // codecvt<wchar_t, char, mbstate_t> required specialization template<> class codecvt<wchar_t, char, mbstate_t> @@ -330,7 +330,7 @@ // Include host and configuration specific partial specializations // with additional functionality, if possible. -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) #include <bits/codecvt_specializations.h> #endif diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/fpos.h b/gnu/lib/libstdc++/libstdc++/include/bits/fpos.h index 5432527421a..c14b998a849 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/fpos.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/fpos.h @@ -118,7 +118,7 @@ namespace std /// 27.2, paragraph 10 about fpos/char_traits circularity typedef fpos<mbstate_t> streampos; -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) /// 27.2, paragraph 10 about fpos/char_traits circularity typedef fpos<mbstate_t> wstreampos; # endif diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/fstream.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/fstream.tcc index c8fa1b4239e..06b176d7316 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/fstream.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/fstream.tcc @@ -518,7 +518,7 @@ namespace std extern template class basic_ofstream<char>; extern template class basic_fstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_filebuf<wchar_t>; extern template class basic_ifstream<wchar_t>; extern template class basic_ofstream<wchar_t>; diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/istream.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/istream.tcc index 07af8b2f3b8..56fefb5b969 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/istream.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/istream.tcc @@ -1149,7 +1149,7 @@ namespace std extern template istream& operator>>(istream&, unsigned char*); extern template istream& operator>>(istream&, signed char*); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_istream<wchar_t>; extern template wistream& ws(wistream&); extern template wistream& operator>>(wistream&, wchar_t&); diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.h b/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.h index 37f6875bc25..8347284c35e 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.h @@ -51,7 +51,7 @@ namespace std { // NB: Don't instantiate required wchar_t facets if no wchar_t support. -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define _GLIBCPP_NUM_FACETS 28 #else # define _GLIBCPP_NUM_FACETS 14 @@ -424,7 +424,7 @@ namespace std const ctype<char>& use_facet<ctype<char> >(const locale& __loc); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) // 22.2.1.3 ctype<wchar_t> specialization template<> class ctype<wchar_t> : public __ctype_abstract_base<wchar_t> @@ -670,7 +670,7 @@ namespace std void numpunct<char>::_M_initialize_numpunct(__c_locale __cloc); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> numpunct<wchar_t>::~numpunct(); @@ -1053,7 +1053,7 @@ namespace std size_t collate<char>::_M_transform(char*, const char*, size_t) const; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> int collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const; @@ -1287,7 +1287,7 @@ namespace std void __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> const wchar_t* __timepunct<wchar_t>::_S_timezones[14]; @@ -1624,7 +1624,7 @@ namespace std void moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> moneypunct<wchar_t, true>::~moneypunct(); @@ -1865,7 +1865,7 @@ namespace std string messages<char>::do_get(catalog, int, int, const string&) const; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> wstring messages<wchar_t>::do_get(catalog, int, int, const wstring&) const; diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.tcc index 8b3bbc3971d..b3013c75cbf 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/locale_facets.tcc @@ -2630,7 +2630,7 @@ namespace std bool has_facet<messages<char> >(const locale&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class moneypunct<wchar_t, false>; extern template class moneypunct<wchar_t, true>; extern template class moneypunct_byname<wchar_t, false>; diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/localefwd.h b/gnu/lib/libstdc++/libstdc++/include/bits/localefwd.h index ac9e1a95425..7c42a0b1263 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/localefwd.h +++ b/gnu/lib/libstdc++/libstdc++/include/bits/localefwd.h @@ -110,7 +110,7 @@ namespace std template<typename _CharT> class ctype; template<> class ctype<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> class ctype<wchar_t>; #endif template<typename _CharT> @@ -122,7 +122,7 @@ namespace std template<typename _InternT, typename _ExternT, typename _StateT> class codecvt; template<> class codecvt<char, char, mbstate_t>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> class codecvt<wchar_t, char, mbstate_t>; #endif template<typename _InternT, typename _ExternT, typename _StateT> diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/ostream.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/ostream.tcc index ab15ae8703b..f4aeb37e574 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/ostream.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/ostream.tcc @@ -40,7 +40,7 @@ namespace std { template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>::sentry:: - sentry(basic_ostream<_CharT,_Traits>& __os) + sentry(basic_ostream<_CharT, _Traits>& __os) : _M_os(__os) { // XXX MT @@ -61,21 +61,10 @@ namespace std basic_ostream<_CharT, _Traits>:: operator<<(__ostream_type& (*__pf)(__ostream_type&)) { - sentry __cerb(*this); - if (__cerb) - { - try - { __pf(*this); } - catch(...) - { - // 27.6.2.5.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } - } - return *this; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + return __pf(*this); } template<typename _CharT, typename _Traits> @@ -83,20 +72,10 @@ namespace std basic_ostream<_CharT, _Traits>:: operator<<(__ios_type& (*__pf)(__ios_type&)) { - sentry __cerb(*this); - if (__cerb) - { - try - { __pf(*this); } - catch(...) - { - // 27.6.2.5.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } - } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + __pf(*this); return *this; } @@ -105,132 +84,91 @@ namespace std basic_ostream<_CharT, _Traits>:: operator<<(ios_base& (*__pf)(ios_base&)) { - sentry __cerb(*this); - if (__cerb) - { - try - { __pf(*this); } - catch(...) - { - // 27.6.2.5.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } - } - return *this; - } - - template<typename _CharT, typename _Traits> - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin) - { - sentry __cerb(*this); - if (__cerb && __sbin) - { - try - { - if (!__copy_streambufs(*this, __sbin, this->rdbuf())) - this->setstate(ios_base::failbit); - } - catch(...) - { - // 27.6.2.5.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } - } - else if (!__sbin) - this->setstate(ios_base::badbit); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + __pf(*this); return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(bool __n) + basic_ostream<_CharT, _Traits>:: + operator<<(bool __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(long __n) + basic_ostream<_CharT, _Traits>:: + operator<<(long __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { + bool __b = false; char_type __c = this->fill(); ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; - if (_M_check_facet(_M_fnumput)) + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) { - bool __b = false; - if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) - { - unsigned long __l = static_cast<unsigned long>(__n); - __b = _M_fnumput->put(*this, *this, __c, __l).failed(); - } - else - __b = _M_fnumput->put(*this, *this, __c, __n).failed(); - if (__b) - this->setstate(ios_base::badbit); + unsigned long __l = static_cast<unsigned long>(__n); + __b = __np.put(*this, *this, __c, __l).failed(); } + else + __b = __np.put(*this, *this, __c, __n).failed(); + if (__b) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) + basic_ostream<_CharT, _Traits>:: + operator<<(unsigned long __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } @@ -238,63 +176,59 @@ namespace std #ifdef _GLIBCPP_USE_LONG_LONG template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(long long __n) + basic_ostream<_CharT, _Traits>:: + operator<<(long long __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { + bool __b = false; char_type __c = this->fill(); ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; - if (_M_check_facet(_M_fnumput)) + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) { - bool __b = false; - if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) - { - unsigned long long __l; - __l = static_cast<unsigned long long>(__n); - __b = _M_fnumput->put(*this, *this, __c, __l).failed(); - } - else - __b = _M_fnumput->put(*this, *this, __c, __n).failed(); - if (__b) - this->setstate(ios_base::badbit); + unsigned long long __l; + __l = static_cast<unsigned long long>(__n); + __b = __np.put(*this, *this, __c, __l).failed(); } + else + __b = __np.put(*this, *this, __c, __n).failed(); + if (__b) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) + basic_ostream<_CharT, _Traits>:: + operator<<(unsigned long long __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } @@ -302,76 +236,97 @@ namespace std template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(double __n) + basic_ostream<_CharT, _Traits>:: + operator<<(double __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(long double __n) + basic_ostream<_CharT, _Traits>:: + operator<<(long double __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>::operator<<(const void* __n) + basic_ostream<_CharT, _Traits>:: + operator<<(const void* __n) { sentry __cerb(*this); if (__cerb) { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) - this->setstate(ios_base::badbit); + _M_check_facet(this->_M_fnumput); + const __numput_type& __np = *this->_M_fnumput; + if (__np.put(*this, *this, this->fill(), __n).failed()) + __err |= ios_base::badbit; } catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template<typename _CharT, typename _Traits> + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(__streambuf_type* __sbin) + { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + sentry __cerb(*this); + if (__cerb && __sbin) + { + try { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - this->_M_setstate(ios_base::badbit); - if ((this->exceptions() & ios_base::badbit) != 0) - __throw_exception_again; + if (!__copy_streambufs(*this, __sbin, this->rdbuf())) + __err |= ios_base::failbit; } + catch(...) + { this->_M_setstate(ios_base::failbit); } } + else if (!__sbin) + __err |= ios_base::badbit; + if (__err) + this->setstate(__err); return *this; } @@ -379,26 +334,55 @@ namespace std basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::put(char_type) is an unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. sentry __cerb(*this); if (__cerb) { - int_type __put = rdbuf()->sputc(__c); - if (traits_type::eq_int_type(__put, traits_type::eof())) - this->setstate(ios_base::badbit); + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + int_type __put = this->rdbuf()->sputc(__c); + if (traits_type::eq_int_type(__put, traits_type::eof())) + __err |= ios_base::badbit; + } + catch (...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } - return *this; - } - + return *this; + } + template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const _CharT* __s, streamsize __n) { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::write(const char_type*, streamsize) is an + // unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. sentry __cerb(*this); if (__cerb) { - streamsize __put = this->rdbuf()->sputn(__s, __n); - if ( __put != __n) - this->setstate(ios_base::badbit); + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + streamsize __put = this->rdbuf()->sputn(__s, __n); + if (__put != __n) + __err |= ios_base::badbit; + } + catch (...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } @@ -407,12 +391,19 @@ namespace std basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { - sentry __cerb(*this); - if (__cerb) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::flush() is *not* an unformatted output function. + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try { if (this->rdbuf() && this->rdbuf()->pubsync() == -1) - this->setstate(ios_base::badbit); + __err |= ios_base::badbit; } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); return *this; } @@ -421,8 +412,13 @@ namespace std basic_ostream<_CharT, _Traits>::tellp() { pos_type __ret = pos_type(-1); - if (!this->fail()) - __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + try + { + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + } + catch(...) + { this->_M_setstate(ios_base::badbit); } return __ret; } @@ -431,37 +427,51 @@ namespace std basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { - if (!this->fail()) + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try { -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 136. seekp, seekg setting wrong streams? - pos_type __err = this->rdbuf()->pubseekpos(__pos, ios_base::out); - -// 129. Need error indication from seekp() and seekg() - if (__err == pos_type(off_type(-1))) - this->setstate(ios_base::failbit); -#endif + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + pos_type __p = this->rdbuf()->pubseekpos(__pos, ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); return *this; } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>:: - seekp(off_type __off, ios_base::seekdir __d) + seekp(off_type __off, ios_base::seekdir __dir) { - if (!this->fail()) + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try { -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 136. seekp, seekg setting wrong streams? - pos_type __err = this->rdbuf()->pubseekoff(__off, __d, - ios_base::out); - -// 129. Need error indication from seekp() and seekg() - if (__err == pos_type(off_type(-1))) - this->setstate(ios_base::failbit); -#endif + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, + ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); return *this; } @@ -490,13 +500,7 @@ namespace std __out.width(0); } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - __out._M_setstate(ios_base::badbit); - if ((__out.exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { __out._M_setstate(ios_base::badbit); } } return __out; } @@ -526,13 +530,7 @@ namespace std __out.width(0); } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - __out._M_setstate(ios_base::badbit); - if ((__out.exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { __out._M_setstate(ios_base::badbit); } } return __out; } @@ -561,13 +559,7 @@ namespace std __out.width(0); } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - __out._M_setstate(ios_base::badbit); - if ((__out.exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { __out._M_setstate(ios_base::badbit); } } else if (!__s) __out.setstate(ios_base::badbit); @@ -610,13 +602,7 @@ namespace std __out.width(0); } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - __out._M_setstate(ios_base::badbit); - if ((__out.exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { __out._M_setstate(ios_base::badbit); } } else if (!__s) __out.setstate(ios_base::badbit); @@ -649,13 +635,7 @@ namespace std __out.width(0); } catch(...) - { - // 27.6.1.2.1 Common requirements. - // Turn this on without causing an ios::failure to be thrown. - __out._M_setstate(ios_base::badbit); - if ((__out.exceptions() & ios_base::badbit) != 0) - __throw_exception_again; - } + { __out._M_setstate(ios_base::badbit); } } else if (!__s) __out.setstate(ios_base::badbit); @@ -709,7 +689,7 @@ namespace std extern template ostream& operator<<(ostream&, const unsigned char*); extern template ostream& operator<<(ostream&, const signed char*); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_ostream<wchar_t>; extern template wostream& endl(wostream&); extern template wostream& ends(wostream&); diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/sstream.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/sstream.tcc index 606705c02e9..6c5fcb57099 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/sstream.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/sstream.tcc @@ -225,17 +225,19 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE extern template class basic_stringbuf<char>; extern template class basic_istringstream<char>; extern template class basic_ostringstream<char>; extern template class basic_stringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_stringbuf<wchar_t>; extern template class basic_istringstream<wchar_t>; extern template class basic_ostringstream<wchar_t>; extern template class basic_stringstream<wchar_t>; #endif +#endif } // namespace std #endif diff --git a/gnu/lib/libstdc++/libstdc++/include/bits/streambuf.tcc b/gnu/lib/libstdc++/libstdc++/include/bits/streambuf.tcc index be858621b85..67477b84ec8 100644 --- a/gnu/lib/libstdc++/libstdc++/include/bits/streambuf.tcc +++ b/gnu/lib/libstdc++/libstdc++/include/bits/streambuf.tcc @@ -194,42 +194,32 @@ namespace std // necessary. template<typename _CharT, typename _Traits> streamsize - __copy_streambufs(basic_ios<_CharT, _Traits>& __ios, + __copy_streambufs(basic_ios<_CharT, _Traits>&, basic_streambuf<_CharT, _Traits>* __sbin, basic_streambuf<_CharT, _Traits>* __sbout) { streamsize __ret = 0; - try + typename _Traits::int_type __c = __sbin->sgetc(); + while (!_Traits::eq_int_type(__c, _Traits::eof())) { - typename _Traits::int_type __c = __sbin->sgetc(); - while (!_Traits::eq_int_type(__c, _Traits::eof())) + const size_t __n = __sbin->_M_in_end - __sbin->_M_in_cur; + if (__n > 1) { - const size_t __n = __sbin->_M_in_end - __sbin->_M_in_cur; - if (__n > 1) - { - const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur, - __n); - __sbin->_M_in_cur_move(__wrote); - __ret += __wrote; - if (__wrote < __n) - break; - __c = __sbin->underflow(); - } - else - { - __c = __sbout->sputc(_Traits::to_char_type(__c)); - if (_Traits::eq_int_type(__c, _Traits::eof())) - break; - ++__ret; - __c = __sbin->snextc(); - } + const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur, __n); + __sbin->_M_in_cur_move(__wrote); + __ret += __wrote; + if (__wrote < __n) + break; + __c = __sbin->underflow(); + } + else + { + __c = __sbout->sputc(_Traits::to_char_type(__c)); + if (_Traits::eq_int_type(__c, _Traits::eof())) + break; + ++__ret; + __c = __sbin->snextc(); } - } - catch(exception& __fail) - { - __ios.setstate(ios_base::failbit); - if ((__ios.exceptions() & ios_base::failbit) != 0) - __throw_exception_again; } return __ret; } @@ -244,7 +234,7 @@ namespace std __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*, basic_streambuf<char>*); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template class basic_streambuf<wchar_t>; extern template streamsize diff --git a/gnu/lib/libstdc++/libstdc++/include/c_compatibility/wchar.h b/gnu/lib/libstdc++/libstdc++/include/c_compatibility/wchar.h index a6a8f8f4a5b..8f9bdb7f4ed 100644 --- a/gnu/lib/libstdc++/libstdc++/include/c_compatibility/wchar.h +++ b/gnu/lib/libstdc++/libstdc++/include/c_compatibility/wchar.h @@ -34,7 +34,7 @@ using std::mbstate_t; -#if defined(_GLIBCPP_USE_WCHAR_T) +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) using std::wint_t; using std::btowc; @@ -45,6 +45,7 @@ using std::fgetws; using std::fputwc; using std::fputws; using std::fwide; +#if defined(_GLIBCPP_USE_WCHAR_T) using std::fwprintf; using std::fwscanf; using std::swprintf; @@ -57,6 +58,7 @@ using std::vwprintf; using std::vwscanf; using std::wprintf; using std::wscanf; +#endif using std::getwc; using std::getwchar; using std::mbsinit; diff --git a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cstdio.h b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cstdio.h index 7b8fc0dad92..93ff0c280c1 100644 --- a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cstdio.h +++ b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cstdio.h @@ -145,7 +145,7 @@ namespace std #if defined(_GLIBCPP_USE_C99) || defined(_GLIBCPP_USE_C99_SNPRINTF) #undef snprintf -//#undef vfscanf +#undef vfscanf #undef vscanf #undef vsnprintf #undef vsscanf @@ -155,8 +155,8 @@ namespace __gnu_cxx #if defined(_GLIBCPP_USE_C99_CHECK) || defined(_GLIBCPP_USE_C99_DYNAMIC) extern "C" int (snprintf)(char * restrict, size_t, const char * restrict, ...); -// extern "C" int -// (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list); + extern "C" int + (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list); extern "C" int (vscanf)(const char * restrict, __gnuc_va_list); extern "C" int (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list); @@ -165,7 +165,7 @@ namespace __gnu_cxx #endif #if !defined(_GLIBCPP_USE_C99_DYNAMIC) using ::snprintf; -//using ::vfscanf; + using ::vfscanf; using ::vscanf; using ::vsnprintf; using ::vsscanf; @@ -175,7 +175,7 @@ namespace __gnu_cxx namespace std { using __gnu_cxx::snprintf; -//using __gnu_cxx::vfscanf; + using __gnu_cxx::vfscanf; using __gnu_cxx::vscanf; using __gnu_cxx::vsnprintf; using __gnu_cxx::vsscanf; diff --git a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwchar.h b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwchar.h index a2c75430699..6374087a822 100644 --- a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwchar.h +++ b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwchar.h @@ -129,7 +129,7 @@ namespace std #undef wprintf #undef wscanf -#if defined(_GLIBCPP_USE_WCHAR_T) +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) namespace std { using ::wint_t; @@ -140,8 +140,25 @@ namespace std using ::fputwc; using ::fputws; using ::fwide; +#if defined(_GLIBCPP_USE_WCHAR_T) using ::fwprintf; using ::fwscanf; + using ::swprintf; + using ::swscanf; + using ::vfwprintf; + using ::vfwscanf; + using ::vswprintf; + using ::vswscanf; + using ::vwprintf; + using ::vwscanf; + using ::wcsftime; + using ::wcstod; + using ::wcstof; + using ::wcstol; + using ::wcstoul; + using ::wprintf; + using ::wscanf; +#endif using ::getwc; using ::getwchar; using ::mbrlen; @@ -150,41 +167,26 @@ namespace std using ::mbsrtowcs; using ::putwc; using ::putwchar; - using ::swprintf; - using ::swscanf; using ::ungetwc; - using ::vfwprintf; - using ::vfwscanf; - using ::vswprintf; - using ::vswscanf; - using ::vwprintf; - using ::vwscanf; using ::wcrtomb; using ::wcscat; using ::wcscmp; using ::wcscoll; using ::wcscpy; using ::wcscspn; - using ::wcsftime; using ::wcslen; using ::wcsncat; using ::wcsncmp; using ::wcsncpy; using ::wcsrtombs; using ::wcsspn; - using ::wcstod; - using ::wcstof; using ::wcstok; - using ::wcstol; - using ::wcstoul; using ::wcsxfrm; using ::wctob; using ::wmemcmp; using ::wmemcpy; using ::wmemmove; using ::wmemset; - using ::wprintf; - using ::wscanf; using ::wcschr; diff --git a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwctype.h b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwctype.h index c3117d65b75..d330e5ff054 100644 --- a/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwctype.h +++ b/gnu/lib/libstdc++/libstdc++/include/c_std/std_cwctype.h @@ -73,7 +73,7 @@ #undef wctrans #undef wctype -#if defined(_GLIBCPP_USE_WCHAR_T) +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) namespace std { using ::wint_t; // cwchar @@ -97,8 +97,10 @@ namespace std using ::iswctype; using ::towlower; using ::towupper; +#if defined(_GLIBCPP_USE_WCHAR_T) using ::towctrans; using ::wctrans; +#endif using ::wctype; } #endif //_GLIBCPP_USE_WCHAR_T diff --git a/gnu/lib/libstdc++/libstdc++/include/std/std_fstream.h b/gnu/lib/libstdc++/libstdc++/include/std/std_fstream.h index bcbbb971946..88159a87516 100644 --- a/gnu/lib/libstdc++/libstdc++/include/std/std_fstream.h +++ b/gnu/lib/libstdc++/libstdc++/include/std/std_fstream.h @@ -441,11 +441,11 @@ namespace std basic_filebuf<char>::int_type basic_filebuf<char>::_M_underflow_common(bool __bump); - #ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::_M_underflow_common(bool __bump); - #endif +# endif // Generic definitions. template <typename _CharT, typename _Traits> diff --git a/gnu/lib/libstdc++/libstdc++/include/std/std_iomanip.h b/gnu/lib/libstdc++/libstdc++/include/std/std_iomanip.h index 490d5ac1cfb..94139659eb0 100644 --- a/gnu/lib/libstdc++/libstdc++/include/std/std_iomanip.h +++ b/gnu/lib/libstdc++/libstdc++/include/std/std_iomanip.h @@ -280,7 +280,7 @@ namespace std extern template istream& operator>>(istream&, _Setprecision); extern template istream& operator>>(istream&, _Setw); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern template wostream& operator<<(wostream&, _Setfill<wchar_t>); extern template wostream& operator<<(wostream&, _Setiosflags); extern template wostream& operator<<(wostream&, _Resetiosflags); diff --git a/gnu/lib/libstdc++/libstdc++/include/std/std_iosfwd.h b/gnu/lib/libstdc++/libstdc++/include/std/std_iosfwd.h index 55b0e0b19fa..325229cea1c 100644 --- a/gnu/lib/libstdc++/libstdc++/include/std/std_iosfwd.h +++ b/gnu/lib/libstdc++/libstdc++/include/std/std_iosfwd.h @@ -147,7 +147,7 @@ namespace std typedef basic_ofstream<char> ofstream; ///< @isiosfwd typedef basic_fstream<char> fstream; ///< @isiosfwd -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef basic_ios<wchar_t> wios; ///< @isiosfwd typedef basic_streambuf<wchar_t> wstreambuf; ///< @isiosfwd typedef basic_istream<wchar_t> wistream; ///< @isiosfwd diff --git a/gnu/lib/libstdc++/libstdc++/include/std/std_iostream.h b/gnu/lib/libstdc++/libstdc++/include/std/std_iostream.h index d70949377df..45851c5cf3b 100644 --- a/gnu/lib/libstdc++/libstdc++/include/std/std_iostream.h +++ b/gnu/lib/libstdc++/libstdc++/include/std/std_iostream.h @@ -65,7 +65,7 @@ namespace std extern ostream cerr; ///< Linked to standard error (unbuffered) extern ostream clog; ///< Linked to standard error (buffered) -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern wistream wcin; ///< Linked to standard input extern wostream wcout; ///< Linked to standard output extern wostream wcerr; ///< Linked to standard error (unbuffered) diff --git a/gnu/lib/libstdc++/libstdc++/libio/_G_config.h b/gnu/lib/libstdc++/libstdc++/libio/_G_config.h index d6738c2bf7b..d52795189b2 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/_G_config.h +++ b/gnu/lib/libstdc++/libstdc++/libio/_G_config.h @@ -1,3 +1,28 @@ +/* Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU IO 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. + + As a special exception, if you link this library with files + compiled with a GNU compiler to produce an executable, this does + not cause the resulting executable to be covered by the GNU General + Public License. This exception does not however invalidate any + other reasons why the executable file might be covered by the GNU + General Public License. */ + /* This file is needed by libio to define various configuration parameters. These are always the same in the GNU C library. */ @@ -52,7 +77,7 @@ typedef struct typedef size_t _G_size_t; -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef struct { __off_t __pos; @@ -76,7 +101,7 @@ typedef __off64_t _G_fpos64_t; #define _G_wchar_t wchar_t #define _G_wint_t wint_t #define _G_stat64 stat64 -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # include <iconv.h> typedef iconv_t _G_iconv_t; #endif diff --git a/gnu/lib/libstdc++/libstdc++/libio/fileops.c b/gnu/lib/libstdc++/libstdc++/libio/fileops.c index a830b5cd439..cdebc9f3bba 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/fileops.c +++ b/gnu/lib/libstdc++/libstdc++/libio/fileops.c @@ -160,7 +160,7 @@ _IO_new_file_close_it (fp) _IO_setg (fp, NULL, NULL, NULL); _IO_setp (fp, NULL, NULL); } -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) else { _IO_wsetb (fp, NULL, NULL, 0); diff --git a/gnu/lib/libstdc++/libstdc++/libio/genops.c b/gnu/lib/libstdc++/libstdc++/libio/genops.c index b1ae5afc506..11b2bab6d35 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/genops.c +++ b/gnu/lib/libstdc++/libstdc++/libio/genops.c @@ -285,7 +285,7 @@ int __underflow (fp) _IO_FILE *fp; { -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1) return EOF; #endif @@ -317,7 +317,7 @@ int __uflow (fp) _IO_FILE *fp; { -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1) return EOF; #endif @@ -584,7 +584,7 @@ _IO_no_init (fp, flags, orientation, wd, jmp) _IO_lock_init (*fp->_lock); #endif fp->_mode = orientation; -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) if (orientation >= 0) { fp->_wide_data = wd; @@ -755,7 +755,7 @@ _IO_flush_all () struct _IO_FILE *fp; for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain) if (((fp->_mode < 0 && fp->_IO_write_ptr > fp->_IO_write_base) -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) || (fp->_vtable_offset == 0 && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base)) diff --git a/gnu/lib/libstdc++/libstdc++/libio/iofopen.c b/gnu/lib/libstdc++/libstdc++/libio/iofopen.c index 2dcdee0235c..09deeb40c70 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/iofopen.c +++ b/gnu/lib/libstdc++/libstdc++/libio/iofopen.c @@ -44,7 +44,7 @@ _IO_new_fopen (filename, mode) #ifdef _IO_MTSAFE_IO _IO_lock_t lock; #endif -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) struct _IO_wide_data wd; #endif /* !(defined _LIBC || defined _GLIBCPP_USE_WCHAR_T) */ } *new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); @@ -54,7 +54,7 @@ _IO_new_fopen (filename, mode) #ifdef _IO_MTSAFE_IO new_f->fp.file._lock = &new_f->lock; #endif -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps); #else _IO_no_init (&new_f->fp.file, 1, 0, NULL, NULL); diff --git a/gnu/lib/libstdc++/libstdc++/libio/iofwide.c b/gnu/lib/libstdc++/libstdc++/libio/iofwide.c index 76a20ce3fb4..0e81e154fd3 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/iofwide.c +++ b/gnu/lib/libstdc++/libstdc++/libio/iofwide.c @@ -34,11 +34,11 @@ #include <stdlib.h> #include <string.h> -#if defined(_LIBC) || defined(_GLIBCPP_USE_WCHAR_T) +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # include <langinfo.h> #endif -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) /* Prototypes of libio's codecvt functions. */ static enum __codecvt_result do_out (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, @@ -104,7 +104,7 @@ _IO_fwide (fp, mode) /* Set the orientation appropriately. */ if (mode > 0) { -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) struct _IO_codecvt *cc = fp->_codecvt; fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end; @@ -148,7 +148,7 @@ _IO_fwide (fp, mode) cc->__cd_out.__cd.__data[0].__trans = &libio_translit; } #else -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) { /* Determine internal and external character sets. XXX For now we make our life easy: we assume a fixed internal @@ -190,7 +190,7 @@ _IO_fwide (fp, mode) weak_alias (_IO_fwide, fwide) #endif -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) static enum __codecvt_result do_out (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, @@ -235,7 +235,7 @@ do_out (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, break; } #else -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) size_t res; const char *from_start_copy = (const char *) from_start; size_t from_len = from_end - from_start; @@ -299,7 +299,7 @@ do_unshift (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, break; } #else -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) size_t res; char *to_start_copy = (char *) to_start; size_t to_len = to_end - to_start; @@ -363,7 +363,7 @@ do_in (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, break; } #else -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) size_t res; const char *from_start_copy = (const char *) from_start; size_t from_len = from_end - from_start; @@ -442,7 +442,7 @@ do_length (struct _IO_codecvt *codecvt, __c_mbstate_t *statep, result = cp - (const unsigned char *) from_start; #else -# ifdef _GLIBCPP_USE_WCHAR_T +# if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) const char *from_start_copy = (const char *) from_start; size_t from_len = from_end - from_start; wchar_t to_buf[max]; diff --git a/gnu/lib/libstdc++/libstdc++/libio/libio.h b/gnu/lib/libstdc++/libstdc++/libio/libio.h index e2a2a15bcb0..c951ef407fe 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/libio.h +++ b/gnu/lib/libstdc++/libstdc++/libio/libio.h @@ -205,7 +205,7 @@ enum __codecvt_result __codecvt_noconv }; -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) /* The order of the elements in the following struct must match the order of the virtual functions in the libstdc++ codecvt class. */ struct _IO_codecvt @@ -252,7 +252,7 @@ struct _IO_wide_data backup area */ wchar_t *_IO_save_end; /* Pointer to end of non-current get area. */ -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) __c_mbstate_t _IO_state; __c_mbstate_t _IO_last_state; #endif @@ -260,7 +260,7 @@ struct _IO_wide_data wchar_t _shortbuf[1]; -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) struct _IO_jump_t *_wide_vtable; #endif }; @@ -317,7 +317,7 @@ struct _IO_FILE_complete #endif #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 _IO_off64_t _offset; -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) /* Wide character stream stuff. */ struct _IO_codecvt *_codecvt; struct _IO_wide_data *_wide_data; @@ -475,7 +475,7 @@ extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; extern void _IO_free_backup_area (_IO_FILE *) __THROW; -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW; extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW; extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; diff --git a/gnu/lib/libstdc++/libstdc++/libio/libioP.h b/gnu/lib/libstdc++/libstdc++/libio/libioP.h index 4aecf4eaa1b..11772e929a8 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/libioP.h +++ b/gnu/lib/libstdc++/libstdc++/libio/libioP.h @@ -434,7 +434,7 @@ extern int _IO_new_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *)); extern int _IO_old_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *)); -#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define _IO_do_flush(_f) \ ((_f)->_mode <= 0 \ ? _IO_do_write(_f, (_f)->_IO_write_base, \ @@ -726,7 +726,7 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock } # else -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ @@ -747,7 +747,7 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD } # else -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ diff --git a/gnu/lib/libstdc++/libstdc++/libio/stdfiles.c b/gnu/lib/libstdc++/libstdc++/libio/stdfiles.c index b81fef8b883..35e5b0baa75 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/stdfiles.c +++ b/gnu/lib/libstdc++/libstdc++/libio/stdfiles.c @@ -33,7 +33,7 @@ #include "libioP.h" #ifdef _IO_MTSAFE_IO -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \ static struct _IO_wide_data _IO_wide_data_##FD \ @@ -49,7 +49,7 @@ &_IO_file_jumps}; # endif #else -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || defined(_GLIBCPP_USE_TYPE_WCHAR_T) # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ static struct _IO_wide_data _IO_wide_data_##FD \ = { ._wide_vtable = &_IO_wfile_jumps }; \ diff --git a/gnu/lib/libstdc++/libstdc++/libio/wfiledoalloc.c b/gnu/lib/libstdc++/libstdc++/libio/wfiledoalloc.c index dddbd44fd3b..156b38b0de8 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/wfiledoalloc.c +++ b/gnu/lib/libstdc++/libstdc++/libio/wfiledoalloc.c @@ -46,7 +46,7 @@ # define _POSIX_SOURCE #endif #include "libioP.h" -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) #include <sys/types.h> #include <sys/stat.h> #ifdef __STDC__ diff --git a/gnu/lib/libstdc++/libstdc++/libio/wfileops.c b/gnu/lib/libstdc++/libstdc++/libio/wfileops.c index 1dd524a3ffb..b36fc01e27d 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/wfileops.c +++ b/gnu/lib/libstdc++/libstdc++/libio/wfileops.c @@ -27,7 +27,7 @@ #include <assert.h> #include <libioP.h> -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) #include <wchar.h> #ifdef HAVE_GCONV_H # include <gconv.h> diff --git a/gnu/lib/libstdc++/libstdc++/libio/wgenops.c b/gnu/lib/libstdc++/libstdc++/libio/wgenops.c index 74854524295..991a5d2e724 100644 --- a/gnu/lib/libstdc++/libstdc++/libio/wgenops.c +++ b/gnu/lib/libstdc++/libstdc++/libio/wgenops.c @@ -28,7 +28,7 @@ /* Generic or default I/O operations. */ #include "libioP.h" -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) #ifdef __STDC__ #include <stdlib.h> #endif diff --git a/gnu/lib/libstdc++/libstdc++/src/codecvt.cc b/gnu/lib/libstdc++/libstdc++/src/codecvt.cc index bc5508a4f40..c35bd4d5c11 100644 --- a/gnu/lib/libstdc++/libstdc++/src/codecvt.cc +++ b/gnu/lib/libstdc++/libstdc++/src/codecvt.cc @@ -34,7 +34,7 @@ namespace std // Definitions for locale::id of standard facets that are specialized. locale::id codecvt<char, char, mbstate_t>::id; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) locale::id codecvt<wchar_t, char, mbstate_t>::id; #endif @@ -112,7 +112,7 @@ namespace std do_max_length() const throw() { return 1; } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) // codecvt<wchar_t, char, mbstate_t> required specialization codecvt<wchar_t, char, mbstate_t>:: codecvt(size_t __refs) diff --git a/gnu/lib/libstdc++/libstdc++/src/complex_io.cc b/gnu/lib/libstdc++/libstdc++/src/complex_io.cc index a6d502f2dad..7b0abad3cd6 100644 --- a/gnu/lib/libstdc++/libstdc++/src/complex_io.cc +++ b/gnu/lib/libstdc++/libstdc++/src/complex_io.cc @@ -59,7 +59,7 @@ namespace std operator<<(basic_ostream<char, char_traits<char> >&, const complex<long double>&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template basic_istream<wchar_t, char_traits<wchar_t> >& operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, diff --git a/gnu/lib/libstdc++/libstdc++/src/concept-inst.cc b/gnu/lib/libstdc++/libstdc++/src/concept-inst.cc index e173549105d..ff5194cb21c 100644 --- a/gnu/lib/libstdc++/libstdc++/src/concept-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/concept-inst.cc @@ -54,7 +54,7 @@ namespace __gnu_cxx _Instantiate(_InputIteratorConcept<char const*> ); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _Instantiate(_InputIteratorConcept<wchar_t*> ); _Instantiate(_InputIteratorConcept<wchar_t const*> ); @@ -75,7 +75,7 @@ namespace __gnu_cxx _Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator< char, std::char_traits<char> >, char> ); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator< wchar_t, std::char_traits<wchar_t> >, wchar_t> ); #endif @@ -90,7 +90,7 @@ namespace __gnu_cxx _Instantiate(_RandomAccessIteratorConcept< __normal_iterator<char*, std::string> > ); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _Instantiate(_RandomAccessIteratorConcept< __normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, diff --git a/gnu/lib/libstdc++/libstdc++/src/ctype.cc b/gnu/lib/libstdc++/libstdc++/src/ctype.cc index 3d5ee618c53..718bfc807fd 100644 --- a/gnu/lib/libstdc++/libstdc++/src/ctype.cc +++ b/gnu/lib/libstdc++/libstdc++/src/ctype.cc @@ -38,7 +38,7 @@ namespace std // Definitions for locale::id of standard facets that are specialized. locale::id ctype<char>::id; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) locale::id ctype<wchar_t>::id; #endif @@ -51,7 +51,7 @@ namespace std return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i])); } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> const ctype<wchar_t>& use_facet<ctype<wchar_t> >(const locale& __loc) @@ -124,7 +124,7 @@ namespace std return __hi; } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) ctype<wchar_t>::ctype(size_t __refs) : __ctype_abstract_base<wchar_t>(__refs) { _M_c_locale_ctype = _S_c_locale; } diff --git a/gnu/lib/libstdc++/libstdc++/src/ext-inst.cc b/gnu/lib/libstdc++/libstdc++/src/ext-inst.cc index 4896b110d42..b951f1751a7 100644 --- a/gnu/lib/libstdc++/libstdc++/src/ext-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/ext-inst.cc @@ -47,7 +47,7 @@ namespace __gnu_cxx template class stdio_filebuf<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template const unsigned long rope<wchar_t, std::allocator<wchar_t> >::_S_min_len; diff --git a/gnu/lib/libstdc++/libstdc++/src/fstream-inst.cc b/gnu/lib/libstdc++/libstdc++/src/fstream-inst.cc index 8b866c0c927..94e00ffef54 100644 --- a/gnu/lib/libstdc++/libstdc++/src/fstream-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/fstream-inst.cc @@ -38,25 +38,25 @@ namespace std { // filebuf template class basic_filebuf<char, char_traits<char> >; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_filebuf<wchar_t, char_traits<wchar_t> >; #endif // ifstream template class basic_ifstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_ifstream<wchar_t>; #endif // ofstream template class basic_ofstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_ofstream<wchar_t>; #endif // fstream template class basic_fstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_fstream<wchar_t>; #endif } // namespace std diff --git a/gnu/lib/libstdc++/libstdc++/src/fstream.cc b/gnu/lib/libstdc++/libstdc++/src/fstream.cc index 2a099d69227..b5f38f5a48c 100644 --- a/gnu/lib/libstdc++/libstdc++/src/fstream.cc +++ b/gnu/lib/libstdc++/libstdc++/src/fstream.cc @@ -104,7 +104,7 @@ namespace std return __ret; } -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::_M_underflow_common(bool __bump) diff --git a/gnu/lib/libstdc++/libstdc++/src/globals.cc b/gnu/lib/libstdc++/libstdc++/src/globals.cc index efbfdbe854b..5a9b31d9187 100644 --- a/gnu/lib/libstdc++/libstdc++/src/globals.cc +++ b/gnu/lib/libstdc++/libstdc++/src/globals.cc @@ -158,7 +158,7 @@ namespace __gnu_cxx fake_messages_c messages_c; _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10messages_cE, _ZSt10messages_c, GLIBCPP_3.2) -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)] __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>)))); fake_wtype_w ctype_w; @@ -234,7 +234,7 @@ namespace __gnu_cxx __attribute__ ((aligned(__alignof__(std::__locale_cache<numpunct<char> >)))); fake_locale_cache_np_c locale_cache_np_c; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef char fake_locale_cache_np_w[sizeof(std::__locale_cache<numpunct<wchar_t> >)] __attribute__ ((aligned(__alignof__(std::__locale_cache<numpunct<wchar_t> >)))); fake_locale_cache_np_w locale_cache_np_w; @@ -249,7 +249,7 @@ namespace __gnu_cxx _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx7buf_cinE, _ZSt7buf_cin, GLIBCPP_3.2) _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8buf_cerrE, _ZSt8buf_cerr, GLIBCPP_3.2) -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)] __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>)))); fake_wfilebuf buf_wcout; @@ -304,7 +304,7 @@ namespace std fake_ostream cerr; fake_ostream clog; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) typedef char fake_wistream[sizeof(wistream)] __attribute__ ((aligned(__alignof__(wistream)))); typedef char fake_wostream[sizeof(wostream)] diff --git a/gnu/lib/libstdc++/libstdc++/src/io-inst.cc b/gnu/lib/libstdc++/libstdc++/src/io-inst.cc index 31f53b4e395..32200dbbf99 100644 --- a/gnu/lib/libstdc++/libstdc++/src/io-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/io-inst.cc @@ -40,21 +40,21 @@ namespace std { // basic_ios template class basic_ios<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_ios<wchar_t>; #endif // iomanip template class _Setfill<char>; template _Setfill<char> setfill(char); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class _Setfill<wchar_t>; template _Setfill<wchar_t> setfill(wchar_t); #endif // iostream template class basic_iostream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_iostream<wchar_t>; #endif } // namespace std diff --git a/gnu/lib/libstdc++/libstdc++/src/ios.cc b/gnu/lib/libstdc++/libstdc++/src/ios.cc index 00dbe1219c6..ec81bbd823f 100644 --- a/gnu/lib/libstdc++/libstdc++/src/ios.cc +++ b/gnu/lib/libstdc++/libstdc++/src/ios.cc @@ -49,7 +49,7 @@ namespace __gnu_cxx extern stdio_filebuf<char> buf_cin; extern stdio_filebuf<char> buf_cerr; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern stdio_filebuf<wchar_t> buf_wcout; extern stdio_filebuf<wchar_t> buf_wcin; extern stdio_filebuf<wchar_t> buf_wcerr; @@ -65,7 +65,7 @@ namespace std extern ostream cerr; extern ostream clog; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern wistream wcin; extern wostream wcout; extern wostream wcerr; @@ -185,7 +185,7 @@ namespace std cin.tie(&cout); cerr.flags(ios_base::unitbuf); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out, __out_size); new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in, __in_size); new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out, __out_size); @@ -212,7 +212,7 @@ namespace std buf_cin.~stdio_filebuf(); buf_cerr.~stdio_filebuf(); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) buf_wcout.~stdio_filebuf(); buf_wcin.~stdio_filebuf(); buf_wcerr.~stdio_filebuf(); diff --git a/gnu/lib/libstdc++/libstdc++/src/istream-inst.cc b/gnu/lib/libstdc++/libstdc++/src/istream-inst.cc index f2c72fde198..8b78274c600 100644 --- a/gnu/lib/libstdc++/libstdc++/src/istream-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/istream-inst.cc @@ -54,7 +54,7 @@ namespace std template istream& operator>>(istream&, _Setprecision); template istream& operator>>(istream&, _Setw); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_istream<wchar_t>; template wistream& ws(wistream&); template wistream& operator>>(wistream&, wchar_t&); diff --git a/gnu/lib/libstdc++/libstdc++/src/limits.cc b/gnu/lib/libstdc++/libstdc++/src/limits.cc index 294673ea186..2c0637bd938 100644 --- a/gnu/lib/libstdc++/libstdc++/src/limits.cc +++ b/gnu/lib/libstdc++/libstdc++/src/limits.cc @@ -159,7 +159,7 @@ namespace std // wchar_t // This used to be problematic... -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) const bool numeric_limits<wchar_t>::is_specialized; const int numeric_limits<wchar_t>::digits; const int numeric_limits<wchar_t>::digits10; diff --git a/gnu/lib/libstdc++/libstdc++/src/locale-inst.cc b/gnu/lib/libstdc++/libstdc++/src/locale-inst.cc index 8da410f7ff8..fda2faa2989 100644 --- a/gnu/lib/libstdc++/libstdc++/src/locale-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/locale-inst.cc @@ -47,7 +47,7 @@ namespace std template class money_put<char, ostreambuf_iterator<char> >; template class __locale_cache<numpunct<char> >; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class moneypunct<wchar_t, false>; template class moneypunct<wchar_t, true>; template class moneypunct_byname<wchar_t, false>; @@ -100,7 +100,7 @@ namespace std _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char, long double) const; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class numpunct<wchar_t>; template class numpunct_byname<wchar_t>; template class num_get<wchar_t, istreambuf_iterator<wchar_t> >; @@ -173,7 +173,7 @@ namespace std unsigned long long) const; #endif -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template ostreambuf_iterator<wchar_t> num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: @@ -210,7 +210,7 @@ namespace std template class time_get<char, istreambuf_iterator<char> >; template class time_get_byname<char, istreambuf_iterator<char> >; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class __timepunct<wchar_t>; template class time_put<wchar_t, ostreambuf_iterator<wchar_t> >; template class time_put_byname<wchar_t, ostreambuf_iterator<wchar_t> >; @@ -221,7 +221,7 @@ namespace std // messages template class messages<char>; template class messages_byname<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class messages<wchar_t>; template class messages_byname<wchar_t>; #endif @@ -229,7 +229,7 @@ namespace std // ctype inline template class __ctype_abstract_base<char>; template class ctype_byname<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) inline template class __ctype_abstract_base<wchar_t>; template class ctype_byname<wchar_t>; #endif @@ -237,7 +237,7 @@ namespace std // codecvt inline template class __codecvt_abstract_base<char, char, mbstate_t>; template class codecvt_byname<char, char, mbstate_t>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) inline template class __codecvt_abstract_base<wchar_t, char, mbstate_t>; template class codecvt_byname<wchar_t, char, mbstate_t>; #endif @@ -245,7 +245,7 @@ namespace std // collate template class collate<char>; template class collate_byname<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class collate<wchar_t>; template class collate_byname<wchar_t>; #endif @@ -304,7 +304,7 @@ namespace std const messages<char>& use_facet<messages<char> >(const locale&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template const codecvt<wchar_t, char, mbstate_t>& use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&); @@ -411,7 +411,7 @@ namespace std bool has_facet<messages<char> >(const locale&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template bool has_facet<ctype<wchar_t> >(const locale&); @@ -470,7 +470,7 @@ namespace std const __locale_cache<numpunct<char> >& __use_cache<numpunct<char> >(const locale& __loc); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template const __locale_cache<numpunct<wchar_t> >& __use_cache<numpunct<wchar_t> >(const locale& __loc); @@ -488,7 +488,7 @@ namespace std template class __pad<char, char_traits<char> >; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template wchar_t* __add_grouping<wchar_t>(wchar_t*, wchar_t, char const*, char const*, @@ -538,7 +538,7 @@ namespace std __int_to_char(char*, const int, unsigned long, const char*, ios_base::fmtflags, bool); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template int __int_to_char(wchar_t*, const int, unsigned long, const wchar_t*, @@ -551,7 +551,7 @@ namespace std __int_to_char(char*, const int, unsigned long long, const char*, ios_base::fmtflags, bool); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template int __int_to_char(wchar_t*, const int, unsigned long long, const wchar_t*, diff --git a/gnu/lib/libstdc++/libstdc++/src/locale.cc b/gnu/lib/libstdc++/libstdc++/src/locale.cc index 17ccdc2e4c6..f1a56789fcc 100644 --- a/gnu/lib/libstdc++/libstdc++/src/locale.cc +++ b/gnu/lib/libstdc++/libstdc++/src/locale.cc @@ -72,7 +72,7 @@ namespace std { &std::ctype<char>::id, &codecvt<char, char, mbstate_t>::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &std::ctype<wchar_t>::id, &codecvt<wchar_t, char, mbstate_t>::id, #endif @@ -85,7 +85,7 @@ namespace std &num_get<char>::id, &num_put<char>::id, &numpunct<char>::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &num_get<wchar_t>::id, &num_put<wchar_t>::id, &numpunct<wchar_t>::id, @@ -97,7 +97,7 @@ namespace std locale::_Impl::_S_id_collate[] = { &std::collate<char>::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &std::collate<wchar_t>::id, #endif 0 @@ -109,7 +109,7 @@ namespace std &__timepunct<char>::id, &time_get<char>::id, &time_put<char>::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &__timepunct<wchar_t>::id, &time_get<wchar_t>::id, &time_put<wchar_t>::id, @@ -124,7 +124,7 @@ namespace std &money_put<char>::id, &moneypunct<char, false>::id, &moneypunct<char, true >::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &money_get<wchar_t>::id, &money_put<wchar_t>::id, &moneypunct<wchar_t, false>::id, @@ -137,7 +137,7 @@ namespace std locale::_Impl::_S_id_messages[] = { &std::messages<char>::id, -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) &std::messages<wchar_t>::id, #endif 0 @@ -194,19 +194,19 @@ namespace std } else { - char* __res; + string __res; // LANG may set a default different from "C". char* __env = getenv("LANG"); if (!__env || strcmp(__env, "") == 0 || strcmp(__env, "C") == 0 || strcmp(__env, "POSIX") == 0) - __res = strdup("C"); + __res = "C"; else - __res = strdup(__env); + __res = __env; // Scan the categories looking for the first one // different from LANG. size_t __i = 0; - if (strcmp(__res, "C") == 0) + if (__res == "C") for (; __i < _S_categories_size + _S_extra_categories_size; ++__i) { @@ -222,7 +222,7 @@ namespace std { __env = getenv(_S_categories[__i]); if (__env && strcmp(__env, "") != 0 - && strcmp(__env, __res) != 0) + && __res != __env) break; } @@ -273,11 +273,10 @@ namespace std } // ... otherwise either an additional instance of // the "C" locale or LANG. - else if (strcmp(__res, "C") == 0) + else if (__res == "C") (_M_impl = _S_classic)->_M_add_reference(); else - _M_impl = new _Impl(__res, 1); - free(__res); + _M_impl = new _Impl(__res.c_str(), 1); } } } @@ -487,7 +486,7 @@ namespace std "IST", "EET", "CST", "JST" }; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template<> const wchar_t* __timepunct<wchar_t>::_S_timezones[14] = diff --git a/gnu/lib/libstdc++/libstdc++/src/localename.cc b/gnu/lib/libstdc++/libstdc++/src/localename.cc index b837870fac3..45b0c0ed24b 100644 --- a/gnu/lib/libstdc++/libstdc++/src/localename.cc +++ b/gnu/lib/libstdc++/libstdc++/src/localename.cc @@ -53,7 +53,7 @@ namespace __gnu_cxx extern time_get<char> time_get_c; extern time_put<char> time_put_c; extern std::messages<char> messages_c; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern std::ctype<wchar_t> ctype_w; extern std::collate<wchar_t> collate_w; extern numpunct<wchar_t> numpunct_w; @@ -71,7 +71,7 @@ namespace __gnu_cxx #endif extern std::__locale_cache<numpunct<char> > locale_cache_np_c; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) extern std::__locale_cache<numpunct<wchar_t> > locale_cache_np_w; #endif } // namespace __gnu_cxx @@ -203,7 +203,7 @@ namespace std _M_init_facet(new time_put<char>); _M_init_facet(new std::messages<char>(__cloc, __s)); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _M_init_facet(new std::ctype<wchar_t>(__cloc)); _M_init_facet(new codecvt<wchar_t, char, mbstate_t>); _M_init_facet(new numpunct<wchar_t>(__cloc)); @@ -274,7 +274,7 @@ namespace std _M_init_facet(new (&time_get_c) time_get<char>(1)); _M_init_facet(new (&time_put_c) time_put<char>(1)); _M_init_facet(new (&messages_c) std::messages<char>(1)); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) _M_init_facet(new (&ctype_w) std::ctype<wchar_t>(1)); _M_init_facet(new (&codecvt_w) codecvt<wchar_t, char, mbstate_t>(1)); _M_init_facet(new (&numpunct_w) numpunct<wchar_t>(1)); @@ -303,7 +303,7 @@ namespace std _M_facets[numpunct<char>::id._M_id() + _M_facets_size] = reinterpret_cast<locale::facet*>(__lc); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) __locale_cache<numpunct<wchar_t> >* __wlc = new (&locale_cache_np_w) __locale_cache<numpunct<wchar_t> >(ltmp, true); _M_facets[numpunct<wchar_t>::id._M_id() + _M_facets_size] = diff --git a/gnu/lib/libstdc++/libstdc++/src/misc-inst.cc b/gnu/lib/libstdc++/libstdc++/src/misc-inst.cc index 61cb1b36449..3d7ad507888 100644 --- a/gnu/lib/libstdc++/libstdc++/src/misc-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/misc-inst.cc @@ -54,7 +54,7 @@ namespace std template basic_istream<char>& getline(basic_istream<char>&, string&); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template basic_istream<wchar_t>& operator>>(basic_istream<wchar_t>&, wstring&); diff --git a/gnu/lib/libstdc++/libstdc++/src/ostream-inst.cc b/gnu/lib/libstdc++/libstdc++/src/ostream-inst.cc index b834640646b..77f2b50ced3 100644 --- a/gnu/lib/libstdc++/libstdc++/src/ostream-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/ostream-inst.cc @@ -56,7 +56,7 @@ namespace std template ostream& operator<<(ostream&, _Setprecision); template ostream& operator<<(ostream&, _Setw); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_ostream<wchar_t>; template wostream& endl(wostream&); template wostream& ends(wostream&); diff --git a/gnu/lib/libstdc++/libstdc++/src/sstream-inst.cc b/gnu/lib/libstdc++/libstdc++/src/sstream-inst.cc index 6c0272ba289..b13eded8abe 100644 --- a/gnu/lib/libstdc++/libstdc++/src/sstream-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/sstream-inst.cc @@ -38,25 +38,25 @@ namespace std { // stringbuf template class basic_stringbuf<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_stringbuf<wchar_t>; #endif // istringstream template class basic_istringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_istringstream<wchar_t>; #endif // ostringstream template class basic_ostringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_ostringstream<wchar_t>; #endif // stringstream template class basic_stringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_stringstream<wchar_t>; #endif } // namespace std diff --git a/gnu/lib/libstdc++/libstdc++/src/streambuf-inst.cc b/gnu/lib/libstdc++/libstdc++/src/streambuf-inst.cc index 438752e7e5b..b55cde9d212 100644 --- a/gnu/lib/libstdc++/libstdc++/src/streambuf-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/streambuf-inst.cc @@ -39,7 +39,7 @@ namespace std { // streambuf template class basic_streambuf<char>; -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template class basic_streambuf<wchar_t>; #endif @@ -47,7 +47,7 @@ namespace std streamsize __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*, basic_streambuf<char>*); -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) template streamsize __copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*, diff --git a/gnu/lib/libstdc++/libstdc++/src/wstring-inst.cc b/gnu/lib/libstdc++/libstdc++/src/wstring-inst.cc index 0200fd42d67..08e935d8cf9 100644 --- a/gnu/lib/libstdc++/libstdc++/src/wstring-inst.cc +++ b/gnu/lib/libstdc++/libstdc++/src/wstring-inst.cc @@ -1,6 +1,40 @@ +// wide string support -*- C++ -*- + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +// 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. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 21 Strings library +// + #include <bits/c++config.h> -#ifdef _GLIBCPP_USE_WCHAR_T +#if defined(_GLIBCPP_USE_WCHAR_T) || defined(_GLIBCPP_USE_TYPE_WCHAR_T) #define C wchar_t #include "string-inst.cc" #endif diff --git a/gnu/lib/libstdc++/shlib_version b/gnu/lib/libstdc++/shlib_version index b97da722d51..56607597f5e 100644 --- a/gnu/lib/libstdc++/shlib_version +++ b/gnu/lib/libstdc++/shlib_version @@ -1,2 +1,2 @@ -major=39 +major=40 minor=0 diff --git a/include/wchar.h b/include/wchar.h index c53679f85ba..7e4a792e59f 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wchar.h,v 1.3 2005/05/18 13:48:49 espie Exp $ */ +/* $OpenBSD: wchar.h,v 1.4 2005/06/17 20:40:30 espie Exp $ */ /* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */ /*- @@ -146,6 +146,25 @@ wchar_t *wmemset(wchar_t *, wchar_t, size_t); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); int wctob(wint_t); +int wcscoll(const wchar_t *, const wchar_t *); +size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); + +wint_t ungetwc(wint_t, FILE *); +wint_t fgetwc(FILE *); +wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict); +wint_t getwc(FILE *); +wint_t getwchar(void); +wint_t fputwc(wchar_t, FILE *); +int fputws(const wchar_t * __restrict, FILE * __restrict); +wint_t putwc(wchar_t, FILE *); +wint_t putwchar(wchar_t); + +int fwide(FILE *, int); + +#define getwc(f) fgetwc(f) +#define getwchar() getwc(stdin) +#define putwc(wc, f) fputwc((wc), (f)) +#define putwchar(wc) putwc((wc), stdout) __END_DECLS #endif /* !_WCHAR_H_ */ diff --git a/lib/libc/gen/errlist.c b/lib/libc/gen/errlist.c index 8d7a75bdb8c..c803280996f 100644 --- a/lib/libc/gen/errlist.c +++ b/lib/libc/gen/errlist.c @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: errlist.c,v 1.7 2003/06/02 20:18:34 millert Exp $"; +static char *rcsid = "$OpenBSD: errlist.c,v 1.8 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef lint @@ -139,5 +139,6 @@ const char *const "Need authenticator", /* 81 - ENEEDAUTH */ "IPsec processing failure", /* 82 - EIPSEC */ "Attribute not found", /* 83 - ENOATTR */ + "Illegal byte sequence", /* 84 - EILSEQ */ }; int _sys_nerr = { sizeof _sys_errlist/sizeof _sys_errlist[0] }; diff --git a/lib/libc/locale/multibyte_sb.c b/lib/libc/locale/multibyte_sb.c index 4ff06614b3f..3213766e84b 100644 --- a/lib/libc/locale/multibyte_sb.c +++ b/lib/libc/locale/multibyte_sb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: multibyte_sb.c,v 1.1 2005/05/11 18:44:12 espie Exp $ */ +/* $OpenBSD: multibyte_sb.c,v 1.2 2005/06/17 20:40:32 espie Exp $ */ /* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */ /* @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: multibyte_sb.c,v 1.1 2005/05/11 18:44:12 espie Exp $"; +static char rcsid[] = "$OpenBSD: multibyte_sb.c,v 1.2 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <errno.h> @@ -224,3 +224,20 @@ wctob(wint_t c) return EOF; return (int)c; } + +int +wcscoll(const wchar_t *s1, const wchar_t *s2) +{ + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + return ((unsigned char)(*s1) - (unsigned char)(*--s2)); +} + +size_t +wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n) +{ + if (n == 0) + return wcslen(src); + return wcslcpy(dest, src, n); +} diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index fbdb2500180..de1b423353c 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -major=37 +major=38 minor=0 # note: If changes were made to include/thread_private.h or if system # calls were added/changed then libpthread must also be updated. diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index 1c2639bd036..e02e032bfc7 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.12 2005/05/11 18:39:19 espie Exp $ +# $OpenBSD: Makefile.inc,v 1.13 2005/06/17 20:40:32 espie Exp $ # stdio sources .PATH: ${LIBCSRCDIR}/stdio @@ -14,11 +14,14 @@ SRCS+= asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \ scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c sscanf.c \ stdio.c tempnam.c tmpfile.c tmpnam.c ungetc.c vasprintf.c vfprintf.c \ vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c \ - wbuf.c wsetup.c flockfile.c __svfscanf.c + wbuf.c wsetup.c flockfile.c __svfscanf.c \ + fgetwc.c fgetws.c fputwc.c fputws.c fwide.c getwc.c getwchar.c \ + putwc.c putwchar.c ungetwc.c MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fopen.3 fputs.3 \ fread.3 fseek.3 funopen.3 getc.3 mktemp.3 perror.3 printf.3 putc.3 \ - remove.3 scanf.3 setbuf.3 stdio.3 tmpnam.3 ungetc.3 + remove.3 scanf.3 setbuf.3 stdio.3 tmpnam.3 ungetc.3 \ + fgetws.3 fputws.3 fwide.3 getwc.3 putwc.3 ungetwc.3 MLINKS+=ferror.3 clearerr.3 ferror.3 feof.3 ferror.3 fileno.3 MLINKS+=fflush.3 fpurge.3 @@ -41,3 +44,6 @@ MLINKS+=scanf.3 fscanf.3 scanf.3 sscanf.3 scanf.3 vfscanf.3 scanf.3 vscanf.3 \ scanf.3 vsscanf.3 MLINKS+=setbuf.3 setbuffer.3 setbuf.3 setlinebuf.3 setbuf.3 setvbuf.3 MLINKS+=tmpnam.3 tempnam.3 tmpnam.3 tmpfile.3 + +MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3 +MLINKS+=putwc.3 fputwc.3 putwc.3 putwchar.3 diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c index 604ca412b4a..9ee69664382 100644 --- a/lib/libc/stdio/fclose.c +++ b/lib/libc/stdio/fclose.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fclose.c,v 1.4 2004/09/28 18:12:43 otto Exp $"; +static char rcsid[] = "$OpenBSD: fclose.c,v 1.5 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <errno.h> @@ -48,6 +48,7 @@ fclose(FILE *fp) errno = EBADF; return (EOF); } + WCIO_FREE(fp); r = fp->_flags & __SWR ? __sflush(fp) : 0; if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) r = EOF; diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c index fd7ff2b885b..9aef535baeb 100644 --- a/lib/libc/stdio/fgets.c +++ b/lib/libc/stdio/fgets.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fgets.c,v 1.8 2005/05/28 04:34:05 millert Exp $"; +static char rcsid[] = "$OpenBSD: fgets.c,v 1.9 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -54,6 +54,7 @@ fgets(char *buf, int n, FILE *fp) if (n <= 0) /* sanity check */ return (NULL); + _SET_ORIENTATION(fp, -1); s = buf; n--; /* leave space for NUL */ while (n != 0) { diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c new file mode 100644 index 00000000000..8da50877264 --- /dev/null +++ b/lib/libc/stdio/fgetwc.c @@ -0,0 +1,90 @@ +/* $OpenBSD: fgetwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fgetwc.c,v 1.3 2003/03/07 07:11:36 tshiozak Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <errno.h> +#include <stdio.h> +#include <wchar.h> +#include "local.h" + +wint_t +__fgetwc_unlock(FILE *fp) +{ + struct wchar_io_data *wcio; + mbstate_t *st; + wchar_t wc; + size_t size; + + _SET_ORIENTATION(fp, 1); + wcio = WCIO_GET(fp); + if (wcio == 0) { + errno = ENOMEM; + return WEOF; + } + + /* if there're ungetwc'ed wchars, use them */ + if (wcio->wcio_ungetwc_inbuf) { + wc = wcio->wcio_ungetwc_buf[--wcio->wcio_ungetwc_inbuf]; + + return wc; + } + + st = &wcio->wcio_mbstate_in; + + do { + char c; + int ch = __sgetc(fp); + + if (ch == EOF) { + return WEOF; + } + + c = ch; + size = mbrtowc(&wc, &c, 1, st); + if (size == (size_t)-1) { + errno = EILSEQ; + return WEOF; + } + } while (size == (size_t)-2); + + return wc; +} + +wint_t +fgetwc(FILE *fp) +{ + wint_t r; + + flockfile(fp); + r = __fgetwc_unlock(fp); + funlockfile(fp); + + return (r); +} diff --git a/lib/libc/stdio/fgetws.3 b/lib/libc/stdio/fgetws.3 new file mode 100644 index 00000000000..0162f9c5446 --- /dev/null +++ b/lib/libc/stdio/fgetws.3 @@ -0,0 +1,122 @@ +.\" $NetBSD: fgetws.3,v 1.2 2003/08/07 16:43:23 agc Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)fgets.3 8.1 (Berkeley) 6/4/93 +.\" +.\" Original version ID: +.\" FreeBSD: src/lib/libc/stdio/fgets.3,v 1.16 2002/05/31 05:01:17 archie Exp +.\" FreeBSD: src/lib/libc/stdio/fgetws.3,v 1.2 2002/09/06 11:23:55 tjr Exp +.\" +.Dd August 6, 2002 +.Dt FGETWS 3 +.Os +.Sh NAME +.Nm fgetws +.Nd get a line of wide characters from a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft "wchar_t *" +.Fn fgetws "wchar_t * restrict ws" "int n" "FILE * restrict fp" +.Sh DESCRIPTION +The +.Fn fgetws +function +reads at most one less than the number of characters specified by +.Fa n +from the given +.Fa fp +and stores them in the wide character string +.Fa ws . +Reading stops when a newline character is found, +at end-of-file or error. +The newline, if any, is retained. +If any characters are read and there is no error, a +.Ql \e0 +character is appended to end the string. +.Sh RETURN VALUES +Upon successful completion, +.Fn fgetws +returns +.Fa ws . +If end-of-file occurs before any characters are read, +.Fn fgetws +returns +.Dv NULL +and the buffer contents remain unchanged. +If an error occurs, +.Fn fgetws +returns +.Dv NULL +and the buffer contents are indeterminate. +The +.Fn fgetws +function +does not distinguish between end-of-file and error, and callers must use +.Xr feof 3 +and +.Xr ferror 3 +to determine which occurred. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The given +.Fa fp +argument is not a readable stream. +.It Bq Er EILSEQ +The data obtained from the input stream does not form a valid +multibyte character. +.El +.Pp +The function +.Fn fgetws +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr fflush 3 , +.Xr fstat 2 , +.Xr read 2 , +or +.Xr malloc 3 . +.Sh SEE ALSO +.Xr feof 3 , +.Xr ferror 3 , +.Xr fgets 3 +.Sh STANDARDS +The +.Fn fgetws +function +conforms to +.St -p1003.1-2001 . diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c new file mode 100644 index 00000000000..f70b43707fd --- /dev/null +++ b/lib/libc/stdio/fgetws.c @@ -0,0 +1,86 @@ +/* $OpenBSD: fgetws.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fgetws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */ + +/*- + * Copyright (c) 2002 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Original version ID: + * FreeBSD: src/lib/libc/stdio/fgetws.c,v 1.4 2002/09/20 13:25:40 tjr Exp + * + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: fgetws.c,v 1.1 2005/06/17 20:40:32 espie Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <errno.h> +#include <stdio.h> +#include <wchar.h> +#include "local.h" + +wchar_t * +fgetws(ws, n, fp) + wchar_t * __restrict ws; + int n; + FILE * __restrict fp; +{ + wchar_t *wsp; + wint_t wc; + + flockfile(fp); + _SET_ORIENTATION(fp, 1); + + if (n <= 0) { + errno = EINVAL; + goto error; + } + + wsp = ws; + while (n-- > 1) { + if ((wc = __fgetwc_unlock(fp)) == WEOF && errno == EILSEQ) { + goto error; + } + if (wc == WEOF) { + if (wsp == ws) { + /* EOF/error, no characters read yet. */ + goto error; + } + break; + } + *wsp++ = (wchar_t)wc; + if (wc == L'\n') { + break; + } + } + + *wsp++ = L'\0'; + funlockfile(fp); + + return (ws); + +error: + funlockfile(fp); + return (NULL); +} diff --git a/lib/libc/stdio/fileext.h b/lib/libc/stdio/fileext.h index 5619940c2bc..2d070430248 100644 --- a/lib/libc/stdio/fileext.h +++ b/lib/libc/stdio/fileext.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fileext.h,v 1.1 2005/04/30 09:25:17 espie Exp $ */ +/* $OpenBSD: fileext.h,v 1.2 2005/06/17 20:40:32 espie Exp $ */ /* $NetBSD: fileext.h,v 1.5 2003/07/18 21:46:41 nathanw Exp $ */ /*- @@ -34,9 +34,21 @@ */ struct __sfileext { struct __sbuf _ub; /* ungetc buffer */ - /* further data */ + struct wchar_io_data _wcio; /* wide char io status */ }; #define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) #define _UB(fp) _EXT(fp)->_ub -#define _FILEEXT_SETUP(f, fext) /* LINTED */(f)->_ext._base = (unsigned char *)(fext) + +#define _FILEEXT_INIT(fp) \ +do { \ + _UB(fp)._base = NULL; \ + _UB(fp)._size = 0; \ + WCIO_INIT(fp); \ +} while (0) + +#define _FILEEXT_SETUP(f, fext) \ +do { \ + (f)->_ext._base = (unsigned char *)(fext); \ + _FILEEXT_INIT(f); \ +} while (0) diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index f4de6458146..442a5959e12 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: findfp.c,v 1.6 2005/04/30 09:25:17 espie Exp $"; +static char rcsid[] = "$OpenBSD: findfp.c,v 1.7 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -125,10 +125,9 @@ found: fp->_lbfsize = 0; /* not line buffered */ fp->_file = -1; /* no file */ /* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */ - _UB(fp)._base = NULL; /* no ungetc buffer */ - _UB(fp)._size = 0; fp->_lb._base = NULL; /* no line buffer */ fp->_lb._size = 0; + _FILEEXT_INIT(fp); return (fp); } @@ -172,8 +171,9 @@ __sinit(void) { int i; - for (i = 0; i < FOPEN_MAX - 3; i++) + for (i = 0; i < FOPEN_MAX - 3; i++) { _FILEEXT_SETUP(usual+i, usualext+i); + } /* make sure we clean up on exit */ __atexit_register_cleanup(_cleanup); /* conservative */ __sdidinit = 1; diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c index 1891bb9b491..e928c73b016 100644 --- a/lib/libc/stdio/fpurge.c +++ b/lib/libc/stdio/fpurge.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fpurge.c,v 1.4 2004/09/28 18:12:44 otto Exp $"; +static char rcsid[] = "$OpenBSD: fpurge.c,v 1.5 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <errno.h> @@ -53,6 +53,7 @@ fpurge(FILE *fp) if (HASUB(fp)) FREEUB(fp); + WCIO_FREE(fp); fp->_p = fp->_bf._base; fp->_r = 0; fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c index 99194a68ee6..ffb0df788ba 100644 --- a/lib/libc/stdio/fputs.c +++ b/lib/libc/stdio/fputs.c @@ -31,11 +31,12 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fputs.c,v 1.5 2004/09/28 18:12:44 otto Exp $"; +static char rcsid[] = "$OpenBSD: fputs.c,v 1.6 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> #include <string.h> +#include "local.h" #include "fvwrite.h" /* @@ -51,5 +52,6 @@ fputs(const char *s, FILE *fp) iov.iov_len = uio.uio_resid = strlen(s); uio.uio_iov = &iov; uio.uio_iovcnt = 1; + _SET_ORIENTATION(fp, -1); return (__sfvwrite(fp, &uio)); } diff --git a/lib/libc/stdio/fputwc.c b/lib/libc/stdio/fputwc.c new file mode 100644 index 00000000000..4b54cfa4dd5 --- /dev/null +++ b/lib/libc/stdio/fputwc.c @@ -0,0 +1,88 @@ +/* $OpenBSD: fputwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fputwc.c,v 1.3 2003/03/07 07:11:37 tshiozak Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <wchar.h> +#include "local.h" +#include "fvwrite.h" + +wint_t +__fputwc_unlock(wchar_t wc, FILE *fp) +{ + struct wchar_io_data *wcio; + mbstate_t *st; + size_t size; + char buf[MB_LEN_MAX]; + struct __suio uio; + struct __siov iov; + + /* LINTED we don't play with buf */ + iov.iov_base = (void *)buf; + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + + _SET_ORIENTATION(fp, 1); + wcio = WCIO_GET(fp); + if (wcio == 0) { + errno = ENOMEM; + return WEOF; + } + + wcio->wcio_ungetwc_inbuf = 0; + st = &wcio->wcio_mbstate_out; + + size = wcrtomb(buf, wc, st); + if (size == (size_t)-1) { + errno = EILSEQ; + return WEOF; + } + + uio.uio_resid = iov.iov_len = size; + if (__sfvwrite(fp, &uio)) { + return WEOF; + } + + return (wint_t)wc; +} + +wint_t +fputwc(wchar_t wc, FILE *fp) +{ + wint_t r; + + flockfile(fp); + r = __fputwc_unlock(wc, fp); + funlockfile(fp); + + return (r); +} diff --git a/lib/libc/stdio/fputws.3 b/lib/libc/stdio/fputws.3 new file mode 100644 index 00000000000..b622bf468eb --- /dev/null +++ b/lib/libc/stdio/fputws.3 @@ -0,0 +1,89 @@ +.\" $NetBSD: fputws.3,v 1.2 2003/08/07 16:43:24 agc Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)fputs.3 8.1 (Berkeley) 6/4/93 +.\" +.\" Original version ID: +.\" FreeBSD: src/lib/libc/stdio/fputs.3,v 1.8 2001/10/01 16:08:59 ru Exp +.\" FreeBSD: src/lib/libc/stdio/fputws.c,v 1.4 2002/09/20 13:25:40 tjr Exp +.\" +.Dd August 6, 2002 +.Dt FPUTWS 3 +.Os +.Sh NAME +.Nm fputws +.Nd output a line of wide characters to a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft int +.Fn fputws "const wchar_t * restrict ws" "FILE * restrict fp" +.Sh DESCRIPTION +The +.Fn fputws +function writes the wide character string pointed to by +.Fa ws +to the stream pointed to by +.Fa fp . +.Sh RETURN VALUES +The +.Fn fputws +function +returns 0 on success and \-1 on error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fp +argument supplied +is not a writable stream. +.El +.Pp +The +.Fn fputws +function may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr write 2 . +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fputs 3 , +.Xr putwc 3 , +.Xr stdio 3 +.Sh STANDARDS +The +.Fn fputws +function conforms to +.St -p1003.1-2001 . diff --git a/lib/libc/stdio/fputws.c b/lib/libc/stdio/fputws.c new file mode 100644 index 00000000000..f6aa2366e2a --- /dev/null +++ b/lib/libc/stdio/fputws.c @@ -0,0 +1,60 @@ +/* $OpenBSD: fputws.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */ + +/*- + * Copyright (c) 2002 Tim J. Robbins. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Original version ID: + * FreeBSD: src/lib/libc/stdio/fputws.c,v 1.4 2002/09/20 13:25:40 tjr Exp + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: fputws.c,v 1.1 2005/06/17 20:40:32 espie Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <errno.h> +#include <stdio.h> +#include <wchar.h> +#include "local.h" + +int +fputws(ws, fp) + const wchar_t * __restrict ws; + FILE * __restrict fp; +{ + flockfile(fp); + _SET_ORIENTATION(fp, 1); + + while (*ws != '\0') { + if (__fputwc_unlock(*ws++, fp) == WEOF) { + funlockfile(fp); + return (-1); + } + } + + funlockfile(fp); + + return (0); +} diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c index 0131001bea6..4667332b2d6 100644 --- a/lib/libc/stdio/freopen.c +++ b/lib/libc/stdio/freopen.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: freopen.c,v 1.7 2005/04/30 09:25:17 espie Exp $"; +static char rcsid[] = "$OpenBSD: freopen.c,v 1.8 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -116,6 +116,7 @@ freopen(const char *file, const char *mode, FILE *fp) if (HASUB(fp)) FREEUB(fp); _UB(fp)._size = 0; + WCIO_FREE(fp); if (HASLB(fp)) FREELB(fp); fp->_lb._size = 0; diff --git a/lib/libc/stdio/fwide.3 b/lib/libc/stdio/fwide.3 new file mode 100644 index 00000000000..62bc368c1fc --- /dev/null +++ b/lib/libc/stdio/fwide.3 @@ -0,0 +1,94 @@ +.\" $NetBSD: fwide.3,v 1.6 2003/09/08 17:54:32 wiz Exp $ +.\" +.\" Copyright (c)2001 Citrus Project, +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $Citrus: xpg4dl/FreeBSD/lib/libc/stdio/fwide.3,v 1.2 2001/12/07 04:47:08 yamt Exp $ +.\" +.Dd October 24, 2001 +.Dt FWIDE 3 +.Os +.Sh NAME +.Nm fwide +.Nd get/set orientation of a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft int +.Fn fwide "FILE *stream" "int mode" +.Sh DESCRIPTION +The +.Fn fwide +function +determines the orientation of the stream pointed at by +.Fa stream . +.Pp +If the orientation of +.Fa stream +has already been determined, +.Fn fwide +leaves it unchanged. +Otherwise, +.Fn fwide +sets the orientation of +.Fa stream +according to +.Fa mode . +.Pp +If +.Fa mode +is less than zero, +.Fa stream +is set to byte-oriented. +If it is greater than zero, +.Fa stream +is set to wide-oriented. +Otherwise, +.Fa mode +is zero, and +.Fa stream +is unchanged. +.Sh RETURN VALUES +.Fn fwide +returns a value according to orientation after the call of +.Fn fwide ; +a value less than zero if byte-oriented, a value greater than zero +if wide-oriented, and zero if the stream has no orientation. +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fgetc 3 , +.Xr fgetwc 3 , +.Xr fopen 3 , +.Xr fputc 3 , +.Xr fputwc 3 , +.Xr freopen 3 , +.Xr stdio 3 +.Sh STANDARDS +The +.Fn fwide +function +conforms to +.St -isoC-99 . diff --git a/lib/libc/stdio/fwide.c b/lib/libc/stdio/fwide.c new file mode 100644 index 00000000000..6fd31b0e73e --- /dev/null +++ b/lib/libc/stdio/fwide.c @@ -0,0 +1,64 @@ +/* $OpenBSD: fwide.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: fwide.c,v 1.2 2003/01/18 11:29:54 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <stdio.h> +#include <wchar.h> +#include "local.h" + +int +fwide(FILE *fp, int mode) +{ + struct wchar_io_data *wcio; + + /* + * this implementation use only -1, 0, 1 + * for mode value. + * (we don't need to do this, but + * this can make things simpler.) + */ + if (mode > 0) + mode = 1; + else if (mode < 0) + mode = -1; + + flockfile(fp); + wcio = WCIO_GET(fp); + if (!wcio) + return 0; /* XXX */ + + if (wcio->wcio_mode == 0 && mode != 0) + wcio->wcio_mode = mode; + else + mode = wcio->wcio_mode; + funlockfile(fp); + + return mode; +} diff --git a/lib/libc/stdio/getwc.3 b/lib/libc/stdio/getwc.3 new file mode 100644 index 00000000000..2632aa2ae62 --- /dev/null +++ b/lib/libc/stdio/getwc.3 @@ -0,0 +1,112 @@ +.\" $NetBSD: getwc.3,v 1.7 2003/09/08 17:54:32 wiz Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)getc.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd October 24, 2001 +.Dt GETWC 3 +.Os +.Sh NAME +.Nm fgetwc , +.Nm getwc , +.Nm getwchar , +.Nd get next wide-character from input stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft wint_t +.Fn fgetwc "FILE *stream" +.Ft wint_t +.Fn getwc "FILE *stream" +.Ft wint_t +.Fn getwchar +.Sh DESCRIPTION +The +.Fn fgetwc +function +obtains the next input wide-character (if present) from the stream pointed at by +.Fa stream , +or the next character pushed back on the stream via +.Xr ungetwc 3 . +.Pp +The +.Fn getwc +function +acts essentially identically to +.Fn fgetwc , +but is a macro that expands in-line. +.Pp +The +.Fn getwchar +function +is equivalent to +.Fn getwc +with the argument stdin. +.Sh RETURN VALUES +If successful, these routines return the next wide-character +from the +.Fa stream . +If the stream is at end-of-file or a read error occurs, +the routines return +.Dv WEOF . +The routines +.Xr feof 3 +and +.Xr ferror 3 +must be used to distinguish between end-of-file and error. +If an error occurs, the global variable +.Va errno +is set to indicate the error. +The end-of-file condition is remembered, even on a terminal, and all +subsequent attempts to read will return +.Dv WEOF +until the condition is cleared with +.Xr clearerr 3 . +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fopen 3 , +.Xr fread 3 , +.Xr putwc 3 , +.Xr stdio 3 , +.Xr ungetwc 3 +.Sh STANDARDS +The +.Fn fgetwc , +.Fn getwc +and +.Fn getwchar +functions +conform to +.St -isoC-99 . diff --git a/lib/libc/stdio/getwc.c b/lib/libc/stdio/getwc.c new file mode 100644 index 00000000000..e9bbb7c2421 --- /dev/null +++ b/lib/libc/stdio/getwc.c @@ -0,0 +1,45 @@ +/* $OpenBSD: getwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: getwc.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <stdio.h> +#include <wchar.h> + +/* + * A subroutine version of the macro getwc. + */ +#undef getwc + +wint_t +getwc(FILE *fp) +{ + + return fgetwc(fp); +} diff --git a/lib/libc/stdio/getwchar.c b/lib/libc/stdio/getwchar.c new file mode 100644 index 00000000000..2a112ed8fbe --- /dev/null +++ b/lib/libc/stdio/getwchar.c @@ -0,0 +1,45 @@ +/* $OpenBSD: getwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: getwchar.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <stdio.h> +#include <wchar.h> + +/* + * A subroutine version of the macro getwchar. + */ +#undef getwchar + +wint_t +getwchar() +{ + + return fgetwc(stdin); +} diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index c2e912eae2b..ca3533ece1b 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: local.h,v 1.10 2005/04/30 09:25:17 espie Exp $ */ +/* $OpenBSD: local.h,v 1.11 2005/06/17 20:40:32 espie Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,6 +37,8 @@ * in particular, macros and private variables. */ +#include <wchar.h> +#include "wcio.h" #include "fileext.h" int __sflush(FILE *); diff --git a/lib/libc/stdio/putwc.3 b/lib/libc/stdio/putwc.3 new file mode 100644 index 00000000000..65d1d188727 --- /dev/null +++ b/lib/libc/stdio/putwc.3 @@ -0,0 +1,101 @@ +.\" $NetBSD: putwc.3,v 1.7 2003/09/08 17:54:32 wiz Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)putc.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd October 20, 2001 +.Dt PUTWC 3 +.Os +.Sh NAME +.Nm fputwc , +.Nm putwc , +.Nm putwchar , +.Nd output a wide-character to a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft wint_t +.Fn fputwc "wchar_t wc" "FILE *stream" +.Ft wint_t +.Fn putwc "wchar_t wc" "FILE *stream" +.Ft wint_t +.Fn putwchar "wchar_t wc" +.Sh DESCRIPTION +The +.Fn fputwc +function +writes the wide-character +.Fa wc +to the output stream pointed to by +.Fa stream . +.Pp +.Fn putwc +acts essentially identically to +.Fn fputwc , +but is a macro that expands in-line. +It may evaluate +.Fa stream +more than once, so arguments given to +.Fn putwc +should not be expressions with potential side effects. +.Pp +.Fn putwchar +is identical to +.Fn putwc +with an output stream of +.Em stdout . +.Sh RETURN VALUES +The functions, +.Fn fputwc , +.Fn putwc +and +.Fn putwchar +return the wide-character written. +If an error occurs, the value +.Dv WEOF +is returned. +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fopen 3 , +.Xr getwc 3 , +.Xr stdio 3 +.Sh STANDARDS +The functions +.Fn fputwc , +.Fn putwc , +and +.Fn putwchar , +conform to +.St -isoC-99 . diff --git a/lib/libc/stdio/putwc.c b/lib/libc/stdio/putwc.c new file mode 100644 index 00000000000..8e2ff2dca45 --- /dev/null +++ b/lib/libc/stdio/putwc.c @@ -0,0 +1,45 @@ +/* $OpenBSD: putwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: putwc.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <stdio.h> +#include <wchar.h> + +/* + * A subroutine version of the macro putwc. + */ +#undef putwc + +wint_t +putwc(wchar_t wc, FILE *fp) +{ + + return fputwc(wc, fp); +} diff --git a/lib/libc/stdio/putwchar.c b/lib/libc/stdio/putwchar.c new file mode 100644 index 00000000000..940ec05ab59 --- /dev/null +++ b/lib/libc/stdio/putwchar.c @@ -0,0 +1,45 @@ +/* $OpenBSD: putwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: putwchar.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <stdio.h> +#include <wchar.h> + +/* + * A subroutine version of the macro putwchar. + */ +#undef putwchar + +wint_t +putwchar(wchar_t wc) +{ + + return fputwc(wc, stdout); +} diff --git a/lib/libc/stdio/rget.c b/lib/libc/stdio/rget.c index cc258ba6ca0..ecbb8b80c0b 100644 --- a/lib/libc/stdio/rget.c +++ b/lib/libc/stdio/rget.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rget.c,v 1.5 2004/09/28 18:12:44 otto Exp $"; +static char rcsid[] = "$OpenBSD: rget.c,v 1.6 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -45,6 +45,7 @@ static char rcsid[] = "$OpenBSD: rget.c,v 1.5 2004/09/28 18:12:44 otto Exp $"; int __srget(FILE *fp) { + _SET_ORIENTATION(fp, -1); if (__srefill(fp) == 0) { fp->_r--; return (*fp->_p++); diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c index 34ab32dcf67..3605e77e290 100644 --- a/lib/libc/stdio/setvbuf.c +++ b/lib/libc/stdio/setvbuf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: setvbuf.c,v 1.6 2004/09/28 18:12:44 otto Exp $"; +static char rcsid[] = "$OpenBSD: setvbuf.c,v 1.7 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -68,6 +68,7 @@ setvbuf(FILE *fp, char *buf, int mode, size_t size) (void)__sflush(fp); if (HASUB(fp)) FREEUB(fp); + WCIO_FREE(fp); fp->_r = fp->_lbfsize = 0; flags = fp->_flags; if (flags & __SMBF) diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c index e8fea3ee68c..4c1b8d83d78 100644 --- a/lib/libc/stdio/sscanf.c +++ b/lib/libc/stdio/sscanf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: sscanf.c,v 1.10 2005/05/11 18:39:19 espie Exp $"; +static char rcsid[] = "$OpenBSD: sscanf.c,v 1.11 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -60,7 +60,6 @@ sscanf(const char *str, const char *fmt, ...) f._bf._base = f._p = (unsigned char *)str; f._bf._size = f._r = strlen(str); f._read = eofread; - _UB(&f)._base = NULL; f._lb._base = NULL; va_start(ap, fmt); ret = vfscanf(&f, fmt, ap); diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index dc16a8ad562..579ab2cd90d 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: ungetc.c,v 1.7 2005/04/30 09:25:17 espie Exp $"; +static char rcsid[] = "$OpenBSD: ungetc.c,v 1.8 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -85,6 +85,7 @@ ungetc(int c, FILE *fp) return (EOF); if (!__sdidinit) __sinit(); + _SET_ORIENTATION(fp, -1); if ((fp->_flags & __SRD) == 0) { /* * Not already reading: no good unless reading-and-writing. diff --git a/lib/libc/stdio/ungetwc.3 b/lib/libc/stdio/ungetwc.3 new file mode 100644 index 00000000000..b3194656987 --- /dev/null +++ b/lib/libc/stdio/ungetwc.3 @@ -0,0 +1,95 @@ +.\" $NetBSD: ungetwc.3,v 1.7 2003/09/08 17:54:32 wiz Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)ungetc.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd October 24, 2001 +.Dt UNGETWC 3 +.Os +.Sh NAME +.Nm ungetwc +.Nd un-get wide-character from input stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.In wchar.h +.Ft wint_t +.Fn ungetwc "wint_t wc" "FILE *stream" +.Sh DESCRIPTION +The +.Fn ungetwc +function pushes the wide-character +.Fa wc +(converted to an wchar_t) +back onto the input stream pointed to by +.Fa stream . +The pushed-backed wide-characters will be returned by subsequent reads on the +stream (in reverse order). +A successful intervening call, using the same stream, to one of the file +positioning functions +.Xr fseek 3 , +.Xr fsetpos 3 , +or +.Xr rewind 3 +will discard the pushed back wide-characters. +.Pp +One wide-character of push-back is guaranteed, +but as long as there is +sufficient memory, an effectively infinite amount of pushback is allowed. +.Pp +If a character is successfully pushed-back, +the end-of-file indicator for the stream is cleared. +.Sh RETURN VALUES +The +.Fn ungetwc +function +returns +the wide-character pushed-back after the conversion, or +.Dv WEOF +if the operation fails. +If the value of the argument +.Fa c +character equals +.Dv WEOF , +the operation will fail and the stream will remain unchanged. +.Sh SEE ALSO +.Xr fseek 3 , +.Xr getwc 3 +.Sh STANDARDS +The +.Fn ungetwc +function conforms to +.St -isoC-99 . +.Sh BUGS +The current implementation uses a fixed sized ungetwc-buffer. diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c new file mode 100644 index 00000000000..8bd30168130 --- /dev/null +++ b/lib/libc/stdio/ungetwc.c @@ -0,0 +1,70 @@ +/* $OpenBSD: ungetwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: ungetwc.c,v 1.2 2003/01/18 11:29:59 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#include <errno.h> +#include <stdio.h> +#include <wchar.h> +#include "local.h" + +wint_t +ungetwc(wint_t wc, FILE *fp) +{ + struct wchar_io_data *wcio; + + if (wc == WEOF) + return WEOF; + + flockfile(fp); + _SET_ORIENTATION(fp, 1); + /* + * XXX since we have no way to transform a wchar string to + * a char string in reverse order, we can't use ungetc. + */ + /* XXX should we flush ungetc buffer? */ + + wcio = WCIO_GET(fp); + if (wcio == 0) { + funlockfile(fp); + errno = ENOMEM; /* XXX */ + return WEOF; + } + + if (wcio->wcio_ungetwc_inbuf >= WCIO_UNGETWC_BUFSIZE) { + funlockfile(fp); + return WEOF; + } + + wcio->wcio_ungetwc_buf[wcio->wcio_ungetwc_inbuf++] = wc; + __sclearerr(fp); + funlockfile(fp); + + return wc; +} diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 98bd80096f0..c99c8336efc 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: vfprintf.c,v 1.30 2005/06/08 22:08:30 espie Exp $"; +static char *rcsid = "$OpenBSD: vfprintf.c,v 1.31 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -292,6 +292,7 @@ vfprintf(FILE *fp, const char *fmt0, _BSD_VA_LIST_ ap) (((argtable != NULL) ? (void)(ap = argtable[nextarg]) : (void)0), \ nextarg++, va_arg(ap, type)) + _SET_ORIENTATION(fp, -1); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite(fp)) { errno = EBADF; diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 58a59145033..cf184c6ef3e 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: vfscanf.c,v 1.13 2005/05/28 04:34:05 millert Exp $"; +static char rcsid[] = "$OpenBSD: vfscanf.c,v 1.14 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -113,6 +113,8 @@ VFSCANF(FILE *fp, const char *fmt0, _BSD_VA_LIST_ ap) static short basefix[17] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + _SET_ORIENTATION(fp, -1); + nassigned = 0; nread = 0; base = 0; /* XXX just to keep gcc happy */ diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c index a1585c622a0..7b6040a26b4 100644 --- a/lib/libc/stdio/vsscanf.c +++ b/lib/libc/stdio/vsscanf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: vsscanf.c,v 1.8 2005/05/11 18:39:19 espie Exp $"; +static char rcsid[] = "$OpenBSD: vsscanf.c,v 1.9 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -57,7 +57,6 @@ vsscanf(const char *str, const char *fmt, _BSD_VA_LIST_ ap) f._bf._base = f._p = (unsigned char *)str; f._bf._size = f._r = strlen(str); f._read = eofread; - _UB(&f)._base = NULL; f._lb._base = NULL; return (vfscanf(&f, fmt, ap)); } diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index e099b3d89c6..2f702668a92 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: wbuf.c,v 1.7 2004/09/28 18:12:44 otto Exp $"; +static char rcsid[] = "$OpenBSD: wbuf.c,v 1.8 2005/06/17 20:40:32 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -48,6 +48,7 @@ __swbuf(int c, FILE *fp) { int n; + _SET_ORIENTATION(fp, -1); /* * In case we cannot write, or longjmp takes us out early, * make sure _w is 0 (if fully- or un-buffered) or -_bf._size diff --git a/lib/libc/stdio/wcio.h b/lib/libc/stdio/wcio.h new file mode 100644 index 00000000000..1b41ec971d2 --- /dev/null +++ b/lib/libc/stdio/wcio.h @@ -0,0 +1,81 @@ +/* $OpenBSD: wcio.h,v 1.1 2005/06/17 20:40:32 espie Exp $ */ +/* $NetBSD: wcio.h,v 1.3 2003/01/18 11:30:00 thorpej Exp $ */ + +/*- + * Copyright (c)2001 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Citrus$ + */ + +#ifndef _WCIO_H_ +#define _WCIO_H_ + +/* minimal requirement of SUSv2 */ +#define WCIO_UNGETWC_BUFSIZE 1 + +struct wchar_io_data { + mbstate_t wcio_mbstate_in; + mbstate_t wcio_mbstate_out; + + wchar_t wcio_ungetwc_buf[WCIO_UNGETWC_BUFSIZE]; + size_t wcio_ungetwc_inbuf; + + int wcio_mode; /* orientation */ +}; + +#define WCIO_GET(fp) \ + (_EXT(fp) ? &(_EXT(fp)->_wcio) : (struct wchar_io_data *)0) + +#define _SET_ORIENTATION(fp, mode) \ +do {\ + struct wchar_io_data *_wcio = WCIO_GET(fp); \ + if (_wcio && _wcio->wcio_mode == 0) \ + _wcio->wcio_mode = (mode);\ +} while (0) + +/* + * WCIO_FREE should be called by fclose + */ +#define WCIO_FREE(fp) \ +do {\ + struct wchar_io_data *_wcio = WCIO_GET(fp); \ + if (_wcio) { \ + _wcio->wcio_mode = 0;\ + _wcio->wcio_ungetwc_inbuf = 0;\ + } \ +} while (0) + +#define WCIO_FREEUB(fp) \ +do {\ + struct wchar_io_data *_wcio = WCIO_GET(fp); \ + if (_wcio) { \ + _wcio->wcio_ungetwc_inbuf = 0;\ + } \ +} while (0) + +#define WCIO_INIT(fp) \ + memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data)) + +#endif /*_WCIO_H_*/ |