Subject: C locale and _C_ctype_ question
To: None <tech-userlevel@netbsd.org>
From: Krister Walfridsson <cato@df.lth.se>
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
implementation:

  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();
#else
    __ret = __ctype_b;
#endif
    setlocale(LC_CTYPE, __old);
    free(__old);
    return __ret;
  }

   /Krister