Blame tests/cxx/clocale.c

Packit 5c3484
/* Manipulable localeconv and nl_langinfo.
Packit 5c3484
Packit 5c3484
Copyright 2001, 2002, 2014 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library test suite.
Packit 5c3484
Packit 5c3484
The GNU MP Library test suite is free software; you can redistribute it
Packit 5c3484
and/or modify it under the terms of the GNU General Public License as
Packit 5c3484
published by the Free Software Foundation; either version 3 of the License,
Packit 5c3484
or (at your option) any later version.
Packit 5c3484
Packit 5c3484
The GNU MP Library test suite is distributed in the hope that it will be
Packit 5c3484
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5c3484
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit 5c3484
Public License for more details.
Packit 5c3484
Packit 5c3484
You should have received a copy of the GNU General Public License along with
Packit 5c3484
the GNU MP Library test suite.  If not, see https://www.gnu.org/licenses/.  */
Packit 5c3484
Packit 5c3484
#include "config.h"
Packit 5c3484
Packit 5c3484
#if HAVE_NL_TYPES_H
Packit 5c3484
#include <nl_types.h>  /* for nl_item */
Packit 5c3484
#endif
Packit 5c3484
Packit 5c3484
#if HAVE_LANGINFO_H
Packit 5c3484
#include <langinfo.h>  /* for nl_langinfo */
Packit 5c3484
#endif
Packit 5c3484
Packit 5c3484
#if HAVE_LOCALE_H
Packit 5c3484
#include <locale.h>    /* for lconv */
Packit 5c3484
#endif
Packit 5c3484
Packit 5c3484
Packit 5c3484
/* Replace the libc localeconv and nl_langinfo with ones we can manipulate.
Packit 5c3484
Packit 5c3484
   This is done in a C file since if it was in a C++ file then we'd have to
Packit 5c3484
   match the "throw" or lack thereof declared for localeconv in <locale.h>.
Packit 5c3484
   g++ 3.2 gives an error about mismatched throws under "-pedantic", other
Packit 5c3484
   C++ compilers may very possibly do so too.  */
Packit 5c3484
Packit 5c3484
extern char point_string[];
Packit 5c3484
Packit 5c3484
#if HAVE_LOCALECONV && ! defined __MINGW32__
Packit 5c3484
struct lconv *
Packit 5c3484
localeconv (void)
Packit 5c3484
#if defined __cplusplus && defined __GLIBC__
Packit 5c3484
  throw()
Packit 5c3484
#endif
Packit 5c3484
{
Packit 5c3484
  static struct lconv  l;
Packit 5c3484
  l.decimal_point = point_string;
Packit 5c3484
  return &l;
Packit 5c3484
}
Packit 5c3484
#endif
Packit 5c3484
Packit 5c3484
#if HAVE_NL_LANGINFO
Packit 5c3484
char *
Packit 5c3484
nl_langinfo (nl_item n)
Packit 5c3484
#if defined __cplusplus && defined __GLIBC__
Packit 5c3484
  throw()
Packit 5c3484
#endif
Packit 5c3484
{
Packit 5c3484
  return point_string;
Packit 5c3484
}
Packit 5c3484
#endif