Subject: C locale and _C_ctype_ question
To: None <>
From: Krister Walfridsson <>
List: tech-userlevel
Date: 05/12/2003 23:17:26
I'm currently fixing some minor things in the gcc-current libstdc++.

The C++ library has a method for returning a pointer to the "C" locale
table. This is currently implemented in libstdc++ as

   return _ctype_ + 1;

which is not correct if the locale has been changed.

Is it OK to use the (normally NetBSD private) _C_ctype_ for this
functionality, or do I need to do something similar to the Linux

  const ctype_base::mask*
  ctype<char>::classic_table() throw()
    const ctype_base::mask* __ret;
    char* __old = strdup(setlocale(LC_CTYPE, NULL));
    setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
    __ret = *__ctype_b_loc();
    __ret = __ctype_b;
    setlocale(LC_CTYPE, __old);
    return __ret;