mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
Merge commit 'origin/master' into vm
Conflicts: INSTALL
This commit is contained in:
commit
0c91a9105d
31 changed files with 2948 additions and 965 deletions
94
INSTALL
94
INSTALL
|
@ -2,15 +2,15 @@ Installation Instructions
|
|||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
||||
2006, 2007 Free Software Foundation, Inc.
|
||||
2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package.
|
||||
|
@ -73,9 +73,9 @@ The simplest way to compile this package is:
|
|||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
|
@ -88,7 +88,7 @@ is an example:
|
|||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
|
@ -100,10 +100,24 @@ architecture at a time in the source code directory. After you have
|
|||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple `-arch' options to the
|
||||
compiler but only a single `-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the `lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX'.
|
||||
|
@ -126,7 +140,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
|||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
|
@ -138,14 +152,36 @@ find the X include and library files automatically, but if it doesn't,
|
|||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
|
@ -171,9 +207,9 @@ eventually be run) with `--host=TYPE'.
|
|||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
|
@ -182,7 +218,7 @@ A warning: not all `configure' scripts look for a site script.
|
|||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
|
@ -201,11 +237,19 @@ an Autoconf bug. Until the bug is fixed you can use this workaround:
|
|||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
Print a summary of all of the options to `configure', and exit.
|
||||
|
||||
`--help=short'
|
||||
`--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
`configure', and exit. The `short' variant lists options used
|
||||
only in the top level, while the `recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
|
@ -232,6 +276,16 @@ an Autoconf bug. Until the bug is fixed you can use this workaround:
|
|||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--prefix=DIR'
|
||||
Use DIR as the installation prefix. *Note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
|
||||
`--no-create'
|
||||
`-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
|
|
9
lib/.gitignore
vendored
9
lib/.gitignore
vendored
|
@ -1,9 +0,0 @@
|
|||
/config.charset
|
||||
/localcharset.c
|
||||
/localcharset.h
|
||||
/mbrlen.c
|
||||
/mbrtowc.c
|
||||
/mbsinit.c
|
||||
/ref-add.sin
|
||||
/ref-del.sin
|
||||
/streq.h
|
|
@ -9,7 +9,7 @@
|
|||
# the same distribution terms as the rest of that program.
|
||||
#
|
||||
# Generated by gnulib-tool.
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca-opt autobuild count-one-bits extensions full-read full-write strcase strftime
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl --no-vc-files alloca-opt autobuild count-one-bits extensions full-read full-write strcase strftime
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.5 gnits
|
||||
|
||||
|
|
57
lib/alloca.h
57
lib/alloca.h
|
@ -1,57 +0,0 @@
|
|||
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
||||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
|
||||
means there is a real alloca function. */
|
||||
#ifndef _GL_ALLOCA_H
|
||||
#define _GL_ALLOCA_H
|
||||
|
||||
/* alloca (N) returns a pointer to N bytes of memory
|
||||
allocated on the stack, which will last until the function returns.
|
||||
Use of alloca should be avoided:
|
||||
- inside arguments of function calls - undefined behaviour,
|
||||
- in inline functions - the allocation may actually last until the
|
||||
calling function returns,
|
||||
- for huge N (say, N >= 65536) - you never know how large (or small)
|
||||
the stack is, and when the stack cannot fulfill the memory allocation
|
||||
request, the program just crashes.
|
||||
*/
|
||||
|
||||
#ifndef alloca
|
||||
# ifdef __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined _AIX
|
||||
# define alloca __alloca
|
||||
# elif defined _MSC_VER
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined __DECC && defined __VMS
|
||||
# define alloca __ALLOCA
|
||||
# else
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
void *alloca (size_t);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _GL_ALLOCA_H */
|
|
@ -1,5 +0,0 @@
|
|||
# This file contains a table of character encoding aliases,
|
||||
# suitable for operating system 'linux-gnu'.
|
||||
# It was automatically generated from config.charset.
|
||||
# Packages using this file:
|
||||
ISO_646.IRV:1983 ASCII
|
649
lib/config.charset
Executable file
649
lib/config.charset
Executable file
|
@ -0,0 +1,649 @@
|
|||
#! /bin/sh
|
||||
# Output a system dependent table of character encoding aliases.
|
||||
#
|
||||
# Copyright (C) 2000-2004, 2006-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# The table consists of lines of the form
|
||||
# ALIAS CANONICAL
|
||||
#
|
||||
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
|
||||
# ALIAS is compared in a case sensitive way.
|
||||
#
|
||||
# CANONICAL is the GNU canonical name for this character encoding.
|
||||
# It must be an encoding supported by libiconv. Support by GNU libc is
|
||||
# also desirable. CANONICAL is case insensitive. Usually an upper case
|
||||
# MIME charset name is preferred.
|
||||
# The current list of GNU canonical charset names is as follows.
|
||||
#
|
||||
# name MIME? used by which systems
|
||||
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin
|
||||
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin
|
||||
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin
|
||||
# ISO-8859-3 Y glibc solaris
|
||||
# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
|
||||
# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin
|
||||
# ISO-8859-6 Y glibc aix hpux solaris
|
||||
# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin
|
||||
# ISO-8859-8 Y glibc aix hpux osf solaris
|
||||
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin
|
||||
# ISO-8859-13 glibc netbsd openbsd darwin
|
||||
# ISO-8859-14 glibc
|
||||
# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin
|
||||
# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
|
||||
# KOI8-U Y glibc freebsd netbsd openbsd darwin
|
||||
# KOI8-T glibc
|
||||
# CP437 dos
|
||||
# CP775 dos
|
||||
# CP850 aix osf dos
|
||||
# CP852 dos
|
||||
# CP855 dos
|
||||
# CP856 aix
|
||||
# CP857 dos
|
||||
# CP861 dos
|
||||
# CP862 dos
|
||||
# CP864 dos
|
||||
# CP865 dos
|
||||
# CP866 freebsd netbsd openbsd darwin dos
|
||||
# CP869 dos
|
||||
# CP874 woe32 dos
|
||||
# CP922 aix
|
||||
# CP932 aix woe32 dos
|
||||
# CP943 aix
|
||||
# CP949 osf woe32 dos
|
||||
# CP950 woe32 dos
|
||||
# CP1046 aix
|
||||
# CP1124 aix
|
||||
# CP1125 dos
|
||||
# CP1129 aix
|
||||
# CP1250 woe32
|
||||
# CP1251 glibc solaris netbsd openbsd darwin woe32
|
||||
# CP1252 aix woe32
|
||||
# CP1253 woe32
|
||||
# CP1254 woe32
|
||||
# CP1255 glibc woe32
|
||||
# CP1256 woe32
|
||||
# CP1257 woe32
|
||||
# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
|
||||
# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# EUC-TW glibc aix hpux irix osf solaris netbsd
|
||||
# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin
|
||||
# BIG5-HKSCS glibc solaris
|
||||
# GBK glibc aix osf solaris woe32 dos
|
||||
# GB18030 glibc solaris netbsd
|
||||
# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
|
||||
# JOHAB glibc solaris woe32
|
||||
# TIS-620 glibc aix hpux osf solaris
|
||||
# VISCII Y glibc
|
||||
# TCVN5712-1 glibc
|
||||
# GEORGIAN-PS glibc
|
||||
# HP-ROMAN8 hpux
|
||||
# HP-ARABIC8 hpux
|
||||
# HP-GREEK8 hpux
|
||||
# HP-HEBREW8 hpux
|
||||
# HP-TURKISH8 hpux
|
||||
# HP-KANA8 hpux
|
||||
# DEC-KANJI osf
|
||||
# DEC-HANYU osf
|
||||
# UTF-8 Y glibc aix hpux osf solaris netbsd darwin
|
||||
#
|
||||
# Note: Names which are not marked as being a MIME name should not be used in
|
||||
# Internet protocols for information interchange (mail, news, etc.).
|
||||
#
|
||||
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
|
||||
# must understand both names and treat them as equivalent.
|
||||
#
|
||||
# The first argument passed to this file is the canonical host specification,
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
|
||||
host="$1"
|
||||
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
|
||||
echo "# This file contains a table of character encoding aliases,"
|
||||
echo "# suitable for operating system '${os}'."
|
||||
echo "# It was automatically generated from config.charset."
|
||||
# List of references, updated during installation:
|
||||
echo "# Packages using this file: "
|
||||
case "$os" in
|
||||
linux-gnulibc1*)
|
||||
# Linux libc5 doesn't have nl_langinfo(CODESET); therefore
|
||||
# localcharset.c falls back to using the full locale name
|
||||
# from the environment variables.
|
||||
echo "C ASCII"
|
||||
echo "POSIX ASCII"
|
||||
for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
|
||||
en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
|
||||
en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
|
||||
es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
|
||||
et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
|
||||
fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
|
||||
it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
|
||||
sv_FI sv_SE; do
|
||||
echo "$l ISO-8859-1"
|
||||
echo "$l.iso-8859-1 ISO-8859-1"
|
||||
echo "$l.iso-8859-15 ISO-8859-15"
|
||||
echo "$l.iso-8859-15@euro ISO-8859-15"
|
||||
echo "$l@euro ISO-8859-15"
|
||||
echo "$l.cp-437 CP437"
|
||||
echo "$l.cp-850 CP850"
|
||||
echo "$l.cp-1252 CP1252"
|
||||
echo "$l.cp-1252@euro CP1252"
|
||||
#echo "$l.atari-st ATARI-ST" # not a commonly used encoding
|
||||
echo "$l.utf-8 UTF-8"
|
||||
echo "$l.utf-8@euro UTF-8"
|
||||
done
|
||||
for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
|
||||
sl_SI sr sr_CS sr_YU; do
|
||||
echo "$l ISO-8859-2"
|
||||
echo "$l.iso-8859-2 ISO-8859-2"
|
||||
echo "$l.cp-852 CP852"
|
||||
echo "$l.cp-1250 CP1250"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
for l in mk mk_MK ru ru_RU; do
|
||||
echo "$l ISO-8859-5"
|
||||
echo "$l.iso-8859-5 ISO-8859-5"
|
||||
echo "$l.koi8-r KOI8-R"
|
||||
echo "$l.cp-866 CP866"
|
||||
echo "$l.cp-1251 CP1251"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
for l in ar ar_SA; do
|
||||
echo "$l ISO-8859-6"
|
||||
echo "$l.iso-8859-6 ISO-8859-6"
|
||||
echo "$l.cp-864 CP864"
|
||||
#echo "$l.cp-868 CP868" # not a commonly used encoding
|
||||
echo "$l.cp-1256 CP1256"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
for l in el el_GR gr gr_GR; do
|
||||
echo "$l ISO-8859-7"
|
||||
echo "$l.iso-8859-7 ISO-8859-7"
|
||||
echo "$l.cp-869 CP869"
|
||||
echo "$l.cp-1253 CP1253"
|
||||
echo "$l.cp-1253@euro CP1253"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
echo "$l.utf-8@euro UTF-8"
|
||||
done
|
||||
for l in he he_IL iw iw_IL; do
|
||||
echo "$l ISO-8859-8"
|
||||
echo "$l.iso-8859-8 ISO-8859-8"
|
||||
echo "$l.cp-862 CP862"
|
||||
echo "$l.cp-1255 CP1255"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
for l in tr tr_TR; do
|
||||
echo "$l ISO-8859-9"
|
||||
echo "$l.iso-8859-9 ISO-8859-9"
|
||||
echo "$l.cp-857 CP857"
|
||||
echo "$l.cp-1254 CP1254"
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
for l in lt lt_LT lv lv_LV; do
|
||||
#echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
|
||||
echo "$l ISO-8859-13"
|
||||
done
|
||||
for l in ru_UA uk uk_UA; do
|
||||
echo "$l KOI8-U"
|
||||
done
|
||||
for l in zh zh_CN; do
|
||||
#echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
|
||||
echo "$l GB2312"
|
||||
done
|
||||
for l in ja ja_JP ja_JP.EUC; do
|
||||
echo "$l EUC-JP"
|
||||
done
|
||||
for l in ko ko_KR; do
|
||||
echo "$l EUC-KR"
|
||||
done
|
||||
for l in th th_TH; do
|
||||
echo "$l TIS-620"
|
||||
done
|
||||
for l in fa fa_IR; do
|
||||
#echo "$l ISIRI-3342" # a broken encoding
|
||||
echo "$l.utf-8 UTF-8"
|
||||
done
|
||||
;;
|
||||
linux* | *-gnu*)
|
||||
# With glibc-2.1 or newer, we don't need any canonicalization,
|
||||
# because glibc has iconv and both glibc and libiconv support all
|
||||
# GNU canonical names directly. Therefore, the Makefile does not
|
||||
# need to install the alias file at all.
|
||||
# The following applies only to glibc-2.0.x and older libcs.
|
||||
echo "ISO_646.IRV:1983 ASCII"
|
||||
;;
|
||||
aix*)
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-6 ISO-8859-6"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-8 ISO-8859-8"
|
||||
echo "ISO8859-9 ISO-8859-9"
|
||||
echo "ISO8859-15 ISO-8859-15"
|
||||
echo "IBM-850 CP850"
|
||||
echo "IBM-856 CP856"
|
||||
echo "IBM-921 ISO-8859-13"
|
||||
echo "IBM-922 CP922"
|
||||
echo "IBM-932 CP932"
|
||||
echo "IBM-943 CP943"
|
||||
echo "IBM-1046 CP1046"
|
||||
echo "IBM-1124 CP1124"
|
||||
echo "IBM-1129 CP1129"
|
||||
echo "IBM-1252 CP1252"
|
||||
echo "IBM-eucCN GB2312"
|
||||
echo "IBM-eucJP EUC-JP"
|
||||
echo "IBM-eucKR EUC-KR"
|
||||
echo "IBM-eucTW EUC-TW"
|
||||
echo "big5 BIG5"
|
||||
echo "GBK GBK"
|
||||
echo "TIS-620 TIS-620"
|
||||
echo "UTF-8 UTF-8"
|
||||
;;
|
||||
hpux*)
|
||||
echo "iso88591 ISO-8859-1"
|
||||
echo "iso88592 ISO-8859-2"
|
||||
echo "iso88595 ISO-8859-5"
|
||||
echo "iso88596 ISO-8859-6"
|
||||
echo "iso88597 ISO-8859-7"
|
||||
echo "iso88598 ISO-8859-8"
|
||||
echo "iso88599 ISO-8859-9"
|
||||
echo "iso885915 ISO-8859-15"
|
||||
echo "roman8 HP-ROMAN8"
|
||||
echo "arabic8 HP-ARABIC8"
|
||||
echo "greek8 HP-GREEK8"
|
||||
echo "hebrew8 HP-HEBREW8"
|
||||
echo "turkish8 HP-TURKISH8"
|
||||
echo "kana8 HP-KANA8"
|
||||
echo "tis620 TIS-620"
|
||||
echo "big5 BIG5"
|
||||
echo "eucJP EUC-JP"
|
||||
echo "eucKR EUC-KR"
|
||||
echo "eucTW EUC-TW"
|
||||
echo "hp15CN GB2312"
|
||||
#echo "ccdc ?" # what is this?
|
||||
echo "SJIS SHIFT_JIS"
|
||||
echo "utf8 UTF-8"
|
||||
;;
|
||||
irix*)
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-9 ISO-8859-9"
|
||||
echo "eucCN GB2312"
|
||||
echo "eucJP EUC-JP"
|
||||
echo "eucKR EUC-KR"
|
||||
echo "eucTW EUC-TW"
|
||||
;;
|
||||
osf*)
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-4 ISO-8859-4"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-8 ISO-8859-8"
|
||||
echo "ISO8859-9 ISO-8859-9"
|
||||
echo "ISO8859-15 ISO-8859-15"
|
||||
echo "cp850 CP850"
|
||||
echo "big5 BIG5"
|
||||
echo "dechanyu DEC-HANYU"
|
||||
echo "dechanzi GB2312"
|
||||
echo "deckanji DEC-KANJI"
|
||||
echo "deckorean EUC-KR"
|
||||
echo "eucJP EUC-JP"
|
||||
echo "eucKR EUC-KR"
|
||||
echo "eucTW EUC-TW"
|
||||
echo "GBK GBK"
|
||||
echo "KSC5601 CP949"
|
||||
echo "sdeckanji EUC-JP"
|
||||
echo "SJIS SHIFT_JIS"
|
||||
echo "TACTIS TIS-620"
|
||||
echo "UTF-8 UTF-8"
|
||||
;;
|
||||
solaris*)
|
||||
echo "646 ASCII"
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-3 ISO-8859-3"
|
||||
echo "ISO8859-4 ISO-8859-4"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-6 ISO-8859-6"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-8 ISO-8859-8"
|
||||
echo "ISO8859-9 ISO-8859-9"
|
||||
echo "ISO8859-15 ISO-8859-15"
|
||||
echo "koi8-r KOI8-R"
|
||||
echo "ansi-1251 CP1251"
|
||||
echo "BIG5 BIG5"
|
||||
echo "Big5-HKSCS BIG5-HKSCS"
|
||||
echo "gb2312 GB2312"
|
||||
echo "GBK GBK"
|
||||
echo "GB18030 GB18030"
|
||||
echo "cns11643 EUC-TW"
|
||||
echo "5601 EUC-KR"
|
||||
echo "ko_KR.johap92 JOHAB"
|
||||
echo "eucJP EUC-JP"
|
||||
echo "PCK SHIFT_JIS"
|
||||
echo "TIS620.2533 TIS-620"
|
||||
#echo "sun_eu_greek ?" # what is this?
|
||||
echo "UTF-8 UTF-8"
|
||||
;;
|
||||
freebsd* | os2*)
|
||||
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
|
||||
# localcharset.c falls back to using the full locale name
|
||||
# from the environment variables.
|
||||
# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
|
||||
# reuse FreeBSD's locale data for OS/2.
|
||||
echo "C ASCII"
|
||||
echo "US-ASCII ASCII"
|
||||
for l in la_LN lt_LN; do
|
||||
echo "$l.ASCII ASCII"
|
||||
done
|
||||
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
|
||||
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
|
||||
lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
|
||||
echo "$l.ISO_8859-1 ISO-8859-1"
|
||||
echo "$l.DIS_8859-15 ISO-8859-15"
|
||||
done
|
||||
for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
|
||||
echo "$l.ISO_8859-2 ISO-8859-2"
|
||||
done
|
||||
for l in la_LN lt_LT; do
|
||||
echo "$l.ISO_8859-4 ISO-8859-4"
|
||||
done
|
||||
for l in ru_RU ru_SU; do
|
||||
echo "$l.KOI8-R KOI8-R"
|
||||
echo "$l.ISO_8859-5 ISO-8859-5"
|
||||
echo "$l.CP866 CP866"
|
||||
done
|
||||
echo "uk_UA.KOI8-U KOI8-U"
|
||||
echo "zh_TW.BIG5 BIG5"
|
||||
echo "zh_TW.Big5 BIG5"
|
||||
echo "zh_CN.EUC GB2312"
|
||||
echo "ja_JP.EUC EUC-JP"
|
||||
echo "ja_JP.SJIS SHIFT_JIS"
|
||||
echo "ja_JP.Shift_JIS SHIFT_JIS"
|
||||
echo "ko_KR.EUC EUC-KR"
|
||||
;;
|
||||
netbsd*)
|
||||
echo "646 ASCII"
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-4 ISO-8859-4"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-13 ISO-8859-13"
|
||||
echo "ISO8859-15 ISO-8859-15"
|
||||
echo "eucCN GB2312"
|
||||
echo "eucJP EUC-JP"
|
||||
echo "eucKR EUC-KR"
|
||||
echo "eucTW EUC-TW"
|
||||
echo "BIG5 BIG5"
|
||||
echo "SJIS SHIFT_JIS"
|
||||
;;
|
||||
openbsd*)
|
||||
echo "646 ASCII"
|
||||
echo "ISO8859-1 ISO-8859-1"
|
||||
echo "ISO8859-2 ISO-8859-2"
|
||||
echo "ISO8859-4 ISO-8859-4"
|
||||
echo "ISO8859-5 ISO-8859-5"
|
||||
echo "ISO8859-7 ISO-8859-7"
|
||||
echo "ISO8859-13 ISO-8859-13"
|
||||
echo "ISO8859-15 ISO-8859-15"
|
||||
;;
|
||||
darwin[56]*)
|
||||
# Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
|
||||
# localcharset.c falls back to using the full locale name
|
||||
# from the environment variables.
|
||||
echo "C ASCII"
|
||||
for l in en_AU en_CA en_GB en_US la_LN; do
|
||||
echo "$l.US-ASCII ASCII"
|
||||
done
|
||||
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
|
||||
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
|
||||
nl_NL no_NO pt_PT sv_SE; do
|
||||
echo "$l ISO-8859-1"
|
||||
echo "$l.ISO8859-1 ISO-8859-1"
|
||||
echo "$l.ISO8859-15 ISO-8859-15"
|
||||
done
|
||||
for l in la_LN; do
|
||||
echo "$l.ISO8859-1 ISO-8859-1"
|
||||
echo "$l.ISO8859-15 ISO-8859-15"
|
||||
done
|
||||
for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
|
||||
echo "$l.ISO8859-2 ISO-8859-2"
|
||||
done
|
||||
for l in la_LN lt_LT; do
|
||||
echo "$l.ISO8859-4 ISO-8859-4"
|
||||
done
|
||||
for l in ru_RU; do
|
||||
echo "$l.KOI8-R KOI8-R"
|
||||
echo "$l.ISO8859-5 ISO-8859-5"
|
||||
echo "$l.CP866 CP866"
|
||||
done
|
||||
for l in bg_BG; do
|
||||
echo "$l.CP1251 CP1251"
|
||||
done
|
||||
echo "uk_UA.KOI8-U KOI8-U"
|
||||
echo "zh_TW.BIG5 BIG5"
|
||||
echo "zh_TW.Big5 BIG5"
|
||||
echo "zh_CN.EUC GB2312"
|
||||
echo "ja_JP.EUC EUC-JP"
|
||||
echo "ja_JP.SJIS SHIFT_JIS"
|
||||
echo "ko_KR.EUC EUC-KR"
|
||||
;;
|
||||
darwin*)
|
||||
# Darwin 7.5 has nl_langinfo(CODESET), but it is useless:
|
||||
# - It returns the empty string when LANG is set to a locale of the
|
||||
# form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
|
||||
# LC_CTYPE file.
|
||||
# - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
|
||||
# the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
|
||||
# - The documentation says:
|
||||
# "... all code that calls BSD system routines should ensure
|
||||
# that the const *char parameters of these routines are in UTF-8
|
||||
# encoding. All BSD system functions expect their string
|
||||
# parameters to be in UTF-8 encoding and nothing else."
|
||||
# It also says
|
||||
# "An additional caveat is that string parameters for files,
|
||||
# paths, and other file-system entities must be in canonical
|
||||
# UTF-8. In a canonical UTF-8 Unicode string, all decomposable
|
||||
# characters are decomposed ..."
|
||||
# but this is not true: You can pass non-decomposed UTF-8 strings
|
||||
# to file system functions, and it is the OS which will convert
|
||||
# them to decomposed UTF-8 before accessing the file system.
|
||||
# - The Apple Terminal application displays UTF-8 by default.
|
||||
# - However, other applications are free to use different encodings:
|
||||
# - xterm uses ISO-8859-1 by default.
|
||||
# - TextEdit uses MacRoman by default.
|
||||
# We prefer UTF-8 over decomposed UTF-8-MAC because one should
|
||||
# minimize the use of decomposed Unicode. Unfortunately, through the
|
||||
# Darwin file system, decomposed UTF-8 strings are leaked into user
|
||||
# space nevertheless.
|
||||
echo "* UTF-8"
|
||||
;;
|
||||
beos* | haiku*)
|
||||
# BeOS and Haiku have a single locale, and it has UTF-8 encoding.
|
||||
echo "* UTF-8"
|
||||
;;
|
||||
msdosdjgpp*)
|
||||
# DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
|
||||
# localcharset.c falls back to using the full locale name
|
||||
# from the environment variables.
|
||||
echo "#"
|
||||
echo "# The encodings given here may not all be correct."
|
||||
echo "# If you find that the encoding given for your language and"
|
||||
echo "# country is not the one your DOS machine actually uses, just"
|
||||
echo "# correct it in this file, and send a mail to"
|
||||
echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
|
||||
echo "# and Bruno Haible <bruno@clisp.org>."
|
||||
echo "#"
|
||||
echo "C ASCII"
|
||||
# ISO-8859-1 languages
|
||||
echo "ca CP850"
|
||||
echo "ca_ES CP850"
|
||||
echo "da CP865" # not CP850 ??
|
||||
echo "da_DK CP865" # not CP850 ??
|
||||
echo "de CP850"
|
||||
echo "de_AT CP850"
|
||||
echo "de_CH CP850"
|
||||
echo "de_DE CP850"
|
||||
echo "en CP850"
|
||||
echo "en_AU CP850" # not CP437 ??
|
||||
echo "en_CA CP850"
|
||||
echo "en_GB CP850"
|
||||
echo "en_NZ CP437"
|
||||
echo "en_US CP437"
|
||||
echo "en_ZA CP850" # not CP437 ??
|
||||
echo "es CP850"
|
||||
echo "es_AR CP850"
|
||||
echo "es_BO CP850"
|
||||
echo "es_CL CP850"
|
||||
echo "es_CO CP850"
|
||||
echo "es_CR CP850"
|
||||
echo "es_CU CP850"
|
||||
echo "es_DO CP850"
|
||||
echo "es_EC CP850"
|
||||
echo "es_ES CP850"
|
||||
echo "es_GT CP850"
|
||||
echo "es_HN CP850"
|
||||
echo "es_MX CP850"
|
||||
echo "es_NI CP850"
|
||||
echo "es_PA CP850"
|
||||
echo "es_PY CP850"
|
||||
echo "es_PE CP850"
|
||||
echo "es_SV CP850"
|
||||
echo "es_UY CP850"
|
||||
echo "es_VE CP850"
|
||||
echo "et CP850"
|
||||
echo "et_EE CP850"
|
||||
echo "eu CP850"
|
||||
echo "eu_ES CP850"
|
||||
echo "fi CP850"
|
||||
echo "fi_FI CP850"
|
||||
echo "fr CP850"
|
||||
echo "fr_BE CP850"
|
||||
echo "fr_CA CP850"
|
||||
echo "fr_CH CP850"
|
||||
echo "fr_FR CP850"
|
||||
echo "ga CP850"
|
||||
echo "ga_IE CP850"
|
||||
echo "gd CP850"
|
||||
echo "gd_GB CP850"
|
||||
echo "gl CP850"
|
||||
echo "gl_ES CP850"
|
||||
echo "id CP850" # not CP437 ??
|
||||
echo "id_ID CP850" # not CP437 ??
|
||||
echo "is CP861" # not CP850 ??
|
||||
echo "is_IS CP861" # not CP850 ??
|
||||
echo "it CP850"
|
||||
echo "it_CH CP850"
|
||||
echo "it_IT CP850"
|
||||
echo "lt CP775"
|
||||
echo "lt_LT CP775"
|
||||
echo "lv CP775"
|
||||
echo "lv_LV CP775"
|
||||
echo "nb CP865" # not CP850 ??
|
||||
echo "nb_NO CP865" # not CP850 ??
|
||||
echo "nl CP850"
|
||||
echo "nl_BE CP850"
|
||||
echo "nl_NL CP850"
|
||||
echo "nn CP865" # not CP850 ??
|
||||
echo "nn_NO CP865" # not CP850 ??
|
||||
echo "no CP865" # not CP850 ??
|
||||
echo "no_NO CP865" # not CP850 ??
|
||||
echo "pt CP850"
|
||||
echo "pt_BR CP850"
|
||||
echo "pt_PT CP850"
|
||||
echo "sv CP850"
|
||||
echo "sv_SE CP850"
|
||||
# ISO-8859-2 languages
|
||||
echo "cs CP852"
|
||||
echo "cs_CZ CP852"
|
||||
echo "hr CP852"
|
||||
echo "hr_HR CP852"
|
||||
echo "hu CP852"
|
||||
echo "hu_HU CP852"
|
||||
echo "pl CP852"
|
||||
echo "pl_PL CP852"
|
||||
echo "ro CP852"
|
||||
echo "ro_RO CP852"
|
||||
echo "sk CP852"
|
||||
echo "sk_SK CP852"
|
||||
echo "sl CP852"
|
||||
echo "sl_SI CP852"
|
||||
echo "sq CP852"
|
||||
echo "sq_AL CP852"
|
||||
echo "sr CP852" # CP852 or CP866 or CP855 ??
|
||||
echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
|
||||
echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
|
||||
# ISO-8859-3 languages
|
||||
echo "mt CP850"
|
||||
echo "mt_MT CP850"
|
||||
# ISO-8859-5 languages
|
||||
echo "be CP866"
|
||||
echo "be_BE CP866"
|
||||
echo "bg CP866" # not CP855 ??
|
||||
echo "bg_BG CP866" # not CP855 ??
|
||||
echo "mk CP866" # not CP855 ??
|
||||
echo "mk_MK CP866" # not CP855 ??
|
||||
echo "ru CP866"
|
||||
echo "ru_RU CP866"
|
||||
echo "uk CP1125"
|
||||
echo "uk_UA CP1125"
|
||||
# ISO-8859-6 languages
|
||||
echo "ar CP864"
|
||||
echo "ar_AE CP864"
|
||||
echo "ar_DZ CP864"
|
||||
echo "ar_EG CP864"
|
||||
echo "ar_IQ CP864"
|
||||
echo "ar_IR CP864"
|
||||
echo "ar_JO CP864"
|
||||
echo "ar_KW CP864"
|
||||
echo "ar_MA CP864"
|
||||
echo "ar_OM CP864"
|
||||
echo "ar_QA CP864"
|
||||
echo "ar_SA CP864"
|
||||
echo "ar_SY CP864"
|
||||
# ISO-8859-7 languages
|
||||
echo "el CP869"
|
||||
echo "el_GR CP869"
|
||||
# ISO-8859-8 languages
|
||||
echo "he CP862"
|
||||
echo "he_IL CP862"
|
||||
# ISO-8859-9 languages
|
||||
echo "tr CP857"
|
||||
echo "tr_TR CP857"
|
||||
# Japanese
|
||||
echo "ja CP932"
|
||||
echo "ja_JP CP932"
|
||||
# Chinese
|
||||
echo "zh_CN GBK"
|
||||
echo "zh_TW CP950" # not CP938 ??
|
||||
# Korean
|
||||
echo "kr CP949" # not CP934 ??
|
||||
echo "kr_KR CP949" # not CP934 ??
|
||||
# Thai
|
||||
echo "th CP874"
|
||||
echo "th_TH CP874"
|
||||
# Other
|
||||
echo "eo CP850"
|
||||
echo "eo_EO CP850"
|
||||
;;
|
||||
esac
|
|
@ -1,26 +0,0 @@
|
|||
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
||||
#define PREFIX "/usr/local"
|
||||
#define EXEC_PREFIX "/usr/local"
|
||||
#define BINDIR "/usr/local/bin"
|
||||
#define SBINDIR "/usr/local/sbin"
|
||||
#define LIBEXECDIR "/usr/local/libexec"
|
||||
#define DATAROOTDIR "/usr/local/share"
|
||||
#define DATADIR "/usr/local/share"
|
||||
#define SYSCONFDIR "/usr/local/etc"
|
||||
#define SHAREDSTATEDIR "/usr/local/com"
|
||||
#define LOCALSTATEDIR "/usr/local/var"
|
||||
#define INCLUDEDIR "/usr/local/include"
|
||||
#define OLDINCLUDEDIR "/usr/include"
|
||||
#define DOCDIR "/usr/local/share/doc/guile"
|
||||
#define INFODIR "/usr/local/share/info"
|
||||
#define HTMLDIR "/usr/local/share/doc/guile"
|
||||
#define DVIDIR "/usr/local/share/doc/guile"
|
||||
#define PDFDIR "/usr/local/share/doc/guile"
|
||||
#define PSDIR "/usr/local/share/doc/guile"
|
||||
#define LIBDIR "/usr/local/lib"
|
||||
#define LISPDIR "/usr/local/share/emacs/site-lisp"
|
||||
#define LOCALEDIR "/usr/local/share/locale"
|
||||
#define MANDIR "/usr/local/share/man"
|
||||
#define PKGDATADIR "/usr/local/share/guile"
|
||||
#define PKGINCLUDEDIR "/usr/local/include/guile"
|
||||
#define PKGLIBDIR "/usr/local/lib/guile"
|
462
lib/localcharset.c
Normal file
462
lib/localcharset.c
Normal file
|
@ -0,0 +1,462 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
|
||||
Copyright (C) 2000-2006, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "localcharset.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__
|
||||
# define WIN32_NATIVE
|
||||
#endif
|
||||
|
||||
#if defined __EMX__
|
||||
/* Assume EMX program runs on OS/2, even if compiled under DOS. */
|
||||
# ifndef OS2
|
||||
# define OS2
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined WIN32_NATIVE
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
# else
|
||||
# if 0 /* see comment below */
|
||||
# include <locale.h>
|
||||
# endif
|
||||
# endif
|
||||
# ifdef __CYGWIN__
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# endif
|
||||
#elif defined WIN32_NATIVE
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#if defined OS2
|
||||
# define INCL_DOS
|
||||
# include <os2.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_RELOCATABLE
|
||||
# include "relocatable.h"
|
||||
#else
|
||||
# define relocate(pathname) (pathname)
|
||||
#endif
|
||||
|
||||
/* Get LIBDIR. */
|
||||
#ifndef LIBDIR
|
||||
# include "configmake.h"
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, Cygwin, OS/2, DOS */
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
#endif
|
||||
|
||||
#ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
#endif
|
||||
|
||||
#if HAVE_DECL_GETC_UNLOCKED
|
||||
# undef getc
|
||||
# define getc getc_unlocked
|
||||
#endif
|
||||
|
||||
/* The following static variable is declared 'volatile' to avoid a
|
||||
possible multithread problem in the function get_charset_aliases. If we
|
||||
are running in a threaded environment, and if two threads initialize
|
||||
'charset_aliases' simultaneously, both will produce the same value,
|
||||
and everything will be ok if the two assignments to 'charset_aliases'
|
||||
are atomic. But I don't know what will happen if the two assignments mix. */
|
||||
#if __STDC__ != 1
|
||||
# define volatile /* empty */
|
||||
#endif
|
||||
/* Pointer to the contents of the charset.alias file, if it has already been
|
||||
read, else NULL. Its format is:
|
||||
ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
|
||||
static const char * volatile charset_aliases;
|
||||
|
||||
/* Return a pointer to the contents of the charset.alias file. */
|
||||
static const char *
|
||||
get_charset_aliases (void)
|
||||
{
|
||||
const char *cp;
|
||||
|
||||
cp = charset_aliases;
|
||||
if (cp == NULL)
|
||||
{
|
||||
#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
|
||||
FILE *fp;
|
||||
const char *dir;
|
||||
const char *base = "charset.alias";
|
||||
char *file_name;
|
||||
|
||||
/* Make it possible to override the charset.alias location. This is
|
||||
necessary for running the testsuite before "make install". */
|
||||
dir = getenv ("CHARSETALIASDIR");
|
||||
if (dir == NULL || dir[0] == '\0')
|
||||
dir = relocate (LIBDIR);
|
||||
|
||||
/* Concatenate dir and base into freshly allocated file_name. */
|
||||
{
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
|
||||
/* Out of memory or file not found, treat it as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
size_t l1, l2;
|
||||
char *old_res_ptr;
|
||||
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n' || c == ' ' || c == '\t')
|
||||
continue;
|
||||
if (c == '#')
|
||||
{
|
||||
/* Skip comment, to end of line. */
|
||||
do
|
||||
c = getc (fp);
|
||||
while (!(c == EOF || c == '\n'));
|
||||
if (c == EOF)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ungetc (c, fp);
|
||||
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
|
||||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
}
|
||||
fclose (fp);
|
||||
if (res_size == 0)
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
*(res_ptr + res_size) = '\0';
|
||||
cp = res_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name != NULL)
|
||||
free (file_name);
|
||||
|
||||
#else
|
||||
|
||||
# if defined VMS
|
||||
/* To avoid the troubles of an extra file charset.alias_vms in the
|
||||
sources of many GNU packages, simply inline the aliases here. */
|
||||
/* The list of encodings is taken from the OpenVMS 7.3-1 documentation
|
||||
"Compaq C Run-Time Library Reference Manual for OpenVMS systems"
|
||||
section 10.7 "Handling Different Character Sets". */
|
||||
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-8" "\0" "ISO-8859-8" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
/* Japanese */
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"DECKANJI" "\0" "DEC-KANJI" "\0"
|
||||
"SDECKANJI" "\0" "EUC-JP" "\0"
|
||||
/* Chinese */
|
||||
"eucTW" "\0" "EUC-TW" "\0"
|
||||
"DECHANYU" "\0" "DEC-HANYU" "\0"
|
||||
"DECHANZI" "\0" "GB2312" "\0"
|
||||
/* Korean */
|
||||
"DECKOREAN" "\0" "EUC-KR" "\0";
|
||||
# endif
|
||||
|
||||
# if defined WIN32_NATIVE || defined __CYGWIN__
|
||||
/* To avoid the troubles of installing a separate file in the same
|
||||
directory as the DLL and of retrieving the DLL's directory at
|
||||
runtime, simply inline the aliases here. */
|
||||
|
||||
cp = "CP936" "\0" "GBK" "\0"
|
||||
"CP1361" "\0" "JOHAB" "\0"
|
||||
"CP20127" "\0" "ASCII" "\0"
|
||||
"CP20866" "\0" "KOI8-R" "\0"
|
||||
"CP20936" "\0" "GB2312" "\0"
|
||||
"CP21866" "\0" "KOI8-RU" "\0"
|
||||
"CP28591" "\0" "ISO-8859-1" "\0"
|
||||
"CP28592" "\0" "ISO-8859-2" "\0"
|
||||
"CP28593" "\0" "ISO-8859-3" "\0"
|
||||
"CP28594" "\0" "ISO-8859-4" "\0"
|
||||
"CP28595" "\0" "ISO-8859-5" "\0"
|
||||
"CP28596" "\0" "ISO-8859-6" "\0"
|
||||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\0"
|
||||
"CP38598" "\0" "ISO-8859-8" "\0"
|
||||
"CP51932" "\0" "EUC-JP" "\0"
|
||||
"CP51936" "\0" "GB2312" "\0"
|
||||
"CP51949" "\0" "EUC-KR" "\0"
|
||||
"CP51950" "\0" "EUC-TW" "\0"
|
||||
"CP54936" "\0" "GB18030" "\0"
|
||||
"CP65001" "\0" "UTF-8" "\0";
|
||||
# endif
|
||||
#endif
|
||||
|
||||
charset_aliases = cp;
|
||||
}
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
/* Determine the current locale's character encoding, and canonicalize it
|
||||
into one of the canonical names listed in config.charset.
|
||||
The result must not be freed; it is statically allocated.
|
||||
If the canonical name cannot be determined, the result is a non-canonical
|
||||
name. */
|
||||
|
||||
#ifdef STATIC
|
||||
STATIC
|
||||
#endif
|
||||
const char *
|
||||
locale_charset (void)
|
||||
{
|
||||
const char *codeset;
|
||||
const char *aliases;
|
||||
|
||||
#if !(defined WIN32_NATIVE || defined OS2)
|
||||
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
|
||||
/* Most systems support nl_langinfo (CODESET) nowadays. */
|
||||
codeset = nl_langinfo (CODESET);
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
/* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
|
||||
returns "US-ASCII". As long as this is not fixed, return the suffix
|
||||
of the locale name from the environment variables (if present) or
|
||||
the codepage as a number. */
|
||||
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
|
||||
{
|
||||
const char *locale;
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
}
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
/* On old systems which lack it, use setlocale or getenv. */
|
||||
const char *locale = NULL;
|
||||
|
||||
/* But most old systems don't have a complete set of locales. Some
|
||||
(like SunOS 4 or DJGPP) have only the C locale. Therefore we don't
|
||||
use setlocale here; it would return "C" when it doesn't support the
|
||||
locale name the user has set. */
|
||||
# if 0
|
||||
locale = setlocale (LC_CTYPE, NULL);
|
||||
# endif
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
}
|
||||
|
||||
/* On some old systems, one used to set locale = "iso8859_1". On others,
|
||||
you set it to "language_COUNTRY.charset". In any case, we resolve it
|
||||
through the charset.alias file. */
|
||||
codeset = locale;
|
||||
|
||||
# endif
|
||||
|
||||
#elif defined WIN32_NATIVE
|
||||
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
|
||||
#elif defined OS2
|
||||
|
||||
const char *locale;
|
||||
static char buf[2 + 10 + 1];
|
||||
ULONG cp[3];
|
||||
ULONG cplen;
|
||||
|
||||
/* Allow user to override the codeset, as set in the operating system,
|
||||
with standard language environment variables. */
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resolve through the charset.alias file. */
|
||||
codeset = locale;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* OS/2 has a function returning the locale's codepage as a number. */
|
||||
if (DosQueryCp (sizeof (cp), cp, &cplen))
|
||||
codeset = "";
|
||||
else
|
||||
{
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (codeset == NULL)
|
||||
/* The canonical name cannot be determined. */
|
||||
codeset = "";
|
||||
|
||||
/* Resolve alias. */
|
||||
for (aliases = get_charset_aliases ();
|
||||
*aliases != '\0';
|
||||
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
|
||||
if (strcmp (codeset, aliases) == 0
|
||||
|| (aliases[0] == '*' && aliases[1] == '\0'))
|
||||
{
|
||||
codeset = aliases + strlen (aliases) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't return an empty string. GNU libc and GNU libiconv interpret
|
||||
the empty string as denoting "the locale's character encoding",
|
||||
thus GNU libiconv would call this function a second time. */
|
||||
if (codeset[0] == '\0')
|
||||
codeset = "ASCII";
|
||||
|
||||
return codeset;
|
||||
}
|
41
lib/localcharset.h
Normal file
41
lib/localcharset.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
Copyright (C) 2000-2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU CHARSET Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _LOCALCHARSET_H
|
||||
#define _LOCALCHARSET_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine the current locale's character encoding, and canonicalize it
|
||||
into one of the canonical names listed in config.charset.
|
||||
The result must not be freed; it is statically allocated.
|
||||
If the canonical name cannot be determined, the result is a non-canonical
|
||||
name. */
|
||||
extern const char * locale_charset (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _LOCALCHARSET_H */
|
32
lib/mbrlen.c
Normal file
32
lib/mbrlen.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Recognize multibyte character.
|
||||
Copyright (C) 1999-2000, 2008 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
static mbstate_t internal_state;
|
||||
|
||||
size_t
|
||||
mbrlen (const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
if (ps == NULL)
|
||||
ps = &internal_state;
|
||||
return mbrtowc (NULL, s, n, ps);
|
||||
}
|
349
lib/mbrtowc.c
Normal file
349
lib/mbrtowc.c
Normal file
|
@ -0,0 +1,349 @@
|
|||
/* Convert multibyte character to wide character.
|
||||
Copyright (C) 1999-2002, 2005-2008 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <wchar.h>
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
/* Implement mbrtowc() on top of mbtowc(). */
|
||||
|
||||
# include <errno.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
# include "verify.h"
|
||||
|
||||
|
||||
verify (sizeof (mbstate_t) >= 4);
|
||||
|
||||
static char internal_state[4];
|
||||
|
||||
size_t
|
||||
mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
char *pstate = (char *)ps;
|
||||
|
||||
if (pstate == NULL)
|
||||
pstate = internal_state;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
return (size_t)(-2);
|
||||
|
||||
/* Here n > 0. */
|
||||
{
|
||||
size_t nstate = pstate[0];
|
||||
char buf[4];
|
||||
const char *p;
|
||||
size_t m;
|
||||
|
||||
switch (nstate)
|
||||
{
|
||||
case 0:
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
case 3:
|
||||
buf[2] = pstate[3];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
buf[1] = pstate[2];
|
||||
/*FALLTHROUGH*/
|
||||
case 1:
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
/* Here 0 < m ≤ 4. */
|
||||
|
||||
# if __GLIBC__
|
||||
/* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
|
||||
mbtowc (NULL, NULL, 0);
|
||||
# endif
|
||||
{
|
||||
int res = mbtowc (pwc, p, m);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if (pwc != NULL && ((*pwc == 0) != (res == 0)))
|
||||
abort ();
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* mbtowc does not distinguish between invalid and incomplete multibyte
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems that
|
||||
lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, SJIS,
|
||||
- UTF-8.
|
||||
Use specialized code for each. */
|
||||
if (m >= 4 || m >= MB_CUR_MAX)
|
||||
goto invalid;
|
||||
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
|
||||
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
{
|
||||
/* Cf. unistr/u8-mblen.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
|
||||
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
}
|
||||
|
||||
incomplete:
|
||||
{
|
||||
size_t k = nstate;
|
||||
/* Here 0 < k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
pstate[++k] = s[1];
|
||||
if (k != m)
|
||||
abort ();
|
||||
}
|
||||
pstate[0] = m;
|
||||
return (size_t)(-2);
|
||||
|
||||
invalid:
|
||||
errno = EILSEQ;
|
||||
/* The conversion state is undefined, says POSIX. */
|
||||
return (size_t)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
/* Override the system's mbrtowc() function. */
|
||||
|
||||
# undef mbrtowc
|
||||
|
||||
size_t
|
||||
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||
{
|
||||
# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
|
||||
if (s == NULL)
|
||||
{
|
||||
pwc = NULL;
|
||||
s = "";
|
||||
n = 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_RETVAL_BUG
|
||||
{
|
||||
static mbstate_t internal_state;
|
||||
|
||||
/* Override mbrtowc's internal state. We can not call mbsinit() on the
|
||||
hidden internal state, but we can call it on our variable. */
|
||||
if (ps == NULL)
|
||||
ps = &internal_state;
|
||||
|
||||
if (!mbsinit (ps))
|
||||
{
|
||||
/* Parse the rest of the multibyte character byte for byte. */
|
||||
size_t count = 0;
|
||||
for (; n > 0; s++, n--)
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, 1, ps);
|
||||
|
||||
if (ret == (size_t)(-1))
|
||||
return (size_t)(-1);
|
||||
count++;
|
||||
if (ret != (size_t)(-2))
|
||||
{
|
||||
/* The multibyte character has been completed. */
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
return (wc == 0 ? 0 : count);
|
||||
}
|
||||
}
|
||||
return (size_t)(-2);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# if MBRTOWC_NUL_RETVAL_BUG
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, n, ps);
|
||||
|
||||
if (ret != (size_t)(-1) && ret != (size_t)(-2))
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
if (wc == 0)
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
# else
|
||||
return mbrtowc (pwc, s, n, ps);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
47
lib/mbsinit.c
Normal file
47
lib/mbsinit.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Test for initial conversion state.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <wchar.h>
|
||||
|
||||
#include "verify.h"
|
||||
|
||||
/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
|
||||
and wcrtomb(), wcsrtombs().
|
||||
We assume that
|
||||
- sizeof (mbstate_t) >= 4,
|
||||
- only stateless encodings are supported (such as UTF-8 and EUC-JP, but
|
||||
not ISO-2022 variants),
|
||||
- for each encoding, the number of bytes for a wide character is <= 4.
|
||||
(This maximum is attained for UTF-8, GB18030, EUC-TW.)
|
||||
We define the meaning of mbstate_t as follows:
|
||||
- In mb -> wc direction, mbstate_t's first byte contains the number of
|
||||
buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
|
||||
- In wc -> mb direction, mbstate_t contains no information. In other
|
||||
words, it is always in the initial state. */
|
||||
|
||||
verify (sizeof (mbstate_t) >= 4);
|
||||
|
||||
int
|
||||
mbsinit (const mbstate_t *ps)
|
||||
{
|
||||
const char *pstate = (const char *)ps;
|
||||
|
||||
return pstate[0] == 0;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/^# Packages using this file: / {
|
||||
s/# Packages using this file://
|
||||
ta
|
||||
:a
|
||||
s/ guile / guile /
|
||||
tb
|
||||
s/ $/ guile /
|
||||
:b
|
||||
s/^/# Packages using this file:/
|
||||
}
|
30
lib/ref-add.sin
Normal file
30
lib/ref-add.sin
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Add this package to a list of references stored in a text file.
|
||||
#
|
||||
# Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Written by Bruno Haible <haible@clisp.cons.org>.
|
||||
#
|
||||
/^# Packages using this file: / {
|
||||
s/# Packages using this file://
|
||||
ta
|
||||
:a
|
||||
s/ @PACKAGE@ / @PACKAGE@ /
|
||||
tb
|
||||
s/ $/ @PACKAGE@ /
|
||||
:b
|
||||
s/^/# Packages using this file:/
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
/^# Packages using this file: / {
|
||||
s/# Packages using this file://
|
||||
s/ guile / /
|
||||
s/^/# Packages using this file:/
|
||||
}
|
25
lib/ref-del.sin
Normal file
25
lib/ref-del.sin
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Remove this package from a list of references stored in a text file.
|
||||
#
|
||||
# Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Written by Bruno Haible <haible@clisp.cons.org>.
|
||||
#
|
||||
/^# Packages using this file: / {
|
||||
s/# Packages using this file://
|
||||
s/ @PACKAGE@ / /
|
||||
s/^/# Packages using this file:/
|
||||
}
|
176
lib/streq.h
Normal file
176
lib/streq.h
Normal file
|
@ -0,0 +1,176 @@
|
|||
/* Optimized string comparison.
|
||||
Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>. */
|
||||
|
||||
#ifndef _GL_STREQ_H
|
||||
#define _GL_STREQ_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* STREQ allows to optimize string comparison with a small literal string.
|
||||
STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
is semantically equivalent to
|
||||
strcmp (s, "EUC-KR") == 0
|
||||
just faster. */
|
||||
|
||||
/* Help GCC to generate good code for string comparisons with
|
||||
immediate strings. */
|
||||
#if defined (__GNUC__) && defined (__OPTIMIZE__)
|
||||
|
||||
static inline int
|
||||
streq9 (const char *s1, const char *s2)
|
||||
{
|
||||
return strcmp (s1 + 9, s2 + 9) == 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq8 (const char *s1, const char *s2, char s28)
|
||||
{
|
||||
if (s1[8] == s28)
|
||||
{
|
||||
if (s28 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq9 (s1, s2);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq7 (const char *s1, const char *s2, char s27, char s28)
|
||||
{
|
||||
if (s1[7] == s27)
|
||||
{
|
||||
if (s27 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq8 (s1, s2, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[6] == s26)
|
||||
{
|
||||
if (s26 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq7 (s1, s2, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[5] == s25)
|
||||
{
|
||||
if (s25 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq6 (s1, s2, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[4] == s24)
|
||||
{
|
||||
if (s24 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq5 (s1, s2, s25, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[3] == s23)
|
||||
{
|
||||
if (s23 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq4 (s1, s2, s24, s25, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[2] == s22)
|
||||
{
|
||||
if (s22 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[1] == s21)
|
||||
{
|
||||
if (s21 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
|
||||
{
|
||||
if (s1[0] == s20)
|
||||
{
|
||||
if (s20 == 0)
|
||||
return 1;
|
||||
else
|
||||
return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
|
||||
streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
|
||||
|
||||
#else
|
||||
|
||||
#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
|
||||
(strcmp (s1, s2) == 0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _GL_STREQ_H */
|
119
lib/strings.h
119
lib/strings.h
|
@ -1,119 +0,0 @@
|
|||
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
||||
/* A substitute <strings.h>.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GL_STRINGS_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#include_next <strings.h>
|
||||
|
||||
#ifndef _GL_STRINGS_H
|
||||
#define _GL_STRINGS_H
|
||||
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
|
||||
a linker warning on most glibc systems.
|
||||
We use a linker warning rather than a preprocessor warning, because
|
||||
#warning cannot be used inside macros. */
|
||||
#ifndef GL_LINK_WARNING
|
||||
/* This works on platforms with GNU ld and ELF object format.
|
||||
Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
|
||||
Testing __ELF__ guarantees the ELF object format.
|
||||
Testing __GNUC__ is necessary for the compound expression syntax. */
|
||||
# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
|
||||
# define GL_LINK_WARNING(message) \
|
||||
GL_LINK_WARNING1 (__FILE__, __LINE__, message)
|
||||
# define GL_LINK_WARNING1(file, line, message) \
|
||||
GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */
|
||||
# define GL_LINK_WARNING2(file, line, message) \
|
||||
GL_LINK_WARNING3 (file ":" #line ": warning: " message)
|
||||
# define GL_LINK_WARNING3(message) \
|
||||
({ static const char warning[sizeof (message)] \
|
||||
__attribute__ ((__unused__, \
|
||||
__section__ (".gnu.warning"), \
|
||||
__aligned__ (1))) \
|
||||
= message "\n"; \
|
||||
(void)0; \
|
||||
})
|
||||
# else
|
||||
# define GL_LINK_WARNING(message) ((void) 0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less than, equal to or greater
|
||||
than S2.
|
||||
Note: This function does not work in multibyte locales. */
|
||||
#if ! 1
|
||||
extern int strcasecmp (char const *s1, char const *s2);
|
||||
#endif
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strcasecmp() does not work with multibyte strings:
|
||||
POSIX says that it operates on "strings", and "string" in POSIX is defined
|
||||
as a sequence of bytes, not of characters. */
|
||||
# undef strcasecmp
|
||||
# define strcasecmp(a,b) \
|
||||
(GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbscasecmp if you care about " \
|
||||
"internationalization, or use c_strcasecmp (from " \
|
||||
"gnulib module c-strcase) if you want a locale " \
|
||||
"independent function"), \
|
||||
strcasecmp (a, b))
|
||||
#endif
|
||||
|
||||
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
|
||||
returning less than, equal to or greater than zero if S1 is
|
||||
lexicographically less than, equal to or greater than S2.
|
||||
Note: This function cannot work correctly in multibyte locales. */
|
||||
#if ! 1
|
||||
extern int strncasecmp (char const *s1, char const *s2, size_t n);
|
||||
#endif
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strncasecmp() does not work with multibyte strings:
|
||||
POSIX says that it operates on "strings", and "string" in POSIX is defined
|
||||
as a sequence of bytes, not of characters. */
|
||||
# undef strncasecmp
|
||||
# define strncasecmp(a,b,n) \
|
||||
(GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \
|
||||
"strings in multibyte locales - " \
|
||||
"use mbsncasecmp or mbspcasecmp if you care about " \
|
||||
"internationalization, or use c_strncasecmp (from " \
|
||||
"gnulib module c-strcase) if you want a locale " \
|
||||
"independent function"), \
|
||||
strncasecmp (a, b, n))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_STRING_H */
|
||||
#endif /* _GL_STRING_H */
|
119
lib/time.h
119
lib/time.h
|
@ -1,119 +0,0 @@
|
|||
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
||||
/* A more-standard <time.h>.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
/* Don't get in the way of glibc when it includes time.h merely to
|
||||
declare a few standard symbols, rather than to declare all the
|
||||
symbols. Also, Solaris 8 <time.h> eventually includes itself
|
||||
recursively; if that is happening, just include the system <time.h>
|
||||
without adding our own declarations. */
|
||||
#if (defined __need_time_t || defined __need_clock_t \
|
||||
|| defined __need_timespec \
|
||||
|| defined _GL_TIME_H)
|
||||
|
||||
# include_next <time.h>
|
||||
|
||||
#else
|
||||
|
||||
# define _GL_TIME_H
|
||||
|
||||
# include_next <time.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
|
||||
Or they define it with the wrong member names or define it in <sys/time.h>
|
||||
(e.g., FreeBSD circa 1997). */
|
||||
# if ! 1
|
||||
# if 0
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# undef timespec
|
||||
# define timespec rpl_timespec
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec;
|
||||
long int tv_nsec;
|
||||
};
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
|
||||
return -1 and store the remaining time into RMTP. See
|
||||
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
|
||||
# if GNULIB_PORTCHECK
|
||||
# define nanosleep rpl_nanosleep
|
||||
int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
|
||||
# endif
|
||||
|
||||
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
|
||||
<http://www.opengroup.org/susv3xsh/localtime_r.html> and
|
||||
<http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
|
||||
# if 0
|
||||
# undef localtime_r
|
||||
# define localtime_r rpl_localtime_r
|
||||
# undef gmtime_r
|
||||
# define gmtime_r rpl_gmtime_r
|
||||
struct tm *localtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result);
|
||||
struct tm *gmtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result);
|
||||
# endif
|
||||
|
||||
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
|
||||
the resulting broken-down time into TM. See
|
||||
<http://www.opengroup.org/susv3xsh/strptime.html>. */
|
||||
# if GNULIB_PORTCHECK
|
||||
# undef strptime
|
||||
# define strptime rpl_strptime
|
||||
char *strptime (char const *restrict __buf, char const *restrict __format,
|
||||
struct tm *restrict __tm);
|
||||
# endif
|
||||
|
||||
/* Convert TM to a time_t value, assuming UTC. */
|
||||
# if GNULIB_PORTCHECK
|
||||
# undef timegm
|
||||
# define timegm rpl_timegm
|
||||
time_t timegm (struct tm *__tm);
|
||||
# endif
|
||||
|
||||
/* Encourage applications to avoid unsafe functions that can overrun
|
||||
buffers when given outlandish struct tm values. Portable
|
||||
applications should use strftime (or even sprintf) instead. */
|
||||
# if GNULIB_PORTCHECK
|
||||
# undef asctime
|
||||
# define asctime eschew_asctime
|
||||
# undef asctime_r
|
||||
# define asctime_r eschew_asctime_r
|
||||
# undef ctime
|
||||
# define ctime eschew_ctime
|
||||
# undef ctime_r
|
||||
# define ctime_r eschew_ctime_r
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
583
lib/unistd.h
583
lib/unistd.h
|
@ -1,583 +0,0 @@
|
|||
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
||||
/* Substitute for and wrapper around <unistd.h>.
|
||||
Copyright (C) 2003-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GL_UNISTD_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if 1
|
||||
# include_next <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef _GL_UNISTD_H
|
||||
#define _GL_UNISTD_H
|
||||
|
||||
/* mingw doesn't define the SEEK_* macros in <unistd.h>. */
|
||||
#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* mingw fails to declare _exit in <unistd.h>. */
|
||||
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#if 1 && 0 && 0
|
||||
/* Get ssize_t. */
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Get all possible declarations of gethostname(). */
|
||||
# if 0
|
||||
# include <winsock2.h>
|
||||
# if !defined _GL_SYS_SOCKET_H
|
||||
# undef socket
|
||||
# define socket socket_used_without_including_sys_socket_h
|
||||
# undef connect
|
||||
# define connect connect_used_without_including_sys_socket_h
|
||||
# undef accept
|
||||
# define accept accept_used_without_including_sys_socket_h
|
||||
# undef bind
|
||||
# define bind bind_used_without_including_sys_socket_h
|
||||
# undef getpeername
|
||||
# define getpeername getpeername_used_without_including_sys_socket_h
|
||||
# undef getsockname
|
||||
# define getsockname getsockname_used_without_including_sys_socket_h
|
||||
# undef getsockopt
|
||||
# define getsockopt getsockopt_used_without_including_sys_socket_h
|
||||
# undef listen
|
||||
# define listen listen_used_without_including_sys_socket_h
|
||||
# undef recv
|
||||
# define recv recv_used_without_including_sys_socket_h
|
||||
# undef send
|
||||
# define send send_used_without_including_sys_socket_h
|
||||
# undef recvfrom
|
||||
# define recvfrom recvfrom_used_without_including_sys_socket_h
|
||||
# undef sendto
|
||||
# define sendto sendto_used_without_including_sys_socket_h
|
||||
# undef setsockopt
|
||||
# define setsockopt setsockopt_used_without_including_sys_socket_h
|
||||
# undef shutdown
|
||||
# define shutdown shutdown_used_without_including_sys_socket_h
|
||||
# endif
|
||||
# if !defined _GL_SYS_SELECT_H
|
||||
# undef select
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
|
||||
a linker warning on most glibc systems.
|
||||
We use a linker warning rather than a preprocessor warning, because
|
||||
#warning cannot be used inside macros. */
|
||||
#ifndef GL_LINK_WARNING
|
||||
/* This works on platforms with GNU ld and ELF object format.
|
||||
Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
|
||||
Testing __ELF__ guarantees the ELF object format.
|
||||
Testing __GNUC__ is necessary for the compound expression syntax. */
|
||||
# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
|
||||
# define GL_LINK_WARNING(message) \
|
||||
GL_LINK_WARNING1 (__FILE__, __LINE__, message)
|
||||
# define GL_LINK_WARNING1(file, line, message) \
|
||||
GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */
|
||||
# define GL_LINK_WARNING2(file, line, message) \
|
||||
GL_LINK_WARNING3 (file ":" #line ": warning: " message)
|
||||
# define GL_LINK_WARNING3(message) \
|
||||
({ static const char warning[sizeof (message)] \
|
||||
__attribute__ ((__unused__, \
|
||||
__section__ (".gnu.warning"), \
|
||||
__aligned__ (1))) \
|
||||
= message "\n"; \
|
||||
(void)0; \
|
||||
})
|
||||
# else
|
||||
# define GL_LINK_WARNING(message) ((void) 0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Declare overridden functions. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
# ifndef REPLACE_CHOWN
|
||||
# define REPLACE_CHOWN 1
|
||||
# endif
|
||||
# if REPLACE_CHOWN
|
||||
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
|
||||
to GID (if GID is not -1). Follow symbolic links.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/chown.html>. */
|
||||
# define chown rpl_chown
|
||||
extern int chown (const char *file, uid_t uid, gid_t gid);
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef chown
|
||||
# define chown(f,u,g) \
|
||||
(GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
|
||||
"doesn't treat a uid or gid of -1 on some systems - " \
|
||||
"use gnulib module chown for portability"), \
|
||||
chown (f, u, g))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
/* Need a gnulib internal function. */
|
||||
# define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
|
||||
# endif
|
||||
# if 0
|
||||
/* Automatically included by modules that need a replacement for close. */
|
||||
# undef close
|
||||
# define close rpl_close
|
||||
extern int close (int);
|
||||
# endif
|
||||
#elif 0
|
||||
# undef close
|
||||
# define close close_used_without_requesting_gnulib_module_close
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef close
|
||||
# define close(f) \
|
||||
(GL_LINK_WARNING ("close does not portably work on sockets - " \
|
||||
"use gnulib module close for portability"), \
|
||||
close (f))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
|
||||
NEWFD = OLDFD, otherwise close NEWFD first if it is open.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/dup2.html>. */
|
||||
extern int dup2 (int oldfd, int newfd);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef dup2
|
||||
# define dup2(o,n) \
|
||||
(GL_LINK_WARNING ("dup2 is unportable - " \
|
||||
"use gnulib module dup2 for portability"), \
|
||||
dup2 (o, n))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Set of environment variables and values. An array of strings of the form
|
||||
"VARIABLE=VALUE", terminated with a NULL. */
|
||||
# if defined __APPLE__ && defined __MACH__
|
||||
# include <crt_externs.h>
|
||||
# define environ (*_NSGetEnviron ())
|
||||
# else
|
||||
extern char **environ;
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef environ
|
||||
# define environ \
|
||||
(GL_LINK_WARNING ("environ is unportable - " \
|
||||
"use gnulib module environ for portability"), \
|
||||
environ)
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Like access(), except that is uses the effective user id and group id of
|
||||
the current process. */
|
||||
extern int euidaccess (const char *filename, int mode);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef euidaccess
|
||||
# define euidaccess(f,m) \
|
||||
(GL_LINK_WARNING ("euidaccess is unportable - " \
|
||||
"use gnulib module euidaccess for portability"), \
|
||||
euidaccess (f, m))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
|
||||
/* Change the process' current working directory to the directory on which
|
||||
the given file descriptor is open.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
|
||||
extern int fchdir (int /*fd*/);
|
||||
|
||||
# define dup rpl_dup
|
||||
extern int dup (int);
|
||||
# define dup2 rpl_dup2
|
||||
extern int dup2 (int, int);
|
||||
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fchdir
|
||||
# define fchdir(f) \
|
||||
(GL_LINK_WARNING ("fchdir is unportable - " \
|
||||
"use gnulib module fchdir for portability"), \
|
||||
fchdir (f))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Synchronize changes to a file.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/fsync.html>. */
|
||||
# if !1
|
||||
extern int fsync (int fd);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fsync
|
||||
# define fsync(fd) \
|
||||
(GL_LINK_WARNING ("fsync is unportable - " \
|
||||
"use gnulib module fsync for portability"), \
|
||||
fsync (fd))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Change the size of the file to which FD is opened to become equal to LENGTH.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/ftruncate.html>. */
|
||||
extern int ftruncate (int fd, off_t length);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef ftruncate
|
||||
# define ftruncate(f,l) \
|
||||
(GL_LINK_WARNING ("ftruncate is unportable - " \
|
||||
"use gnulib module ftruncate for portability"), \
|
||||
ftruncate (f, l))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Include the headers that might declare getcwd so that they will not
|
||||
cause confusion if included after this file. */
|
||||
# include <stdlib.h>
|
||||
# if 0
|
||||
/* Get the name of the current working directory, and put it in SIZE bytes
|
||||
of BUF.
|
||||
Return BUF if successful, or NULL if the directory couldn't be determined
|
||||
or SIZE was too small.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/getcwd.html>.
|
||||
Additionally, the gnulib module 'getcwd' guarantees the following GNU
|
||||
extension: If BUF is NULL, an array is allocated with 'malloc'; the array
|
||||
is SIZE bytes long, unless SIZE == 0, in which case it is as big as
|
||||
necessary. */
|
||||
# define getcwd rpl_getcwd
|
||||
extern char * getcwd (char *buf, size_t size);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getcwd
|
||||
# define getcwd(b,s) \
|
||||
(GL_LINK_WARNING ("getcwd is unportable - " \
|
||||
"use gnulib module getcwd for portability"), \
|
||||
getcwd (b, s))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Return the NIS domain name of the machine.
|
||||
WARNING! The NIS domain name is unrelated to the fully qualified host name
|
||||
of the machine. It is also unrelated to email addresses.
|
||||
WARNING! The NIS domain name is usually the empty string or "(none)" when
|
||||
not using NIS.
|
||||
|
||||
Put up to LEN bytes of the NIS domain name into NAME.
|
||||
Null terminate it if the name is shorter than LEN.
|
||||
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
|
||||
Return 0 if successful, otherwise set errno and return -1. */
|
||||
# if !1
|
||||
extern int getdomainname(char *name, size_t len);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdomainname
|
||||
# define getdomainname(n,l) \
|
||||
(GL_LINK_WARNING ("getdomainname is unportable - " \
|
||||
"use gnulib module getdomainname for portability"), \
|
||||
getdomainname (n, l))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Return the maximum number of file descriptors in the current process. */
|
||||
extern int getdtablesize (void);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdtablesize
|
||||
# define getdtablesize() \
|
||||
(GL_LINK_WARNING ("getdtablesize is unportable - " \
|
||||
"use gnulib module getdtablesize for portability"), \
|
||||
getdtablesize ())
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Return the standard host name of the machine.
|
||||
WARNING! The host name may or may not be fully qualified.
|
||||
|
||||
Put up to LEN bytes of the host name into NAME.
|
||||
Null terminate it if the name is shorter than LEN.
|
||||
If the host name is longer than LEN, set errno = EINVAL and return -1.
|
||||
Return 0 if successful, otherwise set errno and return -1. */
|
||||
# if 0
|
||||
# undef gethostname
|
||||
# define gethostname rpl_gethostname
|
||||
# endif
|
||||
# if 0 || !1
|
||||
extern int gethostname(char *name, size_t len);
|
||||
# endif
|
||||
#elif 0
|
||||
# undef gethostname
|
||||
# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef gethostname
|
||||
# define gethostname(n,l) \
|
||||
(GL_LINK_WARNING ("gethostname is unportable - " \
|
||||
"use gnulib module gethostname for portability"), \
|
||||
gethostname (n, l))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Copies the user's login name to NAME.
|
||||
The array pointed to by NAME has room for SIZE bytes.
|
||||
|
||||
Returns 0 if successful. Upon error, an error number is returned, or -1 in
|
||||
the case that the login name cannot be found but no specific error is
|
||||
provided (this case is hopefully rare but is left open by the POSIX spec).
|
||||
|
||||
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
|
||||
*/
|
||||
# if !1
|
||||
# include <stddef.h>
|
||||
extern int getlogin_r (char *name, size_t size);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getlogin_r
|
||||
# define getlogin_r(n,s) \
|
||||
(GL_LINK_WARNING ("getlogin_r is unportable - " \
|
||||
"use gnulib module getlogin_r for portability"), \
|
||||
getlogin_r (n, s))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
# define getpagesize rpl_getpagesize
|
||||
extern int getpagesize (void);
|
||||
# elif !1
|
||||
/* This is for POSIX systems. */
|
||||
# if !defined getpagesize && defined _SC_PAGESIZE
|
||||
# if ! (defined __VMS && __VMS_VER < 70000000)
|
||||
# define getpagesize() sysconf (_SC_PAGESIZE)
|
||||
# endif
|
||||
# endif
|
||||
/* This is for older VMS. */
|
||||
# if !defined getpagesize && defined __VMS
|
||||
# ifdef __ALPHA
|
||||
# define getpagesize() 8192
|
||||
# else
|
||||
# define getpagesize() 512
|
||||
# endif
|
||||
# endif
|
||||
/* This is for BeOS. */
|
||||
# if !defined getpagesize && 0
|
||||
# include <OS.h>
|
||||
# if defined B_PAGE_SIZE
|
||||
# define getpagesize() B_PAGE_SIZE
|
||||
# endif
|
||||
# endif
|
||||
/* This is for AmigaOS4.0. */
|
||||
# if !defined getpagesize && defined __amigaos4__
|
||||
# define getpagesize() 2048
|
||||
# endif
|
||||
/* This is for older Unix systems. */
|
||||
# if !defined getpagesize && 0
|
||||
# include <sys/param.h>
|
||||
# ifdef EXEC_PAGESIZE
|
||||
# define getpagesize() EXEC_PAGESIZE
|
||||
# else
|
||||
# ifdef NBPG
|
||||
# ifndef CLSIZE
|
||||
# define CLSIZE 1
|
||||
# endif
|
||||
# define getpagesize() (NBPG * CLSIZE)
|
||||
# else
|
||||
# ifdef NBPC
|
||||
# define getpagesize() NBPC
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getpagesize
|
||||
# define getpagesize() \
|
||||
(GL_LINK_WARNING ("getpagesize is unportable - " \
|
||||
"use gnulib module getpagesize for portability"), \
|
||||
getpagesize ())
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if !1
|
||||
/* Return the next valid login shell on the system, or NULL when the end of
|
||||
the list has been reached. */
|
||||
extern char *getusershell (void);
|
||||
/* Rewind to pointer that is advanced at each getusershell() call. */
|
||||
extern void setusershell (void);
|
||||
/* Free the pointer that is advanced at each getusershell() call and
|
||||
associated resources. */
|
||||
extern void endusershell (void);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getusershell
|
||||
# define getusershell() \
|
||||
(GL_LINK_WARNING ("getusershell is unportable - " \
|
||||
"use gnulib module getusershell for portability"), \
|
||||
getusershell ())
|
||||
# undef setusershell
|
||||
# define setusershell() \
|
||||
(GL_LINK_WARNING ("setusershell is unportable - " \
|
||||
"use gnulib module getusershell for portability"), \
|
||||
setusershell ())
|
||||
# undef endusershell
|
||||
# define endusershell() \
|
||||
(GL_LINK_WARNING ("endusershell is unportable - " \
|
||||
"use gnulib module getusershell for portability"), \
|
||||
endusershell ())
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
|
||||
to GID (if GID is not -1). Do not follow symbolic links.
|
||||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/lchown.html>. */
|
||||
# define lchown rpl_lchown
|
||||
extern int lchown (char const *file, uid_t owner, gid_t group);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lchown
|
||||
# define lchown(f,u,g) \
|
||||
(GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
|
||||
"systems - use gnulib module lchown for portability"), \
|
||||
lchown (f, u, g))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
|
||||
Return the new offset if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/lseek.html>. */
|
||||
# define lseek rpl_lseek
|
||||
extern off_t lseek (int fd, off_t offset, int whence);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lseek
|
||||
# define lseek(f,o,w) \
|
||||
(GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
|
||||
"systems - use gnulib module lseek for portability"), \
|
||||
lseek (f, o, w))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
|
||||
bytes of it into BUF. Return the number of bytes placed into BUF if
|
||||
successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/readlink.html>. */
|
||||
# if !1
|
||||
# include <stddef.h>
|
||||
extern int readlink (const char *file, char *buf, size_t bufsize);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef readlink
|
||||
# define readlink(f,b,s) \
|
||||
(GL_LINK_WARNING ("readlink is unportable - " \
|
||||
"use gnulib module readlink for portability"), \
|
||||
readlink (f, b, s))
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* Pause the execution of the current thread for N seconds.
|
||||
Returns the number of seconds left to sleep.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/sleep.html>. */
|
||||
# if !1
|
||||
extern unsigned int sleep (unsigned int n);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef sleep
|
||||
# define sleep(n) \
|
||||
(GL_LINK_WARNING ("sleep is unportable - " \
|
||||
"use gnulib module sleep for portability"), \
|
||||
sleep (n))
|
||||
#endif
|
||||
|
||||
|
||||
#if 1 && 0 && 0
|
||||
/* Write up to COUNT bytes starting at BUF to file descriptor FD.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/write.html>. */
|
||||
# undef write
|
||||
# define write rpl_write
|
||||
extern ssize_t write (int fd, const void *buf, size_t count);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FCHDIR_REPLACEMENT
|
||||
/* gnulib internal function. */
|
||||
extern void _gl_unregister_fd (int fd);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _GL_UNISTD_H */
|
||||
#endif /* _GL_UNISTD_H */
|
10
m4/.gitignore
vendored
10
m4/.gitignore
vendored
|
@ -1,12 +1,2 @@
|
|||
/libtool.m4
|
||||
/lt*.m4
|
||||
/codeset.m4
|
||||
/glibc21.m4
|
||||
/gnulib-comp.m4
|
||||
/localcharset.m4
|
||||
/locale-fr.m4
|
||||
/locale-ja.m4
|
||||
/locale-zh.m4
|
||||
/mbrlen.m4
|
||||
/mbrtowc.m4
|
||||
/mbsinit.m4
|
||||
|
|
21
m4/codeset.m4
Normal file
21
m4/codeset.m4
Normal file
|
@ -0,0 +1,21 @@
|
|||
# codeset.m4 serial 3 (gettext-0.18)
|
||||
dnl Copyright (C) 2000-2002, 2006, 2008 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_TRY_LINK([#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
|
||||
])
|
30
m4/glibc21.m4
Normal file
30
m4/glibc21.m4
Normal file
|
@ -0,0 +1,30 @@
|
|||
# glibc21.m4 serial 4
|
||||
dnl Copyright (C) 2000-2002, 2004, 2008 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.
|
||||
|
||||
# Test for the GNU C Library, version 2.1 or newer.
|
||||
# From Bruno Haible.
|
||||
|
||||
AC_DEFUN([gl_GLIBC21],
|
||||
[
|
||||
AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
|
||||
[ac_cv_gnu_library_2_1],
|
||||
[AC_EGREP_CPP([Lucky GNU user],
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
|
||||
Lucky GNU user
|
||||
#endif
|
||||
#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"
|
||||
]
|
||||
)
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
|
||||
# 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=build-aux --lgpl --libtool --macro-prefix=gl alloca-opt autobuild count-one-bits extensions full-read full-write strcase strftime
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl --no-vc-files alloca-opt autobuild count-one-bits extensions full-read full-write strcase strftime
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
|
@ -41,3 +41,4 @@ gl_MAKEFILE_NAME([])
|
|||
gl_LIBTOOL
|
||||
gl_MACRO_PREFIX([gl])
|
||||
gl_PO_DOMAIN([])
|
||||
gl_VC_FILES([false])
|
||||
|
|
16
m4/localcharset.m4
Normal file
16
m4/localcharset.m4
Normal file
|
@ -0,0 +1,16 @@
|
|||
# localcharset.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2004, 2006 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_CHECK_DECLS_ONCE(getc_unlocked)
|
||||
|
||||
dnl Prerequisites of the lib/Makefile.am snippet.
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([gl_GLIBC21])
|
||||
])
|
204
m4/locale-fr.m4
Normal file
204
m4/locale-fr.m4
Normal file
|
@ -0,0 +1,204 @@
|
|||
# locale-fr.m4 serial 9
|
||||
dnl Copyright (C) 2003, 2005-2008 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, [
|
||||
macosx=
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
darwin[56]*) ;;
|
||||
darwin*) macosx=yes;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test -n "$macosx"; then
|
||||
# On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
|
||||
# encodings, but the kernel does not support them. The documentation
|
||||
# says:
|
||||
# "... all code that calls BSD system routines should ensure
|
||||
# that the const *char parameters of these routines are in UTF-8
|
||||
# encoding. All BSD system functions expect their string
|
||||
# parameters to be in UTF-8 encoding and nothing else."
|
||||
# See the comments in config.charset. Therefore we bypass the test.
|
||||
gt_cv_locale_fr=none
|
||||
else
|
||||
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 (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On MacOS 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 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;
|
||||
/* 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;
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on MacOS 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
|
||||
fi
|
||||
rm -fr conftest*
|
||||
fi
|
||||
])
|
||||
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 (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On MacOS 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
|
||||
/* 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;
|
||||
return 0;
|
||||
}
|
||||
changequote([,])dnl
|
||||
])])
|
||||
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on MacOS 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
|
||||
fi
|
||||
rm -fr conftest*
|
||||
])
|
||||
LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
|
||||
AC_SUBST([LOCALE_FR_UTF8])
|
||||
])
|
126
m4/locale-ja.m4
Normal file
126
m4/locale-ja.m4
Normal file
|
@ -0,0 +1,126 @@
|
|||
# locale-ja.m4 serial 5
|
||||
dnl Copyright (C) 2003, 2005-2008 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, [
|
||||
macosx=
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
darwin[56]*) ;;
|
||||
darwin*) macosx=yes;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test -n "$macosx"; then
|
||||
# On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
|
||||
# encodings, but the kernel does not support them. The documentation
|
||||
# says:
|
||||
# "... all code that calls BSD system routines should ensure
|
||||
# that the const *char parameters of these routines are in UTF-8
|
||||
# encoding. All BSD system functions expect their string
|
||||
# parameters to be in UTF-8 encoding and nothing else."
|
||||
# See the comments in config.charset. Therefore we bypass the test.
|
||||
gt_cv_locale_ja=none
|
||||
else
|
||||
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 (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On MacOS 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 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. */
|
||||
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
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on MacOS 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
|
||||
fi
|
||||
rm -fr conftest*
|
||||
fi
|
||||
])
|
||||
LOCALE_JA=$gt_cv_locale_ja
|
||||
AC_SUBST([LOCALE_JA])
|
||||
])
|
111
m4/locale-zh.m4
Normal file
111
m4/locale-zh.m4
Normal file
|
@ -0,0 +1,111 @@
|
|||
# locale-zh.m4 serial 4
|
||||
dnl Copyright (C) 2003, 2005-2008 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, [
|
||||
macosx=
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
darwin[56]*) ;;
|
||||
darwin*) macosx=yes;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test -n "$macosx"; then
|
||||
# On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
|
||||
# encodings, but the kernel does not support them. The documentation
|
||||
# says:
|
||||
# "... all code that calls BSD system routines should ensure
|
||||
# that the const *char parameters of these routines are in UTF-8
|
||||
# encoding. All BSD system functions expect their string
|
||||
# parameters to be in UTF-8 encoding and nothing else."
|
||||
# See the comments in config.charset. Therefore we bypass the test.
|
||||
gt_cv_locale_zh_CN=none
|
||||
else
|
||||
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 (setlocale (LC_ALL, "") == NULL) return 1;
|
||||
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
|
||||
On MacOS 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 a month name, no byte in the range 0x80..0x9F occurs.
|
||||
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) < 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
|
||||
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
|
||||
# otherwise on MacOS 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
|
||||
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*
|
||||
fi
|
||||
])
|
||||
LOCALE_ZH_CN=$gt_cv_locale_zh_CN
|
||||
AC_SUBST([LOCALE_ZH_CN])
|
||||
])
|
197
m4/mbrlen.m4
Normal file
197
m4/mbrlen.m4
Normal file
|
@ -0,0 +1,197 @@
|
|||
# mbrlen.m4 serial 2
|
||||
dnl Copyright (C) 2008 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_MBRLEN],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
AC_REQUIRE([gl_FUNC_MBRTOWC])
|
||||
AC_CHECK_FUNCS_ONCE([mbrlen])
|
||||
if test $ac_cv_func_mbrlen = no; then
|
||||
HAVE_MBRLEN=0
|
||||
else
|
||||
dnl Most bugs affecting the system's mbrtowc function also affect the
|
||||
dnl mbrlen function. So override mbrlen whenever mbrtowc is overridden.
|
||||
dnl We could also run the individual tests below; the results would be
|
||||
dnl the same.
|
||||
if test $REPLACE_MBRTOWC = 1; then
|
||||
REPLACE_MBRLEN=1
|
||||
fi
|
||||
fi
|
||||
if test $HAVE_MBRLEN = 0 || test $REPLACE_MBRLEN = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
AC_LIBOBJ([mbrlen])
|
||||
gl_PREREQ_MBRLEN
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Test whether mbrlen puts the state into non-initial state when parsing an
|
||||
dnl incomplete multibyte character.
|
||||
dnl Result is gl_cv_func_mbrlen_incomplete_state.
|
||||
|
||||
AC_DEFUN([gl_MBRLEN_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 mbrlen handles incomplete characters],
|
||||
[gl_cv_func_mbrlen_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.
|
||||
osf*) gl_cv_func_mbrlen_incomplete_state="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrlen_incomplete_state="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_JA != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.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;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrlen (input + 1, 1, &state) == (size_t)(-2))
|
||||
if (mbsinit (&state))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrlen_incomplete_state=yes],
|
||||
[gl_cv_func_mbrlen_incomplete_state=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrlen, 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_mbrlen_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRLEN_RETVAL],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR_UTF8])
|
||||
AC_REQUIRE([gt_LOCALE_JA])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
AC_CACHE_CHECK([whether mbrlen has a correct return value],
|
||||
[gl_cv_func_mbrlen_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 and Solaris.
|
||||
hpux* | solaris*) gl_cv_func_mbrlen_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrlen_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
|
||||
{
|
||||
char input[] = "B\303\274\303\237er"; /* "Büßer" */
|
||||
mbstate_t state;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrlen (input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrlen (input + 2, 5, &state) != 1)
|
||||
return 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;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrlen (input + 1, 1, &state) == (size_t)(-2))
|
||||
{
|
||||
input[1] = '\0';
|
||||
if (mbrlen (input + 2, 5, &state) != 2)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrlen_retval=yes],
|
||||
[gl_cv_func_mbrlen_retval=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
dnl Test whether mbrlen, when parsing a NUL character, correctly returns 0.
|
||||
dnl Result is gl_cv_func_mbrlen_nul_retval.
|
||||
|
||||
AC_DEFUN([gl_MBRLEN_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 mbrlen returns 0 when parsing a NUL character],
|
||||
[gl_cv_func_mbrlen_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 9.
|
||||
solaris2.9) gl_cv_func_mbrlen_nul_retval="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrlen_nul_retval="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_ZH_CN != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This crashes on Solaris 9 inside __mbrtowc_dense_gb18030. */
|
||||
if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
|
||||
{
|
||||
mbstate_t state;
|
||||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
if (mbrlen ("", 1, &state) != 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrlen_nul_retval=yes],
|
||||
[gl_cv_func_mbrlen_nul_retval=no],
|
||||
[])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/mbrlen.c.
|
||||
AC_DEFUN([gl_PREREQ_MBRLEN], [
|
||||
:
|
||||
])
|
325
m4/mbrtowc.m4
Normal file
325
m4/mbrtowc.m4
Normal file
|
@ -0,0 +1,325 @@
|
|||
# mbrtowc.m4 serial 12
|
||||
dnl Copyright (C) 2001-2002, 2004-2005, 2008 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_MBRTOWC],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
gl_MBSTATE_T_BROKEN
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
REPLACE_MBRTOWC=1
|
||||
fi
|
||||
AC_CHECK_FUNCS_ONCE([mbrtowc])
|
||||
if test $ac_cv_func_mbrtowc = no; then
|
||||
HAVE_MBRTOWC=0
|
||||
fi
|
||||
if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
|
||||
gl_MBRTOWC_NULL_ARG
|
||||
gl_MBRTOWC_RETVAL
|
||||
gl_MBRTOWC_NUL_RETVAL
|
||||
case "$gl_cv_func_mbrtowc_null_arg" in
|
||||
*yes) ;;
|
||||
*) AC_DEFINE([MBRTOWC_NULL_ARG_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
|
||||
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
AC_LIBOBJ([mbrtowc])
|
||||
gl_PREREQ_MBRTOWC
|
||||
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
|
||||
case "$gl_cv_func_mbrtowc_incomplete_state" in
|
||||
*yes) REPLACE_MBSTATE_T=0 ;;
|
||||
*) REPLACE_MBSTATE_T=1 ;;
|
||||
esac
|
||||
else
|
||||
REPLACE_MBSTATE_T=1
|
||||
fi
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
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.
|
||||
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_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.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 supports a NULL string argument correctly.
|
||||
dnl Result is gl_cv_func_mbrtowc_null_arg.
|
||||
|
||||
AC_DEFUN([gl_MBRTOWC_NULL_ARG],
|
||||
[
|
||||
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_arg],
|
||||
[
|
||||
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_arg="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_mbrtowc_null_arg="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
if test $LOCALE_FR_UTF8 != none; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.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_arg=yes], [gl_cv_func_mbrtowc_null_arg=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]) dnl for cross-compiles
|
||||
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 and Solaris.
|
||||
hpux* | solaris*) 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; then
|
||||
AC_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* 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)
|
||||
return 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)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_mbrtowc_retval=yes],
|
||||
[gl_cv_func_mbrtowc_retval=no],
|
||||
[])
|
||||
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 9.
|
||||
solaris2.9) 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_TRY_RUN([
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
/* This fails on Solaris 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 override of an autoconf macro can be removed when autoconf 2.60 or
|
||||
dnl newer can be assumed everywhere.
|
||||
|
||||
m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
|
||||
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(
|
||||
[[#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
|
||||
])
|
||||
])
|
30
m4/mbsinit.m4
Normal file
30
m4/mbsinit.m4
Normal file
|
@ -0,0 +1,30 @@
|
|||
# mbsinit.m4 serial 3
|
||||
dnl Copyright (C) 2008 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_TYPE_MBSTATE_T])
|
||||
gl_MBSTATE_T_BROKEN
|
||||
if test $REPLACE_MBSTATE_T = 1; then
|
||||
REPLACE_MBSINIT=1
|
||||
fi
|
||||
AC_CHECK_FUNCS_ONCE([mbsinit])
|
||||
if test $ac_cv_func_mbsinit = no; then
|
||||
HAVE_MBSINIT=0
|
||||
fi
|
||||
if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
|
||||
gl_REPLACE_WCHAR_H
|
||||
AC_LIBOBJ([mbsinit])
|
||||
gl_PREREQ_MBSINIT
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/mbsinit.c.
|
||||
AC_DEFUN([gl_PREREQ_MBSINIT], [
|
||||
:
|
||||
])
|
Loading…
Add table
Add a link
Reference in a new issue