// Locale support -*- C++ -*-
-// Copyright (C) 2011-2015 Free Software Foundation, Inc.
+// Copyright (C) 2014-2015 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
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Information as gleaned from /usr/include/ctype.h
-
+
const ctype_base::mask*
ctype<char>::classic_table() throw()
- { return 0; }
-
- ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
- size_t __refs)
- : facet(__refs), _M_del(__table != 0 && __del),
- _M_toupper(NULL), _M_tolower(NULL),
- _M_table(__table ? __table : classic_table())
- {
+ { return NULL; }
+
+ ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+ size_t __refs)
+ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
+ {
+ char* __old = setlocale(LC_CTYPE, NULL);
+ char* __sav = NULL;
+ if (strcmp(__old, "C"))
+ {
+ const size_t __len = strlen(__old) + 1;
+ __sav = new char[__len];
+ memcpy(__sav, __old, __len);
+ setlocale(LC_CTYPE, "C");
+ }
+ _M_toupper = NULL;
+ _M_tolower = NULL;
+ _M_table = __table ? __table : classic_table();
+ if (__sav)
+ {
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
+ }
memset(_M_widen, 0, sizeof(_M_widen));
- _M_widen_ok = 0;
memset(_M_narrow, 0, sizeof(_M_narrow));
- _M_narrow_ok = 0;
}
- ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : facet(__refs), _M_del(__table != 0 && __del),
- _M_toupper(NULL), _M_tolower(NULL),
- _M_table(__table ? __table : classic_table())
- {
+ ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
+ : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+ _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
+ {
+ char* __old = setlocale(LC_CTYPE, NULL);
+ char* __sav = NULL;
+ if (strcmp(__old, "C"))
+ {
+ const size_t __len = strlen(__old) + 1;
+ __sav = new char[__len];
+ memcpy(__sav, __old, __len);
+ setlocale(LC_CTYPE, "C");
+ }
+ _M_toupper = NULL;
+ _M_tolower = NULL;
+ _M_table = __table ? __table : classic_table();
+ if (__sav)
+ {
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
+ }
memset(_M_widen, 0, sizeof(_M_widen));
- _M_widen_ok = 0;
memset(_M_narrow, 0, sizeof(_M_narrow));
- _M_narrow_ok = 0;
}
char
ctype<char>::do_tolower(char __c) const
{ return ::tolower((int) __c); }
- const char*
+ const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
enable_clocale_flag=gnu
;;
- darwin* | freebsd*)
+ darwin*)
enable_clocale_flag=darwin
;;
- dragonfly*)
+ dragonfly* | freebsd*)
enable_clocale_flag=dragonfly
;;
openbsd*)
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
;;
darwin)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: darwin or freebsd" >&5
-$as_echo "darwin or freebsd" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: darwin" >&5
+$as_echo "darwin" >&6; }
CLOCALE_H=config/locale/generic/c_locale.h
CLOCALE_CC=config/locale/generic/c_locale.cc
;;
dragonfly)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: dragonfly" >&5
-$as_echo "dragonfly" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: dragonfly or freebsd" >&5
+$as_echo "dragonfly or freebsd" >&6; }
CLOCALE_H=config/locale/dragonfly/c_locale.h
CLOCALE_CC=config/locale/dragonfly/c_locale.cc