<commit_before>/*
 * Copyright (C) 2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

#include <libport/cstdlib>
#include <libport/cerrno>
#include <libport/xlocale.hh>

namespace libport
{
  /*-----------.
  | strto*_c.  |
  `-----------*/

#if LIBPORT_HAVE_XLOCALE_H
  static locale_t cloc = newlocale(LC_CTYPE_MASK, 0, 0);
<commit_msg>Libport.Xlocale: avoid SEGV.<commit_after>/*
 * Copyright (C) 2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

#include <libport/cassert>
#include <libport/cstdlib>
#include <libport/cerrno>
#include <libport/xlocale.hh>

namespace libport
{
  /*-----------.
  | strto*_c.  |
  `-----------*/

#if LIBPORT_HAVE_XLOCALE_H

  static
  locale_t
  get_c_locale()
  {
    // OS X can be given 0 instead of "C", but GNU Libc then returns 0.
    locale_t res = newlocale(LC_CTYPE_MASK, "C", 0);
    if (!res)
      pabort("cannot create C locale: " << strerror(errno));
    return res;
  }

  static locale_t cloc = assert_exp(get_c_locale());

{'fraction_non_alphanumeric': 0.14081486776268765, 'fraction_numerical': 0.009292351679771264, 'mean_word_length': 3.1791044776119404, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1166984', 'n_tokens_mistral': 482, 'n_tokens_neox': 457, 'n_words': 150}