]> git.pld-linux.org Git - packages/gcc.git/blob - gcc32-locale_in_ctype_members_header.patch
- massive attack: adding Source-md5
[packages/gcc.git] / gcc32-locale_in_ctype_members_header.patch
1 From gcc-patches-return-67562-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org Fri Sep 06 14:44:59 2002
2 Return-Path: <gcc-patches-return-67562-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org>
3 Delivered-To: listarch-gcc-patches at gcc dot gnu dot org
4 Received: (qmail 31503 invoked by alias); 6 Sep 2002 14:44:56 -0000
5 Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm
6 Precedence: bulk
7 List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>
8 List-Post: <mailto:gcc-patches at gcc dot gnu dot org>
9 List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org>
10 Sender: gcc-patches-owner at gcc dot gnu dot org
11 Delivered-To: mailing list gcc-patches at gcc dot gnu dot org
12 Received: (qmail 31479 invoked from network); 6 Sep 2002 14:44:52 -0000
13 Received: from unknown (HELO devserv.devel.redhat.com) (66.187.233.200)
14   by sources dot redhat dot com with SMTP; 6 Sep 2002 14:44:52 -0000
15 Received: (from jakub@localhost)
16         by devserv dot devel dot redhat dot com (8 dot 11 dot 6/8 dot 11 dot 0) id g86EioP06755;
17         Fri, 6 Sep 2002 10:44:50 -0400
18 Date: Fri, 6 Sep 2002 10:44:50 -0400
19 From: Jakub Jelinek <jakub at redhat dot com>
20 To: Benjamin Kosnik <bkoz at redhat dot com>
21 Cc: bkoz at nabi dot net, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
22 Subject: [PATCH] Fix libstdc++ usage of __ctype_b/__ctype_to* (take 2)
23 Message-ID: <20020906104449.C7920@devserv.devel.redhat.com>
24 Reply-To: Jakub Jelinek <jakub at redhat dot com>
25 References: <20020901040933.I7886@dhcp187.sf.frob.com> <20020901095711.C7920@devserv.devel.redhat.com> <20020901102055.A5791@devserv.devel.redhat.com> <3D724B9A.6050908@redhat.com> <20020901145657.E7920@devserv.devel.redhat.com> <3D726A72.2080106@redhat.com> <20020901165440.F7920@devserv.devel.redhat.com> <20020904160557.7dbc29f6.bkoz@nabi.net> <20020905041710.P7920@devserv.devel.redhat.com> <20020905103148.7c1381a2.bkoz@redhat.com>
26 Mime-Version: 1.0
27 Content-Type: text/plain; charset=us-ascii
28 Content-Disposition: inline
29 User-Agent: Mutt/1.2.5.1i
30 In-Reply-To: <20020905103148 dot 7c1381a2 dot bkoz at redhat dot com>; from bkoz at redhat dot com on Thu, Sep 05, 2002 at 10:31:48AM -0500
31
32 On Thu, Sep 05, 2002 at 10:31:48AM -0500, Benjamin Kosnik wrote:
33 > > Most probably yes, but as it is a static method I wanted to be sure.
34 > > Should I leave it in?
35
36 > Sure.
37
38 > > > Just remove all this _GLIBCPP_USE_SHADOW_HEADERS cruft.
39 > > 
40 > > You mean the using lines too?
41
42 > Yep.
43
44 > > BTW: This will have the effect that --enable-clocale=generic will no longer
45 > > work with glibc 2.3+. Although for everything but checking the generic
46 > > clocale gnu it makes no sense to use anything but --enable-clocale=gnu
47 > > with glibc 2.3+, we might as well consider using:
48 > > 
49 > > #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
50 > >     __ret = *__ctype_b_loc();
51 > > #else
52 > >     __ret = __ctype_b;
53 > > #endif
54 > > here (and similarly with __ctype_tolower and __ctype_toupper).
55
56 > Sounds good.
57
58 Ok, here is an updated version of the patch.
59 Ok to commit (head, branch)?
60
61 2002-09-06  Jakub Jelinek  <jakub@redhat.com>
62
63         * config/os/gnu-linux/bits/ctype_noninline.h
64         [_GLIBCPP_USE_SHADOW_HEADERS]: Remove using _C_legacy::__ctype_*.
65         (ctype<char>::classic_table): If _GLIBCPP_C_LOCALE_GNU, return
66         _S_c_locale->__ctype_b, otherwise temporarily switch to "C" locale
67         and return __ctype_b.
68         (ctype<char>::ctype(__c_locale, const mask*, bool, size_t)): If not
69         _GLIBCPP_C_LOCALE_GNU, temporarily switch to "C" locale and
70         initialize using __ctype_{b,tolower,toupper}.
71         (ctype<char>::ctype(const mask*, bool, size_t)): If
72         _GLIBCPP_C_LOCALE_GNU, initialize using
73         _S_c_locale->__ctype_{b,tolower,toupper}, otherwise temporarily
74         switch to "C" locale and initialize using __ctype_{b,tolower,toupper}.
75
76 --- libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h.jj  2002-09-03 11:54:25.000000000 +0200
77 +++ libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h     2002-09-06 10:34:59.000000000 +0200
78 @@ -34,16 +34,32 @@
79    
80  // Information as gleaned from /usr/include/ctype.h
81  
82 -#if _GLIBCPP_USE_SHADOW_HEADERS
83 -  using _C_legacy::__ctype_toupper;
84 -  using _C_legacy::__ctype_tolower;
85 -  using _C_legacy::__ctype_b;
86 -#endif
87 -
88 +#if _GLIBCPP_C_LOCALE_GNU
89    const ctype_base::mask*
90    ctype<char>::classic_table() throw()
91 -  { return __ctype_b; }  
92 -  
93 +  {
94 +    if (!_S_c_locale)
95 +      _S_create_c_locale(_S_c_locale, "C");
96 +    return _S_c_locale->__ctype_b;
97 +  }
98 +#else
99 +  const ctype_base::mask*
100 +  ctype<char>::classic_table() throw()
101 +  {
102 +    const ctype_base::mask* __ret;
103 +    char* __old = strdup(setlocale(LC_CTYPE, NULL));
104 +    setlocale(LC_CTYPE, "C");
105 +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
106 +    __ret = *__ctype_b_loc();
107 +#else
108 +    __ret = __ctype_b;
109 +#endif
110 +    setlocale(LC_CTYPE, __old);
111 +    free(__old);
112 +    return __ret;
113 +  }
114 +#endif
115 +
116  #if _GLIBCPP_C_LOCALE_GNU
117    ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del, 
118                      size_t __refs) 
119 @@ -57,17 +73,55 @@
120  #else
121    ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
122                      size_t __refs) 
123 -  : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), 
124 -  _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
125 -  _M_table(__table ? __table : classic_table())
126 -  { _M_c_locale_ctype = _S_c_locale; }
127 +  : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
128 +  {
129 +    char* __old=strdup(setlocale(LC_CTYPE, NULL));
130 +    setlocale(LC_CTYPE, "C");
131 +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
132 +    _M_toupper = *__ctype_toupper_loc();
133 +    _M_tolower = *__ctype_tolower_loc();
134 +    _M_table = __table ? __table : *__ctype_b_loc();
135 +#else
136 +    _M_toupper = __ctype_toupper;
137 +    _M_tolower = __ctype_tolower;
138 +    _M_table = __table ? __table : __ctype_b;
139 +#endif
140 +    setlocale(LC_CTYPE, __old);
141 +    free(__old);
142 +    _M_c_locale_ctype = _S_c_locale;
143 +  }
144  #endif
145  
146 +#if _GLIBCPP_C_LOCALE_GNU
147    ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : 
148 -  __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), 
149 -  _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
150 -  _M_table(__table ? __table : classic_table())
151 -  { _M_c_locale_ctype = _S_c_locale; }
152 +  __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
153 +  {
154 +    _M_c_locale_ctype = _S_c_locale;
155 +    _M_toupper = _M_c_locale_ctype->__ctype_toupper;
156 +    _M_tolower = _M_c_locale_ctype->__ctype_tolower;
157 +    _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b;
158 +  }
159 +#else
160 +  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
161 +                    size_t __refs) 
162 +  : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
163 +  {
164 +    char* __old=strdup(setlocale(LC_CTYPE, NULL));
165 +    setlocale(LC_CTYPE, "C");
166 +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
167 +    _M_toupper = *__ctype_toupper_loc();
168 +    _M_tolower = *__ctype_tolower_loc();
169 +    _M_table = __table ? __table : *__ctype_b_loc();
170 +#else
171 +    _M_toupper = __ctype_toupper;
172 +    _M_tolower = __ctype_tolower;
173 +    _M_table = __table ? __table : __ctype_b;
174 +#endif
175 +    setlocale(LC_CTYPE, __old);
176 +    free(__old);
177 +    _M_c_locale_ctype = _S_c_locale;
178 +  }
179 +#endif
180  
181    char
182    ctype<char>::do_toupper(char __c) const
183
184
185         Jakub
186
This page took 0.056479 seconds and 3 git commands to generate.