⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 200-uclibc-locale.patch

📁 最新的文件系统生成工具
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+		     _Tv __v, const __c_locale&, int __prec = -1)+    {+# ifdef __UCLIBC_HAS_LOCALE__+      char* __old = setlocale(LC_ALL, NULL);+      char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));+      if (__sav)+        strcpy(__sav, __old);+      setlocale(LC_ALL, "C");+# endif+#endif++      int __ret;+      if (__prec >= 0)+        __ret = snprintf(__out, __size, __fmt, __prec, __v);+      else+        __ret = snprintf(__out, __size, __fmt, __v);++#ifdef __UCLIBC_HAS_XLOCALE__+      __gnu_cxx::__uselocale(__old);+#elif defined __UCLIBC_HAS_LOCALE__+      setlocale(LC_ALL, __sav);+      free(__sav);+#endif+      return __ret;+    }+}++#endifdiff -urN gcc-3.3.2/libstdc++-v3/config/locale/uclibc/codecvt_members.cc gcc-3.3.2-uClibc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc--- gcc-3.3.2/libstdc++-v3/config/locale/uclibc/codecvt_members.cc	1969-12-31 18:00:00.000000000 -0600+++ gcc-3.3.2-uClibc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc	2004-01-09 04:04:34.000000000 -0600@@ -0,0 +1,113 @@+// std::codecvt implementation details, GNU version -*- C++ -*-++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.+//+// This file is part of the GNU ISO C++ Library.  This library is free+// software; you can redistribute it and/or modify it under the+// 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: 22.2.1.5 - Template class codecvt+//++// Written by Benjamin Kosnik <bkoz@redhat.com>++#include <locale>+#include <bits/c++locale_internal.h>++namespace std+{+  // Specializations.+#ifdef _GLIBCPP_USE_WCHAR_T+  codecvt_base::result+  codecvt<wchar_t, char, mbstate_t>::+  do_out(state_type& __state, const intern_type* __from, +	 const intern_type* __from_end, const intern_type*& __from_next,+	 extern_type* __to, extern_type* __to_end,+	 extern_type*& __to_next) const+  {+    result __ret = error;+    size_t __len = min(__from_end - __from, __to_end - __to);+#ifdef __UCLIBC_HAS_XLOCALE__+    __c_locale __old = __uselocale(_S_c_locale);+#endif+    size_t __conv = wcsrtombs(__to, &__from, __len, &__state);+#ifdef __UCLIBC_HAS_XLOCALE__+    __uselocale(__old);+#endif++    if (__conv == __len)+      {+	__from_next = __from;+	__to_next = __to + __conv;+	__ret = ok;+      }+    else if (__conv > 0 && __conv < __len)+      {+	__from_next = __from;+	__to_next = __to + __conv;+	__ret = partial;+      }+    else+      __ret = error;+	+    return __ret; +  }+  +  codecvt_base::result+  codecvt<wchar_t, char, mbstate_t>::+  do_in(state_type& __state, const extern_type* __from, +	const extern_type* __from_end, const extern_type*& __from_next,+	intern_type* __to, intern_type* __to_end,+	intern_type*& __to_next) const+  {+    result __ret = error;+    size_t __len = min(__from_end - __from, __to_end - __to);+#ifdef __UCLIBC_HAS_XLOCALE__+    __c_locale __old = __uselocale(_S_c_locale);+#endif+    size_t __conv = mbsrtowcs(__to, &__from, __len, &__state);+#ifdef __UCLIBC_HAS_XLOCALE__+    __uselocale(__old);+#endif++    if (__conv == __len)+      {+	__from_next = __from;+	__to_next = __to + __conv;+	__ret = ok;+      }+    else if (__conv > 0 && __conv < __len)+      {+	__from_next = __from;+	__to_next = __to + __conv;+	__ret = partial;+      }+    else+      __ret = error;+	+    return __ret; +  }+#endif+}diff -urN gcc-3.3.2/libstdc++-v3/config/locale/uclibc/codecvt_specializations.h gcc-3.3.2-uClibc/libstdc++-v3/config/locale/uclibc/codecvt_specializations.h--- gcc-3.3.2/libstdc++-v3/config/locale/uclibc/codecvt_specializations.h	1969-12-31 18:00:00.000000000 -0600+++ gcc-3.3.2-uClibc/libstdc++-v3/config/locale/uclibc/codecvt_specializations.h	2004-01-09 01:53:51.000000000 -0600@@ -0,0 +1,461 @@+// Locale support (codecvt) -*- C++ -*-++// Copyright (C) 2000, 2001, 2002 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: 22.2.1.5 Template class codecvt+//++// Warning: this file is not meant for user inclusion.  Use <locale>.++// Written by Benjamin Kosnik <bkoz@cygnus.com>++  // XXX+  // Define this here to codecvt.cc can have _S_max_size definition.+#define _GLIBCPP_USE___ENC_TRAITS 1++  // Extension to use icov for dealing with character encodings,+  // including conversions and comparisons between various character+  // sets.  This object encapsulates data that may need to be shared between+  // char_traits, codecvt and ctype.+  class __enc_traits+  {+  public:+    // Types: +    // NB: A conversion descriptor subsumes and enhances the+    // functionality of a simple state type such as mbstate_t.+    typedef iconv_t	__desc_type;+    +  protected:+    // Data Members:+    // Max size of charset encoding name+    static const int 	_S_max_size = 32;+    // Name of internal character set encoding.+    char	       	_M_int_enc[_S_max_size];+    // Name of external character set encoding.+    char  	       	_M_ext_enc[_S_max_size];++    // Conversion descriptor between external encoding to internal encoding.+    __desc_type		_M_in_desc;+    // Conversion descriptor between internal encoding to external encoding.+    __desc_type		_M_out_desc;++    // Details the byte-order marker for the external encoding, if necessary.+    int			_M_ext_bom;++    // Details the byte-order marker for the internal encoding, if necessary.+    int			_M_int_bom;++  public:+    explicit __enc_traits() +    : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0) +    {+      memset(_M_int_enc, 0, _S_max_size);+      memset(_M_ext_enc, 0, _S_max_size);+    }++    explicit __enc_traits(const char* __int, const char* __ext, +			  int __ibom = 0, int __ebom = 0)+    : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0)+    {+      strncpy(_M_int_enc, __int, _S_max_size);+      strncpy(_M_ext_enc, __ext, _S_max_size);+    }++    // 21.1.2 traits typedefs+    // p4+    // typedef STATE_T state_type+    // requires: state_type shall meet the requirements of+    // CopyConstructible types (20.1.3)+    __enc_traits(const __enc_traits& __obj): _M_in_desc(0), _M_out_desc(0)+    {+      strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size);+      strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size);+      _M_ext_bom = __obj._M_ext_bom;+      _M_int_bom = __obj._M_int_bom;+    }++    // Need assignment operator as well.+    __enc_traits&+    operator=(const __enc_traits& __obj)+    {+      strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size);+      strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size);+      _M_in_desc = 0;+      _M_out_desc = 0;+      _M_ext_bom = __obj._M_ext_bom;+      _M_int_bom = __obj._M_int_bom;+      return *this;+    }++    ~__enc_traits()+    {+      __desc_type __err = reinterpret_cast<iconv_t>(-1);+      if (_M_in_desc && _M_in_desc != __err) +	iconv_close(_M_in_desc);+      if (_M_out_desc && _M_out_desc != __err) +	iconv_close(_M_out_desc);+    } ++    void+    _M_init()+    {+      const __desc_type __err = reinterpret_cast<iconv_t>(-1);+      if (!_M_in_desc)+	{+	  _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);+	  if (_M_in_desc == __err)+	    __throw_runtime_error("creating iconv input descriptor failed.");+	}+      if (!_M_out_desc)+	{+	  _M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);+	  if (_M_out_desc == __err)+	    __throw_runtime_error("creating iconv output descriptor failed.");+	}+    }++    bool+    _M_good()+    { +      const __desc_type __err = reinterpret_cast<iconv_t>(-1);+      bool __test = _M_in_desc && _M_in_desc != __err; +      __test &=  _M_out_desc && _M_out_desc != __err;+      return __test;+    }++    const __desc_type* +    _M_get_in_descriptor()+    { return &_M_in_desc; }++    const __desc_type* +    _M_get_out_descriptor()+    { return &_M_out_desc; }++    int +    _M_get_external_bom()+    { return _M_ext_bom; }++    int +    _M_get_internal_bom()+    { return _M_int_bom; }++    const char* +    _M_get_internal_enc()+    { return _M_int_enc; }++    const char* +    _M_get_external_enc()+    { return _M_ext_enc; }+  };++  // Partial specialization+  // This specialization takes advantage of iconv to provide code+  // conversions between a large number of character encodings.+  template<typename _InternT, typename _ExternT>+    class codecvt<_InternT, _ExternT, __enc_traits>+    : public __codecvt_abstract_base<_InternT, _ExternT, __enc_traits>+    {+    public:      +      // Types:+      typedef codecvt_base::result			result;+      typedef _InternT 					intern_type;+      typedef _ExternT 					extern_type;+      typedef __enc_traits 				state_type;+      typedef __enc_traits::__desc_type 		__desc_type;+      typedef __enc_traits				__enc_type;++      // Data Members:+      static locale::id 		id;++      explicit +      codecvt(size_t __refs = 0)+      : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)+      { }++      explicit +      codecvt(__enc_type* __enc, size_t __refs = 0)+      : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)+      { }++    protected:+      virtual +      ~codecvt() { }++      virtual result+      do_out(state_type& __state, const intern_type* __from, +	     const intern_type* __from_end, const intern_type*& __from_next,+	     extern_type* __to, extern_type* __to_end,+	     extern_type*& __to_next) const;++      virtual result+      do_unshift(state_type& __state, extern_type* __to, +		 extern_type* __to_end, extern_type*& __to_next) const;++      virtual result+      do_in(state_type& __state, const extern_type* __from, +	    const extern_type* __from_end, const extern_type*& __from_next,+	    intern_type* __to, intern_type* __to_end, +	    intern_type*& __to_next) const;++      virtual int +      do_encoding() const throw();++      virtual bool +      do_always_noconv() const throw();++      virtual int +      do_length(const state_type&, const extern_type* __from, +		const extern_type* __end, size_t __max) const;++      virtual int +      do_max_length() const throw();+    };++  template<typename _InternT, typename _ExternT>+    locale::id +    codecvt<_InternT, _ExternT, __enc_traits>::id;++  // This adaptor works around the signature problems of the second+  // argument to iconv():  SUSv2 and others use 'const char**', but glibc 2.2+  // uses 'char**', which matches the POSIX 1003.1-2001 standard.+  // Using this adaptor, g++ will do the work for us.+  template<typename _T>+    inline size_t+    __iconv_adaptor(size_t(*__func)(iconv_t, _T, size_t*, char**, size_t*),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -