gnulib: Add modules argmatch and isatty.
* lib/argmatch.c, lib/argmatch.h, lib/c-ctype.c, lib/c-ctype.h, lib/config.charset, lib/c-strcasecmp.c, lib/c-strcaseeq.h, lib/c-strcase.h, lib/c-strncasecmp.c, lib/exitfail.c, lib/exitfail.h, lib/isatty.c, lib/localcharset.c, lib/localcharset.h, lib/mbrtowc.c, lib/mbsinit.c, lib/quotearg.c, lib/quotearg.h, lib/quote.h, lib/ref-add.sin, lib/ref-del.sin, lib/streq.h, lib/wctype-h.c, lib/wctype.in.h, lib/xalloc-die.c, lib/xalloc.h, lib/xalloc-oversized.h, lib/xmalloc.c, m4/codeset.m4, m4/configmake.m4, m4/glibc21.m4, m4/isatty.m4, m4/localcharset.m4, m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4, m4/mbrtowc.m4, m4/mbsinit.m4, m4/mbstate_t.m4, m4/quotearg.m4, m4/quote.m4, m4/wctype_h.m4, m4/xalloc.m4: New files. * lib/Makefile.am, m4/gnulib-cache.m4, m4/gnulib-comp.m4: Update.
This commit is contained in:
parent
542050bab4
commit
35129e5a5a
46 changed files with 7818 additions and 2 deletions
23
m4/codeset.m4
Normal file
23
m4/codeset.m4
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# codeset.m4 serial 5 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
AC_DEFUN([AM_LANGINFO_CODESET],
|
||||
[
|
||||
AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <langinfo.h>]],
|
||||
[[char* cs = nl_langinfo(CODESET); return !cs;]])],
|
||||
[am_cv_langinfo_codeset=yes],
|
||||
[am_cv_langinfo_codeset=no])
|
||||
])
|
||||
if test $am_cv_langinfo_codeset = yes; then
|
||||
AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
|
||||
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
|
||||
fi
|
||||
])
|
||||
50
m4/configmake.m4
Normal file
50
m4/configmake.m4
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# configmake.m4 serial 1
|
||||
dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# gl_CONFIGMAKE_PREP
|
||||
# ------------------
|
||||
# Guarantee all of the standard directory variables, even when used with
|
||||
# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
|
||||
# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
|
||||
AC_DEFUN([gl_CONFIGMAKE_PREP],
|
||||
[
|
||||
dnl Technically, datadir should default to datarootdir. But if
|
||||
dnl autoconf is too old to provide datarootdir, then reversing the
|
||||
dnl definition is a reasonable compromise. Only AC_SUBST a variable
|
||||
dnl if it was not already defined earlier by autoconf.
|
||||
if test "x$datarootdir" = x; then
|
||||
AC_SUBST([datarootdir], ['${datadir}'])
|
||||
fi
|
||||
dnl Copy the approach used in autoconf 2.60.
|
||||
if test "x$docdir" = x; then
|
||||
AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
|
||||
['${datarootdir}/doc/${PACKAGE_TARNAME}'],
|
||||
['${datarootdir}/doc/${PACKAGE}'])])
|
||||
fi
|
||||
dnl The remaining variables missing from autoconf 2.59 are easier.
|
||||
if test "x$htmldir" = x; then
|
||||
AC_SUBST([htmldir], ['${docdir}'])
|
||||
fi
|
||||
if test "x$dvidir" = x; then
|
||||
AC_SUBST([dvidir], ['${docdir}'])
|
||||
fi
|
||||
if test "x$pdfdir" = x; then
|
||||
AC_SUBST([pdfdir], ['${docdir}'])
|
||||
fi
|
||||
if test "x$psdir" = x; then
|
||||
AC_SUBST([psdir], ['${docdir}'])
|
||||
fi
|
||||
if test "x$lispdir" = x; then
|
||||
AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
|
||||
fi
|
||||
if test "x$localedir" = x; then
|
||||
AC_SUBST([localedir], ['${datarootdir}/locale'])
|
||||
fi
|
||||
|
||||
dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
|
||||
dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
|
||||
AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
|
||||
])
|
||||
34
m4/glibc21.m4
Normal file
34
m4/glibc21.m4
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# glibc21.m4 serial 5
|
||||
dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
|
||||
dnl Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# Test for the GNU C Library, version 2.1 or newer, or uClibc.
|
||||
# From Bruno Haible.
|
||||
|
||||
AC_DEFUN([gl_GLIBC21],
|
||||
[
|
||||
AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
|
||||
[ac_cv_gnu_library_2_1],
|
||||
[AC_EGREP_CPP([Lucky],
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
|
||||
Lucky GNU user
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __UCLIBC__
|
||||
Lucky user
|
||||
#endif
|
||||
],
|
||||
[ac_cv_gnu_library_2_1=yes],
|
||||
[ac_cv_gnu_library_2_1=no])
|
||||
]
|
||||
)
|
||||
AC_SUBST([GLIBC21])
|
||||
GLIBC21="$ac_cv_gnu_library_2_1"
|
||||
]
|
||||
)
|
||||
|
|
@ -27,14 +27,16 @@
|
|||
|
||||
|
||||
# Specification in the form of a command-line invocation:
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=tools --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files argp error gethrxtime mkstemp progname sys_wait
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=tools --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files argmatch argp error gethrxtime isatty mkstemp progname sys_wait
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
gl_MODULES([
|
||||
argmatch
|
||||
argp
|
||||
error
|
||||
gethrxtime
|
||||
isatty
|
||||
mkstemp
|
||||
progname
|
||||
sys_wait
|
||||
|
|
|
|||
|
|
@ -40,13 +40,19 @@ AC_DEFUN([gl_EARLY],
|
|||
AC_REQUIRE([gl_PROG_AR_RANLIB])
|
||||
# Code from module alloca:
|
||||
# Code from module alloca-opt:
|
||||
# Code from module argmatch:
|
||||
# Code from module argp:
|
||||
# Code from module c-ctype:
|
||||
# Code from module c-strcase:
|
||||
# Code from module c-strcaseeq:
|
||||
# Code from module clock-time:
|
||||
# Code from module configmake:
|
||||
# Code from module dirname-lgpl:
|
||||
# Code from module dosname:
|
||||
# Code from module double-slash-root:
|
||||
# Code from module errno:
|
||||
# Code from module error:
|
||||
# Code from module exitfail:
|
||||
# Code from module extensions:
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
# Code from module extern-inline:
|
||||
|
|
@ -60,11 +66,15 @@ AC_DEFUN([gl_EARLY],
|
|||
# Code from module gettimeofday:
|
||||
# Code from module include_next:
|
||||
# Code from module intprops:
|
||||
# Code from module isatty:
|
||||
# Code from module largefile:
|
||||
AC_REQUIRE([AC_SYS_LARGEFILE])
|
||||
# Code from module localcharset:
|
||||
# Code from module lstat:
|
||||
# Code from module malloc-gnu:
|
||||
# Code from module malloc-posix:
|
||||
# Code from module mbrtowc:
|
||||
# Code from module mbsinit:
|
||||
# Code from module memchr:
|
||||
# Code from module mempcpy:
|
||||
# Code from module mkstemp:
|
||||
|
|
@ -74,6 +84,9 @@ AC_DEFUN([gl_EARLY],
|
|||
# Code from module nocrash:
|
||||
# Code from module pathmax:
|
||||
# Code from module progname:
|
||||
# Code from module quote:
|
||||
# Code from module quotearg:
|
||||
# Code from module quotearg-simple:
|
||||
# Code from module rawmemchr:
|
||||
# Code from module secure_getenv:
|
||||
# Code from module size_max:
|
||||
|
|
@ -92,6 +105,7 @@ AC_DEFUN([gl_EARLY],
|
|||
# Code from module stdlib:
|
||||
# Code from module strcase:
|
||||
# Code from module strchrnul:
|
||||
# Code from module streq:
|
||||
# Code from module strerror:
|
||||
# Code from module strerror-override:
|
||||
# Code from module string:
|
||||
|
|
@ -111,6 +125,10 @@ AC_DEFUN([gl_EARLY],
|
|||
# Code from module verify:
|
||||
# Code from module vsnprintf:
|
||||
# Code from module wchar:
|
||||
# Code from module wctype-h:
|
||||
# Code from module xalloc:
|
||||
# Code from module xalloc-die:
|
||||
# Code from module xalloc-oversized:
|
||||
# Code from module xsize:
|
||||
])
|
||||
|
||||
|
|
@ -138,6 +156,7 @@ AC_SUBST([LTALLOCA])
|
|||
[AM_][XGETTEXT_OPTION([--flag=argp_error:2:c-format])
|
||||
AM_][XGETTEXT_OPTION([--flag=argp_failure:4:c-format])])
|
||||
gl_CLOCK_TIME
|
||||
gl_CONFIGMAKE_PREP
|
||||
gl_DIRNAME_LGPL
|
||||
gl_DOUBLE_SLASH_ROOT
|
||||
gl_HEADER_ERRNO_H
|
||||
|
|
@ -187,7 +206,16 @@ AC_SUBST([LTALLOCA])
|
|||
gl_PREREQ_GETTIMEOFDAY
|
||||
fi
|
||||
gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
|
||||
gl_FUNC_ISATTY
|
||||
if test $REPLACE_ISATTY = 1; then
|
||||
AC_LIBOBJ([isatty])
|
||||
gl_PREREQ_ISATTY
|
||||
fi
|
||||
gl_UNISTD_MODULE_INDICATOR([isatty])
|
||||
AC_REQUIRE([gl_LARGEFILE])
|
||||
gl_LOCALCHARSET
|
||||
LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\""
|
||||
AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
|
||||
gl_FUNC_LSTAT
|
||||
if test $REPLACE_LSTAT = 1; then
|
||||
AC_LIBOBJ([lstat])
|
||||
|
|
@ -204,6 +232,18 @@ AC_SUBST([LTALLOCA])
|
|||
AC_LIBOBJ([malloc])
|
||||
fi
|
||||
gl_STDLIB_MODULE_INDICATOR([malloc-posix])
|
||||
gl_FUNC_MBRTOWC
|
||||
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
|
||||
AC_LIBOBJ([mbrtowc])
|
||||
gl_PREREQ_MBRTOWC
|
||||
fi
|
||||
gl_WCHAR_MODULE_INDICATOR([mbrtowc])
|
||||
gl_FUNC_MBSINIT
|
||||
if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
|
||||
AC_LIBOBJ([mbsinit])
|
||||
gl_PREREQ_MBSINIT
|
||||
fi
|
||||
gl_WCHAR_MODULE_INDICATOR([mbsinit])
|
||||
gl_FUNC_MEMCHR
|
||||
if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
|
||||
AC_LIBOBJ([memchr])
|
||||
|
|
@ -234,6 +274,8 @@ AC_SUBST([LTALLOCA])
|
|||
gl_PATHMAX
|
||||
AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
|
||||
AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
|
||||
gl_QUOTE
|
||||
gl_QUOTEARG
|
||||
gl_FUNC_RAWMEMCHR
|
||||
if test $HAVE_RAWMEMCHR = 0; then
|
||||
AC_LIBOBJ([rawmemchr])
|
||||
|
|
@ -322,6 +364,8 @@ AC_SUBST([LTALLOCA])
|
|||
gl_FUNC_VSNPRINTF
|
||||
gl_STDIO_MODULE_INDICATOR([vsnprintf])
|
||||
gl_WCHAR_H
|
||||
gl_WCTYPE_H
|
||||
gl_XALLOC
|
||||
gl_XSIZE
|
||||
# End of code from modules
|
||||
m4_ifval(gl_LIBSOURCES_LIST, [
|
||||
|
|
@ -465,6 +509,8 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
build-aux/snippet/warn-on-use.h
|
||||
lib/alloca.c
|
||||
lib/alloca.in.h
|
||||
lib/argmatch.c
|
||||
lib/argmatch.h
|
||||
lib/argp-ba.c
|
||||
lib/argp-eexst.c
|
||||
lib/argp-fmtstream.c
|
||||
|
|
@ -480,12 +526,21 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/argp.h
|
||||
lib/asnprintf.c
|
||||
lib/basename-lgpl.c
|
||||
lib/c-ctype.c
|
||||
lib/c-ctype.h
|
||||
lib/c-strcase.h
|
||||
lib/c-strcasecmp.c
|
||||
lib/c-strcaseeq.h
|
||||
lib/c-strncasecmp.c
|
||||
lib/config.charset
|
||||
lib/dirname-lgpl.c
|
||||
lib/dirname.h
|
||||
lib/dosname.h
|
||||
lib/errno.in.h
|
||||
lib/error.c
|
||||
lib/error.h
|
||||
lib/exitfail.c
|
||||
lib/exitfail.h
|
||||
lib/fcntl.in.h
|
||||
lib/float+.h
|
||||
lib/float.c
|
||||
|
|
@ -500,9 +555,14 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/gettime.c
|
||||
lib/gettimeofday.c
|
||||
lib/intprops.h
|
||||
lib/isatty.c
|
||||
lib/itold.c
|
||||
lib/localcharset.c
|
||||
lib/localcharset.h
|
||||
lib/lstat.c
|
||||
lib/malloc.c
|
||||
lib/mbrtowc.c
|
||||
lib/mbsinit.c
|
||||
lib/memchr.c
|
||||
lib/memchr.valgrind
|
||||
lib/mempcpy.c
|
||||
|
|
@ -518,8 +578,13 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/printf-parse.h
|
||||
lib/progname.c
|
||||
lib/progname.h
|
||||
lib/quote.h
|
||||
lib/quotearg.c
|
||||
lib/quotearg.h
|
||||
lib/rawmemchr.c
|
||||
lib/rawmemchr.valgrind
|
||||
lib/ref-add.sin
|
||||
lib/ref-del.sin
|
||||
lib/secure_getenv.c
|
||||
lib/size_max.h
|
||||
lib/sleep.c
|
||||
|
|
@ -533,6 +598,7 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/strcasecmp.c
|
||||
lib/strchrnul.c
|
||||
lib/strchrnul.valgrind
|
||||
lib/streq.h
|
||||
lib/strerror-override.c
|
||||
lib/strerror-override.h
|
||||
lib/strerror.c
|
||||
|
|
@ -559,6 +625,12 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/verify.h
|
||||
lib/vsnprintf.c
|
||||
lib/wchar.in.h
|
||||
lib/wctype-h.c
|
||||
lib/wctype.in.h
|
||||
lib/xalloc-die.c
|
||||
lib/xalloc-oversized.h
|
||||
lib/xalloc.h
|
||||
lib/xmalloc.c
|
||||
lib/xsize.c
|
||||
lib/xsize.h
|
||||
lib/xtime.c
|
||||
|
|
@ -567,6 +639,8 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/alloca.m4
|
||||
m4/argp.m4
|
||||
m4/clock_time.m4
|
||||
m4/codeset.m4
|
||||
m4/configmake.m4
|
||||
m4/dirname.m4
|
||||
m4/double-slash-root.m4
|
||||
m4/errno_h.m4
|
||||
|
|
@ -581,15 +655,24 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/getopt.m4
|
||||
m4/gettime.m4
|
||||
m4/gettimeofday.m4
|
||||
m4/glibc21.m4
|
||||
m4/gnulib-common.m4
|
||||
m4/include_next.m4
|
||||
m4/intmax_t.m4
|
||||
m4/inttypes_h.m4
|
||||
m4/isatty.m4
|
||||
m4/largefile.m4
|
||||
m4/localcharset.m4
|
||||
m4/locale-fr.m4
|
||||
m4/locale-ja.m4
|
||||
m4/locale-zh.m4
|
||||
m4/longlong.m4
|
||||
m4/lstat.m4
|
||||
m4/malloc.m4
|
||||
m4/math_h.m4
|
||||
m4/mbrtowc.m4
|
||||
m4/mbsinit.m4
|
||||
m4/mbstate_t.m4
|
||||
m4/memchr.m4
|
||||
m4/mempcpy.m4
|
||||
m4/mkstemp.m4
|
||||
|
|
@ -601,6 +684,8 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/off_t.m4
|
||||
m4/pathmax.m4
|
||||
m4/printf.m4
|
||||
m4/quote.m4
|
||||
m4/quotearg.m4
|
||||
m4/rawmemchr.m4
|
||||
m4/secure_getenv.m4
|
||||
m4/size_max.m4
|
||||
|
|
@ -636,6 +721,8 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/warn-on-use.m4
|
||||
m4/wchar_h.m4
|
||||
m4/wchar_t.m4
|
||||
m4/wctype_h.m4
|
||||
m4/wint_t.m4
|
||||
m4/xalloc.m4
|
||||
m4/xsize.m4
|
||||
])
|
||||
|
|
|
|||
19
m4/isatty.m4
Normal file
19
m4/isatty.m4
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# isatty.m4 serial 3
|
||||
dnl Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_ISATTY],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
dnl On native Windows, the system's isatty(), defined as an alias of _isatty()
|
||||
dnl in the "oldnames" library, returns true for the NUL device.
|
||||
case $host_os in
|
||||
mingw*) REPLACE_ISATTY=1 ;;
|
||||
esac
|
||||
])
|
||||
|
||||
# Prerequisites of lib/isatty.c.
|
||||
AC_DEFUN([gl_PREREQ_ISATTY], [:])
|
||||
17
m4/localcharset.m4
Normal file
17
m4/localcharset.m4
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# localcharset.m4 serial 7
|
||||
dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_LOCALCHARSET],
|
||||
[
|
||||
dnl Prerequisites of lib/localcharset.c.
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
AC_REQUIRE([gl_FCNTL_O_FLAGS])
|
||||
AC_CHECK_DECLS_ONCE([getc_unlocked])
|
||||
|
||||
dnl Prerequisites of the lib/Makefile.am snippet.
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([gl_GLIBC21])
|
||||
])
|
||||
250
m4/locale-fr.m4
Normal file
250
m4/locale-fr.m4
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
# locale-fr.m4 serial 17
|
||||
dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
dnl Determine the name of a french locale with traditional encoding.
|
||||
AC_DEFUN([gt_LOCALE_FR],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
|
||||
AC_LANG_CONFTEST([AC_LANG_SOURCE([
|
||||
changequote(,)dnl
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
struct tm t;
|
||||
char buf[16];
|
||||
int main () {
|
||||
/* Check whether the given locale name is recognized by the system. */
|
||||
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
|
||||
/* On native Windows, setlocale(category, "") looks at the system settings,
|
||||
not at the environment variables. Also, when an encoding suffix such
|
||||
as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
|
||||
category of the locale to "C". */
|
||||
if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
|
||||
|| strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
|
||||
return 1;
|
||||
#else
|
||||
if (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
|
||||
is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
|
||||
On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "646". In this situation,
|
||||
some unit tests fail.
|
||||
On MirBSD 10, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "UTF-8". */
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
{
|
||||
const char *cs = nl_langinfo (CODESET);
|
||||
if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
|
||||
|| strcmp (cs, "UTF-8") == 0)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
/* On Cygwin, avoid locale names without encoding suffix, because the
|
||||
locale_charset() function relies on the encoding suffix. Note that
|
||||
LC_ALL is set on the command line. */
|
||||
if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether in the abbreviation of the second month, the second
|
||||
character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
|
||||
one byte long. This excludes the UTF-8 encoding. */
|
||||
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
|
||||
if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
|
||||
#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
|
||||
/* Check whether the decimal separator is a comma.
|
||||
On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
|
||||
are nl_langinfo(RADIXCHAR) are both ".". */
|
||||
if (localeconv () ->decimal_point[0] != ',') return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
case "$host_os" in
|
||||
# Handle native Windows specially, because there setlocale() interprets
|
||||
# "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
|
||||
# "fr" or "fra" as "French" or "French_France.1252",
|
||||
# "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
|
||||
# "ja" as "Japanese" or "Japanese_Japan.932",
|
||||
# and similar.
|
||||
mingw*)
|
||||
# Test for the native Windows locale name.
|
||||
if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=French_France.1252
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_fr=none
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
|
||||
# configure script would override the LC_ALL setting. Likewise for
|
||||
# LC_CTYPE, which is also set at the beginning of the configure script.
|
||||
# Test for the usual locale name.
|
||||
if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=fr_FR
|
||||
else
|
||||
# Test for the locale name with explicit encoding suffix.
|
||||
if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=fr_FR.ISO-8859-1
|
||||
else
|
||||
# Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
|
||||
if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=fr_FR.ISO8859-1
|
||||
else
|
||||
# Test for the HP-UX locale name.
|
||||
if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=fr_FR.iso88591
|
||||
else
|
||||
# Test for the Solaris 7 locale name.
|
||||
if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr=fr
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_fr=none
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -fr conftest*
|
||||
])
|
||||
LOCALE_FR=$gt_cv_locale_fr
|
||||
AC_SUBST([LOCALE_FR])
|
||||
])
|
||||
|
||||
dnl Determine the name of a french locale with UTF-8 encoding.
|
||||
AC_DEFUN([gt_LOCALE_FR_UTF8],
|
||||
[
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
|
||||
AC_LANG_CONFTEST([AC_LANG_SOURCE([
|
||||
changequote(,)dnl
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
struct tm t;
|
||||
char buf[16];
|
||||
int main () {
|
||||
/* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
|
||||
imitates locale dependent behaviour by looking at the environment
|
||||
variables, and all locales use the UTF-8 encoding. */
|
||||
#if !(defined __BEOS__ || defined __HAIKU__)
|
||||
/* Check whether the given locale name is recognized by the system. */
|
||||
# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
|
||||
/* On native Windows, setlocale(category, "") looks at the system settings,
|
||||
not at the environment variables. Also, when an encoding suffix such
|
||||
as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
|
||||
category of the locale to "C". */
|
||||
if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
|
||||
|| strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
|
||||
return 1;
|
||||
# else
|
||||
if (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
# endif
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
|
||||
is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
|
||||
On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "646". In this situation,
|
||||
some unit tests fail. */
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
{
|
||||
const char *cs = nl_langinfo (CODESET);
|
||||
if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
# ifdef __CYGWIN__
|
||||
/* On Cygwin, avoid locale names without encoding suffix, because the
|
||||
locale_charset() function relies on the encoding suffix. Note that
|
||||
LC_ALL is set on the command line. */
|
||||
if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
|
||||
# endif
|
||||
/* Check whether in the abbreviation of the second month, the second
|
||||
character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
|
||||
two bytes long, with UTF-8 encoding. */
|
||||
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
|
||||
if (strftime (buf, sizeof (buf), "%b", &t) < 4
|
||||
|| buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
|
||||
return 1;
|
||||
#endif
|
||||
#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
|
||||
/* Check whether the decimal separator is a comma.
|
||||
On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
|
||||
are nl_langinfo(RADIXCHAR) are both ".". */
|
||||
if (localeconv () ->decimal_point[0] != ',') return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
case "$host_os" in
|
||||
# Handle native Windows specially, because there setlocale() interprets
|
||||
# "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
|
||||
# "fr" or "fra" as "French" or "French_France.1252",
|
||||
# "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
|
||||
# "ja" as "Japanese" or "Japanese_Japan.932",
|
||||
# and similar.
|
||||
mingw*)
|
||||
# Test for the hypothetical native Windows locale name.
|
||||
if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr_utf8=French_France.65001
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_fr_utf8=none
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
|
||||
# configure script would override the LC_ALL setting. Likewise for
|
||||
# LC_CTYPE, which is also set at the beginning of the configure script.
|
||||
# Test for the usual locale name.
|
||||
if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr_utf8=fr_FR
|
||||
else
|
||||
# Test for the locale name with explicit encoding suffix.
|
||||
if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr_utf8=fr_FR.UTF-8
|
||||
else
|
||||
# Test for the Solaris 7 locale name.
|
||||
if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_fr_utf8=fr.UTF-8
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_fr_utf8=none
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -fr conftest*
|
||||
])
|
||||
LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
|
||||
AC_SUBST([LOCALE_FR_UTF8])
|
||||
])
|
||||
136
m4/locale-ja.m4
Normal file
136
m4/locale-ja.m4
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
# locale-ja.m4 serial 12
|
||||
dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
dnl Determine the name of a japanese locale with EUC-JP encoding.
|
||||
AC_DEFUN([gt_LOCALE_JA],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
|
||||
AC_LANG_CONFTEST([AC_LANG_SOURCE([
|
||||
changequote(,)dnl
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
struct tm t;
|
||||
char buf[16];
|
||||
int main ()
|
||||
{
|
||||
const char *p;
|
||||
/* Check whether the given locale name is recognized by the system. */
|
||||
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
|
||||
/* On native Windows, setlocale(category, "") looks at the system settings,
|
||||
not at the environment variables. Also, when an encoding suffix such
|
||||
as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
|
||||
category of the locale to "C". */
|
||||
if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
|
||||
|| strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
|
||||
return 1;
|
||||
#else
|
||||
if (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
|
||||
is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
|
||||
On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "646". In this situation,
|
||||
some unit tests fail.
|
||||
On MirBSD 10, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "UTF-8". */
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
{
|
||||
const char *cs = nl_langinfo (CODESET);
|
||||
if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
|
||||
|| strcmp (cs, "UTF-8") == 0)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
/* On Cygwin, avoid locale names without encoding suffix, because the
|
||||
locale_charset() function relies on the encoding suffix. Note that
|
||||
LC_ALL is set on the command line. */
|
||||
if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
|
||||
on Cygwin 1.5.x. */
|
||||
if (MB_CUR_MAX == 1)
|
||||
return 1;
|
||||
/* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
|
||||
This excludes the UTF-8 encoding (except on MirBSD). */
|
||||
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
|
||||
if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
|
||||
for (p = buf; *p != '\0'; p++)
|
||||
if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
case "$host_os" in
|
||||
# Handle native Windows specially, because there setlocale() interprets
|
||||
# "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
|
||||
# "fr" or "fra" as "French" or "French_France.1252",
|
||||
# "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
|
||||
# "ja" as "Japanese" or "Japanese_Japan.932",
|
||||
# and similar.
|
||||
mingw*)
|
||||
# Note that on native Windows, the Japanese locale is
|
||||
# Japanese_Japan.932, and CP932 is very different from EUC-JP, so we
|
||||
# cannot use it here.
|
||||
gt_cv_locale_ja=none
|
||||
;;
|
||||
*)
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
|
||||
# configure script would override the LC_ALL setting. Likewise for
|
||||
# LC_CTYPE, which is also set at the beginning of the configure script.
|
||||
# Test for the AIX locale name.
|
||||
if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_ja=ja_JP
|
||||
else
|
||||
# Test for the locale name with explicit encoding suffix.
|
||||
if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_ja=ja_JP.EUC-JP
|
||||
else
|
||||
# Test for the HP-UX, OSF/1, NetBSD locale name.
|
||||
if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_ja=ja_JP.eucJP
|
||||
else
|
||||
# Test for the IRIX, FreeBSD locale name.
|
||||
if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_ja=ja_JP.EUC
|
||||
else
|
||||
# Test for the Solaris 7 locale name.
|
||||
if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_ja=ja
|
||||
else
|
||||
# Special test for NetBSD 1.6.
|
||||
if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
|
||||
gt_cv_locale_ja=ja_JP.eucJP
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_ja=none
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -fr conftest*
|
||||
])
|
||||
LOCALE_JA=$gt_cv_locale_ja
|
||||
AC_SUBST([LOCALE_JA])
|
||||
])
|
||||
130
m4/locale-zh.m4
Normal file
130
m4/locale-zh.m4
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# locale-zh.m4 serial 12
|
||||
dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
dnl Determine the name of a chinese locale with GB18030 encoding.
|
||||
AC_DEFUN([gt_LOCALE_ZH_CN],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
|
||||
AC_LANG_CONFTEST([AC_LANG_SOURCE([
|
||||
changequote(,)dnl
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
struct tm t;
|
||||
char buf[16];
|
||||
int main ()
|
||||
{
|
||||
const char *p;
|
||||
/* Check whether the given locale name is recognized by the system. */
|
||||
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
|
||||
/* On native Windows, setlocale(category, "") looks at the system settings,
|
||||
not at the environment variables. Also, when an encoding suffix such
|
||||
as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
|
||||
category of the locale to "C". */
|
||||
if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
|
||||
|| strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
|
||||
return 1;
|
||||
#else
|
||||
if (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
|
||||
is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
|
||||
On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "646". In this situation,
|
||||
some unit tests fail.
|
||||
On MirBSD 10, when an unsupported locale is specified, setlocale()
|
||||
succeeds but then nl_langinfo(CODESET) is "UTF-8". */
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
{
|
||||
const char *cs = nl_langinfo (CODESET);
|
||||
if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
|
||||
|| strcmp (cs, "UTF-8") == 0)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
/* On Cygwin, avoid locale names without encoding suffix, because the
|
||||
locale_charset() function relies on the encoding suffix. Note that
|
||||
LC_ALL is set on the command line. */
|
||||
if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
|
||||
#endif
|
||||
/* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
|
||||
This excludes the UTF-8 encoding (except on MirBSD). */
|
||||
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
|
||||
if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
|
||||
for (p = buf; *p != '\0'; p++)
|
||||
if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
|
||||
return 1;
|
||||
/* Check whether a typical GB18030 multibyte sequence is recognized as a
|
||||
single wide character. This excludes the GB2312 and GBK encodings. */
|
||||
if (mblen ("\203\062\332\066", 5) != 4)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
case "$host_os" in
|
||||
# Handle native Windows specially, because there setlocale() interprets
|
||||
# "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
|
||||
# "fr" or "fra" as "French" or "French_France.1252",
|
||||
# "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
|
||||
# "ja" as "Japanese" or "Japanese_Japan.932",
|
||||
# and similar.
|
||||
mingw*)
|
||||
# Test for the hypothetical native Windows locale name.
|
||||
if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_zh_CN=Chinese_China.54936
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_zh_CN=none
|
||||
fi
|
||||
;;
|
||||
solaris2.8)
|
||||
# On Solaris 8, the locales zh_CN.GB18030, zh_CN.GBK, zh.GBK are
|
||||
# broken. One witness is the test case in gl_MBRTOWC_SANITYCHECK.
|
||||
# Another witness is that "LC_ALL=zh_CN.GB18030 bash -c true" dumps core.
|
||||
gt_cv_locale_zh_CN=none
|
||||
;;
|
||||
*)
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
|
||||
# configure script would override the LC_ALL setting. Likewise for
|
||||
# LC_CTYPE, which is also set at the beginning of the configure script.
|
||||
# Test for the locale name without encoding suffix.
|
||||
if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_zh_CN=zh_CN
|
||||
else
|
||||
# Test for the locale name with explicit encoding suffix.
|
||||
if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
|
||||
gt_cv_locale_zh_CN=zh_CN.GB18030
|
||||
else
|
||||
# None found.
|
||||
gt_cv_locale_zh_CN=none
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# If there was a link error, due to mblen(), the system is so old that
|
||||
# it certainly doesn't have a chinese locale.
|
||||
gt_cv_locale_zh_CN=none
|
||||
fi
|
||||
rm -fr conftest*
|
||||
])
|
||||
LOCALE_ZH_CN=$gt_cv_locale_zh_CN
|
||||
AC_SUBST([LOCALE_ZH_CN])
|
||||
])
|
||||
572
m4/mbrtowc.m4
Normal file
572
m4/mbrtowc.m4
Normal file
|
|
@ -0,0 +1,572 @@
|
|||
# mbrtowc.m4 serial 25
|
||||
dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation,
|
||||
dnl Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_MBRTOWC],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
gl_MBSTATE_T_BROKEN
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([mbrtowc])
|
||||
if test $ac_cv_func_mbrtowc = no; then
|
||||
HAVE_MBRTOWC=0
|
||||
AC_CHECK_DECLS([mbrtowc],,, [[
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
]])
|
||||
if test $ac_cv_have_decl_mbrtowc = yes; then
|
||||
dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
|
||||
dnl it does not have the function. Avoid a collision with gnulib's
|
||||
dnl replacement.
|
||||
REPLACE_MBRTOWC=1
|
||||
fi
|
||||
else
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
REPLACE_MBRTOWC=1
|
||||
else
|
||||
gl_MBRTOWC_NULL_ARG1
|
||||
gl_MBRTOWC_NULL_ARG2
|
||||
gl_MBRTOWC_RETVAL
|
||||
gl_MBRTOWC_NUL_RETVAL
|
||||
case "$gl_cv_func_mbrtowc_null_arg1" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
|
||||
[Define if the mbrtowc function has the NULL pwc argument bug.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_null_arg2" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
|
||||
[Define if the mbrtowc function has the NULL string argument bug.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_retval" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
|
||||
[Define if the mbrtowc function returns a wrong return value.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_nul_retval" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
|
||||
[Define if the mbrtowc function does not return 0 for a NUL character.])
|
||||
REPLACE_MBRTOWC=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
|
||||
dnl redefines the semantics of the given mbstate_t type.
|
||||
dnl Result is REPLACE_MBSTATE_T.
|
||||
dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
|
||||
dnl avoid inconsistencies.
|
||||
|
||||
AC_DEFUN([gl_MBSTATE_T_BROKEN],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
AC_CHECK_FUNCS_ONCE([mbsinit])
|
||||
AC_CHECK_FUNCS_ONCE([mbrtowc])
|
||||
if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
|
||||
gl_MBRTOWC_INCOMPLETE_STATE
|
||||
gl_MBRTOWC_SANITYCHECK
|
||||
REPLACE_MBSTATE_T=0
|
||||
case "$gl_cv_func_mbrtowc_incomplete_state" in
|
||||
*yes) ;;
|
||||
*) REPLACE_MBSTATE_T=1 ;;
|
||||
esac
|
||||
case "$gl_cv_func_mbrtowc_sanitycheck" in
|
||||
*yes) ;;
|
||||
*) REPLACE_MBSTATE_T=1 ;;
|
||||
esac
|
||||
else
|
||||
REPLACE_MBSTATE_T=1
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc puts the state into non-initial state when parsing an
|
||||
dnl incomplete multibyte character.
|
||||
dnl Result is gl_cv_func_mbrtowc_incomplete_state.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_JA])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
|
||||
[gl_cv_func_mbrtowc_incomplete_state],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on AIX and OSF/1.
|
||||
aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_JA != none; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
|
||||
{
|
||||
const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
if (mbsinit (&state))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_incomplete_state=yes],
|
||||
[gl_cv_func_mbrtowc_incomplete_state=no],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc works not worse than mbtowc.
|
||||
dnl Result is gl_cv_func_mbrtowc_sanitycheck.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_ZH_CN])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
|
||||
[gl_cv_func_mbrtowc_sanitycheck],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Solaris 8.
|
||||
solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_ZH_CN != none; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris 8:
|
||||
mbrtowc returns 2, and sets wc to 0x00F0.
|
||||
mbtowc returns 4 (correct) and sets wc to 0x5EDC. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
|
||||
{
|
||||
char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 3, 6, &state) != 4
|
||||
&& mbtowc (&wc, input + 3, 6) == 4)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_sanitycheck=yes],
|
||||
[gl_cv_func_mbrtowc_sanitycheck=no],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc supports a NULL pwc argument correctly.
|
||||
dnl Result is gl_cv_func_mbrtowc_null_arg1.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
|
||||
[gl_cv_func_mbrtowc_null_arg1],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Solaris.
|
||||
solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
char input[] = "\303\237er";
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
size_t ret;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
wc = (wchar_t) 0xBADFACE;
|
||||
ret = mbrtowc (&wc, input, 5, &state);
|
||||
if (ret != 2)
|
||||
result |= 1;
|
||||
if (!mbsinit (&state))
|
||||
result |= 2;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
ret = mbrtowc (NULL, input, 5, &state);
|
||||
if (ret != 2) /* Solaris 7 fails here: ret is -1. */
|
||||
result |= 4;
|
||||
if (!mbsinit (&state))
|
||||
result |= 8;
|
||||
}
|
||||
return result;
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_null_arg1=yes],
|
||||
[gl_cv_func_mbrtowc_null_arg1=no],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc supports a NULL string argument correctly.
|
||||
dnl Result is gl_cv_func_mbrtowc_null_arg2.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
|
||||
[gl_cv_func_mbrtowc_null_arg2],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on OSF/1.
|
||||
osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
int ret;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
wc = (wchar_t) 0xBADFACE;
|
||||
mbrtowc (&wc, NULL, 5, &state);
|
||||
/* Check that wc was not modified. */
|
||||
if (wc != (wchar_t) 0xBADFACE)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_null_arg2=yes],
|
||||
[gl_cv_func_mbrtowc_null_arg2=no],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc, when parsing the end of a multibyte character,
|
||||
dnl correctly returns the number of bytes that were needed to complete the
|
||||
dnl character (not the total number of bytes of the multibyte character).
|
||||
dnl Result is gl_cv_func_mbrtowc_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_RETVAL],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([gt_LOCALE_JA])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CACHE_CHECK([whether mbrtowc has a correct return value],
|
||||
[gl_cv_func_mbrtowc_retval],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on HP-UX, Solaris, native Windows.
|
||||
hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
|
||||
|| { case "$host_os" in mingw*) true;; *) false;; esac; }; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
int result = 0;
|
||||
int found_some_locale = 0;
|
||||
/* This fails on Solaris. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
char input[] = "B\303\274\303\237er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrtowc (&wc, input + 2, 5, &state) != 1)
|
||||
result |= 1;
|
||||
}
|
||||
found_some_locale = 1;
|
||||
}
|
||||
/* This fails on HP-UX 11.11. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
|
||||
{
|
||||
char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrtowc (&wc, input + 2, 5, &state) != 2)
|
||||
result |= 2;
|
||||
}
|
||||
found_some_locale = 1;
|
||||
}
|
||||
/* This fails on native Windows. */
|
||||
if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
|
||||
{
|
||||
char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[3] = '\0';
|
||||
if (mbrtowc (&wc, input + 4, 4, &state) != 1)
|
||||
result |= 4;
|
||||
}
|
||||
found_some_locale = 1;
|
||||
}
|
||||
if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
|
||||
{
|
||||
char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[3] = '\0';
|
||||
if (mbrtowc (&wc, input + 4, 4, &state) != 1)
|
||||
result |= 8;
|
||||
}
|
||||
found_some_locale = 1;
|
||||
}
|
||||
if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
|
||||
{
|
||||
char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[3] = '\0';
|
||||
if (mbrtowc (&wc, input + 4, 4, &state) != 1)
|
||||
result |= 16;
|
||||
}
|
||||
found_some_locale = 1;
|
||||
}
|
||||
return (found_some_locale ? result : 77);
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_retval=yes],
|
||||
[if test $? != 77; then
|
||||
gl_cv_func_mbrtowc_retval=no
|
||||
fi
|
||||
],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
|
||||
dnl Result is gl_cv_func_mbrtowc_nul_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_ZH_CN])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
|
||||
[gl_cv_func_mbrtowc_nul_retval],
|
||||
[
|
||||
dnl Initial guess, used when cross-compiling or when no suitable locale
|
||||
dnl is present.
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Solaris 8 and 9.
|
||||
solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_ZH_CN != none; then
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris 8 and 9. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
|
||||
{
|
||||
mbstate_t state;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrtowc (&wc, "", 1, &state) != 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}]])],
|
||||
[gl_cv_func_mbrtowc_nul_retval=yes],
|
||||
[gl_cv_func_mbrtowc_nul_retval=no],
|
||||
[:])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/mbrtowc.c.
|
||||
AC_DEFUN([gl_PREREQ_MBRTOWC], [
|
||||
:
|
||||
])
|
||||
|
||||
|
||||
dnl From Paul Eggert
|
||||
|
||||
dnl This is an override of an autoconf macro.
|
||||
|
||||
AC_DEFUN([AC_FUNC_MBRTOWC],
|
||||
[
|
||||
dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
|
||||
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
|
||||
gl_cv_func_mbrtowc,
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
|
||||
included before <wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
|
||||
must be included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>]],
|
||||
[[wchar_t wc;
|
||||
char const s[] = "";
|
||||
size_t n = 1;
|
||||
mbstate_t state;
|
||||
return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
|
||||
gl_cv_func_mbrtowc=yes,
|
||||
gl_cv_func_mbrtowc=no)])
|
||||
if test $gl_cv_func_mbrtowc = yes; then
|
||||
AC_DEFINE([HAVE_MBRTOWC], [1],
|
||||
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
|
||||
fi
|
||||
])
|
||||
51
m4/mbsinit.m4
Normal file
51
m4/mbsinit.m4
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# mbsinit.m4 serial 8
|
||||
dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_MBSINIT],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
gl_MBSTATE_T_BROKEN
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([mbsinit])
|
||||
if test $ac_cv_func_mbsinit = no; then
|
||||
HAVE_MBSINIT=0
|
||||
AC_CHECK_DECLS([mbsinit],,, [[
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
]])
|
||||
if test $ac_cv_have_decl_mbsinit = yes; then
|
||||
dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
|
||||
dnl it does not have the function. Avoid a collision with gnulib's
|
||||
dnl replacement.
|
||||
REPLACE_MBSINIT=1
|
||||
fi
|
||||
else
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
REPLACE_MBSINIT=1
|
||||
else
|
||||
dnl On mingw, mbsinit() always returns 1, which is inappropriate for
|
||||
dnl states produced by mbrtowc() for an incomplete multibyte character
|
||||
dnl in multibyte locales.
|
||||
case "$host_os" in
|
||||
mingw*) REPLACE_MBSINIT=1 ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/mbsinit.c.
|
||||
AC_DEFUN([gl_PREREQ_MBSINIT], [
|
||||
:
|
||||
])
|
||||
41
m4/mbstate_t.m4
Normal file
41
m4/mbstate_t.m4
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# mbstate_t.m4 serial 13
|
||||
dnl Copyright (C) 2000-2002, 2008-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# From Paul Eggert.
|
||||
|
||||
# BeOS 5 has <wchar.h> but does not define mbstate_t,
|
||||
# so you can't declare an object of that type.
|
||||
# Check for this incompatibility with Standard C.
|
||||
|
||||
# AC_TYPE_MBSTATE_T
|
||||
# -----------------
|
||||
AC_DEFUN([AC_TYPE_MBSTATE_T],
|
||||
[
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
|
||||
|
||||
AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT[
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>]],
|
||||
[[mbstate_t x; return sizeof x;]])],
|
||||
[ac_cv_type_mbstate_t=yes],
|
||||
[ac_cv_type_mbstate_t=no])])
|
||||
if test $ac_cv_type_mbstate_t = yes; then
|
||||
AC_DEFINE([HAVE_MBSTATE_T], [1],
|
||||
[Define to 1 if <wchar.h> declares mbstate_t.])
|
||||
else
|
||||
AC_DEFINE([mbstate_t], [int],
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi
|
||||
])
|
||||
13
m4/quote.m4
Normal file
13
m4/quote.m4
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# quote.m4 serial 6
|
||||
dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation,
|
||||
dnl Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTE],
|
||||
[
|
||||
dnl Prerequisites of lib/quote.c.
|
||||
dnl (none)
|
||||
:
|
||||
])
|
||||
10
m4/quotearg.m4
Normal file
10
m4/quotearg.m4
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# quotearg.m4 serial 9
|
||||
dnl Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTEARG],
|
||||
[
|
||||
:
|
||||
])
|
||||
209
m4/wctype_h.m4
Normal file
209
m4/wctype_h.m4
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
# wctype_h.m4 serial 18
|
||||
|
||||
dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
|
||||
|
||||
dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Written by Paul Eggert.
|
||||
|
||||
AC_DEFUN([gl_WCTYPE_H],
|
||||
[
|
||||
AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CHECK_FUNCS_ONCE([iswcntrl])
|
||||
if test $ac_cv_func_iswcntrl = yes; then
|
||||
HAVE_ISWCNTRL=1
|
||||
else
|
||||
HAVE_ISWCNTRL=0
|
||||
fi
|
||||
AC_SUBST([HAVE_ISWCNTRL])
|
||||
|
||||
AC_REQUIRE([gt_TYPE_WINT_T])
|
||||
if test $gt_cv_c_wint_t = yes; then
|
||||
HAVE_WINT_T=1
|
||||
else
|
||||
HAVE_WINT_T=0
|
||||
fi
|
||||
AC_SUBST([HAVE_WINT_T])
|
||||
|
||||
gl_CHECK_NEXT_HEADERS([wctype.h])
|
||||
if test $ac_cv_header_wctype_h = yes; then
|
||||
if test $ac_cv_func_iswcntrl = yes; then
|
||||
dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
|
||||
dnl The other functions are likely broken in the same way.
|
||||
AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
|
||||
[
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
|
||||
included before <wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
|
||||
must be included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
int main () { return iswprint ('x') == 0; }
|
||||
]])],
|
||||
[gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
|
||||
#if __GNU_LIBRARY__ == 1
|
||||
Linux libc5 i18n is broken.
|
||||
#endif]], [])],
|
||||
[gl_cv_func_iswcntrl_works="guessing yes"],
|
||||
[gl_cv_func_iswcntrl_works="guessing no"])
|
||||
])
|
||||
])
|
||||
fi
|
||||
HAVE_WCTYPE_H=1
|
||||
else
|
||||
HAVE_WCTYPE_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_WCTYPE_H])
|
||||
|
||||
case "$gl_cv_func_iswcntrl_works" in
|
||||
*yes) REPLACE_ISWCNTRL=0 ;;
|
||||
*) REPLACE_ISWCNTRL=1 ;;
|
||||
esac
|
||||
AC_SUBST([REPLACE_ISWCNTRL])
|
||||
|
||||
if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
|
||||
dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
|
||||
:
|
||||
fi
|
||||
|
||||
if test $REPLACE_ISWCNTRL = 1; then
|
||||
REPLACE_TOWLOWER=1
|
||||
else
|
||||
AC_CHECK_FUNCS([towlower])
|
||||
if test $ac_cv_func_towlower = yes; then
|
||||
REPLACE_TOWLOWER=0
|
||||
else
|
||||
AC_CHECK_DECLS([towlower],,,
|
||||
[[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
|
||||
included before <wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
|
||||
must be included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#if HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
]])
|
||||
if test $ac_cv_have_decl_towlower = yes; then
|
||||
dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
|
||||
dnl towupper() although it does not have the functions. Avoid a
|
||||
dnl collision with gnulib's replacement.
|
||||
REPLACE_TOWLOWER=1
|
||||
else
|
||||
REPLACE_TOWLOWER=0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([REPLACE_TOWLOWER])
|
||||
|
||||
if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
|
||||
dnl Redefine towlower, towupper in <wctype.h>.
|
||||
:
|
||||
fi
|
||||
|
||||
dnl We assume that the wctype() and iswctype() functions exist if and only
|
||||
dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
|
||||
dnl exists.
|
||||
dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
|
||||
AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
|
||||
included before <wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
|
||||
must be included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#if HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
wctype_t a;
|
||||
]],
|
||||
[[]])],
|
||||
[gl_cv_type_wctype_t=yes],
|
||||
[gl_cv_type_wctype_t=no])
|
||||
])
|
||||
if test $gl_cv_type_wctype_t = no; then
|
||||
HAVE_WCTYPE_T=0
|
||||
fi
|
||||
|
||||
dnl We assume that the wctrans() and towctrans() functions exist if and only
|
||||
dnl if the type wctrans_t is defined in <wctype.h>.
|
||||
AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
|
||||
included before <wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
|
||||
must be included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
wctrans_t a;
|
||||
]],
|
||||
[[]])],
|
||||
[gl_cv_type_wctrans_t=yes],
|
||||
[gl_cv_type_wctrans_t=no])
|
||||
])
|
||||
if test $gl_cv_type_wctrans_t = no; then
|
||||
HAVE_WCTRANS_T=0
|
||||
fi
|
||||
|
||||
dnl Check for declarations of anything we want to poison if the
|
||||
dnl corresponding gnulib module is not in use.
|
||||
gl_WARN_ON_USE_PREPARE([[
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#if !(defined __GLIBC__ && !defined __UCLIBC__)
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
# include <time.h>
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
#include <wctype.h>
|
||||
]],
|
||||
[wctype iswctype wctrans towctrans
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
|
||||
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
|
||||
dnl Define it also as a C macro, for the benefit of the unit tests.
|
||||
gl_MODULE_INDICATOR_FOR_TESTS([$1])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
|
||||
GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
|
||||
GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
|
||||
GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
|
||||
GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
|
||||
HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
|
||||
HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
|
||||
REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
|
||||
])
|
||||
7
m4/xalloc.m4
Normal file
7
m4/xalloc.m4
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# xalloc.m4 serial 18
|
||||
dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_XALLOC], [:])
|
||||
Loading…
Add table
Add a link
Reference in a new issue