Configure tsocks with a simple heuristic.
Consider the proxy has to be in a 'local' network. It means it is directly
reachable by the local machine, even if the local machine has to hop through
one or more gates to reach the proxy (often the case in enterprise networks
where class A 10.0.0.0/8 is in fact sub-divided into smaller networks, each
one of them in a different location, eg. 10.1.0.0/16 in a place, while
10.2.0.0/16 would be on the other side of the world). Not being in the same
subnet does not mean the proxy is not available.
So we will build a mask with at most high bits set, which defines a network
that has both the local machine and the proxy. Because a machine may have
more than one interface, build a mask for each of them, removing 127.0.0.1
which is added automagically by tsocks, and removing duplicate masks.
If all of this does not work, then it means the local machine can NOT in fact
reach the proxy, which in turn means the user mis-configured something (most
probably a typo...).
/trunk/scripts/crosstool.sh | 61 52 9 0 +++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 9 deletions(-)
1 --- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
2 +++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
4 __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
5 const __c_locale& __cloc)
7 - if (!(__err & ios_base::failbit))
11 - float __f = __strtof_l(__s, &__sanity, __cloc);
12 - if (__sanity != __s && errno != ERANGE)
15 - __err |= ios_base::failbit;
19 + float __f = __strtof_l(__s, &__sanity, __cloc);
20 + if (__sanity != __s && errno != ERANGE)
23 + __err |= ios_base::failbit;
28 __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
29 const __c_locale& __cloc)
31 - if (!(__err & ios_base::failbit))
35 - double __d = __strtod_l(__s, &__sanity, __cloc);
36 - if (__sanity != __s && errno != ERANGE)
39 - __err |= ios_base::failbit;
43 + double __d = __strtod_l(__s, &__sanity, __cloc);
44 + if (__sanity != __s && errno != ERANGE)
47 + __err |= ios_base::failbit;
52 __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
53 const __c_locale& __cloc)
55 - if (!(__err & ios_base::failbit))
59 - long double __ld = __strtold_l(__s, &__sanity, __cloc);
60 - if (__sanity != __s && errno != ERANGE)
63 - __err |= ios_base::failbit;
67 + long double __ld = __strtold_l(__s, &__sanity, __cloc);
68 + if (__sanity != __s && errno != ERANGE)
71 + __err |= ios_base::failbit;
77 locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
79 - if (_S_get_c_locale() != __cloc)
80 + if (__cloc && _S_get_c_locale() != __cloc)
84 --- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
85 +++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
88 // Written by Benjamin Kosnik <bkoz@redhat.com>
90 +#include <features.h>
91 +#ifdef __UCLIBC_HAS_LOCALE__
98 #include <bits/c++locale_internal.h>
101 @@ -138,20 +143,34 @@
103 do_is(mask __m, wchar_t __c) const
105 - // Highest bitmask in ctype_base == 10, but extra in "C"
106 - // library for blank.
107 + // The case of __m == ctype_base::space is particularly important,
108 + // due to its use in many istream functions. Therefore we deal with
109 + // it first, exploiting the knowledge that on GNU systems _M_bit[5]
110 + // is the mask corresponding to ctype_base::space. NB: an encoding
111 + // change would not affect correctness!
113 - const size_t __bitmasksize = 11;
114 - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
115 - if (__m & _M_bit[__bitcur]
116 - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
121 + if (__m == _M_bit[5])
122 + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
125 + // Highest bitmask in ctype_base == 10, but extra in "C"
126 + // library for blank.
127 + const size_t __bitmasksize = 11;
128 + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
129 + if (__m & _M_bit[__bitcur])
131 + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
136 + else if (__m == _M_bit[__bitcur])
146 do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
147 --- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
148 +++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
150 template<typename _CharT>
151 messages<_CharT>::messages(size_t __refs)
152 : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
153 - _M_name_messages(_S_get_c_name())
154 + _M_name_messages(_S_get_c_name())
157 template<typename _CharT>
158 messages<_CharT>::messages(__c_locale __cloc, const char* __s,
160 - : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
161 - _M_name_messages(__s)
162 + : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
164 - char* __tmp = new char[std::strlen(__s) + 1];
165 - std::strcpy(__tmp, __s);
166 + const size_t __len = std::strlen(__s) + 1;
167 + char* __tmp = new char[__len];
168 + std::memcpy(__tmp, __s, __len);
169 _M_name_messages = __tmp;
171 + // Last to avoid leaking memory if new throws.
172 + _M_c_locale_messages = _S_clone_c_locale(__cloc);
175 template<typename _CharT>
176 --- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
177 +++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
180 // Written by Benjamin Kosnik <bkoz@redhat.com>
182 +#include <features.h>
183 +#ifdef __UCLIBC_HAS_LOCALE__
190 #include <bits/c++locale_internal.h>
192 #ifdef __UCLIBC_MJN3_ONLY__
202 --- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
203 +++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
206 // Written by Benjamin Kosnik <bkoz@redhat.com>
208 +#include <features.h>
209 +#ifdef __UCLIBC_HAS_LOCALE__
216 #include <bits/c++locale_internal.h>
218 #ifdef __UCLIBC_MJN3_ONLY__
219 --- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
220 +++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
222 template<typename _CharT>
223 __timepunct<_CharT>::__timepunct(size_t __refs)
224 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
225 - _M_name_timepunct(_S_get_c_name())
226 + _M_name_timepunct(_S_get_c_name())
227 { _M_initialize_timepunct(); }
229 template<typename _CharT>
230 __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
231 : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
232 - _M_name_timepunct(_S_get_c_name())
233 + _M_name_timepunct(_S_get_c_name())
234 { _M_initialize_timepunct(); }
236 template<typename _CharT>
237 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
239 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
240 - _M_name_timepunct(__s)
241 + _M_name_timepunct(NULL)
243 - char* __tmp = new char[std::strlen(__s) + 1];
244 - std::strcpy(__tmp, __s);
245 + const size_t __len = std::strlen(__s) + 1;
246 + char* __tmp = new char[__len];
247 + std::memcpy(__tmp, __s, __len);
248 _M_name_timepunct = __tmp;
249 - _M_initialize_timepunct(__cloc);
252 + { _M_initialize_timepunct(__cloc); }
255 + delete [] _M_name_timepunct;
256 + __throw_exception_again;
260 template<typename _CharT>
261 --- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
262 +++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
264 #pragma GCC system_header
266 #include <cstring> // get std::strlen
267 -#include <cstdio> // get std::snprintf or std::sprintf
268 +#include <cstdio> // get std::vsnprintf or std::vsprintf
270 #include <langinfo.h> // For codecvt
271 #ifdef __UCLIBC_MJN3_ONLY__
274 -#ifdef __UCLIBC_HAS_LOCALE__
275 +#ifdef _GLIBCXX_USE_ICONV
276 #include <iconv.h> // For codecvt using iconv, iconv_t
278 -#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
279 -#include <libintl.h> // For messages
280 +#ifdef HAVE_LIBINTL_H
281 +#include <libintl.h> // For messages
285 #ifdef __UCLIBC_MJN3_ONLY__
286 #warning what is _GLIBCXX_C_LOCALE_GNU for
287 +// psm: used in os/gnu-linux/ctype_noninline.h
289 #define _GLIBCXX_C_LOCALE_GNU 1
293 // #define _GLIBCXX_NUM_CATEGORIES 6
294 #define _GLIBCXX_NUM_CATEGORIES 0
297 #ifdef __UCLIBC_HAS_XLOCALE__
301 typedef int* __c_locale;
304 - // Convert numeric value of type _Tv to string and return length of
305 - // string. If snprintf is available use it, otherwise fall back to
306 - // the unsafe sprintf which, in general, can be dangerous and should
307 + // Convert numeric value of type double to string and return length of
308 + // string. If vsnprintf is available use it, otherwise fall back to
309 + // the unsafe vsprintf which, in general, can be dangerous and should
311 - template<typename _Tv>
313 - __convert_from_v(char* __out,
314 - const int __size __attribute__ ((__unused__)),
316 -#ifdef __UCLIBC_HAS_XCLOCALE__
317 - _Tv __v, const __c_locale& __cloc, int __prec)
319 + __convert_from_v(const __c_locale&
320 +#ifndef __UCLIBC_HAS_XCLOCALE__
321 + __cloc __attribute__ ((__unused__))
326 + const char* __fmt, ...)
329 +#ifdef __UCLIBC_HAS_XCLOCALE__
330 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
332 - _Tv __v, const __c_locale&, int __prec)
334 # ifdef __UCLIBC_HAS_LOCALE__
335 char* __old = std::setlocale(LC_ALL, NULL);
336 char* __sav = new char[std::strlen(__old) + 1];
341 - const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
342 + va_start(__args, __fmt);
343 + const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
346 #ifdef __UCLIBC_HAS_XCLOCALE__
347 __gnu_cxx::__uselocale(__old);