plptools-1.0.13/ 0000755 0001750 0001750 00000000000 12417353501 010452 5 0000000 0000000 plptools-1.0.13/install-sh 0000755 0001750 0001750 00000033255 12417352656 012420 0000000 0000000 #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
plptools-1.0.13/Makefile.am 0000644 0001750 0001750 00000001315 12417352220 012423 0000000 0000000 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = intl po lib ncpd plpftp plpprint sisinstall doc
if BUILD_PLPFUSE
SUBDIRS += plpfuse
endif
EXTRA_DIST = AUTHORS COPYING INSTALL NEWS README TODO HISTORY ABOUT-NLS \
etc/s5magic etc/s5kdemagic etc/plptools.in \
etc/ttytap.c etc/psidump etc/psidump.1 \
etc/udev-usbserial-plptools.rules
DISTCLEANFILES = etc/plptools
uninstall-local:
rm -f $(DESTDIR)$(initdir)/plptools
install-exec-local:
install -D $(top_builddir)/etc/plptools $(DESTDIR)$(initdir)/plptools
release: distcheck
git diff && \
git tag rel-`echo $(VERSION) | sed -e 's/\./-/g'` && git push --tag && \
woger sourceforge package=$(PACKAGE) version=$(VERSION) notes=release-notes-$(VERSION) dist_type="tar.gz"
plptools-1.0.13/intl/ 0000755 0001750 0001750 00000000000 12417353500 011417 5 0000000 0000000 plptools-1.0.13/intl/wprintf-parse.h 0000644 0001750 0001750 00000005105 12417352631 014316 0000000 0000000 /* Parse printf format string.
Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011 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.1 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 . */
#ifndef _WPRINTF_PARSE_H
#define _WPRINTF_PARSE_H
#if HAVE_FEATURES_H
# include /* for __GLIBC__, __UCLIBC__ */
#endif
#include "printf-args.h"
/* Flags */
#define FLAG_GROUP 1 /* ' flag */
#define FLAG_LEFT 2 /* - flag */
#define FLAG_SHOWSIGN 4 /* + flag */
#define FLAG_SPACE 8 /* space flag */
#define FLAG_ALT 16 /* # flag */
#define FLAG_ZERO 32
#if __GLIBC__ >= 2 && !defined __UCLIBC__
# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
#endif
/* arg_index value indicating that no argument is consumed. */
#define ARG_NONE (~(size_t)0)
/* Number of directly allocated directives (no malloc() needed). */
#define N_DIRECT_ALLOC_DIRECTIVES 7
/* A parsed directive. */
typedef struct
{
const wchar_t* dir_start;
const wchar_t* dir_end;
int flags;
const wchar_t* width_start;
const wchar_t* width_end;
size_t width_arg_index;
const wchar_t* precision_start;
const wchar_t* precision_end;
size_t precision_arg_index;
wchar_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
size_t arg_index;
}
wchar_t_directive;
/* A parsed format string. */
typedef struct
{
size_t count;
wchar_t_directive *dir;
size_t max_width_length;
size_t max_precision_length;
wchar_t_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
}
wchar_t_directives;
/* Parses the format string. Fills in the number N of directives, and fills
in directives[0], ..., directives[N-1], and sets directives[N].dir_start
to the end of the format string. Also fills in the arg_type fields of the
arguments and the needed count of arguments. */
#ifdef STATIC
STATIC
#else
extern
#endif
int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
#endif /* _WPRINTF_PARSE_H */
plptools-1.0.13/intl/localcharset.h 0000644 0001750 0001750 00000002466 12417352631 014170 0000000 0000000 /* 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.1 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 . */
#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 */
plptools-1.0.13/intl/ref-del.sin 0000644 0001750 0001750 00000001731 12417352631 013376 0000000 0000000 # 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.1 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 .
#
# Written by Bruno Haible .
#
/^# Packages using this file: / {
s/# Packages using this file://
s/ @PACKAGE@ / /
s/^/# Packages using this file:/
}
plptools-1.0.13/intl/eval-plural.h 0000644 0001750 0001750 00000005245 12417352630 013745 0000000 0000000 /* Plural expression evaluation.
Copyright (C) 2000-2003, 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 2.1 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 . */
#ifndef STATIC
#define STATIC static
#endif
/* Evaluate the plural expression and return an index value. */
STATIC
unsigned long int
internal_function
plural_eval (const struct expression *pexp, unsigned long int n)
{
switch (pexp->nargs)
{
case 0:
switch (pexp->operation)
{
case var:
return n;
case num:
return pexp->val.num;
default:
break;
}
/* NOTREACHED */
break;
case 1:
{
/* pexp->operation must be lnot. */
unsigned long int arg = plural_eval (pexp->val.args[0], n);
return ! arg;
}
case 2:
{
unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
if (pexp->operation == lor)
return leftarg || plural_eval (pexp->val.args[1], n);
else if (pexp->operation == land)
return leftarg && plural_eval (pexp->val.args[1], n);
else
{
unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
switch (pexp->operation)
{
case mult:
return leftarg * rightarg;
case divide:
#if !INTDIV0_RAISES_SIGFPE
if (rightarg == 0)
raise (SIGFPE);
#endif
return leftarg / rightarg;
case module:
#if !INTDIV0_RAISES_SIGFPE
if (rightarg == 0)
raise (SIGFPE);
#endif
return leftarg % rightarg;
case plus:
return leftarg + rightarg;
case minus:
return leftarg - rightarg;
case less_than:
return leftarg < rightarg;
case greater_than:
return leftarg > rightarg;
case less_or_equal:
return leftarg <= rightarg;
case greater_or_equal:
return leftarg >= rightarg;
case equal:
return leftarg == rightarg;
case not_equal:
return leftarg != rightarg;
default:
break;
}
}
/* NOTREACHED */
break;
}
case 3:
{
/* pexp->operation must be qmop. */
unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
}
}
/* NOTREACHED */
return 0;
}
plptools-1.0.13/intl/textdomain.c 0000644 0001750 0001750 00000007371 12417352631 013673 0000000 0000000 /* Implementation of the textdomain(3) function.
Copyright (C) 1995-1998, 2000-2003, 2005-2006 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
# define gl_rwlock_define __libc_rwlock_define
# define gl_rwlock_wrlock __libc_rwlock_wrlock
# define gl_rwlock_unlock __libc_rwlock_unlock
#else
# include "lock.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define TEXTDOMAIN __textdomain
# ifndef strdup
# define strdup(str) __strdup (str)
# endif
#else
# define TEXTDOMAIN libintl_textdomain
#endif
/* Lock variable to protect the global data in the gettext implementation. */
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
char *
TEXTDOMAIN (const char *domainname)
{
char *new_domain;
char *old_domain;
/* A NULL pointer requests the current setting. */
if (domainname == NULL)
return (char *) _nl_current_default_domain;
gl_rwlock_wrlock (_nl_state_lock);
old_domain = (char *) _nl_current_default_domain;
/* If domain name is the null string set to default domain "messages". */
if (domainname[0] == '\0'
|| strcmp (domainname, _nl_default_default_domain) == 0)
{
_nl_current_default_domain = _nl_default_default_domain;
new_domain = (char *) _nl_current_default_domain;
}
else if (strcmp (domainname, old_domain) == 0)
/* This can happen and people will use it to signal that some
environment variable changed. */
new_domain = old_domain;
else
{
/* If the following malloc fails `_nl_current_default_domain'
will be NULL. This value will be returned and so signals we
are out of core. */
#if defined _LIBC || defined HAVE_STRDUP
new_domain = strdup (domainname);
#else
size_t len = strlen (domainname) + 1;
new_domain = (char *) malloc (len);
if (new_domain != NULL)
memcpy (new_domain, domainname, len);
#endif
if (new_domain != NULL)
_nl_current_default_domain = new_domain;
}
/* We use this possibility to signal a change of the loaded catalogs
since this is most likely the case and there is no other easy we
to do it. Do it only when the call was successful. */
if (new_domain != NULL)
{
++_nl_msg_cat_cntr;
if (old_domain != new_domain && old_domain != _nl_default_default_domain)
free (old_domain);
}
gl_rwlock_unlock (_nl_state_lock);
return new_domain;
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__textdomain, textdomain);
#endif
plptools-1.0.13/intl/ChangeLog 0000644 0001750 0001750 00000000111 12417352630 013105 0000000 0000000 2013-07-07 GNU
* Version 0.18.3 released.
plptools-1.0.13/intl/setlocale.c 0000644 0001750 0001750 00000100517 12417352631 013466 0000000 0000000 /* setlocale() function that respects the locale chosen by the user.
Copyright (C) 2009 Free Software Foundation, Inc.
Written by Bruno Haible , 2009.
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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
/* Override setlocale() and newlocale() so that when the default locale is
requested (locale = "") and no relevant environment variable is set, the
locale chosen by the user is used.
This matters on MacOS X 10 and Windows.
See the comments in localename.c, function gl_locale_name_default. */
#include
#include
#include
/* When building a DLL, we must export some functions. Note that because
the functions are only defined for binary backward compatibility, we
don't need to use __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# define DLL_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
# define DLL_EXPORTED __declspec(dllexport)
#else
# define DLL_EXPORTED
#endif
#include "gettextP.h"
#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
# undef setlocale
# undef newlocale
/* Return string representation of locale category CATEGORY. */
static const char *
category_to_name (int category)
{
const char *retval;
switch (category)
{
case LC_COLLATE:
retval = "LC_COLLATE";
break;
case LC_CTYPE:
retval = "LC_CTYPE";
break;
case LC_MONETARY:
retval = "LC_MONETARY";
break;
case LC_NUMERIC:
retval = "LC_NUMERIC";
break;
case LC_TIME:
retval = "LC_TIME";
break;
case LC_MESSAGES:
retval = "LC_MESSAGES";
break;
default:
/* If you have a better idea for a default value let me know. */
retval = "LC_XXX";
}
return retval;
}
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* The native Win32 setlocale() function expects locale names of the form
"German" or "German_Germany" or "DEU", but not "de" or "de_DE". We need
to convert the names from the form with ISO 639 language code and ISO 3166
country code to the form with English names or with three-letter identifier.
The three-letter identifiers known by a Windows XP SP2 or SP3 are:
AFK Afrikaans_South Africa.1252
ARA Arabic_Saudi Arabia.1256
ARB Arabic_Lebanon.1256
ARE Arabic_Egypt.1256
ARG Arabic_Algeria.1256
ARH Arabic_Bahrain.1256
ARI Arabic_Iraq.1256
ARJ Arabic_Jordan.1256
ARK Arabic_Kuwait.1256
ARL Arabic_Libya.1256
ARM Arabic_Morocco.1256
ARO Arabic_Oman.1256
ARQ Arabic_Qatar.1256
ARS Arabic_Syria.1256
ART Arabic_Tunisia.1256
ARU Arabic_U.A.E..1256
ARY Arabic_Yemen.1256
AZE Azeri (Latin)_Azerbaijan.1254
BEL Belarusian_Belarus.1251
BGR Bulgarian_Bulgaria.1251
BSB Bosnian_Bosnia and Herzegovina.1250
BSC Bosnian (Cyrillic)_Bosnia and Herzegovina.1250 (wrong encoding!)
CAT Catalan_Spain.1252
CHH Chinese_Hong Kong S.A.R..950
CHI Chinese_Singapore.936
CHS Chinese_People's Republic of China.936
CHT Chinese_Taiwan.950
CSY Czech_Czech Republic.1250
CYM Welsh_United Kingdom.1252
DAN Danish_Denmark.1252
DEA German_Austria.1252
DEC German_Liechtenstein.1252
DEL German_Luxembourg.1252
DES German_Switzerland.1252
DEU German_Germany.1252
ELL Greek_Greece.1253
ENA English_Australia.1252
ENB English_Caribbean.1252
ENC English_Canada.1252
ENG English_United Kingdom.1252
ENI English_Ireland.1252
ENJ English_Jamaica.1252
ENL English_Belize.1252
ENP English_Republic of the Philippines.1252
ENS English_South Africa.1252
ENT English_Trinidad and Tobago.1252
ENU English_United States.1252
ENW English_Zimbabwe.1252
ENZ English_New Zealand.1252
ESA Spanish_Panama.1252
ESB Spanish_Bolivia.1252
ESC Spanish_Costa Rica.1252
ESD Spanish_Dominican Republic.1252
ESE Spanish_El Salvador.1252
ESF Spanish_Ecuador.1252
ESG Spanish_Guatemala.1252
ESH Spanish_Honduras.1252
ESI Spanish_Nicaragua.1252
ESL Spanish_Chile.1252
ESM Spanish_Mexico.1252
ESN Spanish_Spain.1252
ESO Spanish_Colombia.1252
ESP Spanish_Spain.1252
ESR Spanish_Peru.1252
ESS Spanish_Argentina.1252
ESU Spanish_Puerto Rico.1252
ESV Spanish_Venezuela.1252
ESY Spanish_Uruguay.1252
ESZ Spanish_Paraguay.1252
ETI Estonian_Estonia.1257
EUQ Basque_Spain.1252
FAR Farsi_Iran.1256
FIN Finnish_Finland.1252
FOS Faroese_Faroe Islands.1252
FPO Filipino_Philippines.1252
FRA French_France.1252
FRB French_Belgium.1252
FRC French_Canada.1252
FRL French_Luxembourg.1252
FRM French_Principality of Monaco.1252
FRS French_Switzerland.1252
FYN Frisian_Netherlands.1252
GLC Galician_Spain.1252
HEB Hebrew_Israel.1255
HRB Croatian_Bosnia and Herzegovina.1250
HRV Croatian_Croatia.1250
HUN Hungarian_Hungary.1250
IND Indonesian_Indonesia.1252
IRE Irish_Ireland.1252
ISL Icelandic_Iceland.1252
ITA Italian_Italy.1252
ITS Italian_Switzerland.1252
IUK Inuktitut (Latin)_Canada.1252
JPN Japanese_Japan.932
KKZ Kazakh_Kazakhstan.1251
KOR Korean_Korea.949
KYR Kyrgyz_Kyrgyzstan.1251
LBX Luxembourgish_Luxembourg.1252
LTH Lithuanian_Lithuania.1257
LVI Latvian_Latvia.1257
MKI FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251
MON Mongolian_Mongolia.1251
MPD Mapudungun_Chile.1252
MSB Malay_Brunei Darussalam.1252
MSL Malay_Malaysia.1252
MWK Mohawk_Canada.1252
NLB Dutch_Belgium.1252
NLD Dutch_Netherlands.1252
NON Norwegian-Nynorsk_Norway.1252
NOR Norwegian (Bokmål)_Norway.1252
NSO Northern Sotho_South Africa.1252
PLK Polish_Poland.1250
PTB Portuguese_Brazil.1252
PTG Portuguese_Portugal.1252
QUB Quechua_Bolivia.1252
QUE Quechua_Ecuador.1252
QUP Quechua_Peru.1252
RMC Romansh_Switzerland.1252
ROM Romanian_Romania.1250
RUS Russian_Russia.1251
SKY Slovak_Slovakia.1250
SLV Slovenian_Slovenia.1250
SMA Sami (Southern)_Norway.1252
SMB Sami (Southern)_Sweden.1252
SME Sami (Northern)_Norway.1252
SMF Sami (Northern)_Sweden.1252
SMG Sami (Northern)_Finland.1252
SMJ Sami (Lule)_Norway.1252
SMK Sami (Lule)_Sweden.1252
SMN Sami (Inari)_Finland.1252
SMS Sami (Skolt)_Finland.1252
SQI Albanian_Albania.1250
SRB Serbian (Cyrillic)_Serbia and Montenegro.1251
SRL Serbian (Latin)_Serbia and Montenegro.1250
SRN Serbian (Cyrillic)_Bosnia and Herzegovina.1251
SRS Serbian (Latin)_Bosnia and Herzegovina.1250
SVE Swedish_Sweden.1252
SVF Swedish_Finland.1252
SWK Swahili_Kenya.1252
THA Thai_Thailand.874
TRK Turkish_Turkey.1254
TSN Tswana_South Africa.1252
TTT Tatar_Russia.1251
UKR Ukrainian_Ukraine.1251
URD Urdu_Islamic Republic of Pakistan.1256
USA English_United States.1252
UZB Uzbek (Latin)_Uzbekistan.1254
VIT Vietnamese_Viet Nam.1258
XHO Xhosa_South Africa.1252
ZHH Chinese_Hong Kong S.A.R..950
ZHI Chinese_Singapore.936
ZHM Chinese_Macau S.A.R..950
ZUL Zulu_South Africa.1252
*/
/* Table from ISO 639 language code, optionally with country or script suffix,
to English name.
Keep in sync with the gl_locale_name_from_win32_LANGID function in
localename.c! */
struct table_entry
{
const char *code;
const char *english;
};
static const struct table_entry language_table[] =
{
{ "af", "Afrikaans" },
{ "am", "Amharic" },
{ "ar", "Arabic" },
{ "arn", "Mapudungun" },
{ "as", "Assamese" },
{ "az@cyrillic", "Azeri (Cyrillic)" },
{ "az@latin", "Azeri (Latin)" },
{ "ba", "Bashkir" },
{ "be", "Belarusian" },
{ "ber", "Tamazight" },
{ "ber@arabic", "Tamazight (Arabic)" },
{ "ber@latin", "Tamazight (Latin)" },
{ "bg", "Bulgarian" },
{ "bin", "Edo" },
{ "bn", "Bengali" },
{ "bn_BD", "Bengali (Bangladesh)" },
{ "bn_IN", "Bengali (India)" },
{ "bnt", "Sutu" },
{ "bo", "Tibetan" },
{ "br", "Breton" },
{ "bs", "BSB" }, /* "Bosnian (Latin)" */
{ "bs@cyrillic", "BSC" }, /* Bosnian (Cyrillic) */
{ "ca", "Catalan" },
{ "chr", "Cherokee" },
{ "co", "Corsican" },
{ "cpe", "Hawaiian" },
{ "cs", "Czech" },
{ "cy", "Welsh" },
{ "da", "Danish" },
{ "de", "German" },
{ "dsb", "Lower Sorbian" },
{ "dv", "Divehi" },
{ "el", "Greek" },
{ "en", "English" },
{ "es", "Spanish" },
{ "et", "Estonian" },
{ "eu", "Basque" },
{ "fa", "Farsi" },
{ "ff", "Fulfulde" },
{ "fi", "Finnish" },
{ "fo", "Faroese" }, /* "Faeroese" does not work */
{ "fr", "French" },
{ "fy", "Frisian" },
{ "ga", "IRE" }, /* Gaelic (Ireland) */
{ "gd", "Gaelic (Scotland)" },
{ "gd", "Scottish Gaelic" },
{ "gl", "Galician" },
{ "gn", "Guarani" },
{ "gsw", "Alsatian" },
{ "gu", "Gujarati" },
{ "ha", "Hausa" },
{ "he", "Hebrew" },
{ "hi", "Hindi" },
{ "hr", "Croatian" },
{ "hsb", "Upper Sorbian" },
{ "hu", "Hungarian" },
{ "hy", "Armenian" },
{ "id", "Indonesian" },
{ "ig", "Igbo" },
{ "ii", "Yi" },
{ "is", "Icelandic" },
{ "it", "Italian" },
{ "iu", "IUK" }, /* Inuktitut */
{ "ja", "Japanese" },
{ "ka", "Georgian" },
{ "kk", "Kazakh" },
{ "kl", "Greenlandic" },
{ "km", "Cambodian" },
{ "km", "Khmer" },
{ "kn", "Kannada" },
{ "ko", "Korean" },
{ "kok", "Konkani" },
{ "kr", "Kanuri" },
{ "ks", "Kashmiri" },
{ "ks_IN", "Kashmiri_India" },
{ "ks_PK", "Kashmiri (Arabic)_Pakistan" },
{ "ky", "Kyrgyz" },
{ "la", "Latin" },
{ "lb", "Luxembourgish" },
{ "lo", "Lao" },
{ "lt", "Lithuanian" },
{ "lv", "Latvian" },
{ "mi", "Maori" },
{ "mk", "FYRO Macedonian" },
{ "mk", "Macedonian" },
{ "ml", "Malayalam" },
{ "mn", "Mongolian" },
{ "mni", "Manipuri" },
{ "moh", "Mohawk" },
{ "mr", "Marathi" },
{ "ms", "Malay" },
{ "mt", "Maltese" },
{ "my", "Burmese" },
{ "nb", "NOR" }, /* Norwegian Bokmål */
{ "ne", "Nepali" },
{ "nic", "Ibibio" },
{ "nl", "Dutch" },
{ "nn", "NON" }, /* Norwegian Nynorsk */
{ "no", "Norwegian" },
{ "nso", "Northern Sotho" },
{ "nso", "Sepedi" },
{ "oc", "Occitan" },
{ "om", "Oromo" },
{ "or", "Oriya" },
{ "pa", "Punjabi" },
{ "pap", "Papiamentu" },
{ "pl", "Polish" },
{ "prs", "Dari" },
{ "ps", "Pashto" },
{ "pt", "Portuguese" },
{ "qu", "Quechua" },
{ "qut", "K'iche'" },
{ "rm", "Romansh" },
{ "ro", "Romanian" },
{ "ru", "Russian" },
{ "rw", "Kinyarwanda" },
{ "sa", "Sanskrit" },
{ "sah", "Yakut" },
{ "sd", "Sindhi" },
{ "se", "Sami (Northern)" },
{ "se", "Northern Sami" },
{ "si", "Sinhalese" },
{ "sk", "Slovak" },
{ "sl", "Slovenian" },
{ "sma", "Sami (Southern)" },
{ "sma", "Southern Sami" },
{ "smj", "Sami (Lule)" },
{ "smj", "Lule Sami" },
{ "smn", "Sami (Inari)" },
{ "smn", "Inari Sami" },
{ "sms", "Sami (Skolt)" },
{ "sms", "Skolt Sami" },
{ "so", "Somali" },
{ "sq", "Albanian" },
{ "sr", "Serbian (Latin)" },
{ "sr@cyrillic", "SRB" }, /* Serbian (Cyrillic) */
{ "sw", "Swahili" },
{ "syr", "Syriac" },
{ "ta", "Tamil" },
{ "te", "Telugu" },
{ "tg", "Tajik" },
{ "th", "Thai" },
{ "ti", "Tigrinya" },
{ "tk", "Turkmen" },
{ "tl", "Filipino" },
{ "tn", "Tswana" },
{ "tr", "Turkish" },
{ "ts", "Tsonga" },
{ "tt", "Tatar" },
{ "ug", "Uighur" },
{ "uk", "Ukrainian" },
{ "ur", "Urdu" },
{ "uz", "Uzbek" },
{ "uz", "Uzbek (Latin)" },
{ "uz@cyrillic", "Uzbek (Cyrillic)" },
{ "ve", "Venda" },
{ "vi", "Vietnamese" },
{ "wen", "Sorbian" },
{ "wo", "Wolof" },
{ "xh", "Xhosa" },
{ "yi", "Yiddish" },
{ "yo", "Yoruba" },
{ "zh", "Chinese" },
{ "zu", "Zulu" }
};
/* Table from ISO 3166 country code to English name.
Keep in sync with the gl_locale_name_from_win32_LANGID function in
localename.c! */
static const struct table_entry country_table[] =
{
{ "AE", "U.A.E." },
{ "AF", "Afghanistan" },
{ "AL", "Albania" },
{ "AM", "Armenia" },
{ "AN", "Netherlands Antilles" },
{ "AR", "Argentina" },
{ "AT", "Austria" },
{ "AU", "Australia" },
{ "AZ", "Azerbaijan" },
{ "BA", "Bosnia and Herzegovina" },
{ "BD", "Bangladesh" },
{ "BE", "Belgium" },
{ "BG", "Bulgaria" },
{ "BH", "Bahrain" },
{ "BN", "Brunei Darussalam" },
{ "BO", "Bolivia" },
{ "BR", "Brazil" },
{ "BT", "Bhutan" },
{ "BY", "Belarus" },
{ "BZ", "Belize" },
{ "CA", "Canada" },
{ "CG", "Congo" },
{ "CH", "Switzerland" },
{ "CI", "Cote d'Ivoire" },
{ "CL", "Chile" },
{ "CM", "Cameroon" },
{ "CN", "People's Republic of China" },
{ "CO", "Colombia" },
{ "CR", "Costa Rica" },
{ "CS", "Serbia and Montenegro" },
{ "CZ", "Czech Republic" },
{ "DE", "Germany" },
{ "DK", "Denmark" },
{ "DO", "Dominican Republic" },
{ "DZ", "Algeria" },
{ "EC", "Ecuador" },
{ "EE", "Estonia" },
{ "EG", "Egypt" },
{ "ER", "Eritrea" },
{ "ES", "Spain" },
{ "ET", "Ethiopia" },
{ "FI", "Finland" },
{ "FO", "Faroe Islands" },
{ "FR", "France" },
{ "GB", "United Kingdom" },
{ "GD", "Caribbean" },
{ "GE", "Georgia" },
{ "GL", "Greenland" },
{ "GR", "Greece" },
{ "GT", "Guatemala" },
{ "HK", "Hong Kong" },
{ "HK", "Hong Kong S.A.R." },
{ "HN", "Honduras" },
{ "HR", "Croatia" },
{ "HT", "Haiti" },
{ "HU", "Hungary" },
{ "ID", "Indonesia" },
{ "IE", "Ireland" },
{ "IL", "Israel" },
{ "IN", "India" },
{ "IQ", "Iraq" },
{ "IR", "Iran" },
{ "IS", "Iceland" },
{ "IT", "Italy" },
{ "JM", "Jamaica" },
{ "JO", "Jordan" },
{ "JP", "Japan" },
{ "KE", "Kenya" },
{ "KG", "Kyrgyzstan" },
{ "KH", "Cambodia" },
{ "KR", "South Korea" },
{ "KW", "Kuwait" },
{ "KZ", "Kazakhstan" },
{ "LA", "Laos" },
{ "LB", "Lebanon" },
{ "LI", "Liechtenstein" },
{ "LK", "Sri Lanka" },
{ "LT", "Lithuania" },
{ "LU", "Luxembourg" },
{ "LV", "Latvia" },
{ "LY", "Libya" },
{ "MA", "Morocco" },
{ "MC", "Principality of Monaco" },
{ "MD", "Moldava" },
{ "MD", "Moldova" },
{ "ME", "Montenegro" },
{ "MK", "Former Yugoslav Republic of Macedonia" },
{ "ML", "Mali" },
{ "MM", "Myanmar" },
{ "MN", "Mongolia" },
{ "MO", "Macau S.A.R." },
{ "MT", "Malta" },
{ "MV", "Maldives" },
{ "MX", "Mexico" },
{ "MY", "Malaysia" },
{ "NG", "Nigeria" },
{ "NI", "Nicaragua" },
{ "NL", "Netherlands" },
{ "NO", "Norway" },
{ "NP", "Nepal" },
{ "NZ", "New Zealand" },
{ "OM", "Oman" },
{ "PA", "Panama" },
{ "PE", "Peru" },
{ "PH", "Philippines" },
{ "PK", "Islamic Republic of Pakistan" },
{ "PL", "Poland" },
{ "PR", "Puerto Rico" },
{ "PT", "Portugal" },
{ "PY", "Paraguay" },
{ "QA", "Qatar" },
{ "RE", "Reunion" },
{ "RO", "Romania" },
{ "RS", "Serbia" },
{ "RU", "Russia" },
{ "RW", "Rwanda" },
{ "SA", "Saudi Arabia" },
{ "SE", "Sweden" },
{ "SG", "Singapore" },
{ "SI", "Slovenia" },
{ "SK", "Slovak" },
{ "SN", "Senegal" },
{ "SO", "Somalia" },
{ "SR", "Suriname" },
{ "SV", "El Salvador" },
{ "SY", "Syria" },
{ "TH", "Thailand" },
{ "TJ", "Tajikistan" },
{ "TM", "Turkmenistan" },
{ "TN", "Tunisia" },
{ "TR", "Turkey" },
{ "TT", "Trinidad and Tobago" },
{ "TW", "Taiwan" },
{ "TZ", "Tanzania" },
{ "UA", "Ukraine" },
{ "US", "United States" },
{ "UY", "Uruguay" },
{ "VA", "Vatican" },
{ "VE", "Venezuela" },
{ "VN", "Viet Nam" },
{ "YE", "Yemen" },
{ "ZA", "South Africa" },
{ "ZW", "Zimbabwe" }
};
/* Given a string STRING, find the set of indices i such that TABLE[i].code is
the given STRING. It is a range [lo,hi-1]. */
typedef struct { size_t lo; size_t hi; } range_t;
static void
search (const struct table_entry *table, size_t table_size, const char *string,
range_t *result)
{
/* The table is sorted. Perform a binary search. */
size_t hi = table_size;
size_t lo = 0;
while (lo < hi)
{
/* Invariant:
for i < lo, strcmp (table[i].code, string) < 0,
for i >= hi, strcmp (table[i].code, string) > 0. */
size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
int cmp = strcmp (table[mid].code, string);
if (cmp < 0)
lo = mid + 1;
else if (cmp > 0)
hi = mid;
else
{
/* Found an i with
strcmp (language_table[i].code, string) == 0.
Find the entire interval of such i. */
{
size_t i;
for (i = mid; i > lo; )
{
i--;
if (strcmp (table[i].code, string) < 0)
{
lo = i + 1;
break;
}
}
}
{
size_t i;
for (i = mid; i < hi; i++)
{
if (strcmp (table[i].code, string) > 0)
{
hi = i;
break;
}
}
}
/* The set of i with
strcmp (language_table[i].code, string) == 0
is the interval [lo, hi-1]. */
break;
}
}
result->lo = lo;
result->hi = hi;
}
/* Like setlocale, but accept also locale names in the form ll or ll_CC,
where ll is an ISO 639 language code and CC is an ISO 3166 country code. */
static char *
setlocale_unixlike (int category, const char *locale)
{
char *result;
char llCC_buf[64];
char ll_buf[64];
char CC_buf[64];
/* First, try setlocale with the original argument unchanged. */
result = setlocale (category, locale);
if (result != NULL)
return result;
/* Otherwise, assume the argument is in the form
language[_territory][.codeset][@modifier]
and try to map it using the tables. */
if (strlen (locale) < sizeof (llCC_buf))
{
/* Second try: Remove the codeset part. */
{
const char *p = locale;
char *q = llCC_buf;
/* Copy the part before the dot. */
for (; *p != '\0' && *p != '.'; p++, q++)
*q = *p;
if (*p == '.')
/* Skip the part up to the '@', if any. */
for (; *p != '\0' && *p != '@'; p++)
;
/* Copy the part starting with '@', if any. */
for (; *p != '\0'; p++, q++)
*q = *p;
*q = '\0';
}
/* llCC_buf now contains
language[_territory][@modifier]
*/
if (strcmp (llCC_buf, locale) != 0)
{
result = setlocale (category, llCC_buf);
if (result != NULL)
return result;
}
/* Look it up in language_table. */
{
range_t range;
size_t i;
search (language_table,
sizeof (language_table) / sizeof (language_table[0]),
llCC_buf,
&range);
for (i = range.lo; i < range.hi; i++)
{
/* Try the replacement in language_table[i]. */
result = setlocale (category, language_table[i].english);
if (result != NULL)
return result;
}
}
/* Split language[_territory][@modifier]
into ll_buf = language[@modifier]
and CC_buf = territory
*/
{
const char *underscore = strchr (llCC_buf, '_');
if (underscore != NULL)
{
const char *territory_start = underscore + 1;
const char *territory_end = strchr (territory_start, '@');
if (territory_end == NULL)
territory_end = territory_start + strlen (territory_start);
memcpy (ll_buf, llCC_buf, underscore - llCC_buf);
strcpy (ll_buf + (underscore - llCC_buf), territory_end);
memcpy (CC_buf, territory_start, territory_end - territory_start);
CC_buf[territory_end - territory_start] = '\0';
{
/* Look up ll_buf in language_table
and CC_buf in country_table. */
range_t language_range;
search (language_table,
sizeof (language_table) / sizeof (language_table[0]),
ll_buf,
&language_range);
if (language_range.lo < language_range.hi)
{
range_t country_range;
search (country_table,
sizeof (country_table) / sizeof (country_table[0]),
CC_buf,
&country_range);
if (country_range.lo < country_range.hi)
{
size_t i;
size_t j;
for (i = language_range.lo; i < language_range.hi; i++)
for (j = country_range.lo; j < country_range.hi; j++)
{
/* Concatenate the replacements. */
const char *part1 = language_table[i].english;
size_t part1_len = strlen (part1);
const char *part2 = country_table[j].english;
size_t part2_len = strlen (part2) + 1;
char buf[64+64];
if (!(part1_len + 1 + part2_len <= sizeof (buf)))
abort ();
memcpy (buf, part1, part1_len);
buf[part1_len] = '_';
memcpy (buf + part1_len + 1, part2, part2_len);
/* Try the concatenated replacements. */
result = setlocale (category, buf);
if (result != NULL)
return result;
}
}
/* Try omitting the country entirely. This may set a locale
corresponding to the wrong country, but is better than
failing entirely. */
{
size_t i;
for (i = language_range.lo; i < language_range.hi; i++)
{
/* Try only the language replacement. */
result =
setlocale (category, language_table[i].english);
if (result != NULL)
return result;
}
}
}
}
}
}
}
/* Failed. */
return NULL;
}
# else
# define setlocale_unixlike setlocale
# endif
# if LC_MESSAGES == 1729
/* The system does not store an LC_MESSAGES locale category. Do it here. */
static char lc_messages_name[64] = "C";
/* Like setlocale, but support also LC_MESSAGES. */
static char *
setlocale_single (int category, const char *locale)
{
if (category == LC_MESSAGES)
{
if (locale != NULL)
{
lc_messages_name[sizeof (lc_messages_name) - 1] = '\0';
strncpy (lc_messages_name, locale, sizeof (lc_messages_name) - 1);
}
return lc_messages_name;
}
else
return setlocale_unixlike (category, locale);
}
# else
# define setlocale_single setlocale_unixlike
# endif
DLL_EXPORTED
char *
libintl_setlocale (int category, const char *locale)
{
if (locale != NULL && locale[0] == '\0')
{
/* A request to the set the current locale to the default locale. */
if (category == LC_ALL)
{
/* Set LC_CTYPE first. Then the other categories. */
static int const categories[] =
{
LC_NUMERIC,
LC_TIME,
LC_COLLATE,
LC_MONETARY,
LC_MESSAGES
};
char *saved_locale;
const char *base_name;
unsigned int i;
/* Back up the old locale, in case one of the steps fails. */
saved_locale = setlocale (LC_ALL, NULL);
if (saved_locale == NULL)
return NULL;
saved_locale = strdup (saved_locale);
if (saved_locale == NULL)
return NULL;
/* Set LC_CTYPE category. Set all other categories (except possibly
LC_MESSAGES) to the same value in the same call; this is likely to
save calls. */
base_name =
gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE));
if (base_name == NULL)
base_name = gl_locale_name_default ();
if (setlocale_unixlike (LC_ALL, base_name) == NULL)
goto fail;
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* On native Windows, setlocale(LC_ALL,...) may succeed but set the
LC_CTYPE category to an invalid value ("C") when it does not
support the specified encoding. Report a failure instead. */
if (strchr (base_name, '.') != NULL
&& strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
goto fail;
# endif
for (i = 0; i < sizeof (categories) / sizeof (categories[0]); i++)
{
int cat = categories[i];
const char *name;
name = gl_locale_name_environ (cat, category_to_name (cat));
if (name == NULL)
name = gl_locale_name_default ();
/* If name is the same as base_name, it has already been set
through the setlocale call before the loop. */
if (strcmp (name, base_name) != 0
# if LC_MESSAGES == 1729
|| cat == LC_MESSAGES
# endif
)
if (setlocale_single (cat, name) == NULL)
goto fail;
}
/* All steps were successful. */
++_nl_msg_cat_cntr;
free (saved_locale);
return setlocale (LC_ALL, NULL);
fail:
if (saved_locale[0] != '\0') /* don't risk an endless recursion */
setlocale (LC_ALL, saved_locale);
free (saved_locale);
return NULL;
}
else
{
char *result;
const char *name =
gl_locale_name_environ (category, category_to_name (category));
if (name == NULL)
name = gl_locale_name_default ();
result = setlocale_single (category, name);
if (result != NULL)
++_nl_msg_cat_cntr;
return result;
}
}
else
{
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
if (category == LC_ALL && locale != NULL && strchr (locale, '.') != NULL)
{
char *saved_locale;
/* Back up the old locale. */
saved_locale = setlocale (LC_ALL, NULL);
if (saved_locale == NULL)
return NULL;
saved_locale = strdup (saved_locale);
if (saved_locale == NULL)
return NULL;
if (setlocale_unixlike (LC_ALL, locale) == NULL)
{
free (saved_locale);
return NULL;
}
/* On native Windows, setlocale(LC_ALL,...) may succeed but set the
LC_CTYPE category to an invalid value ("C") when it does not
support the specified encoding. Report a failure instead. */
if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
{
if (saved_locale[0] != '\0') /* don't risk an endless recursion */
setlocale (LC_ALL, saved_locale);
free (saved_locale);
return NULL;
}
/* It was really successful. */
++_nl_msg_cat_cntr;
free (saved_locale);
return setlocale (LC_ALL, NULL);
}
else
# endif
{
char *result = setlocale_single (category, locale);
if (result != NULL)
++_nl_msg_cat_cntr;
return result;
}
}
}
# if HAVE_NEWLOCALE
DLL_EXPORTED
locale_t
libintl_newlocale (int category_mask, const char *locale, locale_t base)
{
if (category_mask != 0 && locale != NULL && locale[0] == '\0')
{
/* A request to construct a locale_t object that refers to the default
locale. */
/* Set LC_CTYPE first. Then the other categories. */
static struct { int cat; int mask; } const categories[] =
{
{ LC_CTYPE, LC_CTYPE_MASK },
{ LC_NUMERIC, LC_NUMERIC_MASK },
{ LC_TIME, LC_TIME_MASK },
{ LC_COLLATE, LC_COLLATE_MASK },
{ LC_MONETARY, LC_MONETARY_MASK },
{ LC_MESSAGES, LC_MESSAGES_MASK }
};
locale_t orig_base = base;
if ((LC_ALL_MASK & ~category_mask) == 0)
{
const char *base_name;
unsigned int i;
/* Set LC_CTYPE category. Set all other categories (except possibly
LC_MESSAGES) to the same value in the same call; this is likely to
save calls. */
base_name =
gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE));
if (base_name == NULL)
base_name = gl_locale_name_default ();
base = newlocale (LC_ALL_MASK, base_name, base);
if (base == NULL)
return NULL;
for (i = 1; i < sizeof (categories) / sizeof (categories[0]); i++)
{
int category = categories[i].cat;
int category_mask = categories[i].mask;
const char *name;
name =
gl_locale_name_environ (category, category_to_name (category));
if (name == NULL)
name = gl_locale_name_default ();
/* If name is the same as base_name, it has already been set
through the setlocale call before the loop. */
if (strcmp (name, base_name) != 0)
{
locale_t copy = newlocale (category_mask, name, base);
if (copy == NULL)
goto fail;
/* No need to call freelocale (base) if copy != base; the
newlocale function already takes care of doing it. */
base = copy;
}
}
}
else
{
unsigned int i;
for (i = 0; i < sizeof (categories) / sizeof (categories[0]); i++)
{
int cat_mask = categories[i].mask;
if ((category_mask & cat_mask) != 0)
{
int cat = categories[i].cat;
const char *name;
locale_t copy;
name = gl_locale_name_environ (cat, category_to_name (cat));
if (name == NULL)
name = gl_locale_name_default ();
copy = newlocale (cat_mask, name, base);
if (copy == NULL)
goto fail;
/* No need to call freelocale (base) if copy != base; the
newlocale function already takes care of doing it. */
base = copy;
}
}
}
/* All steps were successful. */
return base;
fail:
if (base != NULL && orig_base == NULL)
{
int saved_errno = errno;
freelocale (base);
errno = saved_errno;
}
return NULL;
}
else
return newlocale (category_mask, locale, base);
}
# endif
#endif
plptools-1.0.13/intl/Makefile.in 0000644 0001750 0001750 00000060027 12417352630 013414 0000000 0000000 # Makefile for directory with message catalog handling library of GNU gettext
# Copyright (C) 1995-1998, 2000-2007, 2009-2012 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.1 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 .
PACKAGE = @PACKAGE@
VERSION = @VERSION@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
# The VPATH variables allows builds with $builddir != $srcdir, assuming a
# 'make' program that supports VPATH (such as GNU make). This line is removed
# by autoconf automatically when "$(srcdir)" = ".".
# In this directory, the VPATH handling is particular:
# 1. If INTL_LIBTOOL_SUFFIX_PREFIX is 'l' (indicating a build with libtool),
# the .c -> .lo rules carefully use $(srcdir), so that VPATH can be omitted.
# 2. If PACKAGE = gettext-tools, VPATH _must_ be omitted, because otherwise
# 'make' does the wrong thing if GNU gettext was configured with
# "./configure --srcdir=`pwd`", namely it gets confused by the .lo and .la
# files it finds in srcdir = ../../gettext-runtime/intl.
VPATH = $(srcdir)
prefix = @prefix@
exec_prefix = @exec_prefix@
transform = @program_transform_name@
libdir = @libdir@
includedir = @includedir@
datarootdir = @datarootdir@
datadir = @datadir@
localedir = $(datadir)/locale
gettextsrcdir = $(datadir)/gettext/intl
aliaspath = $(localedir)
subdir = intl
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
# We use $(mkdir_p).
# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
# @install_sh@ does not start with $(SHELL), so we add it.
# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined
# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
# versions, $(mkinstalldirs) and $(install_sh) are unused.
mkinstalldirs = $(SHELL) @install_sh@ -d
install_sh = $(SHELL) @install_sh@
MKDIR_P = @MKDIR_P@
mkdir_p = @mkdir_p@
l = @INTL_LIBTOOL_SUFFIX_PREFIX@
AR = ar
CC = @CC@
LIBTOOL = @LIBTOOL@
RANLIB = @RANLIB@
YACC = @INTLBISON@ -y -d
YFLAGS = --name-prefix=__gettext
# Windows resource compiler (windres). Used when libtool is not used.
WINDRES = @WINDRES@
# Windows resource compiler (windres). Used via libtool.
RC = @RC@
# Support for silent-rules.
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_@INTL_DEFAULT_VERBOSITY@)
am__v_at_0 = @
AM_V_AR = $(am__v_AR_$(V))
am__v_AR_ = $(am__v_AR_@INTL_DEFAULT_VERBOSITY@)
am__v_AR_0 = @echo " AR " $@;
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_@INTL_DEFAULT_VERBOSITY@)
am__v_CC_0 = @echo " CC " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_@INTL_DEFAULT_VERBOSITY@)
am__v_GEN_0 = @echo " GEN " $@;
AM_V_YACC = $(am__v_YACC_$(V))
am__v_YACC_ = $(am__v_YACC_@INTL_DEFAULT_VERBOSITY@)
am__v_YACC_0 = @echo " YACC " $@;
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_@INTL_DEFAULT_VERBOSITY@)
am__v_lt_0 = --silent
# -DBUILDING_LIBINTL: Change expansion of LIBINTL_DLL_EXPORTED macro.
# -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro.
DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
-DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL \
-DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \
-Dset_relocation_prefix=libintl_set_relocation_prefix \
-Drelocate=libintl_relocate \
-DDEPENDS_ON_LIBICONV=1 @DEFS@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@ @CFLAG_VISIBILITY@
LDFLAGS = @LDFLAGS@ $(LDFLAGS_@WOE32DLL@)
LDFLAGS_yes = -Wl,--export-all-symbols
LDFLAGS_no =
LIBS = @LIBS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
HEADERS = \
gmo.h \
gettextP.h \
hash-string.h \
loadinfo.h \
plural-exp.h \
eval-plural.h \
localcharset.h \
lock.h \
relocatable.h \
tsearch.h tsearch.c \
verify.h \
xsize.h \
printf-args.h printf-args.c \
printf-parse.h wprintf-parse.h printf-parse.c \
vasnprintf.h vasnwprintf.h vasnprintf.c \
os2compat.h \
libgnuintl.in.h
SOURCES = \
bindtextdom.c \
dcgettext.c \
dgettext.c \
gettext.c \
finddomain.c \
hash-string.c \
loadmsgcat.c \
localealias.c \
textdomain.c \
l10nflist.c \
explodename.c \
dcigettext.c \
dcngettext.c \
dngettext.c \
ngettext.c \
plural.y \
plural-exp.c \
localcharset.c \
threadlib.c \
lock.c \
relocatable.c \
langprefs.c \
localename.c \
log.c \
printf.c \
setlocale.c \
version.c \
xsize.c \
osdep.c \
os2compat.c \
intl-exports.c \
intl-compat.c
OBJECTS = \
bindtextdom.$lo \
dcgettext.$lo \
dgettext.$lo \
gettext.$lo \
finddomain.$lo \
hash-string.$lo \
loadmsgcat.$lo \
localealias.$lo \
textdomain.$lo \
l10nflist.$lo \
explodename.$lo \
dcigettext.$lo \
dcngettext.$lo \
dngettext.$lo \
ngettext.$lo \
plural.$lo \
plural-exp.$lo \
localcharset.$lo \
threadlib.$lo \
lock.$lo \
relocatable.$lo \
langprefs.$lo \
localename.$lo \
log.$lo \
printf.$lo \
setlocale.$lo \
version.$lo \
xsize.$lo \
osdep.$lo \
intl-compat.$lo
OBJECTS_RES_yes = libintl.res.$lo
OBJECTS_RES_no =
DISTFILES.common = Makefile.in \
config.charset locale.alias ref-add.sin ref-del.sin export.h libintl.rc \
$(HEADERS) $(SOURCES)
DISTFILES.generated = plural.c
DISTFILES.normal = VERSION
DISTFILES.gettext = COPYING.LIB libintl.glibc README.woe32
DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \
COPYING.LIB-2 COPYING.LIB-2.0 COPYING.LIB-2.1 \
gettext.h libgettext.h plural-eval.c libgnuintl.h \
libgnuintl.h_vms Makefile.vms libgnuintl.h.msvc-static \
libgnuintl.h.msvc-shared Makefile.msvc
all: all-@USE_INCLUDED_LIBINTL@
all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
all-no: all-no-@BUILD_INCLUDED_LIBINTL@
all-no-yes: libgnuintl.$la
all-no-no:
libintl.a libgnuintl.a: $(OBJECTS)
$(AM_V_at)rm -f $@
$(AM_V_AR)$(AR) cru $@ $(OBJECTS)
$(AM_V_at)$(RANLIB) $@
libintl.la libgnuintl.la: $(OBJECTS) $(OBJECTS_RES_@WOE32@)
$(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=link \
$(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \
$(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) @LTLIBTHREAD@ @LTLIBC@ \
$(OBJECTS_RES_@WOE32@) \
-version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
-rpath $(libdir) \
-no-undefined
# Libtool's library version information for libintl.
# Before making a gettext release, the gettext maintainer must change this
# according to the libtool documentation, section "Library interface versions".
# Maintainers of other packages that include the intl directory must *not*
# change these values.
LTV_CURRENT=9
LTV_REVISION=2
LTV_AGE=1
.SUFFIXES:
.SUFFIXES: .c .y .o .lo .sin .sed
.c.o:
$(AM_V_CC)$(COMPILE) $<
.y.c:
$(AM_V_YACC)$(YACC) $(YFLAGS) --output $@ $<
$(AM_V_at)rm -f $*.h
bindtextdom.lo: $(srcdir)/bindtextdom.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/bindtextdom.c
dcgettext.lo: $(srcdir)/dcgettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/dcgettext.c
dgettext.lo: $(srcdir)/dgettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/dgettext.c
gettext.lo: $(srcdir)/gettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/gettext.c
finddomain.lo: $(srcdir)/finddomain.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/finddomain.c
hash-string.lo: $(srcdir)/hash-string.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/hash-string.c
loadmsgcat.lo: $(srcdir)/loadmsgcat.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c
localealias.lo: $(srcdir)/localealias.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/localealias.c
textdomain.lo: $(srcdir)/textdomain.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/textdomain.c
l10nflist.lo: $(srcdir)/l10nflist.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/l10nflist.c
explodename.lo: $(srcdir)/explodename.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/explodename.c
dcigettext.lo: $(srcdir)/dcigettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/dcigettext.c
dcngettext.lo: $(srcdir)/dcngettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/dcngettext.c
dngettext.lo: $(srcdir)/dngettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/dngettext.c
ngettext.lo: $(srcdir)/ngettext.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/ngettext.c
plural.lo: $(srcdir)/plural.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/plural.c
plural-exp.lo: $(srcdir)/plural-exp.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/plural-exp.c
localcharset.lo: $(srcdir)/localcharset.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/localcharset.c
threadlib.lo: $(srcdir)/threadlib.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/threadlib.c
lock.lo: $(srcdir)/lock.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/lock.c
relocatable.lo: $(srcdir)/relocatable.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/relocatable.c
langprefs.lo: $(srcdir)/langprefs.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/langprefs.c
localename.lo: $(srcdir)/localename.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/localename.c
log.lo: $(srcdir)/log.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/log.c
printf.lo: $(srcdir)/printf.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/printf.c
setlocale.lo: $(srcdir)/setlocale.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/setlocale.c
version.lo: $(srcdir)/version.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/version.c
xsize.lo: $(srcdir)/xsize.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/xsize.c
osdep.lo: $(srcdir)/osdep.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/osdep.c
intl-compat.lo: $(srcdir)/intl-compat.c
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/intl-compat.c
# This rule is executed only on Woe32 systems.
# The following sed expressions come from the windres-options script. They are
# inlined here, so that they can be written in a Makefile without requiring a
# temporary file. They must contain literal newlines rather than semicolons,
# so that they work with the sed-3.02 that is shipped with MSYS.
libintl.res.o: $(srcdir)/libintl.rc
nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
sed_extract_major='/^[0-9]/{'$${nl}'s/^\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
$(WINDRES) \
"-DPACKAGE_VERSION_STRING=\\\"$(VERSION)\\\"" \
"-DPACKAGE_VERSION_MAJOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_major"` \
"-DPACKAGE_VERSION_MINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_minor"` \
"-DPACKAGE_VERSION_SUBMINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_subminor"` \
-i $(srcdir)/libintl.rc -o libintl.res.o --output-format=coff
libintl.res.lo: $(srcdir)/libintl.rc
nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
sed_extract_major='/^[0-9]/{'$${nl}'s/^\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \
$(LIBTOOL) --mode=compile --tag=RC $(RC) \
"-DPACKAGE_VERSION_STRING=\\\"$(VERSION)\\\"" \
"-DPACKAGE_VERSION_MAJOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_major"` \
"-DPACKAGE_VERSION_MINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_minor"` \
"-DPACKAGE_VERSION_SUBMINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_subminor"` \
-i $(srcdir)/libintl.rc -o libintl.res.lo --output-format=coff
ref-add.sed: $(srcdir)/ref-add.sin
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-add.sin > t-ref-add.sed
mv t-ref-add.sed ref-add.sed
ref-del.sed: $(srcdir)/ref-del.sin
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-del.sin > t-ref-del.sed
mv t-ref-del.sed ref-del.sed
INCLUDES = -I. -I$(srcdir) -I..
libgnuintl.h: $(srcdir)/libgnuintl.in.h
sed -e '/IN_LIBGLOCALE/d' \
-e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
-e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
< $(srcdir)/libgnuintl.in.h \
| if test '@WOE32DLL@' = yes; then \
sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \
else \
cat; \
fi \
| sed -e 's/extern \([^"]\)/extern LIBINTL_DLL_EXPORTED \1/' \
-e "/#define _LIBINTL_H/r $(srcdir)/export.h" \
| sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \
> libgnuintl.h
libintl.h: $(srcdir)/libgnuintl.in.h
sed -e '/IN_LIBGLOCALE/d' \
-e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
-e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
< $(srcdir)/libgnuintl.in.h > libintl.h
charset.alias: $(srcdir)/config.charset
$(SHELL) $(srcdir)/config.charset '@host@' > t-$@
mv t-$@ $@
check: all
# We must not install the libintl.h/libintl.a files if we are on a
# system which has the GNU gettext() function in its C library or in a
# separate library.
# If you want to use the one which comes with this version of the
# package, you have to use "configure --with-included-gettext".
install: install-exec install-data
install-exec: all
if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
&& test '@USE_INCLUDED_LIBINTL@' = yes; then \
$(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
$(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \
$(LIBTOOL) --mode=install \
$(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \
if test "@RELOCATABLE@" = yes; then \
dependencies=`sed -n -e 's,^dependency_libs=\(.*\),\1,p' < $(DESTDIR)$(libdir)/libintl.la | sed -e "s,^',," -e "s,'\$$,,"`; \
if test -n "$$dependencies"; then \
rm -f $(DESTDIR)$(libdir)/libintl.la; \
fi; \
fi; \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext-tools" \
&& test '@USE_INCLUDED_LIBINTL@' = no \
&& test @GLIBC2@ != no; then \
$(mkdir_p) $(DESTDIR)$(libdir); \
$(LIBTOOL) --mode=install \
$(INSTALL_DATA) libgnuintl.$la $(DESTDIR)$(libdir)/libgnuintl.$la; \
rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \
$(INSTALL_DATA) $(DESTDIR)$(libdir)/libgnuintl.so $(DESTDIR)$(libdir)/preloadable_libintl.so; \
$(LIBTOOL) --mode=uninstall \
rm -f $(DESTDIR)$(libdir)/libgnuintl.$la; \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
if test @GLIBC21@ = no; then \
case '@host_os@' in \
darwin[56]*) \
need_charset_alias=true ;; \
darwin* | cygwin* | mingw* | pw32* | cegcc*) \
need_charset_alias=false ;; \
*) \
need_charset_alias=true ;; \
esac; \
else \
need_charset_alias=false; \
fi; \
if $$need_charset_alias; then \
$(mkdir_p) $(DESTDIR)$(libdir); \
fi; \
temp=$(DESTDIR)$(libdir)/t-charset.alias; \
dest=$(DESTDIR)$(libdir)/charset.alias; \
if test -f $(DESTDIR)$(libdir)/charset.alias; then \
orig=$(DESTDIR)$(libdir)/charset.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
else \
if $$need_charset_alias; then \
orig=charset.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
fi; \
fi; \
$(mkdir_p) $(DESTDIR)$(localedir); \
test -f $(DESTDIR)$(localedir)/locale.alias \
&& orig=$(DESTDIR)$(localedir)/locale.alias \
|| orig=$(srcdir)/locale.alias; \
temp=$(DESTDIR)$(localedir)/t-locale.alias; \
dest=$(DESTDIR)$(localedir)/locale.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
else \
: ; \
fi
install-data: all
if test "$(PACKAGE)" = "gettext-tools"; then \
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
$(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
$(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
dists="COPYING.LIB $(DISTFILES.common)"; \
for file in $$dists; do \
$(INSTALL_DATA) $(srcdir)/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \
dists="$(DISTFILES.generated)"; \
for file in $$dists; do \
if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
$(INSTALL_DATA) $$dir/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
dists="$(DISTFILES.obsolete)"; \
for file in $$dists; do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
install-strip: install
install-dvi install-html install-info install-ps install-pdf:
installdirs:
if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
&& test '@USE_INCLUDED_LIBINTL@' = yes; then \
$(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext-tools" \
&& test '@USE_INCLUDED_LIBINTL@' = no \
&& test @GLIBC2@ != no; then \
$(mkdir_p) $(DESTDIR)$(libdir); \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
if test @GLIBC21@ = no; then \
case '@host_os@' in \
darwin[56]*) \
need_charset_alias=true ;; \
darwin* | cygwin* | mingw* | pw32* | cegcc*) \
need_charset_alias=false ;; \
*) \
need_charset_alias=true ;; \
esac; \
else \
need_charset_alias=false; \
fi; \
if $$need_charset_alias; then \
$(mkdir_p) $(DESTDIR)$(libdir); \
fi; \
$(mkdir_p) $(DESTDIR)$(localedir); \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext-tools"; then \
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
else \
: ; \
fi
# Define this as empty until I found a useful application.
installcheck:
uninstall:
if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
&& test '@USE_INCLUDED_LIBINTL@' = yes; then \
rm -f $(DESTDIR)$(includedir)/libintl.h; \
$(LIBTOOL) --mode=uninstall \
rm -f $(DESTDIR)$(libdir)/libintl.$la; \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext-tools" \
&& test '@USE_INCLUDED_LIBINTL@' = no \
&& test @GLIBC2@ != no; then \
rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
if test -f $(DESTDIR)$(libdir)/charset.alias; then \
temp=$(DESTDIR)$(libdir)/t-charset.alias; \
dest=$(DESTDIR)$(libdir)/charset.alias; \
sed -f ref-del.sed $$dest > $$temp; \
if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
rm -f $$dest; \
else \
$(INSTALL_DATA) $$temp $$dest; \
fi; \
rm -f $$temp; \
fi; \
if test -f $(DESTDIR)$(localedir)/locale.alias; then \
temp=$(DESTDIR)$(localedir)/t-locale.alias; \
dest=$(DESTDIR)$(localedir)/locale.alias; \
sed -f ref-del.sed $$dest > $$temp; \
if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
rm -f $$dest; \
else \
$(INSTALL_DATA) $$temp $$dest; \
fi; \
rm -f $$temp; \
fi; \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext-tools"; then \
for file in VERSION ChangeLog COPYING.LIB $(DISTFILES.common) $(DISTFILES.generated); do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
info dvi ps pdf html:
$(OBJECTS): ../config.h libgnuintl.h
bindtextdom.$lo dcgettext.$lo dcigettext.$lo dcngettext.$lo dgettext.$lo dngettext.$lo finddomain.$lo gettext.$lo intl-compat.$lo loadmsgcat.$lo localealias.$lo ngettext.$lo setlocale.$lo textdomain.$lo: $(srcdir)/gettextP.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h
localename.$lo: $(srcdir)/gettextP.h
hash-string.$lo dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h
explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h
dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h
dcigettext.$lo: $(srcdir)/eval-plural.h
localcharset.$lo: $(srcdir)/localcharset.h
bindtextdom.$lo dcigettext.$lo finddomain.$lo loadmsgcat.$lo localealias.$lo lock.$lo log.$lo: $(srcdir)/lock.h
localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h
printf.$lo: $(srcdir)/printf-args.h $(srcdir)/printf-args.c $(srcdir)/printf-parse.h $(srcdir)/wprintf-parse.h $(srcdir)/xsize.h $(srcdir)/xsize.c $(srcdir)/printf-parse.c $(srcdir)/vasnprintf.h $(srcdir)/vasnwprintf.h $(srcdir)/vasnprintf.c
# A bison-2.1 generated plural.c includes if ENABLE_NLS.
PLURAL_DEPS_yes = libintl.h
PLURAL_DEPS_no =
plural.$lo: $(PLURAL_DEPS_@USE_INCLUDED_LIBINTL@)
tags: TAGS
TAGS: $(HEADERS) $(SOURCES)
here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES)
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES)
here=`pwd`; cd $(srcdir) && ctags -o $$here/CTAGS $(HEADERS) $(SOURCES)
id: ID
ID: $(HEADERS) $(SOURCES)
here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES)
mostlyclean:
rm -f *.a *.la *.o *.obj *.lo core core.*
rm -f libgnuintl.h libintl.h charset.alias ref-add.sed ref-del.sed
rm -f -r .libs _libs
clean: mostlyclean
distclean: clean
rm -f Makefile ID TAGS
if test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; then \
rm -f ChangeLog.inst $(DISTFILES.normal); \
else \
: ; \
fi
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
# GNU gettext needs not contain the file 'VERSION' but contains some
# other files which should not be distributed in other packages.
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir: Makefile
if test "$(PACKAGE)" = "gettext-tools"; then \
: ; \
else \
if test "$(PACKAGE)" = "gettext-runtime"; then \
additional="$(DISTFILES.gettext)"; \
else \
additional="$(DISTFILES.normal)"; \
fi; \
$(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \
for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \
if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
cp -p $$dir/$$file $(distdir) || test $$file = Makefile.in || exit 1; \
done; \
fi
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status
# This would be more efficient, but doesn't work any more with autoconf-2.57,
# when AC_CONFIG_FILES([intl/Makefile:somedir/Makefile.in]) is used.
# cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
plptools-1.0.13/intl/printf.c 0000644 0001750 0001750 00000024117 12417352631 013016 0000000 0000000 /* Formatted output to strings, using POSIX/XSI format strings with positions.
Copyright (C) 2003, 2006-2007, 2009-2011 Free Software Foundation, Inc.
Written by Bruno Haible , 2003.
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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# ifdef _MSC_VER
# include
# define alloca _alloca
# else
# if defined HAVE_ALLOCA_H || defined _LIBC
# include
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#include
#if !HAVE_POSIX_PRINTF
#include
#include
#include
#include
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
/* When building a DLL, we must export some functions. Note that because
the functions are only defined for binary backward compatibility, we
don't need to use __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# define DLL_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
# define DLL_EXPORTED __declspec(dllexport)
#else
# define DLL_EXPORTED
#endif
#define STATIC static
/* This needs to be consistent with libgnuintl.in.h. */
#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
/* Don't break __attribute__((format(printf,M,N))).
This redefinition is only possible because the libc in NetBSD, Cygwin,
mingw does not have a function __printf__. */
# define libintl_printf __printf__
#endif
/* Define auxiliary functions declared in "printf-args.h". */
#include "printf-args.c"
/* Define auxiliary functions declared in "printf-parse.h". */
#include "printf-parse.c"
/* Define functions declared in "vasnprintf.h". */
#define vasnprintf libintl_vasnprintf
#include "vasnprintf.c"
#if 0 /* not needed */
#define asnprintf libintl_asnprintf
#include "asnprintf.c"
#endif
DLL_EXPORTED
int
libintl_vfprintf (FILE *stream, const char *format, va_list args)
{
if (strchr (format, '$') == NULL)
return vfprintf (stream, format, args);
else
{
size_t length;
char *result = libintl_vasnprintf (NULL, &length, format, args);
int retval = -1;
if (result != NULL)
{
size_t written = fwrite (result, 1, length, stream);
free (result);
if (written == length)
{
if (length > INT_MAX)
errno = EOVERFLOW;
else
retval = length;
}
}
return retval;
}
}
DLL_EXPORTED
int
libintl_fprintf (FILE *stream, const char *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vfprintf (stream, format, args);
va_end (args);
return retval;
}
DLL_EXPORTED
int
libintl_vprintf (const char *format, va_list args)
{
return libintl_vfprintf (stdout, format, args);
}
DLL_EXPORTED
int
libintl_printf (const char *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vprintf (format, args);
va_end (args);
return retval;
}
DLL_EXPORTED
int
libintl_vsprintf (char *resultbuf, const char *format, va_list args)
{
if (strchr (format, '$') == NULL)
return vsprintf (resultbuf, format, args);
else
{
size_t length = (size_t) ~0 / (4 * sizeof (char));
char *result = libintl_vasnprintf (resultbuf, &length, format, args);
if (result != resultbuf)
{
free (result);
return -1;
}
if (length > INT_MAX)
{
errno = EOVERFLOW;
return -1;
}
else
return length;
}
}
DLL_EXPORTED
int
libintl_sprintf (char *resultbuf, const char *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vsprintf (resultbuf, format, args);
va_end (args);
return retval;
}
#if HAVE_SNPRINTF
# if HAVE_DECL__SNPRINTF
/* Windows. The mingw function vsnprintf() has fewer bugs than the MSVCRT
function _vsnprintf(), so prefer that. */
# if defined __MINGW32__
# define system_vsnprintf vsnprintf
# else
# define system_vsnprintf _vsnprintf
# endif
# else
/* Unix. */
# define system_vsnprintf vsnprintf
# endif
DLL_EXPORTED
int
libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args)
{
if (strchr (format, '$') == NULL)
return system_vsnprintf (resultbuf, length, format, args);
else
{
size_t maxlength = length;
char *result = libintl_vasnprintf (resultbuf, &length, format, args);
if (result == NULL)
return -1;
if (result != resultbuf)
{
if (maxlength > 0)
{
size_t pruned_length =
(length < maxlength ? length : maxlength - 1);
memcpy (resultbuf, result, pruned_length);
resultbuf[pruned_length] = '\0';
}
free (result);
}
if (length > INT_MAX)
{
errno = EOVERFLOW;
return -1;
}
else
return length;
}
}
DLL_EXPORTED
int
libintl_snprintf (char *resultbuf, size_t length, const char *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vsnprintf (resultbuf, length, format, args);
va_end (args);
return retval;
}
#endif
#if HAVE_ASPRINTF
DLL_EXPORTED
int
libintl_vasprintf (char **resultp, const char *format, va_list args)
{
size_t length;
char *result = libintl_vasnprintf (NULL, &length, format, args);
if (result == NULL)
return -1;
if (length > INT_MAX)
{
free (result);
errno = EOVERFLOW;
return -1;
}
*resultp = result;
return length;
}
DLL_EXPORTED
int
libintl_asprintf (char **resultp, const char *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vasprintf (resultp, format, args);
va_end (args);
return retval;
}
#endif
#if HAVE_FWPRINTF
#include
#define WIDE_CHAR_VERSION 1
#include "wprintf-parse.h"
/* Define auxiliary functions declared in "wprintf-parse.h". */
#define CHAR_T wchar_t
#define DIRECTIVE wchar_t_directive
#define DIRECTIVES wchar_t_directives
#define PRINTF_PARSE wprintf_parse
#include "printf-parse.c"
/* Define functions declared in "vasnprintf.h". */
#define vasnwprintf libintl_vasnwprintf
#include "vasnprintf.c"
#if 0 /* not needed */
#define asnwprintf libintl_asnwprintf
#include "asnprintf.c"
#endif
# if HAVE_DECL__SNWPRINTF
/* Windows. The function vswprintf() has a different signature than
on Unix; we use the function _vsnwprintf() instead. */
# define system_vswprintf _vsnwprintf
# else
/* Unix. */
# define system_vswprintf vswprintf
# endif
DLL_EXPORTED
int
libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args)
{
if (wcschr (format, '$') == NULL)
return vfwprintf (stream, format, args);
else
{
size_t length;
wchar_t *result = libintl_vasnwprintf (NULL, &length, format, args);
int retval = -1;
if (result != NULL)
{
size_t i;
for (i = 0; i < length; i++)
if (fputwc (result[i], stream) == WEOF)
break;
free (result);
if (i == length)
{
if (length > INT_MAX)
errno = EOVERFLOW;
else
retval = length;
}
}
return retval;
}
}
DLL_EXPORTED
int
libintl_fwprintf (FILE *stream, const wchar_t *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vfwprintf (stream, format, args);
va_end (args);
return retval;
}
DLL_EXPORTED
int
libintl_vwprintf (const wchar_t *format, va_list args)
{
return libintl_vfwprintf (stdout, format, args);
}
DLL_EXPORTED
int
libintl_wprintf (const wchar_t *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vwprintf (format, args);
va_end (args);
return retval;
}
DLL_EXPORTED
int
libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args)
{
if (wcschr (format, '$') == NULL)
return system_vswprintf (resultbuf, length, format, args);
else
{
size_t maxlength = length;
wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args);
if (result == NULL)
return -1;
if (result != resultbuf)
{
if (maxlength > 0)
{
size_t pruned_length =
(length < maxlength ? length : maxlength - 1);
memcpy (resultbuf, result, pruned_length * sizeof (wchar_t));
resultbuf[pruned_length] = 0;
}
free (result);
/* Unlike vsnprintf, which has to return the number of character that
would have been produced if the resultbuf had been sufficiently
large, the vswprintf function has to return a negative value if
the resultbuf was not sufficiently large. */
if (length >= maxlength)
return -1;
}
if (length > INT_MAX)
{
errno = EOVERFLOW;
return -1;
}
else
return length;
}
}
DLL_EXPORTED
int
libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, ...)
{
va_list args;
int retval;
va_start (args, format);
retval = libintl_vswprintf (resultbuf, length, format, args);
va_end (args);
return retval;
}
#endif
#endif
plptools-1.0.13/intl/ngettext.c 0000644 0001750 0001750 00000003577 12417352631 013365 0000000 0000000 /* Implementation of ngettext(3) function.
Copyright (C) 1995, 1997, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#ifdef _LIBC
# define __need_NULL
# include
#else
# include /* Just for NULL. */
#endif
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
#include
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define NGETTEXT __ngettext
# define DCNGETTEXT __dcngettext
#else
# define NGETTEXT libintl_ngettext
# define DCNGETTEXT libintl_dcngettext
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
char *
NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n)
{
return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__ngettext, ngettext);
#endif
plptools-1.0.13/intl/dcigettext.c 0000644 0001750 0001750 00000133770 12417352630 013665 0000000 0000000 /* Implementation of the internal dcigettext function.
Copyright (C) 1995-1999, 2000-2010, 2012 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.1 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 . */
/* Tell glibc's to provide a prototype for mempcpy().
This must come before because may include
, and once has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# ifdef _MSC_VER
# include
# define alloca _alloca
# else
# if defined HAVE_ALLOCA_H || defined _LIBC
# include
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#include
#ifndef errno
extern int errno;
#endif
#ifndef __set_errno
# define __set_errno(val) errno = (val)
#endif
#include
#include
#include
#if defined HAVE_UNISTD_H || defined _LIBC
# include
#endif
#include
#ifdef _LIBC
/* Guess whether integer division by zero raises signal SIGFPE.
Set to 1 only if you know for sure. In case of doubt, set to 0. */
# if defined __alpha__ || defined __arm__ || defined __i386__ \
|| defined __m68k__ || defined __s390__
# define INTDIV0_RAISES_SIGFPE 1
# else
# define INTDIV0_RAISES_SIGFPE 0
# endif
#endif
#if !INTDIV0_RAISES_SIGFPE
# include
#endif
#if defined HAVE_SYS_PARAM_H || defined _LIBC
# include
#endif
#if !defined _LIBC
# include "localcharset.h"
#endif
#include "gettextP.h"
#include "plural-exp.h"
#ifdef _LIBC
# include
#else
# ifdef IN_LIBGLOCALE
# include
# endif
# include "libgnuintl.h"
#endif
#include "hash-string.h"
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
# define gl_rwlock_define_initialized __libc_rwlock_define_initialized
# define gl_rwlock_rdlock __libc_rwlock_rdlock
# define gl_rwlock_wrlock __libc_rwlock_wrlock
# define gl_rwlock_unlock __libc_rwlock_unlock
#else
# include "lock.h"
#endif
/* Alignment of types. */
#if defined __GNUC__ && __GNUC__ >= 2
# define alignof(TYPE) __alignof__ (TYPE)
#else
# define alignof(TYPE) \
((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
#endif
/* Some compilers, like SunOS4 cc, don't have offsetof in . */
#ifndef offsetof
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
#endif
/* @@ end of prolog @@ */
#ifdef _LIBC
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
# define getcwd __getcwd
# ifndef stpcpy
# define stpcpy __stpcpy
# endif
# define tfind __tfind
#else
# if !defined HAVE_GETCWD
char *getwd ();
# define getcwd(buf, max) getwd (buf)
# else
# if VMS
# define getcwd(buf, max) (getcwd) (buf, max, 0)
# else
char *getcwd ();
# endif
# endif
# ifndef HAVE_STPCPY
static char *stpcpy (char *dest, const char *src);
# endif
# ifndef HAVE_MEMPCPY
static void *mempcpy (void *dest, const void *src, size_t n);
# endif
#endif
/* Use a replacement if the system does not provide the `tsearch' function
family. */
#if HAVE_TSEARCH || defined _LIBC
# include
#else
# define tsearch libintl_tsearch
# define tfind libintl_tfind
# define tdelete libintl_tdelete
# define twalk libintl_twalk
# include "tsearch.h"
#endif
#ifdef _LIBC
# define tsearch __tsearch
#endif
/* Amount to increase buffer size by in each try. */
#define PATH_INCR 32
/* The following is from pathmax.h. */
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
PATH_MAX but might cause redefinition warnings when sys/param.h is
later included (as on MORE/BSD 4.3). */
#if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__)
# include
#endif
#ifndef _POSIX_PATH_MAX
# define _POSIX_PATH_MAX 255
#endif
#if !defined PATH_MAX && defined _PC_PATH_MAX
# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
#endif
/* Don't include sys/param.h if it already has been. */
#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
# include
#endif
#if !defined PATH_MAX && defined MAXPATHLEN
# define PATH_MAX MAXPATHLEN
#endif
#ifndef PATH_MAX
# define PATH_MAX _POSIX_PATH_MAX
#endif
/* Pathname support.
ISSLASH(C) tests whether C is a directory separator character.
IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
it may be concatenated to a directory pathname.
IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
*/
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Win32, Cygwin, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define HAS_DEVICE(P) \
((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
&& (P)[1] == ':')
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
# define IS_PATH_WITH_DIR(P) \
(strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
#else
/* Unix */
# define ISSLASH(C) ((C) == '/')
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
#endif
/* Whether to support different locales in different threads. */
#if defined _LIBC || HAVE_USELOCALE || defined IN_LIBGLOCALE
# define HAVE_PER_THREAD_LOCALE
#endif
/* This is the type used for the search tree where known translations
are stored. */
struct known_translation_t
{
/* Domain in which to search. */
const char *domainname;
/* The category. */
int category;
#ifdef HAVE_PER_THREAD_LOCALE
/* Name of the relevant locale category, or "" for the global locale. */
const char *localename;
#endif
#ifdef IN_LIBGLOCALE
/* The character encoding. */
const char *encoding;
#endif
/* State of the catalog counter at the point the string was found. */
int counter;
/* Catalog where the string was found. */
struct loaded_l10nfile *domain;
/* And finally the translation. */
const char *translation;
size_t translation_length;
/* Pointer to the string in question. */
union
{
char appended[ZERO]; /* used if domain != NULL */
const char *ptr; /* used if domain == NULL */
}
msgid;
};
gl_rwlock_define_initialized (static, tree_lock)
/* Root of the search tree with known translations. */
static void *root;
/* Function to compare two entries in the table of known translations. */
static int
transcmp (const void *p1, const void *p2)
{
const struct known_translation_t *s1;
const struct known_translation_t *s2;
int result;
s1 = (const struct known_translation_t *) p1;
s2 = (const struct known_translation_t *) p2;
result = strcmp (s1->domain != NULL ? s1->msgid.appended : s1->msgid.ptr,
s2->domain != NULL ? s2->msgid.appended : s2->msgid.ptr);
if (result == 0)
{
result = strcmp (s1->domainname, s2->domainname);
if (result == 0)
{
#ifdef HAVE_PER_THREAD_LOCALE
result = strcmp (s1->localename, s2->localename);
if (result == 0)
#endif
{
#ifdef IN_LIBGLOCALE
result = strcmp (s1->encoding, s2->encoding);
if (result == 0)
#endif
/* We compare the category last (though this is the cheapest
operation) since it is hopefully always the same (namely
LC_MESSAGES). */
result = s1->category - s2->category;
}
}
}
return result;
}
/* Name of the default domain used for gettext(3) prior any call to
textdomain(3). The default value for this is "messages". */
const char _nl_default_default_domain[] attribute_hidden = "messages";
#ifndef IN_LIBGLOCALE
/* Value used as the default domain for gettext(3). */
const char *_nl_current_default_domain attribute_hidden
= _nl_default_default_domain;
#endif
/* Contains the default location of the message catalogs. */
#if defined __EMX__
extern const char _nl_default_dirname[];
#else
# ifdef _LIBC
extern const char _nl_default_dirname[];
libc_hidden_proto (_nl_default_dirname)
# endif
const char _nl_default_dirname[] = LOCALEDIR;
# ifdef _LIBC
libc_hidden_data_def (_nl_default_dirname)
# endif
#endif
#ifndef IN_LIBGLOCALE
/* List with bindings of specific domains created by bindtextdomain()
calls. */
struct binding *_nl_domain_bindings;
#endif
/* Prototypes for local functions. */
static char *plural_lookup (struct loaded_l10nfile *domain,
unsigned long int n,
const char *translation, size_t translation_len)
internal_function;
#ifdef IN_LIBGLOCALE
static const char *guess_category_value (int category,
const char *categoryname,
const char *localename)
internal_function;
#else
static const char *guess_category_value (int category,
const char *categoryname)
internal_function;
#endif
#ifdef _LIBC
# include "../locale/localeinfo.h"
# define category_to_name(category) \
_nl_category_names.str + _nl_category_name_idxs[category]
#else
static const char *category_to_name (int category) internal_function;
#endif
#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
static const char *get_output_charset (struct binding *domainbinding)
internal_function;
#endif
/* For those losing systems which don't have `alloca' we have to add
some additional code emulating it. */
#ifdef HAVE_ALLOCA
/* Nothing has to be done. */
# define freea(p) /* nothing */
# define ADD_BLOCK(list, address) /* nothing */
# define FREE_BLOCKS(list) /* nothing */
#else
struct block_list
{
void *address;
struct block_list *next;
};
# define ADD_BLOCK(list, addr) \
do { \
struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \
/* If we cannot get a free block we cannot add the new element to \
the list. */ \
if (newp != NULL) { \
newp->address = (addr); \
newp->next = (list); \
(list) = newp; \
} \
} while (0)
# define FREE_BLOCKS(list) \
do { \
while (list != NULL) { \
struct block_list *old = list; \
list = list->next; \
free (old->address); \
free (old); \
} \
} while (0)
# undef alloca
# define alloca(size) (malloc (size))
# define freea(p) free (p)
#endif /* have alloca */
#ifdef _LIBC
/* List of blocks allocated for translations. */
typedef struct transmem_list
{
struct transmem_list *next;
char data[ZERO];
} transmem_block_t;
static struct transmem_list *transmem_list;
#else
typedef unsigned char transmem_block_t;
#endif
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DCIGETTEXT __dcigettext
#else
# define DCIGETTEXT libintl_dcigettext
#endif
/* Lock variable to protect the global data in the gettext implementation. */
gl_rwlock_define_initialized (, _nl_state_lock attribute_hidden)
/* Checking whether the binaries runs SUID must be done and glibc provides
easier methods therefore we make a difference here. */
#ifdef _LIBC
# define ENABLE_SECURE __libc_enable_secure
# define DETERMINE_SECURE
#else
# ifndef HAVE_GETUID
# define getuid() 0
# endif
# ifndef HAVE_GETGID
# define getgid() 0
# endif
# ifndef HAVE_GETEUID
# define geteuid() getuid()
# endif
# ifndef HAVE_GETEGID
# define getegid() getgid()
# endif
static int enable_secure;
# define ENABLE_SECURE (enable_secure == 1)
# define DETERMINE_SECURE \
if (enable_secure == 0) \
{ \
if (getuid () != geteuid () || getgid () != getegid ()) \
enable_secure = 1; \
else \
enable_secure = -1; \
}
#endif
/* Get the function to evaluate the plural expression. */
#include "eval-plural.h"
/* Look up MSGID in the DOMAINNAME message catalog for the current
CATEGORY locale and, if PLURAL is nonzero, search over string
depending on the plural form determined by N. */
#ifdef IN_LIBGLOCALE
char *
gl_dcigettext (const char *domainname,
const char *msgid1, const char *msgid2,
int plural, unsigned long int n,
int category,
const char *localename, const char *encoding)
#else
char *
DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
int plural, unsigned long int n, int category)
#endif
{
#ifndef HAVE_ALLOCA
struct block_list *block_list = NULL;
#endif
struct loaded_l10nfile *domain;
struct binding *binding;
const char *categoryname;
const char *categoryvalue;
const char *dirname;
char *xdomainname;
char *single_locale;
char *retval;
size_t retlen;
int saved_errno;
struct known_translation_t search;
struct known_translation_t **foundp = NULL;
#if defined HAVE_PER_THREAD_LOCALE && !defined IN_LIBGLOCALE
const char *localename;
#endif
size_t domainname_len;
/* If no real MSGID is given return NULL. */
if (msgid1 == NULL)
return NULL;
#ifdef _LIBC
if (category < 0 || category >= __LC_LAST || category == LC_ALL)
/* Bogus. */
return (plural == 0
? (char *) msgid1
/* Use the Germanic plural rule. */
: n == 1 ? (char *) msgid1 : (char *) msgid2);
#endif
/* Preserve the `errno' value. */
saved_errno = errno;
#ifdef _LIBC
__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
__libc_rwlock_rdlock (__libc_setlocale_lock);
#endif
gl_rwlock_rdlock (_nl_state_lock);
/* If DOMAINNAME is NULL, we are interested in the default domain. If
CATEGORY is not LC_MESSAGES this might not make much sense but the
definition left this undefined. */
if (domainname == NULL)
domainname = _nl_current_default_domain;
/* OS/2 specific: backward compatibility with older libintl versions */
#ifdef LC_MESSAGES_COMPAT
if (category == LC_MESSAGES_COMPAT)
category = LC_MESSAGES;
#endif
/* Try to find the translation among those which we found at
some time. */
search.domain = NULL;
search.msgid.ptr = msgid1;
search.domainname = domainname;
search.category = category;
#ifdef HAVE_PER_THREAD_LOCALE
# ifndef IN_LIBGLOCALE
# ifdef _LIBC
localename = _strdupa (_current_locale_name (category));
# else
categoryname = category_to_name (category);
# define CATEGORYNAME_INITIALIZED
localename = _nl_locale_name_thread_unsafe (category, categoryname);
if (localename == NULL)
localename = "";
# endif
# endif
search.localename = localename;
# ifdef IN_LIBGLOCALE
search.encoding = encoding;
# endif
/* Since tfind/tsearch manage a balanced tree, concurrent tfind and
tsearch calls can be fatal. */
gl_rwlock_rdlock (tree_lock);
foundp = (struct known_translation_t **) tfind (&search, &root, transcmp);
gl_rwlock_unlock (tree_lock);
if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr)
{
/* Now deal with plural. */
if (plural)
retval = plural_lookup ((*foundp)->domain, n, (*foundp)->translation,
(*foundp)->translation_length);
else
retval = (char *) (*foundp)->translation;
gl_rwlock_unlock (_nl_state_lock);
# ifdef _LIBC
__libc_rwlock_unlock (__libc_setlocale_lock);
# endif
__set_errno (saved_errno);
return retval;
}
#endif
/* See whether this is a SUID binary or not. */
DETERMINE_SECURE;
/* First find matching binding. */
#ifdef IN_LIBGLOCALE
/* We can use a trivial binding, since _nl_find_msg will ignore it anyway,
and _nl_load_domain and _nl_find_domain just pass it through. */
binding = NULL;
dirname = bindtextdomain (domainname, NULL);
#else
for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
{
int compare = strcmp (domainname, binding->domainname);
if (compare == 0)
/* We found it! */
break;
if (compare < 0)
{
/* It is not in the list. */
binding = NULL;
break;
}
}
if (binding == NULL)
dirname = _nl_default_dirname;
else
{
dirname = binding->dirname;
#endif
if (!IS_ABSOLUTE_PATH (dirname))
{
/* We have a relative path. Make it absolute now. */
size_t dirname_len = strlen (dirname) + 1;
size_t path_max;
char *resolved_dirname;
char *ret;
path_max = (unsigned int) PATH_MAX;
path_max += 2; /* The getcwd docs say to do this. */
for (;;)
{
resolved_dirname = (char *) alloca (path_max + dirname_len);
ADD_BLOCK (block_list, tmp_dirname);
__set_errno (0);
ret = getcwd (resolved_dirname, path_max);
if (ret != NULL || errno != ERANGE)
break;
path_max += path_max / 2;
path_max += PATH_INCR;
}
if (ret == NULL)
/* We cannot get the current working directory. Don't signal an
error but simply return the default string. */
goto return_untranslated;
stpcpy (stpcpy (strchr (resolved_dirname, '\0'), "/"), dirname);
dirname = resolved_dirname;
}
#ifndef IN_LIBGLOCALE
}
#endif
/* Now determine the symbolic name of CATEGORY and its value. */
#ifndef CATEGORYNAME_INITIALIZED
categoryname = category_to_name (category);
#endif
#ifdef IN_LIBGLOCALE
categoryvalue = guess_category_value (category, categoryname, localename);
#else
categoryvalue = guess_category_value (category, categoryname);
#endif
domainname_len = strlen (domainname);
xdomainname = (char *) alloca (strlen (categoryname)
+ domainname_len + 5);
ADD_BLOCK (block_list, xdomainname);
stpcpy ((char *) mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
domainname, domainname_len),
".mo");
/* Creating working area. */
single_locale = (char *) alloca (strlen (categoryvalue) + 1);
ADD_BLOCK (block_list, single_locale);
/* Search for the given string. This is a loop because we perhaps
got an ordered list of languages to consider for the translation. */
while (1)
{
/* Make CATEGORYVALUE point to the next element of the list. */
while (categoryvalue[0] != '\0' && categoryvalue[0] == ':')
++categoryvalue;
if (categoryvalue[0] == '\0')
{
/* The whole contents of CATEGORYVALUE has been searched but
no valid entry has been found. We solve this situation
by implicitly appending a "C" entry, i.e. no translation
will take place. */
single_locale[0] = 'C';
single_locale[1] = '\0';
}
else
{
char *cp = single_locale;
while (categoryvalue[0] != '\0' && categoryvalue[0] != ':')
*cp++ = *categoryvalue++;
*cp = '\0';
/* When this is a SUID binary we must not allow accessing files
outside the dedicated directories. */
if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale))
/* Ingore this entry. */
continue;
}
/* If the current locale value is C (or POSIX) we don't load a
domain. Return the MSGID. */
if (strcmp (single_locale, "C") == 0
|| strcmp (single_locale, "POSIX") == 0)
break;
/* Find structure describing the message catalog matching the
DOMAINNAME and CATEGORY. */
domain = _nl_find_domain (dirname, single_locale, xdomainname, binding);
if (domain != NULL)
{
#if defined IN_LIBGLOCALE
retval = _nl_find_msg (domain, binding, encoding, msgid1, &retlen);
#else
retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen);
#endif
if (retval == NULL)
{
int cnt;
for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
{
#if defined IN_LIBGLOCALE
retval = _nl_find_msg (domain->successor[cnt], binding,
encoding, msgid1, &retlen);
#else
retval = _nl_find_msg (domain->successor[cnt], binding,
msgid1, 1, &retlen);
#endif
if (retval != NULL)
{
domain = domain->successor[cnt];
break;
}
}
}
/* Returning -1 means that some resource problem exists
(likely memory) and that the strings could not be
converted. Return the original strings. */
if (__builtin_expect (retval == (char *) -1, 0))
break;
if (retval != NULL)
{
/* Found the translation of MSGID1 in domain DOMAIN:
starting at RETVAL, RETLEN bytes. */
FREE_BLOCKS (block_list);
if (foundp == NULL)
{
/* Create a new entry and add it to the search tree. */
size_t msgid_len;
size_t size;
struct known_translation_t *newp;
msgid_len = strlen (msgid1) + 1;
size = offsetof (struct known_translation_t, msgid)
+ msgid_len + domainname_len + 1;
#ifdef HAVE_PER_THREAD_LOCALE
size += strlen (localename) + 1;
#endif
newp = (struct known_translation_t *) malloc (size);
if (newp != NULL)
{
char *new_domainname;
#ifdef HAVE_PER_THREAD_LOCALE
char *new_localename;
#endif
new_domainname =
(char *) mempcpy (newp->msgid.appended, msgid1,
msgid_len);
memcpy (new_domainname, domainname, domainname_len + 1);
#ifdef HAVE_PER_THREAD_LOCALE
new_localename = new_domainname + domainname_len + 1;
strcpy (new_localename, localename);
#endif
newp->domainname = new_domainname;
newp->category = category;
#ifdef HAVE_PER_THREAD_LOCALE
newp->localename = new_localename;
#endif
#ifdef IN_LIBGLOCALE
newp->encoding = encoding;
#endif
newp->counter = _nl_msg_cat_cntr;
newp->domain = domain;
newp->translation = retval;
newp->translation_length = retlen;
gl_rwlock_wrlock (tree_lock);
/* Insert the entry in the search tree. */
foundp = (struct known_translation_t **)
tsearch (newp, &root, transcmp);
gl_rwlock_unlock (tree_lock);
if (foundp == NULL
|| __builtin_expect (*foundp != newp, 0))
/* The insert failed. */
free (newp);
}
}
else
{
/* We can update the existing entry. */
(*foundp)->counter = _nl_msg_cat_cntr;
(*foundp)->domain = domain;
(*foundp)->translation = retval;
(*foundp)->translation_length = retlen;
}
__set_errno (saved_errno);
/* Now deal with plural. */
if (plural)
retval = plural_lookup (domain, n, retval, retlen);
gl_rwlock_unlock (_nl_state_lock);
#ifdef _LIBC
__libc_rwlock_unlock (__libc_setlocale_lock);
#endif
return retval;
}
}
}
return_untranslated:
/* Return the untranslated MSGID. */
FREE_BLOCKS (block_list);
gl_rwlock_unlock (_nl_state_lock);
#ifdef _LIBC
__libc_rwlock_unlock (__libc_setlocale_lock);
#endif
#ifndef _LIBC
if (!ENABLE_SECURE)
{
extern void _nl_log_untranslated (const char *logfilename,
const char *domainname,
const char *msgid1, const char *msgid2,
int plural);
const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED");
if (logfilename != NULL && logfilename[0] != '\0')
_nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural);
}
#endif
__set_errno (saved_errno);
return (plural == 0
? (char *) msgid1
/* Use the Germanic plural rule. */
: n == 1 ? (char *) msgid1 : (char *) msgid2);
}
/* Look up the translation of msgid within DOMAIN_FILE and DOMAINBINDING.
Return it if found. Return NULL if not found or in case of a conversion
failure (problem in the particular message catalog). Return (char *) -1
in case of a memory allocation failure during conversion (only if
ENCODING != NULL resp. CONVERT == true). */
char *
internal_function
#ifdef IN_LIBGLOCALE
_nl_find_msg (struct loaded_l10nfile *domain_file,
struct binding *domainbinding, const char *encoding,
const char *msgid,
size_t *lengthp)
#else
_nl_find_msg (struct loaded_l10nfile *domain_file,
struct binding *domainbinding,
const char *msgid, int convert,
size_t *lengthp)
#endif
{
struct loaded_domain *domain;
nls_uint32 nstrings;
size_t act;
char *result;
size_t resultlen;
if (domain_file->decided <= 0)
_nl_load_domain (domain_file, domainbinding);
if (domain_file->data == NULL)
return NULL;
domain = (struct loaded_domain *) domain_file->data;
nstrings = domain->nstrings;
/* Locate the MSGID and its translation. */
if (domain->hash_tab != NULL)
{
/* Use the hashing table. */
nls_uint32 len = strlen (msgid);
nls_uint32 hash_val = __hash_string (msgid);
nls_uint32 idx = hash_val % domain->hash_size;
nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2));
while (1)
{
nls_uint32 nstr =
W (domain->must_swap_hash_tab, domain->hash_tab[idx]);
if (nstr == 0)
/* Hash table entry is empty. */
return NULL;
nstr--;
/* Compare msgid with the original string at index nstr.
We compare the lengths with >=, not ==, because plural entries
are represented by strings with an embedded NUL. */
if (nstr < nstrings
? W (domain->must_swap, domain->orig_tab[nstr].length) >= len
&& (strcmp (msgid,
domain->data + W (domain->must_swap,
domain->orig_tab[nstr].offset))
== 0)
: domain->orig_sysdep_tab[nstr - nstrings].length > len
&& (strcmp (msgid,
domain->orig_sysdep_tab[nstr - nstrings].pointer)
== 0))
{
act = nstr;
goto found;
}
if (idx >= domain->hash_size - incr)
idx -= domain->hash_size - incr;
else
idx += incr;
}
/* NOTREACHED */
}
else
{
/* Try the default method: binary search in the sorted array of
messages. */
size_t top, bottom;
bottom = 0;
top = nstrings;
while (bottom < top)
{
int cmp_val;
act = (bottom + top) / 2;
cmp_val = strcmp (msgid, (domain->data
+ W (domain->must_swap,
domain->orig_tab[act].offset)));
if (cmp_val < 0)
top = act;
else if (cmp_val > 0)
bottom = act + 1;
else
goto found;
}
/* No translation was found. */
return NULL;
}
found:
/* The translation was found at index ACT. If we have to convert the
string to use a different character set, this is the time. */
if (act < nstrings)
{
result = (char *)
(domain->data + W (domain->must_swap, domain->trans_tab[act].offset));
resultlen = W (domain->must_swap, domain->trans_tab[act].length) + 1;
}
else
{
result = (char *) domain->trans_sysdep_tab[act - nstrings].pointer;
resultlen = domain->trans_sysdep_tab[act - nstrings].length;
}
#if defined _LIBC || HAVE_ICONV
# ifdef IN_LIBGLOCALE
if (encoding != NULL)
# else
if (convert)
# endif
{
/* We are supposed to do a conversion. */
# ifndef IN_LIBGLOCALE
const char *encoding = get_output_charset (domainbinding);
# endif
size_t nconversions;
struct converted_domain *convd;
size_t i;
/* Protect against reallocation of the table. */
gl_rwlock_rdlock (domain->conversions_lock);
/* Search whether a table with converted translations for this
encoding has already been allocated. */
nconversions = domain->nconversions;
convd = NULL;
for (i = nconversions; i > 0; )
{
i--;
if (strcmp (domain->conversions[i].encoding, encoding) == 0)
{
convd = &domain->conversions[i];
break;
}
}
gl_rwlock_unlock (domain->conversions_lock);
if (convd == NULL)
{
/* We have to allocate a new conversions table. */
gl_rwlock_wrlock (domain->conversions_lock);
nconversions = domain->nconversions;
/* Maybe in the meantime somebody added the translation.
Recheck. */
for (i = nconversions; i > 0; )
{
i--;
if (strcmp (domain->conversions[i].encoding, encoding) == 0)
{
convd = &domain->conversions[i];
goto found_convd;
}
}
{
/* Allocate a table for the converted translations for this
encoding. */
struct converted_domain *new_conversions =
(struct converted_domain *)
(domain->conversions != NULL
? realloc (domain->conversions,
(nconversions + 1) * sizeof (struct converted_domain))
: malloc ((nconversions + 1) * sizeof (struct converted_domain)));
if (__builtin_expect (new_conversions == NULL, 0))
{
/* Nothing we can do, no more memory. We cannot use the
translation because it might be encoded incorrectly. */
unlock_fail:
gl_rwlock_unlock (domain->conversions_lock);
return (char *) -1;
}
domain->conversions = new_conversions;
/* Copy the 'encoding' string to permanent storage. */
encoding = strdup (encoding);
if (__builtin_expect (encoding == NULL, 0))
/* Nothing we can do, no more memory. We cannot use the
translation because it might be encoded incorrectly. */
goto unlock_fail;
convd = &new_conversions[nconversions];
convd->encoding = encoding;
/* Find out about the character set the file is encoded with.
This can be found (in textual form) in the entry "". If this
entry does not exist or if this does not contain the 'charset='
information, we will assume the charset matches the one the
current locale and we don't have to perform any conversion. */
# ifdef _LIBC
convd->conv = (__gconv_t) -1;
# else
# if HAVE_ICONV
convd->conv = (iconv_t) -1;
# endif
# endif
{
char *nullentry;
size_t nullentrylen;
/* Get the header entry. This is a recursion, but it doesn't
reallocate domain->conversions because we pass
encoding = NULL or convert = 0, respectively. */
nullentry =
# ifdef IN_LIBGLOCALE
_nl_find_msg (domain_file, domainbinding, NULL, "",
&nullentrylen);
# else
_nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
# endif
if (nullentry != NULL)
{
const char *charsetstr;
charsetstr = strstr (nullentry, "charset=");
if (charsetstr != NULL)
{
size_t len;
char *charset;
const char *outcharset;
charsetstr += strlen ("charset=");
len = strcspn (charsetstr, " \t\n");
charset = (char *) alloca (len + 1);
# if defined _LIBC || HAVE_MEMPCPY
*((char *) mempcpy (charset, charsetstr, len)) = '\0';
# else
memcpy (charset, charsetstr, len);
charset[len] = '\0';
# endif
outcharset = encoding;
# ifdef _LIBC
/* We always want to use transliteration. */
outcharset = norm_add_slashes (outcharset, "TRANSLIT");
charset = norm_add_slashes (charset, "");
int r = __gconv_open (outcharset, charset, &convd->conv,
GCONV_AVOID_NOCONV);
if (__builtin_expect (r != __GCONV_OK, 0))
{
/* If the output encoding is the same there is
nothing to do. Otherwise do not use the
translation at all. */
if (__builtin_expect (r != __GCONV_NULCONV, 1))
{
gl_rwlock_unlock (domain->conversions_lock);
free ((char *) encoding);
return NULL;
}
convd->conv = (__gconv_t) -1;
}
# else
# if HAVE_ICONV
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) \
&& !defined __UCLIBC__) \
|| _LIBICONV_VERSION >= 0x0105
if (strchr (outcharset, '/') == NULL)
{
char *tmp;
len = strlen (outcharset);
tmp = (char *) alloca (len + 10 + 1);
memcpy (tmp, outcharset, len);
memcpy (tmp + len, "//TRANSLIT", 10 + 1);
outcharset = tmp;
convd->conv = iconv_open (outcharset, charset);
freea (outcharset);
}
else
# endif
convd->conv = iconv_open (outcharset, charset);
# endif
# endif
freea (charset);
}
}
}
convd->conv_tab = NULL;
/* Here domain->conversions is still == new_conversions. */
domain->nconversions++;
}
found_convd:
gl_rwlock_unlock (domain->conversions_lock);
}
if (
# ifdef _LIBC
convd->conv != (__gconv_t) -1
# else
# if HAVE_ICONV
convd->conv != (iconv_t) -1
# endif
# endif
)
{
/* We are supposed to do a conversion. First allocate an
appropriate table with the same structure as the table
of translations in the file, where we can put the pointers
to the converted strings in.
There is a slight complication with plural entries. They
are represented by consecutive NUL terminated strings. We
handle this case by converting RESULTLEN bytes, including
NULs. */
/* This lock primarily protects the memory management variables
freemem, freemem_size. It also protects write accesses to
convd->conv_tab. It's not worth using a separate lock (such
as domain->conversions_lock) for this purpose, because when
modifying convd->conv_tab, we also need to lock freemem,
freemem_size for most of the time. */
__libc_lock_define_initialized (static, lock)
if (__builtin_expect (convd->conv_tab == NULL, 0))
{
__libc_lock_lock (lock);
if (convd->conv_tab == NULL)
{
convd->conv_tab =
(char **) calloc (nstrings + domain->n_sysdep_strings,
sizeof (char *));
if (convd->conv_tab != NULL)
goto not_translated_yet;
/* Mark that we didn't succeed allocating a table. */
convd->conv_tab = (char **) -1;
}
__libc_lock_unlock (lock);
}
if (__builtin_expect (convd->conv_tab == (char **) -1, 0))
/* Nothing we can do, no more memory. We cannot use the
translation because it might be encoded incorrectly. */
return (char *) -1;
if (convd->conv_tab[act] == NULL)
{
/* We haven't used this string so far, so it is not
translated yet. Do this now. */
/* We use a bit more efficient memory handling.
We allocate always larger blocks which get used over
time. This is faster than many small allocations. */
# define INITIAL_BLOCK_SIZE 4080
static unsigned char *freemem;
static size_t freemem_size;
const unsigned char *inbuf;
unsigned char *outbuf;
int malloc_count;
# ifndef _LIBC
transmem_block_t *transmem_list;
# endif
__libc_lock_lock (lock);
not_translated_yet:
inbuf = (const unsigned char *) result;
outbuf = freemem + sizeof (size_t);
# ifndef _LIBC
transmem_list = NULL;
# endif
malloc_count = 0;
while (1)
{
transmem_block_t *newmem;
# ifdef _LIBC
size_t non_reversible;
int res;
if (freemem_size < sizeof (size_t))
goto resize_freemem;
res = __gconv (convd->conv,
&inbuf, inbuf + resultlen,
&outbuf,
outbuf + freemem_size - sizeof (size_t),
&non_reversible);
if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT)
break;
if (res != __GCONV_FULL_OUTPUT)
{
/* We should not use the translation at all, it
is incorrectly encoded. */
__libc_lock_unlock (lock);
return NULL;
}
inbuf = (const unsigned char *) result;
# else
# if HAVE_ICONV
const char *inptr = (const char *) inbuf;
size_t inleft = resultlen;
char *outptr = (char *) outbuf;
size_t outleft;
if (freemem_size < sizeof (size_t))
goto resize_freemem;
outleft = freemem_size - sizeof (size_t);
if (iconv (convd->conv,
(ICONV_CONST char **) &inptr, &inleft,
&outptr, &outleft)
!= (size_t) (-1))
{
outbuf = (unsigned char *) outptr;
break;
}
if (errno != E2BIG)
{
__libc_lock_unlock (lock);
return NULL;
}
# endif
# endif
resize_freemem:
/* We must allocate a new buffer or resize the old one. */
if (malloc_count > 0)
{
++malloc_count;
freemem_size = malloc_count * INITIAL_BLOCK_SIZE;
newmem = (transmem_block_t *) realloc (transmem_list,
freemem_size);
# ifdef _LIBC
if (newmem != NULL)
transmem_list = transmem_list->next;
else
{
struct transmem_list *old = transmem_list;
transmem_list = transmem_list->next;
free (old);
}
# endif
}
else
{
malloc_count = 1;
freemem_size = INITIAL_BLOCK_SIZE;
newmem = (transmem_block_t *) malloc (freemem_size);
}
if (__builtin_expect (newmem == NULL, 0))
{
freemem = NULL;
freemem_size = 0;
__libc_lock_unlock (lock);
return (char *) -1;
}
# ifdef _LIBC
/* Add the block to the list of blocks we have to free
at some point. */
newmem->next = transmem_list;
transmem_list = newmem;
freemem = (unsigned char *) newmem->data;
freemem_size -= offsetof (struct transmem_list, data);
# else
transmem_list = newmem;
freemem = newmem;
# endif
outbuf = freemem + sizeof (size_t);
}
/* We have now in our buffer a converted string. Put this
into the table of conversions. */
*(size_t *) freemem = outbuf - freemem - sizeof (size_t);
convd->conv_tab[act] = (char *) freemem;
/* Shrink freemem, but keep it aligned. */
freemem_size -= outbuf - freemem;
freemem = outbuf;
freemem += freemem_size & (alignof (size_t) - 1);
freemem_size = freemem_size & ~ (alignof (size_t) - 1);
__libc_lock_unlock (lock);
}
/* Now convd->conv_tab[act] contains the translation of all
the plural variants. */
result = convd->conv_tab[act] + sizeof (size_t);
resultlen = *(size_t *) convd->conv_tab[act];
}
}
/* The result string is converted. */
#endif /* _LIBC || HAVE_ICONV */
*lengthp = resultlen;
return result;
}
/* Look up a plural variant. */
static char *
internal_function
plural_lookup (struct loaded_l10nfile *domain, unsigned long int n,
const char *translation, size_t translation_len)
{
struct loaded_domain *domaindata = (struct loaded_domain *) domain->data;
unsigned long int index;
const char *p;
index = plural_eval (domaindata->plural, n);
if (index >= domaindata->nplurals)
/* This should never happen. It means the plural expression and the
given maximum value do not match. */
index = 0;
/* Skip INDEX strings at TRANSLATION. */
p = translation;
while (index-- > 0)
{
#ifdef _LIBC
p = __rawmemchr (p, '\0');
#else
p = strchr (p, '\0');
#endif
/* And skip over the NUL byte. */
p++;
if (p >= translation + translation_len)
/* This should never happen. It means the plural expression
evaluated to a value larger than the number of variants
available for MSGID1. */
return (char *) translation;
}
return (char *) p;
}
#ifndef _LIBC
/* Return string representation of locale CATEGORY. */
static const char *
internal_function
category_to_name (int category)
{
const char *retval;
switch (category)
{
#ifdef LC_COLLATE
case LC_COLLATE:
retval = "LC_COLLATE";
break;
#endif
#ifdef LC_CTYPE
case LC_CTYPE:
retval = "LC_CTYPE";
break;
#endif
#ifdef LC_MONETARY
case LC_MONETARY:
retval = "LC_MONETARY";
break;
#endif
#ifdef LC_NUMERIC
case LC_NUMERIC:
retval = "LC_NUMERIC";
break;
#endif
#ifdef LC_TIME
case LC_TIME:
retval = "LC_TIME";
break;
#endif
#ifdef LC_MESSAGES
case LC_MESSAGES:
retval = "LC_MESSAGES";
break;
#endif
#ifdef LC_RESPONSE
case LC_RESPONSE:
retval = "LC_RESPONSE";
break;
#endif
#ifdef LC_ALL
case LC_ALL:
/* This might not make sense but is perhaps better than any other
value. */
retval = "LC_ALL";
break;
#endif
default:
/* If you have a better idea for a default value let me know. */
retval = "LC_XXX";
}
return retval;
}
#endif
/* Guess value of current locale from value of the environment variables
or system-dependent defaults. */
static const char *
internal_function
#ifdef IN_LIBGLOCALE
guess_category_value (int category, const char *categoryname,
const char *locale)
#else
guess_category_value (int category, const char *categoryname)
#endif
{
const char *language;
#ifndef IN_LIBGLOCALE
const char *locale;
# ifndef _LIBC
const char *language_default;
int locale_defaulted;
# endif
#endif
/* We use the settings in the following order:
1. The value of the environment variable 'LANGUAGE'. This is a GNU
extension. Its value can be a colon-separated list of locale names.
2. The value of the environment variable 'LC_ALL', 'LC_xxx', or 'LANG'.
More precisely, the first among these that is set to a non-empty value.
This is how POSIX specifies it. The value is a single locale name.
3. A system-dependent preference list of languages. Its value can be a
colon-separated list of locale names.
4. A system-dependent default locale name.
This way:
- System-dependent settings can be overridden by environment variables.
- If the system provides both a list of languages and a default locale,
the former is used. */
#ifndef IN_LIBGLOCALE
/* Fetch the locale name, through the POSIX method of looking to `LC_ALL',
`LC_xxx', and `LANG'. On some systems this can be done by the
`setlocale' function itself. */
# ifdef _LIBC
locale = __current_locale_name (category);
# else
locale_defaulted = 0;
# if HAVE_USELOCALE
locale = _nl_locale_name_thread_unsafe (category, categoryname);
if (locale == NULL)
# endif
{
locale = _nl_locale_name_posix (category, categoryname);
if (locale == NULL)
{
locale = _nl_locale_name_default ();
locale_defaulted = 1;
}
}
# endif
#endif
/* Ignore LANGUAGE and its system-dependent analogon if the locale is set
to "C" because
1. "C" locale usually uses the ASCII encoding, and most international
messages use non-ASCII characters. These characters get displayed
as question marks (if using glibc's iconv()) or as invalid 8-bit
characters (because other iconv()s refuse to convert most non-ASCII
characters to ASCII). In any case, the output is ugly.
2. The precise output of some programs in the "C" locale is specified
by POSIX and should not depend on environment variables like
"LANGUAGE" or system-dependent information. We allow such programs
to use gettext(). */
if (strcmp (locale, "C") == 0)
return locale;
/* The highest priority value is the value of the 'LANGUAGE' environment
variable. */
language = getenv ("LANGUAGE");
if (language != NULL && language[0] != '\0')
return language;
#if !defined IN_LIBGLOCALE && !defined _LIBC
/* The next priority value is the locale name, if not defaulted. */
if (locale_defaulted)
{
/* The next priority value is the default language preferences list. */
language_default = _nl_language_preferences_default ();
if (language_default != NULL)
return language_default;
}
/* The least priority value is the locale name, if defaulted. */
#endif
return locale;
}
#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
/* Returns the output charset. */
static const char *
internal_function
get_output_charset (struct binding *domainbinding)
{
/* The output charset should normally be determined by the locale. But
sometimes the locale is not used or not correctly set up, so we provide
a possibility for the user to override this: the OUTPUT_CHARSET
environment variable. Moreover, the value specified through
bind_textdomain_codeset overrides both. */
if (domainbinding != NULL && domainbinding->codeset != NULL)
return domainbinding->codeset;
else
{
/* For speed reasons, we look at the value of OUTPUT_CHARSET only
once. This is a user variable that is not supposed to change
during a program run. */
static char *output_charset_cache;
static int output_charset_cached;
if (!output_charset_cached)
{
const char *value = getenv ("OUTPUT_CHARSET");
if (value != NULL && value[0] != '\0')
{
size_t len = strlen (value) + 1;
char *value_copy = (char *) malloc (len);
if (value_copy != NULL)
memcpy (value_copy, value, len);
output_charset_cache = value_copy;
}
output_charset_cached = 1;
}
if (output_charset_cache != NULL)
return output_charset_cache;
else
{
# ifdef _LIBC
return _NL_CURRENT (LC_CTYPE, CODESET);
# else
# if HAVE_ICONV
return locale_charset ();
# endif
# endif
}
}
}
#endif
/* @@ begin of epilog @@ */
/* We don't want libintl.a to depend on any other library. So we
avoid the non-standard function stpcpy. In GNU C Library this
function is available, though. Also allow the symbol HAVE_STPCPY
to be defined. */
#if !_LIBC && !HAVE_STPCPY
static char *
stpcpy (char *dest, const char *src)
{
while ((*dest++ = *src++) != '\0')
/* Do nothing. */ ;
return dest - 1;
}
#endif
#if !_LIBC && !HAVE_MEMPCPY
static void *
mempcpy (void *dest, const void *src, size_t n)
{
return (void *) ((char *) memcpy (dest, src, n) + n);
}
#endif
#if !_LIBC && !HAVE_TSEARCH
# include "tsearch.c"
#endif
#ifdef _LIBC
/* If we want to free all resources we have to do some work at
program's end. */
libc_freeres_fn (free_mem)
{
void *old;
while (_nl_domain_bindings != NULL)
{
struct binding *oldp = _nl_domain_bindings;
_nl_domain_bindings = _nl_domain_bindings->next;
if (oldp->dirname != _nl_default_dirname)
/* Yes, this is a pointer comparison. */
free (oldp->dirname);
free (oldp->codeset);
free (oldp);
}
if (_nl_current_default_domain != _nl_default_default_domain)
/* Yes, again a pointer comparison. */
free ((char *) _nl_current_default_domain);
/* Remove the search tree with the known translations. */
__tdestroy (root, free);
root = NULL;
while (transmem_list != NULL)
{
old = transmem_list;
transmem_list = transmem_list->next;
free (old);
}
}
#endif
plptools-1.0.13/intl/gettextP.h 0000644 0001750 0001750 00000023551 12417352630 013325 0000000 0000000 /* Header describing internals of libintl library.
Copyright (C) 1995-1999, 2000-2007, 2009-2010 Free Software Foundation, Inc.
Written by Ulrich Drepper , 1995.
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.1 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 . */
#ifndef _GETTEXTP_H
#define _GETTEXTP_H
#include /* Get size_t. */
#ifdef _LIBC
# include "../iconv/gconv_int.h"
#else
# if HAVE_ICONV
# include
# endif
#endif
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
# define gl_rwlock_define __libc_rwlock_define
#else
# include "lock.h"
#endif
#ifdef _LIBC
extern char *__gettext (const char *__msgid);
extern char *__dgettext (const char *__domainname, const char *__msgid);
extern char *__dcgettext (const char *__domainname, const char *__msgid,
int __category);
extern char *__ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n);
extern char *__dngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int n);
extern char *__dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category);
extern char *__dcigettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
int __plural, unsigned long int __n,
int __category);
extern char *__textdomain (const char *__domainname);
extern char *__bindtextdomain (const char *__domainname,
const char *__dirname);
extern char *__bind_textdomain_codeset (const char *__domainname,
const char *__codeset);
extern void _nl_finddomain_subfreeres (void) attribute_hidden;
extern void _nl_unload_domain (struct loaded_domain *__domain)
internal_function attribute_hidden;
#else
/* Declare the exported libintl_* functions, in a way that allows us to
call them under their real name. */
# undef _INTL_REDIRECT_INLINE
# undef _INTL_REDIRECT_MACROS
# define _INTL_REDIRECT_MACROS
# include "libgnuintl.h"
# ifdef IN_LIBGLOCALE
extern char *gl_dcigettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
int __plural, unsigned long int __n,
int __category,
const char *__localename, const char *__encoding);
# else
extern char *libintl_dcigettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
int __plural, unsigned long int __n,
int __category);
# endif
#endif
#include "loadinfo.h"
#include "gmo.h" /* Get nls_uint32. */
/* @@ end of prolog @@ */
#ifndef internal_function
# define internal_function
#endif
#ifndef attribute_hidden
# define attribute_hidden
#endif
/* Tell the compiler when a conditional or integer expression is
almost always true or almost always false. */
#ifndef HAVE_BUILTIN_EXPECT
# define __builtin_expect(expr, val) (expr)
#endif
#ifndef W
# define W(flag, data) ((flag) ? SWAP (data) : (data))
#endif
#ifdef _LIBC
# include
# define SWAP(i) bswap_32 (i)
#else
static inline nls_uint32
# ifdef __cplusplus
SWAP (nls_uint32 i)
# else
SWAP (i)
nls_uint32 i;
# endif
{
return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
#endif
/* In-memory representation of system dependent string. */
struct sysdep_string_desc
{
/* Length of addressed string, including the trailing NUL. */
size_t length;
/* Pointer to addressed string. */
const char *pointer;
};
/* Cache of translated strings after charset conversion.
Note: The strings are converted to the target encoding only on an as-needed
basis. */
struct converted_domain
{
/* The target encoding name. */
const char *encoding;
/* The descriptor for conversion from the message catalog's encoding to
this target encoding. */
#ifdef _LIBC
__gconv_t conv;
#else
# if HAVE_ICONV
iconv_t conv;
# endif
#endif
/* The table of translated strings after charset conversion. */
char **conv_tab;
};
/* The representation of an opened message catalog. */
struct loaded_domain
{
/* Pointer to memory containing the .mo file. */
const char *data;
/* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
int use_mmap;
/* Size of mmap()ed memory. */
size_t mmap_size;
/* 1 if the .mo file uses a different endianness than this machine. */
int must_swap;
/* Pointer to additional malloc()ed memory. */
void *malloced;
/* Number of static strings pairs. */
nls_uint32 nstrings;
/* Pointer to descriptors of original strings in the file. */
const struct string_desc *orig_tab;
/* Pointer to descriptors of translated strings in the file. */
const struct string_desc *trans_tab;
/* Number of system dependent strings pairs. */
nls_uint32 n_sysdep_strings;
/* Pointer to descriptors of original sysdep strings. */
const struct sysdep_string_desc *orig_sysdep_tab;
/* Pointer to descriptors of translated sysdep strings. */
const struct sysdep_string_desc *trans_sysdep_tab;
/* Size of hash table. */
nls_uint32 hash_size;
/* Pointer to hash table. */
const nls_uint32 *hash_tab;
/* 1 if the hash table uses a different endianness than this machine. */
int must_swap_hash_tab;
/* Cache of charset conversions of the translated strings. */
struct converted_domain *conversions;
size_t nconversions;
gl_rwlock_define (, conversions_lock)
const struct expression *plural;
unsigned long int nplurals;
};
/* We want to allocate a string at the end of the struct. But ISO C
doesn't allow zero sized arrays. */
#ifdef __GNUC__
# define ZERO 0
#else
# define ZERO 1
#endif
/* A set of settings bound to a message domain. Used to store settings
from bindtextdomain() and bind_textdomain_codeset(). */
struct binding
{
struct binding *next;
char *dirname;
char *codeset;
char domainname[ZERO];
};
/* A counter which is incremented each time some previous translations
become invalid.
This variable is part of the external ABI of the GNU libintl. */
#ifdef IN_LIBGLOCALE
# include
extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
#else
extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
#endif
#ifndef _LIBC
extern const char *_nl_language_preferences_default (void);
# define gl_locale_name_canonicalize _nl_locale_name_canonicalize
extern void _nl_locale_name_canonicalize (char *name);
# define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID
/* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */
# define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID
/* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */
# define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe
extern const char *_nl_locale_name_thread_unsafe (int category,
const char *categoryname);
# define gl_locale_name_thread _nl_locale_name_thread
/* extern const char *_nl_locale_name_thread (int category,
const char *categoryname); */
# define gl_locale_name_posix _nl_locale_name_posix
extern const char *_nl_locale_name_posix (int category,
const char *categoryname);
# define gl_locale_name_environ _nl_locale_name_environ
extern const char *_nl_locale_name_environ (int category,
const char *categoryname);
# define gl_locale_name_default _nl_locale_name_default
extern const char *_nl_locale_name_default (void);
# define gl_locale_name _nl_locale_name
/* extern const char *_nl_locale_name (int category,
const char *categoryname); */
#endif
struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
const char *__domainname,
struct binding *__domainbinding)
internal_function;
void _nl_load_domain (struct loaded_l10nfile *__domain,
struct binding *__domainbinding)
internal_function;
#ifdef IN_LIBGLOCALE
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
struct binding *domainbinding, const char *encoding,
const char *msgid,
size_t *lengthp)
internal_function;
#else
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
struct binding *domainbinding, const char *msgid,
int convert, size_t *lengthp)
internal_function;
#endif
/* The internal variables in the standalone libintl.a must have different
names than the internal variables in GNU libc, otherwise programs
using libintl.a cannot be linked statically. */
#if !defined _LIBC
# define _nl_default_dirname libintl_nl_default_dirname
# define _nl_domain_bindings libintl_nl_domain_bindings
#endif
/* Contains the default location of the message catalogs. */
extern const char _nl_default_dirname[];
#ifdef _LIBC
libc_hidden_proto (_nl_default_dirname)
#endif
/* List with bindings of specific domains. */
extern struct binding *_nl_domain_bindings;
/* The internal variables in the standalone libintl.a must have different
names than the internal variables in GNU libc, otherwise programs
using libintl.a cannot be linked statically. */
#if !defined _LIBC
# define _nl_default_default_domain libintl_nl_default_default_domain
# define _nl_current_default_domain libintl_nl_current_default_domain
#endif
/* Name of the default text domain. */
extern const char _nl_default_default_domain[] attribute_hidden;
/* Default text domain in which entries for gettext(3) are to be found. */
extern const char *_nl_current_default_domain attribute_hidden;
/* @@ begin of epilog @@ */
#endif /* gettextP.h */
plptools-1.0.13/intl/config.charset 0000755 0001750 0001750 00000055172 12417352630 014177 0000000 0000000 #! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000-2004, 2006-2010 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.1 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 .
#
# 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
# (darwin = Mac OS X, woe32 = native Windows)
#
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-3 Y glibc solaris cygwin
# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-6 Y glibc aix hpux solaris cygwin
# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
# ISO-8859-13 glibc netbsd openbsd darwin cygwin
# ISO-8859-14 glibc cygwin
# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
# 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 cygwin woe32 dos
# CP943 aix
# CP949 osf darwin woe32 dos
# CP950 woe32 dos
# CP1046 aix
# CP1124 aix
# CP1125 dos
# CP1129 aix
# CP1131 darwin
# CP1250 woe32
# CP1251 glibc solaris netbsd openbsd darwin cygwin 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 cygwin
# EUC-TW glibc aix hpux irix osf solaris netbsd
# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
# BIG5-HKSCS glibc solaris darwin
# GBK glibc aix osf solaris darwin cygwin woe32 dos
# GB18030 glibc solaris netbsd darwin
# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
# JOHAB glibc solaris woe32
# TIS-620 glibc aix hpux osf solaris cygwin
# VISCII Y glibc
# TCVN5712-1 glibc
# ARMSCII-8 glibc darwin
# GEORGIAN-PS glibc cygwin
# PT154 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 cygwin
#
# 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 sometimes its value 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.
# Then there are also the locales with encodings other than US-ASCII
# and UTF-8. These locales can be occasionally useful to users (e.g.
# when grepping through ISO-8859-1 encoded text files), when all their
# file names are in US-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-9 ISO-8859-9"
echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
echo "KOI8-R KOI8-R"
echo "KOI8-U KOI8-U"
echo "CP866 CP866"
echo "CP949 CP949"
echo "CP1131 CP1131"
echo "CP1251 CP1251"
echo "eucCN GB2312"
echo "GB2312 GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "Big5 BIG5"
echo "Big5HKSCS BIG5-HKSCS"
echo "GBK GBK"
echo "GB18030 GB18030"
echo "SJIS SHIFT_JIS"
echo "ARMSCII-8 ARMSCII-8"
echo "PT154 PT154"
#echo "ISCII-DEV ?"
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 "
echo "# and Bruno Haible ."
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
plptools-1.0.13/intl/tsearch.h 0000644 0001750 0001750 00000005361 12417352631 013152 0000000 0000000 /* Binary tree data structure.
Copyright (C) 2006 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.1 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 . */
#ifndef _TSEARCH_H
#define _TSEARCH_H
#if HAVE_TSEARCH
/* Get tseach(), tfind(), tdelete(), twalk() declarations. */
#include
#else
#ifdef __cplusplus
extern "C" {
#endif
/* See ,
for details. */
typedef enum
{
preorder,
postorder,
endorder,
leaf
}
VISIT;
/* Searches an element in the tree *VROOTP that compares equal to KEY.
If one is found, it is returned. Otherwise, a new element equal to KEY
is inserted in the tree and is returned. */
extern void * tsearch (const void *key, void **vrootp,
int (*compar) (const void *, const void *));
/* Searches an element in the tree *VROOTP that compares equal to KEY.
If one is found, it is returned. Otherwise, NULL is returned. */
extern void * tfind (const void *key, void *const *vrootp,
int (*compar) (const void *, const void *));
/* Searches an element in the tree *VROOTP that compares equal to KEY.
If one is found, it is removed from the tree, and its parent node is
returned. Otherwise, NULL is returned. */
extern void * tdelete (const void *key, void **vrootp,
int (*compar) (const void *, const void *));
/* Perform a depth-first, left-to-right traversal of the tree VROOT.
The ACTION function is called:
- for non-leaf nodes: 3 times, before the left subtree traversal,
after the left subtree traversal but before the right subtree traversal,
and after the right subtree traversal,
- for leaf nodes: once.
The arguments passed to ACTION are:
1. the node; it can be casted to a 'const void * const *', i.e. into a
pointer to the key,
2. an indicator which visit of the node this is,
3. the level of the node in the tree (0 for the root). */
extern void twalk (const void *vroot,
void (*action) (const void *, VISIT, int));
#ifdef __cplusplus
}
#endif
#endif
#endif /* _TSEARCH_H */
plptools-1.0.13/intl/log.c 0000644 0001750 0001750 00000007404 12417352631 012275 0000000 0000000 /* Log file output.
Copyright (C) 2003, 2005, 2009 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.1 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 . */
/* Written by Bruno Haible . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
#else
# include "lock.h"
#endif
/* Separator between msgctxt and msgid in .mo files. */
#define MSGCTXT_SEPARATOR '\004' /* EOT */
/* Print an ASCII string with quotes and escape sequences where needed. */
static void
print_escaped (FILE *stream, const char *str, const char *str_end)
{
putc ('"', stream);
for (; str != str_end; str++)
if (*str == '\n')
{
fputs ("\\n\"", stream);
if (str + 1 == str_end)
return;
fputs ("\n\"", stream);
}
else
{
if (*str == '"' || *str == '\\')
putc ('\\', stream);
putc (*str, stream);
}
putc ('"', stream);
}
static char *last_logfilename = NULL;
static FILE *last_logfile = NULL;
__libc_lock_define_initialized (static, lock)
static inline void
_nl_log_untranslated_locked (const char *logfilename, const char *domainname,
const char *msgid1, const char *msgid2, int plural)
{
FILE *logfile;
const char *separator;
/* Can we reuse the last opened logfile? */
if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
{
/* Close the last used logfile. */
if (last_logfilename != NULL)
{
if (last_logfile != NULL)
{
fclose (last_logfile);
last_logfile = NULL;
}
free (last_logfilename);
last_logfilename = NULL;
}
/* Open the logfile. */
last_logfilename = (char *) malloc (strlen (logfilename) + 1);
if (last_logfilename == NULL)
return;
strcpy (last_logfilename, logfilename);
last_logfile = fopen (logfilename, "a");
if (last_logfile == NULL)
return;
}
logfile = last_logfile;
fprintf (logfile, "domain ");
print_escaped (logfile, domainname, domainname + strlen (domainname));
separator = strchr (msgid1, MSGCTXT_SEPARATOR);
if (separator != NULL)
{
/* The part before the MSGCTXT_SEPARATOR is the msgctxt. */
fprintf (logfile, "\nmsgctxt ");
print_escaped (logfile, msgid1, separator);
msgid1 = separator + 1;
}
fprintf (logfile, "\nmsgid ");
print_escaped (logfile, msgid1, msgid1 + strlen (msgid1));
if (plural)
{
fprintf (logfile, "\nmsgid_plural ");
print_escaped (logfile, msgid2, msgid2 + strlen (msgid2));
fprintf (logfile, "\nmsgstr[0] \"\"\n");
}
else
fprintf (logfile, "\nmsgstr \"\"\n");
putc ('\n', logfile);
}
/* Add to the log file an entry denoting a failed translation. */
void
_nl_log_untranslated (const char *logfilename, const char *domainname,
const char *msgid1, const char *msgid2, int plural)
{
__libc_lock_lock (lock);
_nl_log_untranslated_locked (logfilename, domainname, msgid1, msgid2, plural);
__libc_lock_unlock (lock);
}
plptools-1.0.13/intl/vasnprintf.h 0000644 0001750 0001750 00000005354 12417352631 013715 0000000 0000000 /* vsprintf with automatic memory allocation.
Copyright (C) 2002-2004, 2012 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.1 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 . */
#ifndef _VASNPRINTF_H
#define _VASNPRINTF_H
/* Get va_list. */
#include
/* Get size_t. */
#include
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of 'format' and 'printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Write formatted output to a string dynamically allocated with malloc().
You can pass a preallocated buffer for the result in RESULTBUF and its
size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
If successful, return the address of the string (this may be = RESULTBUF
if no dynamic memory allocation was necessary) and set *LENGTHP to the
number of resulting bytes, excluding the trailing NUL. Upon error, set
errno and return NULL.
When dynamic memory allocation occurs, the preallocated buffer is left
alone (with possibly modified contents). This makes it possible to use
a statically allocated or stack-allocated buffer, like this:
char buf[100];
size_t len = sizeof (buf);
char *output = vasnprintf (buf, &len, format, args);
if (output == NULL)
... error handling ...;
else
{
... use the output string ...;
if (output != buf)
free (output);
}
*/
extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 3, 0)));
#ifdef __cplusplus
}
#endif
#endif /* _VASNPRINTF_H */
plptools-1.0.13/intl/threadlib.c 0000644 0001750 0001750 00000003605 12417352631 013451 0000000 0000000 /* Multithreading primitives.
Copyright (C) 2005-2009 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.1 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 . */
/* Written by Bruno Haible , 2005. */
#include
/* ========================================================================= */
#if USE_POSIX_THREADS
/* Use the POSIX threads library. */
# include
# include
# if PTHREAD_IN_USE_DETECTION_HARD
/* The function to be executed by a dummy thread. */
static void *
dummy_thread_func (void *arg)
{
return arg;
}
int
glthread_in_use (void)
{
static int tested;
static int result; /* 1: linked with -lpthread, 0: only with libc */
if (!tested)
{
pthread_t thread;
if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
/* Thread creation failed. */
result = 0;
else
{
/* Thread creation works. */
void *retval;
if (pthread_join (thread, &retval) != 0)
abort ();
result = 1;
}
tested = 1;
}
return result;
}
# endif
#endif
/* ========================================================================= */
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;
plptools-1.0.13/intl/intl-compat.c 0000644 0001750 0001750 00000006561 12417352631 013746 0000000 0000000 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
Library.
Copyright (C) 1995, 2000-2003, 2005 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "gettextP.h"
/* @@ end of prolog @@ */
/* This file redirects the gettext functions (without prefix) to those
defined in the included GNU libintl library (with "libintl_" prefix).
It is compiled into libintl in order to make the AM_GNU_GETTEXT test
of gettext <= 0.11.2 work with the libintl library >= 0.11.3 which
has the redirections primarily in the include file.
It is also compiled into libgnuintl so that libgnuintl.so can be used
as LD_PRELOADable library on glibc systems, to provide the extra
features that the functions in the libc don't have (namely, logging). */
#undef gettext
#undef dgettext
#undef dcgettext
#undef ngettext
#undef dngettext
#undef dcngettext
#undef textdomain
#undef bindtextdomain
#undef bind_textdomain_codeset
/* When building a DLL, we must export some functions. Note that because
the functions are only defined for binary backward compatibility, we
don't need to use __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# define DLL_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
# define DLL_EXPORTED __declspec(dllexport)
#else
# define DLL_EXPORTED
#endif
DLL_EXPORTED
char *
gettext (const char *msgid)
{
return libintl_gettext (msgid);
}
DLL_EXPORTED
char *
dgettext (const char *domainname, const char *msgid)
{
return libintl_dgettext (domainname, msgid);
}
DLL_EXPORTED
char *
dcgettext (const char *domainname, const char *msgid, int category)
{
return libintl_dcgettext (domainname, msgid, category);
}
DLL_EXPORTED
char *
ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
{
return libintl_ngettext (msgid1, msgid2, n);
}
DLL_EXPORTED
char *
dngettext (const char *domainname,
const char *msgid1, const char *msgid2, unsigned long int n)
{
return libintl_dngettext (domainname, msgid1, msgid2, n);
}
DLL_EXPORTED
char *
dcngettext (const char *domainname,
const char *msgid1, const char *msgid2, unsigned long int n,
int category)
{
return libintl_dcngettext (domainname, msgid1, msgid2, n, category);
}
DLL_EXPORTED
char *
textdomain (const char *domainname)
{
return libintl_textdomain (domainname);
}
DLL_EXPORTED
char *
bindtextdomain (const char *domainname, const char *dirname)
{
return libintl_bindtextdomain (domainname, dirname);
}
DLL_EXPORTED
char *
bind_textdomain_codeset (const char *domainname, const char *codeset)
{
return libintl_bind_textdomain_codeset (domainname, codeset);
}
plptools-1.0.13/intl/printf-parse.h 0000644 0001750 0001750 00000005024 12417352631 014127 0000000 0000000 /* Parse printf format string.
Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011 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.1 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 . */
#ifndef _PRINTF_PARSE_H
#define _PRINTF_PARSE_H
#if HAVE_FEATURES_H
# include /* for __GLIBC__, __UCLIBC__ */
#endif
#include "printf-args.h"
/* Flags */
#define FLAG_GROUP 1 /* ' flag */
#define FLAG_LEFT 2 /* - flag */
#define FLAG_SHOWSIGN 4 /* + flag */
#define FLAG_SPACE 8 /* space flag */
#define FLAG_ALT 16 /* # flag */
#define FLAG_ZERO 32
#if __GLIBC__ >= 2 && !defined __UCLIBC__
# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
#endif
/* arg_index value indicating that no argument is consumed. */
#define ARG_NONE (~(size_t)0)
/* Number of directly allocated directives (no malloc() needed). */
#define N_DIRECT_ALLOC_DIRECTIVES 7
/* A parsed directive. */
typedef struct
{
const char* dir_start;
const char* dir_end;
int flags;
const char* width_start;
const char* width_end;
size_t width_arg_index;
const char* precision_start;
const char* precision_end;
size_t precision_arg_index;
char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
size_t arg_index;
}
char_directive;
/* A parsed format string. */
typedef struct
{
size_t count;
char_directive *dir;
size_t max_width_length;
size_t max_precision_length;
char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
}
char_directives;
/* Parses the format string. Fills in the number N of directives, and fills
in directives[0], ..., directives[N-1], and sets directives[N].dir_start
to the end of the format string. Also fills in the arg_type fields of the
arguments and the needed count of arguments. */
#ifdef STATIC
STATIC
#else
extern
#endif
int printf_parse (const char *format, char_directives *d, arguments *a);
#endif /* _PRINTF_PARSE_H */
plptools-1.0.13/intl/libgnuintl.in.h 0000644 0001750 0001750 00000040630 12417352631 014273 0000000 0000000 /* Message catalogs for internationalization.
Copyright (C) 1995-1997, 2000-2012 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.1 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 . */
#ifndef _LIBINTL_H
#define _LIBINTL_H 1
#include
#if (defined __APPLE__ && defined __MACH__) && @HAVE_NEWLOCALE@
# include
#endif
/* The LC_MESSAGES locale category is the category used by the functions
gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
On systems that don't define it, use an arbitrary value instead.
On Solaris, defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
then includes (i.e. this file!) and then only defines
LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
in this case. */
#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
# define LC_MESSAGES 1729
#endif
/* We define an additional symbol to signal that we use the GNU
implementation of gettext. */
#define __USE_GNU_GETTEXT 1
/* Provide information about the supported file formats. Returns the
maximum minor revision number supported for a given major revision. */
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
((major) == 0 || (major) == 1 ? 1 : -1)
/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
precedence over _conio_gettext. */
#ifdef __DJGPP__
# undef gettext
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Version number: (major<<16) + (minor<<8) + subminor */
#define LIBINTL_VERSION 0x001203
extern int libintl_version;
/* We redirect the functions to those prefixed with "libintl_". This is
necessary, because some systems define gettext/textdomain/... in the C
library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
If we used the unprefixed names, there would be cases where the
definition in the C library would override the one in the libintl.so
shared library. Recall that on ELF systems, the symbols are looked
up in the following order:
1. in the executable,
2. in the shared libraries specified on the link command line, in order,
3. in the dependencies of the shared libraries specified on the link
command line,
4. in the dlopen()ed shared libraries, in the order in which they were
dlopen()ed.
The definition in the C library would override the one in libintl.so if
either
* -lc is given on the link command line and -lintl isn't, or
* -lc is given on the link command line before -lintl, or
* libintl.so is a dependency of a dlopen()ed shared library but not
linked to the executable at link time.
Since Solaris gettext() behaves differently than GNU gettext(), this
would be unacceptable.
The redirection happens by default through macros in C, so that &gettext
is independent of the compilation unit, but through inline functions in
C++, in order not to interfere with the name mangling of class fields or
class methods called 'gettext'. */
/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
If he doesn't, we choose the method. A third possible method is
_INTL_REDIRECT_ASM, supported only by GCC. */
#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
# if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
# define _INTL_REDIRECT_ASM
# else
# ifdef __cplusplus
# define _INTL_REDIRECT_INLINE
# else
# define _INTL_REDIRECT_MACROS
# endif
# endif
#endif
/* Auxiliary macros. */
#ifdef _INTL_REDIRECT_ASM
# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
# define _INTL_STRINGIFY(prefix) #prefix
#else
# define _INTL_ASM(cname)
#endif
/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
its n-th argument literally. This enables GCC to warn for example about
printf (gettext ("foo %y")). */
#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus)
# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
#else
# define _INTL_MAY_RETURN_STRING_ARG(n)
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_gettext (const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (1);
static inline char *gettext (const char *__msgid)
{
return libintl_gettext (__msgid);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define gettext libintl_gettext
#endif
extern char *gettext (const char *__msgid)
_INTL_ASM (libintl_gettext)
_INTL_MAY_RETURN_STRING_ARG (1);
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (2);
static inline char *dgettext (const char *__domainname, const char *__msgid)
{
return libintl_dgettext (__domainname, __msgid);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define dgettext libintl_dgettext
#endif
extern char *dgettext (const char *__domainname, const char *__msgid)
_INTL_ASM (libintl_dgettext)
_INTL_MAY_RETURN_STRING_ARG (2);
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
int __category)
_INTL_MAY_RETURN_STRING_ARG (2);
static inline char *dcgettext (const char *__domainname, const char *__msgid,
int __category)
{
return libintl_dcgettext (__domainname, __msgid, __category);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define dcgettext libintl_dcgettext
#endif
extern char *dcgettext (const char *__domainname, const char *__msgid,
int __category)
_INTL_ASM (libintl_dcgettext)
_INTL_MAY_RETURN_STRING_ARG (2);
#endif
/* Similar to 'gettext' but select the plural form corresponding to the
number N. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n)
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
static inline char *ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n)
{
return libintl_ngettext (__msgid1, __msgid2, __n);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define ngettext libintl_ngettext
#endif
extern char *ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n)
_INTL_ASM (libintl_ngettext)
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
#endif
/* Similar to 'dgettext' but select the plural form corresponding to the
number N. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
const char *__msgid2, unsigned long int __n)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
static inline char *dngettext (const char *__domainname, const char *__msgid1,
const char *__msgid2, unsigned long int __n)
{
return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define dngettext libintl_dngettext
#endif
extern char *dngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n)
_INTL_ASM (libintl_dngettext)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
#endif
/* Similar to 'dcgettext' but select the plural form corresponding to the
number N. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
static inline char *dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category)
{
return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define dcngettext libintl_dcngettext
#endif
extern char *dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category)
_INTL_ASM (libintl_dcngettext)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
#endif
#ifndef IN_LIBGLOCALE
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_textdomain (const char *__domainname);
static inline char *textdomain (const char *__domainname)
{
return libintl_textdomain (__domainname);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define textdomain libintl_textdomain
#endif
extern char *textdomain (const char *__domainname)
_INTL_ASM (libintl_textdomain);
#endif
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_bindtextdomain (const char *__domainname,
const char *__dirname);
static inline char *bindtextdomain (const char *__domainname,
const char *__dirname)
{
return libintl_bindtextdomain (__domainname, __dirname);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define bindtextdomain libintl_bindtextdomain
#endif
extern char *bindtextdomain (const char *__domainname, const char *__dirname)
_INTL_ASM (libintl_bindtextdomain);
#endif
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_bind_textdomain_codeset (const char *__domainname,
const char *__codeset);
static inline char *bind_textdomain_codeset (const char *__domainname,
const char *__codeset)
{
return libintl_bind_textdomain_codeset (__domainname, __codeset);
}
#else
#ifdef _INTL_REDIRECT_MACROS
# define bind_textdomain_codeset libintl_bind_textdomain_codeset
#endif
extern char *bind_textdomain_codeset (const char *__domainname,
const char *__codeset)
_INTL_ASM (libintl_bind_textdomain_codeset);
#endif
#endif /* IN_LIBGLOCALE */
/* Support for format strings with positions in *printf(), following the
POSIX/XSI specification.
Note: These replacements for the *printf() functions are visible only
in source files that #include or #include "gettext.h".
Packages that use *printf() in source files that don't refer to _()
or gettext() but for which the format string could be the return value
of _() or gettext() need to add this #include. Oh well. */
#if !@HAVE_POSIX_PRINTF@
#include
#include
/* Get va_list. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER
# include
#else
# include
#endif
#if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef fprintf
#define fprintf libintl_fprintf
extern int fprintf (FILE *, const char *, ...);
#endif
#if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef vfprintf
#define vfprintf libintl_vfprintf
extern int vfprintf (FILE *, const char *, va_list);
#endif
#if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */
#undef printf
#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
/* Don't break __attribute__((format(printf,M,N))).
This redefinition is only possible because the libc in NetBSD, Cygwin,
mingw does not have a function __printf__.
Alternatively, we could have done this redirection only when compiling with
__GNUC__, together with a symbol redirection:
extern int printf (const char *, ...)
__asm__ (#__USER_LABEL_PREFIX__ "libintl_printf");
But doing it now would introduce a binary incompatibility with already
distributed versions of libintl on these systems. */
# define libintl_printf __printf__
#endif
#define printf libintl_printf
extern int printf (const char *, ...);
#endif
#if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef vprintf
#define vprintf libintl_vprintf
extern int vprintf (const char *, va_list);
#endif
#if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef sprintf
#define sprintf libintl_sprintf
extern int sprintf (char *, const char *, ...);
#endif
#if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef vsprintf
#define vsprintf libintl_vsprintf
extern int vsprintf (char *, const char *, va_list);
#endif
#if @HAVE_SNPRINTF@
#if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef snprintf
#define snprintf libintl_snprintf
extern int snprintf (char *, size_t, const char *, ...);
#endif
#if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef vsnprintf
#define vsnprintf libintl_vsnprintf
extern int vsnprintf (char *, size_t, const char *, va_list);
#endif
#endif
#if @HAVE_ASPRINTF@
#if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef asprintf
#define asprintf libintl_asprintf
extern int asprintf (char **, const char *, ...);
#endif
#if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */
#undef vasprintf
#define vasprintf libintl_vasprintf
extern int vasprintf (char **, const char *, va_list);
#endif
#endif
#if @HAVE_WPRINTF@
#undef fwprintf
#define fwprintf libintl_fwprintf
extern int fwprintf (FILE *, const wchar_t *, ...);
#undef vfwprintf
#define vfwprintf libintl_vfwprintf
extern int vfwprintf (FILE *, const wchar_t *, va_list);
#undef wprintf
#define wprintf libintl_wprintf
extern int wprintf (const wchar_t *, ...);
#undef vwprintf
#define vwprintf libintl_vwprintf
extern int vwprintf (const wchar_t *, va_list);
#undef swprintf
#define swprintf libintl_swprintf
extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
#undef vswprintf
#define vswprintf libintl_vswprintf
extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
#endif
#endif
/* Support for the locale chosen by the user. */
#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
#ifndef GNULIB_defined_setlocale /* don't override gnulib */
#undef setlocale
#define setlocale libintl_setlocale
extern char *setlocale (int, const char *);
#endif
#if @HAVE_NEWLOCALE@
#undef newlocale
#define newlocale libintl_newlocale
extern locale_t newlocale (int, const char *, locale_t);
#endif
#endif
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
#define libintl_set_relocation_prefix libintl_set_relocation_prefix
extern void
libintl_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif /* libintl.h */
plptools-1.0.13/intl/hash-string.h 0000644 0001750 0001750 00000002471 12417352631 013747 0000000 0000000 /* Description of GNU message catalog format: string hashing function.
Copyright (C) 1995, 1997-1998, 2000-2003, 2005 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.1 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 . */
/* @@ end of prolog @@ */
/* We assume to have `unsigned long int' value with at least 32 bits. */
#define HASHWORDBITS 32
#ifndef _LIBC
# ifdef IN_LIBINTL
# define __hash_string libintl_hash_string
# else
# define __hash_string hash_string
# endif
#endif
/* Defines the so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
extern unsigned long int __hash_string (const char *str_param);
plptools-1.0.13/intl/lock.c 0000644 0001750 0001750 00000064226 12417352631 012451 0000000 0000000 /* Locking in multithreaded situations.
Copyright (C) 2005-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.1 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 . */
/* Written by Bruno Haible , 2005.
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
gthr-win32.h. */
#include
#include "lock.h"
/* ========================================================================= */
#if USE_POSIX_THREADS
/* -------------------------- gl_lock_t datatype -------------------------- */
/* ------------------------- gl_rwlock_t datatype ------------------------- */
# if HAVE_PTHREAD_RWLOCK
# if !defined PTHREAD_RWLOCK_INITIALIZER
int
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_rwlock_init (&lock->rwlock, NULL);
if (err != 0)
return err;
lock->initialized = 1;
return 0;
}
int
glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
{
if (!lock->initialized)
{
int err;
err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
{
err = glthread_rwlock_init_multithreaded (lock);
if (err != 0)
{
pthread_mutex_unlock (&lock->guard);
return err;
}
}
err = pthread_mutex_unlock (&lock->guard);
if (err != 0)
return err;
}
return pthread_rwlock_rdlock (&lock->rwlock);
}
int
glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
{
if (!lock->initialized)
{
int err;
err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
{
err = glthread_rwlock_init_multithreaded (lock);
if (err != 0)
{
pthread_mutex_unlock (&lock->guard);
return err;
}
}
err = pthread_mutex_unlock (&lock->guard);
if (err != 0)
return err;
}
return pthread_rwlock_wrlock (&lock->rwlock);
}
int
glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
{
if (!lock->initialized)
return EINVAL;
return pthread_rwlock_unlock (&lock->rwlock);
}
int
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
{
int err;
if (!lock->initialized)
return EINVAL;
err = pthread_rwlock_destroy (&lock->rwlock);
if (err != 0)
return err;
lock->initialized = 0;
return 0;
}
# endif
# else
int
glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_mutex_init (&lock->lock, NULL);
if (err != 0)
return err;
err = pthread_cond_init (&lock->waiting_readers, NULL);
if (err != 0)
return err;
err = pthread_cond_init (&lock->waiting_writers, NULL);
if (err != 0)
return err;
lock->waiting_writers_count = 0;
lock->runcount = 0;
return 0;
}
int
glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
/* Test whether only readers are currently running, and whether the runcount
field will not overflow. */
/* POSIX says: "It is implementation-defined whether the calling thread
acquires the lock when a writer does not hold the lock and there are
writers blocked on the lock." Let's say, no: give the writers a higher
priority. */
while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
{
/* This thread has to wait for a while. Enqueue it among the
waiting_readers. */
err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
if (err != 0)
{
pthread_mutex_unlock (&lock->lock);
return err;
}
}
lock->runcount++;
return pthread_mutex_unlock (&lock->lock);
}
int
glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
/* Test whether no readers or writers are currently running. */
while (!(lock->runcount == 0))
{
/* This thread has to wait for a while. Enqueue it among the
waiting_writers. */
lock->waiting_writers_count++;
err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
if (err != 0)
{
lock->waiting_writers_count--;
pthread_mutex_unlock (&lock->lock);
return err;
}
lock->waiting_writers_count--;
}
lock->runcount--; /* runcount becomes -1 */
return pthread_mutex_unlock (&lock->lock);
}
int
glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_mutex_lock (&lock->lock);
if (err != 0)
return err;
if (lock->runcount < 0)
{
/* Drop a writer lock. */
if (!(lock->runcount == -1))
{
pthread_mutex_unlock (&lock->lock);
return EINVAL;
}
lock->runcount = 0;
}
else
{
/* Drop a reader lock. */
if (!(lock->runcount > 0))
{
pthread_mutex_unlock (&lock->lock);
return EINVAL;
}
lock->runcount--;
}
if (lock->runcount == 0)
{
/* POSIX recommends that "write locks shall take precedence over read
locks", to avoid "writer starvation". */
if (lock->waiting_writers_count > 0)
{
/* Wake up one of the waiting writers. */
err = pthread_cond_signal (&lock->waiting_writers);
if (err != 0)
{
pthread_mutex_unlock (&lock->lock);
return err;
}
}
else
{
/* Wake up all waiting readers. */
err = pthread_cond_broadcast (&lock->waiting_readers);
if (err != 0)
{
pthread_mutex_unlock (&lock->lock);
return err;
}
}
}
return pthread_mutex_unlock (&lock->lock);
}
int
glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
{
int err;
err = pthread_mutex_destroy (&lock->lock);
if (err != 0)
return err;
err = pthread_cond_destroy (&lock->waiting_readers);
if (err != 0)
return err;
err = pthread_cond_destroy (&lock->waiting_writers);
if (err != 0)
return err;
return 0;
}
# endif
/* --------------------- gl_recursive_lock_t datatype --------------------- */
# if HAVE_PTHREAD_MUTEX_RECURSIVE
# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
pthread_mutexattr_t attributes;
int err;
err = pthread_mutexattr_init (&attributes);
if (err != 0)
return err;
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
if (err != 0)
{
pthread_mutexattr_destroy (&attributes);
return err;
}
err = pthread_mutex_init (lock, &attributes);
if (err != 0)
{
pthread_mutexattr_destroy (&attributes);
return err;
}
err = pthread_mutexattr_destroy (&attributes);
if (err != 0)
return err;
return 0;
}
# else
int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
pthread_mutexattr_t attributes;
int err;
err = pthread_mutexattr_init (&attributes);
if (err != 0)
return err;
err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
if (err != 0)
{
pthread_mutexattr_destroy (&attributes);
return err;
}
err = pthread_mutex_init (&lock->recmutex, &attributes);
if (err != 0)
{
pthread_mutexattr_destroy (&attributes);
return err;
}
err = pthread_mutexattr_destroy (&attributes);
if (err != 0)
return err;
lock->initialized = 1;
return 0;
}
int
glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
{
if (!lock->initialized)
{
int err;
err = pthread_mutex_lock (&lock->guard);
if (err != 0)
return err;
if (!lock->initialized)
{
err = glthread_recursive_lock_init_multithreaded (lock);
if (err != 0)
{
pthread_mutex_unlock (&lock->guard);
return err;
}
}
err = pthread_mutex_unlock (&lock->guard);
if (err != 0)
return err;
}
return pthread_mutex_lock (&lock->recmutex);
}
int
glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
{
if (!lock->initialized)
return EINVAL;
return pthread_mutex_unlock (&lock->recmutex);
}
int
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
{
int err;
if (!lock->initialized)
return EINVAL;
err = pthread_mutex_destroy (&lock->recmutex);
if (err != 0)
return err;
lock->initialized = 0;
return 0;
}
# endif
# else
int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
int err;
err = pthread_mutex_init (&lock->mutex, NULL);
if (err != 0)
return err;
lock->owner = (pthread_t) 0;
lock->depth = 0;
return 0;
}
int
glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
{
pthread_t self = pthread_self ();
if (lock->owner != self)
{
int err;
err = pthread_mutex_lock (&lock->mutex);
if (err != 0)
return err;
lock->owner = self;
}
if (++(lock->depth) == 0) /* wraparound? */
{
lock->depth--;
return EAGAIN;
}
return 0;
}
int
glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
{
if (lock->owner != pthread_self ())
return EPERM;
if (lock->depth == 0)
return EINVAL;
if (--(lock->depth) == 0)
{
lock->owner = (pthread_t) 0;
return pthread_mutex_unlock (&lock->mutex);
}
else
return 0;
}
int
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
{
if (lock->owner != (pthread_t) 0)
return EBUSY;
return pthread_mutex_destroy (&lock->mutex);
}
# endif
/* -------------------------- gl_once_t datatype -------------------------- */
static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
int
glthread_once_singlethreaded (pthread_once_t *once_control)
{
/* We don't know whether pthread_once_t is an integer type, a floating-point
type, a pointer type, or a structure type. */
char *firstbyte = (char *)once_control;
if (*firstbyte == *(const char *)&fresh_once)
{
/* First time use of once_control. Invert the first byte. */
*firstbyte = ~ *(const char *)&fresh_once;
return 1;
}
else
return 0;
}
#endif
/* ========================================================================= */
#if USE_PTH_THREADS
/* Use the GNU Pth threads library. */
/* -------------------------- gl_lock_t datatype -------------------------- */
/* ------------------------- gl_rwlock_t datatype ------------------------- */
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* -------------------------- gl_once_t datatype -------------------------- */
static void
glthread_once_call (void *arg)
{
void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
void (*initfunction) (void) = *gl_once_temp_addr;
initfunction ();
}
int
glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
{
void (*temp) (void) = initfunction;
return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
}
int
glthread_once_singlethreaded (pth_once_t *once_control)
{
/* We know that pth_once_t is an integer type. */
if (*once_control == PTH_ONCE_INIT)
{
/* First time use of once_control. Invert the marker. */
*once_control = ~ PTH_ONCE_INIT;
return 1;
}
else
return 0;
}
#endif
/* ========================================================================= */
#if USE_SOLARIS_THREADS
/* Use the old Solaris threads library. */
/* -------------------------- gl_lock_t datatype -------------------------- */
/* ------------------------- gl_rwlock_t datatype ------------------------- */
/* --------------------- gl_recursive_lock_t datatype --------------------- */
int
glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
{
int err;
err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
if (err != 0)
return err;
lock->owner = (thread_t) 0;
lock->depth = 0;
return 0;
}
int
glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
{
thread_t self = thr_self ();
if (lock->owner != self)
{
int err;
err = mutex_lock (&lock->mutex);
if (err != 0)
return err;
lock->owner = self;
}
if (++(lock->depth) == 0) /* wraparound? */
{
lock->depth--;
return EAGAIN;
}
return 0;
}
int
glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
{
if (lock->owner != thr_self ())
return EPERM;
if (lock->depth == 0)
return EINVAL;
if (--(lock->depth) == 0)
{
lock->owner = (thread_t) 0;
return mutex_unlock (&lock->mutex);
}
else
return 0;
}
int
glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
{
if (lock->owner != (thread_t) 0)
return EBUSY;
return mutex_destroy (&lock->mutex);
}
/* -------------------------- gl_once_t datatype -------------------------- */
int
glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
{
if (!once_control->inited)
{
int err;
/* Use the mutex to guarantee that if another thread is already calling
the initfunction, this thread waits until it's finished. */
err = mutex_lock (&once_control->mutex);
if (err != 0)
return err;
if (!once_control->inited)
{
once_control->inited = 1;
initfunction ();
}
return mutex_unlock (&once_control->mutex);
}
else
return 0;
}
int
glthread_once_singlethreaded (gl_once_t *once_control)
{
/* We know that gl_once_t contains an integer type. */
if (!once_control->inited)
{
/* First time use of once_control. Invert the marker. */
once_control->inited = ~ 0;
return 1;
}
else
return 0;
}
#endif
/* ========================================================================= */
#if USE_WINDOWS_THREADS
/* -------------------------- gl_lock_t datatype -------------------------- */
void
glthread_lock_init_func (gl_lock_t *lock)
{
InitializeCriticalSection (&lock->lock);
lock->guard.done = 1;
}
int
glthread_lock_lock_func (gl_lock_t *lock)
{
if (!lock->guard.done)
{
if (InterlockedIncrement (&lock->guard.started) == 0)
/* This thread is the first one to need this lock. Initialize it. */
glthread_lock_init (lock);
else
/* Yield the CPU while waiting for another thread to finish
initializing this lock. */
while (!lock->guard.done)
Sleep (0);
}
EnterCriticalSection (&lock->lock);
return 0;
}
int
glthread_lock_unlock_func (gl_lock_t *lock)
{
if (!lock->guard.done)
return EINVAL;
LeaveCriticalSection (&lock->lock);
return 0;
}
int
glthread_lock_destroy_func (gl_lock_t *lock)
{
if (!lock->guard.done)
return EINVAL;
DeleteCriticalSection (&lock->lock);
lock->guard.done = 0;
return 0;
}
/* ------------------------- gl_rwlock_t datatype ------------------------- */
/* In this file, the waitqueues are implemented as circular arrays. */
#define gl_waitqueue_t gl_carray_waitqueue_t
static void
gl_waitqueue_init (gl_waitqueue_t *wq)
{
wq->array = NULL;
wq->count = 0;
wq->alloc = 0;
wq->offset = 0;
}
/* Enqueues the current thread, represented by an event, in a wait queue.
Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
static HANDLE
gl_waitqueue_add (gl_waitqueue_t *wq)
{
HANDLE event;
unsigned int index;
if (wq->count == wq->alloc)
{
unsigned int new_alloc = 2 * wq->alloc + 1;
HANDLE *new_array =
(HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
if (new_array == NULL)
/* No more memory. */
return INVALID_HANDLE_VALUE;
/* Now is a good opportunity to rotate the array so that its contents
starts at offset 0. */
if (wq->offset > 0)
{
unsigned int old_count = wq->count;
unsigned int old_alloc = wq->alloc;
unsigned int old_offset = wq->offset;
unsigned int i;
if (old_offset + old_count > old_alloc)
{
unsigned int limit = old_offset + old_count - old_alloc;
for (i = 0; i < limit; i++)
new_array[old_alloc + i] = new_array[i];
}
for (i = 0; i < old_count; i++)
new_array[i] = new_array[old_offset + i];
wq->offset = 0;
}
wq->array = new_array;
wq->alloc = new_alloc;
}
/* Whether the created event is a manual-reset one or an auto-reset one,
does not matter, since we will wait on it only once. */
event = CreateEvent (NULL, TRUE, FALSE, NULL);
if (event == INVALID_HANDLE_VALUE)
/* No way to allocate an event. */
return INVALID_HANDLE_VALUE;
index = wq->offset + wq->count;
if (index >= wq->alloc)
index -= wq->alloc;
wq->array[index] = event;
wq->count++;
return event;
}
/* Notifies the first thread from a wait queue and dequeues it. */
static void
gl_waitqueue_notify_first (gl_waitqueue_t *wq)
{
SetEvent (wq->array[wq->offset + 0]);
wq->offset++;
wq->count--;
if (wq->count == 0 || wq->offset == wq->alloc)
wq->offset = 0;
}
/* Notifies all threads from a wait queue and dequeues them all. */
static void
gl_waitqueue_notify_all (gl_waitqueue_t *wq)
{
unsigned int i;
for (i = 0; i < wq->count; i++)
{
unsigned int index = wq->offset + i;
if (index >= wq->alloc)
index -= wq->alloc;
SetEvent (wq->array[index]);
}
wq->count = 0;
wq->offset = 0;
}
void
glthread_rwlock_init_func (gl_rwlock_t *lock)
{
InitializeCriticalSection (&lock->lock);
gl_waitqueue_init (&lock->waiting_readers);
gl_waitqueue_init (&lock->waiting_writers);
lock->runcount = 0;
lock->guard.done = 1;
}
int
glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
{
if (!lock->guard.done)
{
if (InterlockedIncrement (&lock->guard.started) == 0)
/* This thread is the first one to need this lock. Initialize it. */
glthread_rwlock_init (lock);
else
/* Yield the CPU while waiting for another thread to finish
initializing this lock. */
while (!lock->guard.done)
Sleep (0);
}
EnterCriticalSection (&lock->lock);
/* Test whether only readers are currently running, and whether the runcount
field will not overflow. */
if (!(lock->runcount + 1 > 0))
{
/* This thread has to wait for a while. Enqueue it among the
waiting_readers. */
HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
if (event != INVALID_HANDLE_VALUE)
{
DWORD result;
LeaveCriticalSection (&lock->lock);
/* Wait until another thread signals this event. */
result = WaitForSingleObject (event, INFINITE);
if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
abort ();
CloseHandle (event);
/* The thread which signalled the event already did the bookkeeping:
removed us from the waiting_readers, incremented lock->runcount. */
if (!(lock->runcount > 0))
abort ();
return 0;
}
else
{
/* Allocation failure. Weird. */
do
{
LeaveCriticalSection (&lock->lock);
Sleep (1);
EnterCriticalSection (&lock->lock);
}
while (!(lock->runcount + 1 > 0));
}
}
lock->runcount++;
LeaveCriticalSection (&lock->lock);
return 0;
}
int
glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
{
if (!lock->guard.done)
{
if (InterlockedIncrement (&lock->guard.started) == 0)
/* This thread is the first one to need this lock. Initialize it. */
glthread_rwlock_init (lock);
else
/* Yield the CPU while waiting for another thread to finish
initializing this lock. */
while (!lock->guard.done)
Sleep (0);
}
EnterCriticalSection (&lock->lock);
/* Test whether no readers or writers are currently running. */
if (!(lock->runcount == 0))
{
/* This thread has to wait for a while. Enqueue it among the
waiting_writers. */
HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
if (event != INVALID_HANDLE_VALUE)
{
DWORD result;
LeaveCriticalSection (&lock->lock);
/* Wait until another thread signals this event. */
result = WaitForSingleObject (event, INFINITE);
if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
abort ();
CloseHandle (event);
/* The thread which signalled the event already did the bookkeeping:
removed us from the waiting_writers, set lock->runcount = -1. */
if (!(lock->runcount == -1))
abort ();
return 0;
}
else
{
/* Allocation failure. Weird. */
do
{
LeaveCriticalSection (&lock->lock);
Sleep (1);
EnterCriticalSection (&lock->lock);
}
while (!(lock->runcount == 0));
}
}
lock->runcount--; /* runcount becomes -1 */
LeaveCriticalSection (&lock->lock);
return 0;
}
int
glthread_rwlock_unlock_func (gl_rwlock_t *lock)
{
if (!lock->guard.done)
return EINVAL;
EnterCriticalSection (&lock->lock);
if (lock->runcount < 0)
{
/* Drop a writer lock. */
if (!(lock->runcount == -1))
abort ();
lock->runcount = 0;
}
else
{
/* Drop a reader lock. */
if (!(lock->runcount > 0))
{
LeaveCriticalSection (&lock->lock);
return EPERM;
}
lock->runcount--;
}
if (lock->runcount == 0)
{
/* POSIX recommends that "write locks shall take precedence over read
locks", to avoid "writer starvation". */
if (lock->waiting_writers.count > 0)
{
/* Wake up one of the waiting writers. */
lock->runcount--;
gl_waitqueue_notify_first (&lock->waiting_writers);
}
else
{
/* Wake up all waiting readers. */
lock->runcount += lock->waiting_readers.count;
gl_waitqueue_notify_all (&lock->waiting_readers);
}
}
LeaveCriticalSection (&lock->lock);
return 0;
}
int
glthread_rwlock_destroy_func (gl_rwlock_t *lock)
{
if (!lock->guard.done)
return EINVAL;
if (lock->runcount != 0)
return EBUSY;
DeleteCriticalSection (&lock->lock);
if (lock->waiting_readers.array != NULL)
free (lock->waiting_readers.array);
if (lock->waiting_writers.array != NULL)
free (lock->waiting_writers.array);
lock->guard.done = 0;
return 0;
}
/* --------------------- gl_recursive_lock_t datatype --------------------- */
void
glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
{
lock->owner = 0;
lock->depth = 0;
InitializeCriticalSection (&lock->lock);
lock->guard.done = 1;
}
int
glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
{
if (!lock->guard.done)
{
if (InterlockedIncrement (&lock->guard.started) == 0)
/* This thread is the first one to need this lock. Initialize it. */
glthread_recursive_lock_init (lock);
else
/* Yield the CPU while waiting for another thread to finish
initializing this lock. */
while (!lock->guard.done)
Sleep (0);
}
{
DWORD self = GetCurrentThreadId ();
if (lock->owner != self)
{
EnterCriticalSection (&lock->lock);
lock->owner = self;
}
if (++(lock->depth) == 0) /* wraparound? */
{
lock->depth--;
return EAGAIN;
}
}
return 0;
}
int
glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
{
if (lock->owner != GetCurrentThreadId ())
return EPERM;
if (lock->depth == 0)
return EINVAL;
if (--(lock->depth) == 0)
{
lock->owner = 0;
LeaveCriticalSection (&lock->lock);
}
return 0;
}
int
glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
{
if (lock->owner != 0)
return EBUSY;
DeleteCriticalSection (&lock->lock);
lock->guard.done = 0;
return 0;
}
/* -------------------------- gl_once_t datatype -------------------------- */
void
glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
{
if (once_control->inited <= 0)
{
if (InterlockedIncrement (&once_control->started) == 0)
{
/* This thread is the first one to come to this once_control. */
InitializeCriticalSection (&once_control->lock);
EnterCriticalSection (&once_control->lock);
once_control->inited = 0;
initfunction ();
once_control->inited = 1;
LeaveCriticalSection (&once_control->lock);
}
else
{
/* Undo last operation. */
InterlockedDecrement (&once_control->started);
/* Some other thread has already started the initialization.
Yield the CPU while waiting for the other thread to finish
initializing and taking the lock. */
while (once_control->inited < 0)
Sleep (0);
if (once_control->inited <= 0)
{
/* Take the lock. This blocks until the other thread has
finished calling the initfunction. */
EnterCriticalSection (&once_control->lock);
LeaveCriticalSection (&once_control->lock);
if (!(once_control->inited > 0))
abort ();
}
}
}
}
#endif
/* ========================================================================= */
plptools-1.0.13/intl/VERSION 0000644 0001750 0001750 00000000050 12417352630 012405 0000000 0000000 GNU gettext library from gettext-0.18.3
plptools-1.0.13/intl/l10nflist.c 0000644 0001750 0001750 00000025500 12417352631 013325 0000000 0000000 /* Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc.
Contributed by Ulrich Drepper , 1995.
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.1 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 . */
/* Tell glibc's to provide a prototype for stpcpy().
This must come before because may include
, and once has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#if defined _LIBC || defined HAVE_ARGZ_H
# include
#endif
#include
#include
#include
#include "loadinfo.h"
/* On some strange systems still no definition of NULL is found. Sigh! */
#ifndef NULL
# if defined __STDC__ && __STDC__
# define NULL ((void *) 0)
# else
# define NULL 0
# endif
#endif
/* @@ end of prolog @@ */
#ifdef _LIBC
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
# ifndef stpcpy
# define stpcpy(dest, src) __stpcpy(dest, src)
# endif
#else
# ifndef HAVE_STPCPY
static char *stpcpy (char *dest, const char *src);
# endif
#endif
/* Pathname support.
ISSLASH(C) tests whether C is a directory separator character.
IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
it may be concatenated to a directory pathname.
*/
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Win32, Cygwin, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define HAS_DEVICE(P) \
((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
&& (P)[1] == ':')
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
#else
/* Unix */
# define ISSLASH(C) ((C) == '/')
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
#endif
/* Define function which are usually not available. */
#ifdef _LIBC
# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
#elif defined HAVE_ARGZ_COUNT
# undef __argz_count
# define __argz_count argz_count
#else
/* Returns the number of strings in ARGZ. */
static size_t
argz_count__ (const char *argz, size_t len)
{
size_t count = 0;
while (len > 0)
{
size_t part_len = strlen (argz);
argz += part_len + 1;
len -= part_len + 1;
count++;
}
return count;
}
# undef __argz_count
# define __argz_count(argz, len) argz_count__ (argz, len)
#endif /* !_LIBC && !HAVE_ARGZ_COUNT */
#ifdef _LIBC
# define __argz_stringify(argz, len, sep) \
INTUSE(__argz_stringify) (argz, len, sep)
#elif defined HAVE_ARGZ_STRINGIFY
# undef __argz_stringify
# define __argz_stringify argz_stringify
#else
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
except the last into the character SEP. */
static void
argz_stringify__ (char *argz, size_t len, int sep)
{
while (len > 0)
{
size_t part_len = strlen (argz);
argz += part_len;
len -= part_len + 1;
if (len > 0)
*argz++ = sep;
}
}
# undef __argz_stringify
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */
#ifdef _LIBC
#elif defined HAVE_ARGZ_NEXT
# undef __argz_next
# define __argz_next argz_next
#else
static char *
argz_next__ (char *argz, size_t argz_len, const char *entry)
{
if (entry)
{
if (entry < argz + argz_len)
entry = strchr (entry, '\0') + 1;
return entry >= argz + argz_len ? NULL : (char *) entry;
}
else
if (argz_len > 0)
return argz;
else
return 0;
}
# undef __argz_next
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
#endif /* !_LIBC && !HAVE_ARGZ_NEXT */
/* Return number of bits set in X. */
static inline int
pop (int x)
{
/* We assume that no more than 16 bits are used. */
x = ((x & ~0x5555) >> 1) + (x & 0x5555);
x = ((x & ~0x3333) >> 2) + (x & 0x3333);
x = ((x >> 4) + x) & 0x0f0f;
x = ((x >> 8) + x) & 0xff;
return x;
}
struct loaded_l10nfile *
_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
const char *dirlist, size_t dirlist_len,
int mask, const char *language, const char *territory,
const char *codeset, const char *normalized_codeset,
const char *modifier,
const char *filename, int do_allocate)
{
char *abs_filename;
struct loaded_l10nfile **lastp;
struct loaded_l10nfile *retval;
char *cp;
size_t dirlist_count;
size_t entries;
int cnt;
/* If LANGUAGE contains an absolute directory specification, we ignore
DIRLIST. */
if (IS_ABSOLUTE_PATH (language))
dirlist_len = 0;
/* Allocate room for the full file name. */
abs_filename = (char *) malloc (dirlist_len
+ strlen (language)
+ ((mask & XPG_TERRITORY) != 0
? strlen (territory) + 1 : 0)
+ ((mask & XPG_CODESET) != 0
? strlen (codeset) + 1 : 0)
+ ((mask & XPG_NORM_CODESET) != 0
? strlen (normalized_codeset) + 1 : 0)
+ ((mask & XPG_MODIFIER) != 0
? strlen (modifier) + 1 : 0)
+ 1 + strlen (filename) + 1);
if (abs_filename == NULL)
return NULL;
/* Construct file name. */
cp = abs_filename;
if (dirlist_len > 0)
{
memcpy (cp, dirlist, dirlist_len);
__argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
cp += dirlist_len;
cp[-1] = '/';
}
cp = stpcpy (cp, language);
if ((mask & XPG_TERRITORY) != 0)
{
*cp++ = '_';
cp = stpcpy (cp, territory);
}
if ((mask & XPG_CODESET) != 0)
{
*cp++ = '.';
cp = stpcpy (cp, codeset);
}
if ((mask & XPG_NORM_CODESET) != 0)
{
*cp++ = '.';
cp = stpcpy (cp, normalized_codeset);
}
if ((mask & XPG_MODIFIER) != 0)
{
*cp++ = '@';
cp = stpcpy (cp, modifier);
}
*cp++ = '/';
stpcpy (cp, filename);
/* Look in list of already loaded domains whether it is already
available. */
lastp = l10nfile_list;
for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
if (retval->filename != NULL)
{
int compare = strcmp (retval->filename, abs_filename);
if (compare == 0)
/* We found it! */
break;
if (compare < 0)
{
/* It's not in the list. */
retval = NULL;
break;
}
lastp = &retval->next;
}
if (retval != NULL || do_allocate == 0)
{
free (abs_filename);
return retval;
}
dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
/* Allocate a new loaded_l10nfile. */
retval =
(struct loaded_l10nfile *)
malloc (sizeof (*retval)
+ (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
* sizeof (struct loaded_l10nfile *)));
if (retval == NULL)
{
free (abs_filename);
return NULL;
}
retval->filename = abs_filename;
/* We set retval->data to NULL here; it is filled in later.
Setting retval->decided to 1 here means that retval does not
correspond to a real file (dirlist_count > 1) or is not worth
looking up (if an unnormalized codeset was specified). */
retval->decided = (dirlist_count > 1
|| ((mask & XPG_CODESET) != 0
&& (mask & XPG_NORM_CODESET) != 0));
retval->data = NULL;
retval->next = *lastp;
*lastp = retval;
entries = 0;
/* Recurse to fill the inheritance list of RETVAL.
If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
entry does not correspond to a real file; retval->filename contains
colons. In this case we loop across all elements of DIRLIST and
across all bit patterns dominated by MASK.
If the DIRLIST is a single directory or entirely redundant (i.e.
DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
MASK, excluding MASK itself.
In either case, we loop down from MASK to 0. This has the effect
that the extra bits in the locale name are dropped in this order:
first the modifier, then the territory, then the codeset, then the
normalized_codeset. */
for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
if ((cnt & ~mask) == 0
&& !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0))
{
if (dirlist_count > 1)
{
/* Iterate over all elements of the DIRLIST. */
char *dir = NULL;
while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
!= NULL)
retval->successor[entries++]
= _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
cnt, language, territory, codeset,
normalized_codeset, modifier, filename,
1);
}
else
retval->successor[entries++]
= _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
cnt, language, territory, codeset,
normalized_codeset, modifier, filename, 1);
}
retval->successor[entries] = NULL;
return retval;
}
/* Normalize codeset name. There is no standard for the codeset
names. Normalization allows the user to use any of the common
names. The return value is dynamically allocated and has to be
freed by the caller. */
const char *
_nl_normalize_codeset (const char *codeset, size_t name_len)
{
size_t len = 0;
int only_digit = 1;
char *retval;
char *wp;
size_t cnt;
for (cnt = 0; cnt < name_len; ++cnt)
if (isalnum ((unsigned char) codeset[cnt]))
{
++len;
if (isalpha ((unsigned char) codeset[cnt]))
only_digit = 0;
}
retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
if (retval != NULL)
{
if (only_digit)
wp = stpcpy (retval, "iso");
else
wp = retval;
for (cnt = 0; cnt < name_len; ++cnt)
if (isalpha ((unsigned char) codeset[cnt]))
*wp++ = tolower ((unsigned char) codeset[cnt]);
else if (isdigit ((unsigned char) codeset[cnt]))
*wp++ = codeset[cnt];
*wp = '\0';
}
return (const char *) retval;
}
/* @@ begin of epilog @@ */
/* We don't want libintl.a to depend on any other library. So we
avoid the non-standard function stpcpy. In GNU C Library this
function is available, though. Also allow the symbol HAVE_STPCPY
to be defined. */
#if !_LIBC && !HAVE_STPCPY
static char *
stpcpy (char *dest, const char *src)
{
while ((*dest++ = *src++) != '\0')
/* Do nothing. */ ;
return dest - 1;
}
#endif
plptools-1.0.13/intl/intl-exports.c 0000644 0001750 0001750 00000003343 12417352631 014162 0000000 0000000 /* List of exported symbols of libintl on Cygwin.
Copyright (C) 2006 Free Software Foundation, Inc.
Written by Bruno Haible , 2006.
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.1 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 . */
/* IMP(x) is a symbol that contains the address of x. */
#if USER_LABEL_PREFIX_UNDERSCORE
# define IMP(x) _imp__##x
#else
# define IMP(x) __imp_##x
#endif
/* Ensure that the variable x is exported from the library, and that a
pseudo-variable IMP(x) is available. */
#define VARIABLE(x) \
/* Export x without redefining x. This code was found by compiling a \
snippet: \
extern __declspec(dllexport) int x; int x = 42; */ \
asm (".section .drectve\n"); \
asm (".ascii \" -export:" #x ",data\"\n"); \
asm (".data\n"); \
/* Allocate a pseudo-variable IMP(x). */ \
extern int x; \
void * IMP(x) = &x;
VARIABLE(libintl_version)
plptools-1.0.13/intl/dcgettext.c 0000644 0001750 0001750 00000003324 12417352630 013503 0000000 0000000 /* Implementation of the dcgettext(3) function.
Copyright (C) 1995-1999, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DCGETTEXT __dcgettext
# define DCIGETTEXT __dcigettext
#else
# define DCGETTEXT libintl_dcgettext
# define DCIGETTEXT libintl_dcigettext
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
char *
DCGETTEXT (const char *domainname, const char *msgid, int category)
{
return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
INTDEF(__dcgettext)
weak_alias (__dcgettext, dcgettext);
#endif
plptools-1.0.13/intl/plural-exp.c 0000644 0001750 0001750 00000007635 12417352631 013613 0000000 0000000 /* Expression parsing for plural form selection.
Copyright (C) 2000-2001, 2003, 2005-2007 Free Software Foundation, Inc.
Written by Ulrich Drepper , 2000.
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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include "plural-exp.h"
#if (defined __GNUC__ && !(__APPLE_CC__ > 1) && !defined __cplusplus) \
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
/* These structs are the constant expression for the germanic plural
form determination. It represents the expression "n != 1". */
static const struct expression plvar =
{
.nargs = 0,
.operation = var,
};
static const struct expression plone =
{
.nargs = 0,
.operation = num,
.val =
{
.num = 1
}
};
struct expression GERMANIC_PLURAL =
{
.nargs = 2,
.operation = not_equal,
.val =
{
.args =
{
[0] = (struct expression *) &plvar,
[1] = (struct expression *) &plone
}
}
};
# define INIT_GERMANIC_PLURAL()
#else
/* For compilers without support for ISO C 99 struct/union initializers:
Initialization at run-time. */
static struct expression plvar;
static struct expression plone;
struct expression GERMANIC_PLURAL;
static void
init_germanic_plural ()
{
if (plone.val.num == 0)
{
plvar.nargs = 0;
plvar.operation = var;
plone.nargs = 0;
plone.operation = num;
plone.val.num = 1;
GERMANIC_PLURAL.nargs = 2;
GERMANIC_PLURAL.operation = not_equal;
GERMANIC_PLURAL.val.args[0] = &plvar;
GERMANIC_PLURAL.val.args[1] = &plone;
}
}
# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
#endif
void
internal_function
EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
const struct expression **pluralp,
unsigned long int *npluralsp)
{
if (nullentry != NULL)
{
const char *plural;
const char *nplurals;
plural = strstr (nullentry, "plural=");
nplurals = strstr (nullentry, "nplurals=");
if (plural == NULL || nplurals == NULL)
goto no_plural;
else
{
char *endp;
unsigned long int n;
struct parse_args args;
/* First get the number. */
nplurals += 9;
while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
++nplurals;
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
n = strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
#endif
if (nplurals == endp)
goto no_plural;
*npluralsp = n;
/* Due to the restrictions bison imposes onto the interface of the
scanner function we have to put the input string and the result
passed up from the parser into the same structure which address
is passed down to the parser. */
plural += 7;
args.cp = plural;
if (PLURAL_PARSE (&args) != 0)
goto no_plural;
*pluralp = args.res;
}
}
else
{
/* By default we are using the Germanic form: singular form only
for `one', the plural form otherwise. Yes, this is also what
English is using since English is a Germanic language. */
no_plural:
INIT_GERMANIC_PLURAL ();
*pluralp = &GERMANIC_PLURAL;
*npluralsp = 2;
}
}
plptools-1.0.13/intl/bindtextdom.c 0000644 0001750 0001750 00000021245 12417352630 014033 0000000 0000000 /* Implementation of the bindtextdomain(3) function
Copyright (C) 1995-1998, 2000-2003, 2005-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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
# define gl_rwlock_define __libc_rwlock_define
# define gl_rwlock_wrlock __libc_rwlock_wrlock
# define gl_rwlock_unlock __libc_rwlock_unlock
#else
# include "lock.h"
#endif
/* Some compilers, like SunOS4 cc, don't have offsetof in . */
#ifndef offsetof
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
#endif
/* @@ end of prolog @@ */
/* Lock variable to protect the global data in the gettext implementation. */
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define BINDTEXTDOMAIN __bindtextdomain
# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset
# ifndef strdup
# define strdup(str) __strdup (str)
# endif
#else
# define BINDTEXTDOMAIN libintl_bindtextdomain
# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset
#endif
/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
to be used for the DOMAINNAME message catalog.
If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
modified, only the current value is returned.
If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither
modified nor returned. */
static void
set_binding_values (const char *domainname,
const char **dirnamep, const char **codesetp)
{
struct binding *binding;
int modified;
/* Some sanity checks. */
if (domainname == NULL || domainname[0] == '\0')
{
if (dirnamep)
*dirnamep = NULL;
if (codesetp)
*codesetp = NULL;
return;
}
gl_rwlock_wrlock (_nl_state_lock);
modified = 0;
for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
{
int compare = strcmp (domainname, binding->domainname);
if (compare == 0)
/* We found it! */
break;
if (compare < 0)
{
/* It is not in the list. */
binding = NULL;
break;
}
}
if (binding != NULL)
{
if (dirnamep)
{
const char *dirname = *dirnamep;
if (dirname == NULL)
/* The current binding has be to returned. */
*dirnamep = binding->dirname;
else
{
/* The domain is already bound. If the new value and the old
one are equal we simply do nothing. Otherwise replace the
old binding. */
char *result = binding->dirname;
if (strcmp (dirname, result) != 0)
{
if (strcmp (dirname, _nl_default_dirname) == 0)
result = (char *) _nl_default_dirname;
else
{
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (dirname);
#else
size_t len = strlen (dirname) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result != NULL, 1))
memcpy (result, dirname, len);
#endif
}
if (__builtin_expect (result != NULL, 1))
{
if (binding->dirname != _nl_default_dirname)
free (binding->dirname);
binding->dirname = result;
modified = 1;
}
}
*dirnamep = result;
}
}
if (codesetp)
{
const char *codeset = *codesetp;
if (codeset == NULL)
/* The current binding has be to returned. */
*codesetp = binding->codeset;
else
{
/* The domain is already bound. If the new value and the old
one are equal we simply do nothing. Otherwise replace the
old binding. */
char *result = binding->codeset;
if (result == NULL || strcmp (codeset, result) != 0)
{
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (codeset);
#else
size_t len = strlen (codeset) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result != NULL, 1))
memcpy (result, codeset, len);
#endif
if (__builtin_expect (result != NULL, 1))
{
free (binding->codeset);
binding->codeset = result;
modified = 1;
}
}
*codesetp = result;
}
}
}
else if ((dirnamep == NULL || *dirnamep == NULL)
&& (codesetp == NULL || *codesetp == NULL))
{
/* Simply return the default values. */
if (dirnamep)
*dirnamep = _nl_default_dirname;
if (codesetp)
*codesetp = NULL;
}
else
{
/* We have to create a new binding. */
size_t len = strlen (domainname) + 1;
struct binding *new_binding =
(struct binding *) malloc (offsetof (struct binding, domainname) + len);
if (__builtin_expect (new_binding == NULL, 0))
goto failed;
memcpy (new_binding->domainname, domainname, len);
if (dirnamep)
{
const char *dirname = *dirnamep;
if (dirname == NULL)
/* The default value. */
dirname = _nl_default_dirname;
else
{
if (strcmp (dirname, _nl_default_dirname) == 0)
dirname = _nl_default_dirname;
else
{
char *result;
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (dirname);
if (__builtin_expect (result == NULL, 0))
goto failed_dirname;
#else
size_t len = strlen (dirname) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result == NULL, 0))
goto failed_dirname;
memcpy (result, dirname, len);
#endif
dirname = result;
}
}
*dirnamep = dirname;
new_binding->dirname = (char *) dirname;
}
else
/* The default value. */
new_binding->dirname = (char *) _nl_default_dirname;
if (codesetp)
{
const char *codeset = *codesetp;
if (codeset != NULL)
{
char *result;
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (codeset);
if (__builtin_expect (result == NULL, 0))
goto failed_codeset;
#else
size_t len = strlen (codeset) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result == NULL, 0))
goto failed_codeset;
memcpy (result, codeset, len);
#endif
codeset = result;
}
*codesetp = codeset;
new_binding->codeset = (char *) codeset;
}
else
new_binding->codeset = NULL;
/* Now enqueue it. */
if (_nl_domain_bindings == NULL
|| strcmp (domainname, _nl_domain_bindings->domainname) < 0)
{
new_binding->next = _nl_domain_bindings;
_nl_domain_bindings = new_binding;
}
else
{
binding = _nl_domain_bindings;
while (binding->next != NULL
&& strcmp (domainname, binding->next->domainname) > 0)
binding = binding->next;
new_binding->next = binding->next;
binding->next = new_binding;
}
modified = 1;
/* Here we deal with memory allocation failures. */
if (0)
{
failed_codeset:
if (new_binding->dirname != _nl_default_dirname)
free (new_binding->dirname);
failed_dirname:
free (new_binding);
failed:
if (dirnamep)
*dirnamep = NULL;
if (codesetp)
*codesetp = NULL;
}
}
/* If we modified any binding, we flush the caches. */
if (modified)
++_nl_msg_cat_cntr;
gl_rwlock_unlock (_nl_state_lock);
}
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
char *
BINDTEXTDOMAIN (const char *domainname, const char *dirname)
{
set_binding_values (domainname, &dirname, NULL);
return (char *) dirname;
}
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
char *
BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset)
{
set_binding_values (domainname, NULL, &codeset);
return (char *) codeset;
}
#ifdef _LIBC
/* Aliases for function names in GNU C Library. */
weak_alias (__bindtextdomain, bindtextdomain);
weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset);
#endif
plptools-1.0.13/intl/dngettext.c 0000644 0001750 0001750 00000003451 12417352630 013517 0000000 0000000 /* Implementation of the dngettext(3) function.
Copyright (C) 1995-1997, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "gettextP.h"
#include
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DNGETTEXT __dngettext
# define DCNGETTEXT __dcngettext
#else
# define DNGETTEXT libintl_dngettext
# define DCNGETTEXT libintl_dcngettext
#endif
/* Look up MSGID in the DOMAINNAME message catalog of the current
LC_MESSAGES locale and skip message according to the plural form. */
char *
DNGETTEXT (const char *domainname,
const char *msgid1, const char *msgid2, unsigned long int n)
{
return DCNGETTEXT (domainname, msgid1, msgid2, n, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dngettext, dngettext);
#endif
plptools-1.0.13/intl/printf-args.h 0000644 0001750 0001750 00000007572 12417352631 013763 0000000 0000000 /* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003, 2006-2007, 2011 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.1 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 . */
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
/* This file can be parametrized with the following macros:
ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
PRINTF_FETCHARGS Name of the function to be declared.
STATIC Set to 'static' to declare the function static. */
/* Default parameters. */
#ifndef PRINTF_FETCHARGS
# define PRINTF_FETCHARGS printf_fetchargs
#endif
/* Get size_t. */
#include
/* Get wchar_t. */
#if HAVE_WCHAR_T
# include
#endif
/* Get wint_t. */
#if HAVE_WINT_T
# include
#endif
/* Get va_list. */
#include
/* Argument types */
typedef enum
{
TYPE_NONE,
TYPE_SCHAR,
TYPE_UCHAR,
TYPE_SHORT,
TYPE_USHORT,
TYPE_INT,
TYPE_UINT,
TYPE_LONGINT,
TYPE_ULONGINT,
#if HAVE_LONG_LONG_INT
TYPE_LONGLONGINT,
TYPE_ULONGLONGINT,
#endif
TYPE_DOUBLE,
TYPE_LONGDOUBLE,
TYPE_CHAR,
#if HAVE_WINT_T
TYPE_WIDE_CHAR,
#endif
TYPE_STRING,
#if HAVE_WCHAR_T
TYPE_WIDE_STRING,
#endif
TYPE_POINTER,
TYPE_COUNT_SCHAR_POINTER,
TYPE_COUNT_SHORT_POINTER,
TYPE_COUNT_INT_POINTER,
TYPE_COUNT_LONGINT_POINTER
#if HAVE_LONG_LONG_INT
, TYPE_COUNT_LONGLONGINT_POINTER
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
, TYPE_U8_STRING
, TYPE_U16_STRING
, TYPE_U32_STRING
#endif
} arg_type;
/* Polymorphic argument */
typedef struct
{
arg_type type;
union
{
signed char a_schar;
unsigned char a_uchar;
short a_short;
unsigned short a_ushort;
int a_int;
unsigned int a_uint;
long int a_longint;
unsigned long int a_ulongint;
#if HAVE_LONG_LONG_INT
long long int a_longlongint;
unsigned long long int a_ulonglongint;
#endif
float a_float;
double a_double;
long double a_longdouble;
int a_char;
#if HAVE_WINT_T
wint_t a_wide_char;
#endif
const char* a_string;
#if HAVE_WCHAR_T
const wchar_t* a_wide_string;
#endif
void* a_pointer;
signed char * a_count_schar_pointer;
short * a_count_short_pointer;
int * a_count_int_pointer;
long int * a_count_longint_pointer;
#if HAVE_LONG_LONG_INT
long long int * a_count_longlongint_pointer;
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
const uint8_t * a_u8_string;
const uint16_t * a_u16_string;
const uint32_t * a_u32_string;
#endif
}
a;
}
argument;
/* Number of directly allocated arguments (no malloc() needed). */
#define N_DIRECT_ALLOC_ARGUMENTS 7
typedef struct
{
size_t count;
argument *arg;
argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
}
arguments;
/* Fetch the arguments, putting them into a. */
#ifdef STATIC
STATIC
#else
extern
#endif
int PRINTF_FETCHARGS (va_list args, arguments *a);
#endif /* _PRINTF_ARGS_H */
plptools-1.0.13/intl/finddomain.c 0000644 0001750 0001750 00000013576 12417352630 013632 0000000 0000000 /* Handle list of needed message catalogs
Copyright (C) 1995-1999, 2000-2001, 2003-2007 Free Software Foundation, Inc.
Written by Ulrich Drepper , 1995.
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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include
#if defined HAVE_UNISTD_H || defined _LIBC
# include
#endif
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* Handle multi-threaded applications. */
#ifdef _LIBC
# include
# define gl_rwlock_define_initialized __libc_rwlock_define_initialized
# define gl_rwlock_rdlock __libc_rwlock_rdlock
# define gl_rwlock_wrlock __libc_rwlock_wrlock
# define gl_rwlock_unlock __libc_rwlock_unlock
#else
# include "lock.h"
#endif
/* @@ end of prolog @@ */
/* List of already loaded domains. */
static struct loaded_l10nfile *_nl_loaded_domains;
/* Return a data structure describing the message catalog described by
the DOMAINNAME and CATEGORY parameters with respect to the currently
established bindings. */
struct loaded_l10nfile *
internal_function
_nl_find_domain (const char *dirname, char *locale,
const char *domainname, struct binding *domainbinding)
{
struct loaded_l10nfile *retval;
const char *language;
const char *modifier;
const char *territory;
const char *codeset;
const char *normalized_codeset;
const char *alias_value;
int mask;
/* LOCALE can consist of up to four recognized parts for the XPG syntax:
language[_territory][.codeset][@modifier]
Beside the first part all of them are allowed to be missing. If
the full specified locale is not found, the less specific one are
looked for. The various parts will be stripped off according to
the following order:
(1) codeset
(2) normalized codeset
(3) territory
(4) modifier
*/
/* We need to protect modifying the _NL_LOADED_DOMAINS data. */
gl_rwlock_define_initialized (static, lock);
gl_rwlock_rdlock (lock);
/* If we have already tested for this locale entry there has to
be one data set in the list of loaded domains. */
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
strlen (dirname) + 1, 0, locale, NULL, NULL,
NULL, NULL, domainname, 0);
gl_rwlock_unlock (lock);
if (retval != NULL)
{
/* We know something about this locale. */
int cnt;
if (retval->decided <= 0)
_nl_load_domain (retval, domainbinding);
if (retval->data != NULL)
return retval;
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
{
if (retval->successor[cnt]->decided <= 0)
_nl_load_domain (retval->successor[cnt], domainbinding);
if (retval->successor[cnt]->data != NULL)
break;
}
return retval;
/* NOTREACHED */
}
/* See whether the locale value is an alias. If yes its value
*overwrites* the alias name. No test for the original value is
done. */
alias_value = _nl_expand_alias (locale);
if (alias_value != NULL)
{
#if defined _LIBC || defined HAVE_STRDUP
locale = strdup (alias_value);
if (locale == NULL)
return NULL;
#else
size_t len = strlen (alias_value) + 1;
locale = (char *) malloc (len);
if (locale == NULL)
return NULL;
memcpy (locale, alias_value, len);
#endif
}
/* Now we determine the single parts of the locale name. First
look for the language. Termination symbols are `_', '.', and `@'. */
mask = _nl_explode_name (locale, &language, &modifier, &territory,
&codeset, &normalized_codeset);
if (mask == -1)
/* This means we are out of core. */
return NULL;
/* We need to protect modifying the _NL_LOADED_DOMAINS data. */
gl_rwlock_wrlock (lock);
/* Create all possible locale entries which might be interested in
generalization. */
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
strlen (dirname) + 1, mask, language, territory,
codeset, normalized_codeset, modifier,
domainname, 1);
gl_rwlock_unlock (lock);
if (retval == NULL)
/* This means we are out of core. */
goto out;
if (retval->decided <= 0)
_nl_load_domain (retval, domainbinding);
if (retval->data == NULL)
{
int cnt;
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
{
if (retval->successor[cnt]->decided <= 0)
_nl_load_domain (retval->successor[cnt], domainbinding);
if (retval->successor[cnt]->data != NULL)
break;
}
}
/* The room for an alias was dynamically allocated. Free it now. */
if (alias_value != NULL)
free (locale);
out:
/* The space for normalized_codeset is dynamically allocated. Free it. */
if (mask & XPG_NORM_CODESET)
free ((void *) normalized_codeset);
return retval;
}
#ifdef _LIBC
/* This is called from iconv/gconv_db.c's free_mem, as locales must
be freed before freeing gconv steps arrays. */
void __libc_freeres_fn_section
_nl_finddomain_subfreeres ()
{
struct loaded_l10nfile *runp = _nl_loaded_domains;
while (runp != NULL)
{
struct loaded_l10nfile *here = runp;
if (runp->data != NULL)
_nl_unload_domain ((struct loaded_domain *) runp->data);
runp = runp->next;
free ((char *) here->filename);
free (here);
}
}
#endif
plptools-1.0.13/intl/explodename.c 0000644 0001750 0001750 00000006451 12417352630 014015 0000000 0000000 /* Copyright (C) 1995-1998, 2000-2001, 2003, 2005, 2007 Free Software Foundation, Inc.
Contributed by Ulrich Drepper , 1995.
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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include "loadinfo.h"
/* On some strange systems still no definition of NULL is found. Sigh! */
#ifndef NULL
# if defined __STDC__ && __STDC__
# define NULL ((void *) 0)
# else
# define NULL 0
# endif
#endif
/* @@ end of prolog @@ */
/* Split a locale name NAME into a leading language part and all the
rest. Return a pointer to the first character after the language,
i.e. to the first byte of the rest. */
static char *_nl_find_language (const char *name);
static char *
_nl_find_language (const char *name)
{
while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.')
++name;
return (char *) name;
}
int
_nl_explode_name (char *name,
const char **language, const char **modifier,
const char **territory, const char **codeset,
const char **normalized_codeset)
{
char *cp;
int mask;
*modifier = NULL;
*territory = NULL;
*codeset = NULL;
*normalized_codeset = NULL;
/* Now we determine the single parts of the locale name. First
look for the language. Termination symbols are `_', '.', and `@'. */
mask = 0;
*language = cp = name;
cp = _nl_find_language (*language);
if (*language == cp)
/* This does not make sense: language has to be specified. Use
this entry as it is without exploding. Perhaps it is an alias. */
cp = strchr (*language, '\0');
else
{
if (cp[0] == '_')
{
/* Next is the territory. */
cp[0] = '\0';
*territory = ++cp;
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@')
++cp;
mask |= XPG_TERRITORY;
}
if (cp[0] == '.')
{
/* Next is the codeset. */
cp[0] = '\0';
*codeset = ++cp;
while (cp[0] != '\0' && cp[0] != '@')
++cp;
mask |= XPG_CODESET;
if (*codeset != cp && (*codeset)[0] != '\0')
{
*normalized_codeset = _nl_normalize_codeset (*codeset,
cp - *codeset);
if (*normalized_codeset == NULL)
return -1;
else if (strcmp (*codeset, *normalized_codeset) == 0)
free ((char *) *normalized_codeset);
else
mask |= XPG_NORM_CODESET;
}
}
}
if (cp[0] == '@')
{
/* Next is the modifier. */
cp[0] = '\0';
*modifier = ++cp;
if (cp[0] != '\0')
mask |= XPG_MODIFIER;
}
if (*territory != NULL && (*territory)[0] == '\0')
mask &= ~XPG_TERRITORY;
if (*codeset != NULL && (*codeset)[0] == '\0')
mask &= ~XPG_CODESET;
return mask;
}
plptools-1.0.13/intl/plural.c 0000644 0001750 0001750 00000147566 12417353422 013030 0000000 0000000 /* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Substitute the variable and function names. */
#define yyparse __gettextparse
#define yylex __gettextlex
#define yyerror __gettexterror
#define yydebug __gettextdebug
#define yynerrs __gettextnerrs
/* Copy the first part of user declarations. */
#line 1 "plural.y" /* yacc.c:339 */
/* Expression parsing for plural form selection.
Copyright (C) 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc.
Written by Ulrich Drepper , 2000.
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.1 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 . */
/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
to put this declaration at the beginning of the file. The declaration in
bison's skeleton file comes too late. This must come before
because may include arbitrary system headers.
This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
#if defined _AIX && !defined __GNUC__
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include "plural-exp.h"
/* The main function generated by the parser is called __gettextparse,
but we want it to be called PLURAL_PARSE. */
#ifndef _LIBC
# define __gettextparse PLURAL_PARSE
#endif
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
#line 118 "plural.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
/* In a future release of Bison, this section will be replaced
by #include "plural.h". */
#ifndef YY__GETTEXT_PLURAL_H_INCLUDED
# define YY__GETTEXT_PLURAL_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int __gettextdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
EQUOP2 = 258,
CMPOP2 = 259,
ADDOP2 = 260,
MULOP2 = 261,
NUMBER = 262
};
#endif
/* Tokens. */
#define EQUOP2 258
#define CMPOP2 259
#define ADDOP2 260
#define MULOP2 261
#define NUMBER 262
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 49 "plural.y" /* yacc.c:355 */
unsigned long int num;
enum expression_operator op;
struct expression *exp;
#line 178 "plural.c" /* yacc.c:355 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int __gettextparse (void);
#endif /* !YY__GETTEXT_PLURAL_H_INCLUDED */
/* Copy the second part of user declarations. */
#line 55 "plural.y" /* yacc.c:358 */
/* Prototypes for local functions. */
static int yylex (YYSTYPE *lval, const char **pexp);
static void yyerror (const char *str);
/* Allocation of expressions. */
static struct expression *
new_exp (int nargs, enum expression_operator op,
struct expression * const *args)
{
int i;
struct expression *newp;
/* If any of the argument could not be malloc'ed, just return NULL. */
for (i = nargs - 1; i >= 0; i--)
if (args[i] == NULL)
goto fail;
/* Allocate a new expression. */
newp = (struct expression *) malloc (sizeof (*newp));
if (newp != NULL)
{
newp->nargs = nargs;
newp->operation = op;
for (i = nargs - 1; i >= 0; i--)
newp->val.args[i] = args[i];
return newp;
}
fail:
for (i = nargs - 1; i >= 0; i--)
FREE_EXPRESSION (args[i]);
return NULL;
}
static inline struct expression *
new_exp_0 (enum expression_operator op)
{
return new_exp (0, op, NULL);
}
static inline struct expression *
new_exp_1 (enum expression_operator op, struct expression *right)
{
struct expression *args[1];
args[0] = right;
return new_exp (1, op, args);
}
static struct expression *
new_exp_2 (enum expression_operator op, struct expression *left,
struct expression *right)
{
struct expression *args[2];
args[0] = left;
args[1] = right;
return new_exp (2, op, args);
}
static inline struct expression *
new_exp_3 (enum expression_operator op, struct expression *bexp,
struct expression *tbranch, struct expression *fbranch)
{
struct expression *args[3];
args[0] = bexp;
args[1] = tbranch;
args[2] = fbranch;
return new_exp (3, op, args);
}
#line 268 "plural.c" /* yacc.c:358 */
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T
# include /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 9
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 54
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 16
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 3
/* YYNRULES -- Number of rules. */
#define YYNRULES 13
/* YYNSTATES -- Number of states. */
#define YYNSTATES 27
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 262
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
8, 9, 11
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 152, 152, 160, 164, 168, 172, 176, 180, 184,
188, 192, 196, 201
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
"ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
"$accept", "start", "exp", YY_NULLPTR
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
33, 262, 58, 110, 40, 41
};
# endif
#define YYPACT_NINF -10
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-10)))
#define YYTABLE_NINF -1
#define yytable_value_is_error(Yytable_value) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int8 yypact[] =
{
-9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
-9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
45, 18, -2, 14, -10, -9, 36
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
5, 6, 7, 8, 9, 0, 3
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-10, -10, -1
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 5, 6
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_uint8 yytable[] =
{
7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
16, 13, 14, 15, 16
};
static const yytype_int8 yycheck[] =
{
1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
9, 6, 7, 8, 9
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
18, 18, 18, 18, 18, 12, 18
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
2, 1, 1, 3
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
/*----------------------------------------.
| Print this symbol's value on YYOUTPUT. |
`----------------------------------------*/
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
YYFPRINTF (yyoutput, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
yy_symbol_value_print (yyoutput, yytype, yyvaluep);
YYFPRINTF (yyoutput, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
{
unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, Rule); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
static YYSIZE_T
yystrlen (const char *yystr)
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
}
}
}
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/*----------.
| yyparse. |
`----------*/
int
yyparse (void)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
#line 153 "plural.y" /* yacc.c:1646 */
{
if ((yyvsp[0].exp) == NULL)
YYABORT;
((struct parse_args *) arg)->res = (yyvsp[0].exp);
}
#line 1363 "plural.c" /* yacc.c:1646 */
break;
case 3:
#line 161 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_3 (qmop, (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1371 "plural.c" /* yacc.c:1646 */
break;
case 4:
#line 165 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 (lor, (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1379 "plural.c" /* yacc.c:1646 */
break;
case 5:
#line 169 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 (land, (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1387 "plural.c" /* yacc.c:1646 */
break;
case 6:
#line 173 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1395 "plural.c" /* yacc.c:1646 */
break;
case 7:
#line 177 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1403 "plural.c" /* yacc.c:1646 */
break;
case 8:
#line 181 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1411 "plural.c" /* yacc.c:1646 */
break;
case 9:
#line 185 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
#line 1419 "plural.c" /* yacc.c:1646 */
break;
case 10:
#line 189 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_1 (lnot, (yyvsp[0].exp));
}
#line 1427 "plural.c" /* yacc.c:1646 */
break;
case 11:
#line 193 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = new_exp_0 (var);
}
#line 1435 "plural.c" /* yacc.c:1646 */
break;
case 12:
#line 197 "plural.y" /* yacc.c:1646 */
{
if (((yyval.exp) = new_exp_0 (num)) != NULL)
(yyval.exp)->val.num = (yyvsp[0].num);
}
#line 1444 "plural.c" /* yacc.c:1646 */
break;
case 13:
#line 202 "plural.y" /* yacc.c:1646 */
{
(yyval.exp) = (yyvsp[-1].exp);
}
#line 1452 "plural.c" /* yacc.c:1646 */
break;
#line 1456 "plural.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult;
}
#line 207 "plural.y" /* yacc.c:1906 */
void
internal_function
FREE_EXPRESSION (struct expression *exp)
{
if (exp == NULL)
return;
/* Handle the recursive case. */
switch (exp->nargs)
{
case 3:
FREE_EXPRESSION (exp->val.args[2]);
/* FALLTHROUGH */
case 2:
FREE_EXPRESSION (exp->val.args[1]);
/* FALLTHROUGH */
case 1:
FREE_EXPRESSION (exp->val.args[0]);
/* FALLTHROUGH */
default:
break;
}
free (exp);
}
static int
yylex (YYSTYPE *lval, const char **pexp)
{
const char *exp = *pexp;
int result;
while (1)
{
if (exp[0] == '\0')
{
*pexp = exp;
return YYEOF;
}
if (exp[0] != ' ' && exp[0] != '\t')
break;
++exp;
}
result = *exp++;
switch (result)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
unsigned long int n = result - '0';
while (exp[0] >= '0' && exp[0] <= '9')
{
n *= 10;
n += exp[0] - '0';
++exp;
}
lval->num = n;
result = NUMBER;
}
break;
case '=':
if (exp[0] == '=')
{
++exp;
lval->op = equal;
result = EQUOP2;
}
else
result = YYERRCODE;
break;
case '!':
if (exp[0] == '=')
{
++exp;
lval->op = not_equal;
result = EQUOP2;
}
break;
case '&':
case '|':
if (exp[0] == result)
++exp;
else
result = YYERRCODE;
break;
case '<':
if (exp[0] == '=')
{
++exp;
lval->op = less_or_equal;
}
else
lval->op = less_than;
result = CMPOP2;
break;
case '>':
if (exp[0] == '=')
{
++exp;
lval->op = greater_or_equal;
}
else
lval->op = greater_than;
result = CMPOP2;
break;
case '*':
lval->op = mult;
result = MULOP2;
break;
case '/':
lval->op = divide;
result = MULOP2;
break;
case '%':
lval->op = module;
result = MULOP2;
break;
case '+':
lval->op = plus;
result = ADDOP2;
break;
case '-':
lval->op = minus;
result = ADDOP2;
break;
case 'n':
case '?':
case ':':
case '(':
case ')':
/* Nothing, just return the character. */
break;
case ';':
case '\n':
case '\0':
/* Be safe and let the user call this function again. */
--exp;
result = YYEOF;
break;
default:
result = YYERRCODE;
#if YYDEBUG != 0
--exp;
#endif
break;
}
*pexp = exp;
return result;
}
static void
yyerror (const char *str)
{
/* Do nothing. We don't print error messages here. */
}
plptools-1.0.13/intl/plural.y 0000644 0001750 0001750 00000016501 12417352631 013037 0000000 0000000 %{
/* Expression parsing for plural form selection.
Copyright (C) 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc.
Written by Ulrich Drepper , 2000.
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.1 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 . */
/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
to put this declaration at the beginning of the file. The declaration in
bison's skeleton file comes too late. This must come before
because may include arbitrary system headers.
This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
#if defined _AIX && !defined __GNUC__
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
# include
#endif
#include
#include
#include
#include "plural-exp.h"
/* The main function generated by the parser is called __gettextparse,
but we want it to be called PLURAL_PARSE. */
#ifndef _LIBC
# define __gettextparse PLURAL_PARSE
#endif
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
%}
%pure_parser
%expect 7
%union {
unsigned long int num;
enum expression_operator op;
struct expression *exp;
}
%{
/* Prototypes for local functions. */
static int yylex (YYSTYPE *lval, const char **pexp);
static void yyerror (const char *str);
/* Allocation of expressions. */
static struct expression *
new_exp (int nargs, enum expression_operator op,
struct expression * const *args)
{
int i;
struct expression *newp;
/* If any of the argument could not be malloc'ed, just return NULL. */
for (i = nargs - 1; i >= 0; i--)
if (args[i] == NULL)
goto fail;
/* Allocate a new expression. */
newp = (struct expression *) malloc (sizeof (*newp));
if (newp != NULL)
{
newp->nargs = nargs;
newp->operation = op;
for (i = nargs - 1; i >= 0; i--)
newp->val.args[i] = args[i];
return newp;
}
fail:
for (i = nargs - 1; i >= 0; i--)
FREE_EXPRESSION (args[i]);
return NULL;
}
static inline struct expression *
new_exp_0 (enum expression_operator op)
{
return new_exp (0, op, NULL);
}
static inline struct expression *
new_exp_1 (enum expression_operator op, struct expression *right)
{
struct expression *args[1];
args[0] = right;
return new_exp (1, op, args);
}
static struct expression *
new_exp_2 (enum expression_operator op, struct expression *left,
struct expression *right)
{
struct expression *args[2];
args[0] = left;
args[1] = right;
return new_exp (2, op, args);
}
static inline struct expression *
new_exp_3 (enum expression_operator op, struct expression *bexp,
struct expression *tbranch, struct expression *fbranch)
{
struct expression *args[3];
args[0] = bexp;
args[1] = tbranch;
args[2] = fbranch;
return new_exp (3, op, args);
}
%}
/* This declares that all operators have the same associativity and the
precedence order as in C. See [Harbison, Steele: C, A Reference Manual].
There is no unary minus and no bitwise operators.
Operators with the same syntactic behaviour have been merged into a single
token, to save space in the array generated by bison. */
%right '?' /* ? */
%left '|' /* || */
%left '&' /* && */
%left EQUOP2 /* == != */
%left CMPOP2 /* < > <= >= */
%left ADDOP2 /* + - */
%left MULOP2 /* * / % */
%right '!' /* ! */
%token EQUOP2 CMPOP2 ADDOP2 MULOP2
%token NUMBER
%type exp
%%
start: exp
{
if ($1 == NULL)
YYABORT;
((struct parse_args *) arg)->res = $1;
}
;
exp: exp '?' exp ':' exp
{
$$ = new_exp_3 (qmop, $1, $3, $5);
}
| exp '|' exp
{
$$ = new_exp_2 (lor, $1, $3);
}
| exp '&' exp
{
$$ = new_exp_2 (land, $1, $3);
}
| exp EQUOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp CMPOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp ADDOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp MULOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| '!' exp
{
$$ = new_exp_1 (lnot, $2);
}
| 'n'
{
$$ = new_exp_0 (var);
}
| NUMBER
{
if (($$ = new_exp_0 (num)) != NULL)
$$->val.num = $1;
}
| '(' exp ')'
{
$$ = $2;
}
;
%%
void
internal_function
FREE_EXPRESSION (struct expression *exp)
{
if (exp == NULL)
return;
/* Handle the recursive case. */
switch (exp->nargs)
{
case 3:
FREE_EXPRESSION (exp->val.args[2]);
/* FALLTHROUGH */
case 2:
FREE_EXPRESSION (exp->val.args[1]);
/* FALLTHROUGH */
case 1:
FREE_EXPRESSION (exp->val.args[0]);
/* FALLTHROUGH */
default:
break;
}
free (exp);
}
static int
yylex (YYSTYPE *lval, const char **pexp)
{
const char *exp = *pexp;
int result;
while (1)
{
if (exp[0] == '\0')
{
*pexp = exp;
return YYEOF;
}
if (exp[0] != ' ' && exp[0] != '\t')
break;
++exp;
}
result = *exp++;
switch (result)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
unsigned long int n = result - '0';
while (exp[0] >= '0' && exp[0] <= '9')
{
n *= 10;
n += exp[0] - '0';
++exp;
}
lval->num = n;
result = NUMBER;
}
break;
case '=':
if (exp[0] == '=')
{
++exp;
lval->op = equal;
result = EQUOP2;
}
else
result = YYERRCODE;
break;
case '!':
if (exp[0] == '=')
{
++exp;
lval->op = not_equal;
result = EQUOP2;
}
break;
case '&':
case '|':
if (exp[0] == result)
++exp;
else
result = YYERRCODE;
break;
case '<':
if (exp[0] == '=')
{
++exp;
lval->op = less_or_equal;
}
else
lval->op = less_than;
result = CMPOP2;
break;
case '>':
if (exp[0] == '=')
{
++exp;
lval->op = greater_or_equal;
}
else
lval->op = greater_than;
result = CMPOP2;
break;
case '*':
lval->op = mult;
result = MULOP2;
break;
case '/':
lval->op = divide;
result = MULOP2;
break;
case '%':
lval->op = module;
result = MULOP2;
break;
case '+':
lval->op = plus;
result = ADDOP2;
break;
case '-':
lval->op = minus;
result = ADDOP2;
break;
case 'n':
case '?':
case ':':
case '(':
case ')':
/* Nothing, just return the character. */
break;
case ';':
case '\n':
case '\0':
/* Be safe and let the user call this function again. */
--exp;
result = YYEOF;
break;
default:
result = YYERRCODE;
#if YYDEBUG != 0
--exp;
#endif
break;
}
*pexp = exp;
return result;
}
static void
yyerror (const char *str)
{
/* Do nothing. We don't print error messages here. */
}
plptools-1.0.13/intl/localcharset.c 0000644 0001750 0001750 00000043561 12417352631 014164 0000000 0000000 /* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2006, 2008-2012 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.1 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 . */
/* Written by Bruno Haible . */
#include
/* Specification. */
#include "localcharset.h"
#include
#include
#include
#include
#include
#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
#endif
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_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 WINDOWS_NATIVE
# include
# if HAVE_LANGINFO_CODESET
# include
# else
# if 0 /* see comment below */
# include
# endif
# endif
# ifdef __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include
# endif
#elif defined WINDOWS_NATIVE
# define WIN32_LEAN_AND_MEAN
# include
#endif
#if defined OS2
# define INCL_DOS
# include
#endif
/* For MB_CUR_MAX_L */
#if defined DARWIN7
# include
#endif
#if ENABLE_RELOCATABLE
# include "relocatable.h"
#else
# define relocate(pathname) (pathname)
#endif
/* Get LIBDIR. */
#ifndef LIBDIR
# include "configmake.h"
#endif
/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
#endif
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Native Windows, 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 DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
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)
/* Out of memory. Treat the file as empty. */
cp = "";
else
{
int fd;
/* Open the file. Reject symbolic links on platforms that support
O_NOFOLLOW. This is a security feature. Without it, an attacker
could retrieve parts of the contents (namely, the tail of the
first line that starts with "* ") of an arbitrary file by placing
a symbolic link to that file under the name "charset.alias" in
some writable directory and defining the environment variable
CHARSETALIASDIR to point to that directory. */
fd = open (file_name,
O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
if (fd < 0)
/* File not found. Treat it as empty. */
cp = "";
else
{
FILE *fp;
fp = fdopen (fd, "r");
if (fp == NULL)
{
/* Out of memory. Treat the file as empty. */
close (fd);
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;
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;
}
}
}
free (file_name);
}
#else
# if defined DARWIN7
/* To avoid the trouble of installing a file that is shared by many
GNU packages -- many packaging systems have problems with this --,
simply inline the aliases here. */
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
"ISO8859-2" "\0" "ISO-8859-2" "\0"
"ISO8859-4" "\0" "ISO-8859-4" "\0"
"ISO8859-5" "\0" "ISO-8859-5" "\0"
"ISO8859-7" "\0" "ISO-8859-7" "\0"
"ISO8859-9" "\0" "ISO-8859-9" "\0"
"ISO8859-13" "\0" "ISO-8859-13" "\0"
"ISO8859-15" "\0" "ISO-8859-15" "\0"
"KOI8-R" "\0" "KOI8-R" "\0"
"KOI8-U" "\0" "KOI8-U" "\0"
"CP866" "\0" "CP866" "\0"
"CP949" "\0" "CP949" "\0"
"CP1131" "\0" "CP1131" "\0"
"CP1251" "\0" "CP1251" "\0"
"eucCN" "\0" "GB2312" "\0"
"GB2312" "\0" "GB2312" "\0"
"eucJP" "\0" "EUC-JP" "\0"
"eucKR" "\0" "EUC-KR" "\0"
"Big5" "\0" "BIG5" "\0"
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
"GBK" "\0" "GBK" "\0"
"GB18030" "\0" "GB18030" "\0"
"SJIS" "\0" "SHIFT_JIS" "\0"
"ARMSCII-8" "\0" "ARMSCII-8" "\0"
"PT154" "\0" "PT154" "\0"
/*"ISCII-DEV" "\0" "?" "\0"*/
"*" "\0" "UTF-8" "\0";
# endif
# 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 WINDOWS_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 WINDOWS_NATIVE || defined OS2)
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
# ifdef __CYGWIN__
/* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
returns "US-ASCII". 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;
}
}
}
/* The Windows API has a function returning the locale's codepage as a
number: GetACP(). This encoding is used by Cygwin, unless the user
has set the environment variable CYGWIN=codepage:oem (which very few
people do).
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
this conversion transparently (see winsup/cygwin/fhandler_console.cc),
converting to GetConsoleOutputCP(). This leads to correct results,
except when SetConsoleOutputCP has been called and a raster font is
in use. */
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 WINDOWS_NATIVE
static char buf[2 + 10 + 1];
/* The Windows API has a function returning the locale's codepage as a
number: GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
But in GUI programs and for output sent to files and pipes, GetACP()
encoding is the best bet. */
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";
#ifdef DARWIN7
/* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
(the default codeset) does not work when MB_CUR_MAX is 1. */
if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
codeset = "ASCII";
#endif
return codeset;
}
plptools-1.0.13/intl/xsize.c 0000644 0001750 0001750 00000000116 12417352631 012647 0000000 0000000 #include
#define XSIZE_INLINE _GL_EXTERN_INLINE
#include "xsize.h"
plptools-1.0.13/intl/dcngettext.c 0000644 0001750 0001750 00000003377 12417352630 013671 0000000 0000000 /* Implementation of the dcngettext(3) function.
Copyright (C) 1995-1999, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DCNGETTEXT __dcngettext
# define DCIGETTEXT __dcigettext
#else
# define DCNGETTEXT libintl_dcngettext
# define DCIGETTEXT libintl_dcigettext
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
char *
DCNGETTEXT (const char *domainname,
const char *msgid1, const char *msgid2, unsigned long int n,
int category)
{
return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dcngettext, dcngettext);
#endif
plptools-1.0.13/intl/printf-parse.c 0000644 0001750 0001750 00000053243 12417352631 014130 0000000 0000000 /* Formatted output to strings.
Copyright (C) 1999-2000, 2002-2003, 2006-2008, 2011 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.1 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 . */
/* This file can be parametrized with the following macros:
CHAR_T The element type of the format string.
CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters
in the format string are ASCII.
DIRECTIVE Structure denoting a format directive.
Depends on CHAR_T.
DIRECTIVES Structure denoting the set of format directives of a
format string. Depends on CHAR_T.
PRINTF_PARSE Function that parses a format string.
Depends on CHAR_T.
STATIC Set to 'static' to declare the function static.
ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */
#ifndef PRINTF_PARSE
# include
#endif
/* Specification. */
#ifndef PRINTF_PARSE
# include "printf-parse.h"
#endif
/* Default parameters. */
#ifndef PRINTF_PARSE
# define PRINTF_PARSE printf_parse
# define CHAR_T char
# define DIRECTIVE char_directive
# define DIRECTIVES char_directives
#endif
/* Get size_t, NULL. */
#include
/* Get intmax_t. */
#if defined IN_LIBINTL || defined IN_LIBASPRINTF
# if HAVE_STDINT_H_WITH_UINTMAX
# include
# endif
# if HAVE_INTTYPES_H_WITH_UINTMAX
# include
# endif
#else
# include
#endif
/* malloc(), realloc(), free(). */
#include
/* memcpy(). */
#include
/* errno. */
#include
/* Checked size_t computations. */
#include "xsize.h"
#if CHAR_T_ONLY_ASCII
/* c_isascii(). */
# include "c-ctype.h"
#endif
#ifdef STATIC
STATIC
#endif
int
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
{
const CHAR_T *cp = format; /* pointer into format */
size_t arg_posn = 0; /* number of regular arguments consumed */
size_t d_allocated; /* allocated elements of d->dir */
size_t a_allocated; /* allocated elements of a->arg */
size_t max_width_length = 0;
size_t max_precision_length = 0;
d->count = 0;
d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
d->dir = d->direct_alloc_dir;
a->count = 0;
a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
a->arg = a->direct_alloc_arg;
#define REGISTER_ARG(_index_,_type_) \
{ \
size_t n = (_index_); \
if (n >= a_allocated) \
{ \
size_t memory_size; \
argument *memory; \
\
a_allocated = xtimes (a_allocated, 2); \
if (a_allocated <= n) \
a_allocated = xsum (n, 1); \
memory_size = xtimes (a_allocated, sizeof (argument)); \
if (size_overflow_p (memory_size)) \
/* Overflow, would lead to out of memory. */ \
goto out_of_memory; \
memory = (argument *) (a->arg != a->direct_alloc_arg \
? realloc (a->arg, memory_size) \
: malloc (memory_size)); \
if (memory == NULL) \
/* Out of memory. */ \
goto out_of_memory; \
if (a->arg == a->direct_alloc_arg) \
memcpy (memory, a->arg, a->count * sizeof (argument)); \
a->arg = memory; \
} \
while (a->count <= n) \
a->arg[a->count++].type = TYPE_NONE; \
if (a->arg[n].type == TYPE_NONE) \
a->arg[n].type = (_type_); \
else if (a->arg[n].type != (_type_)) \
/* Ambiguous type for positional argument. */ \
goto error; \
}
while (*cp != '\0')
{
CHAR_T c = *cp++;
if (c == '%')
{
size_t arg_index = ARG_NONE;
DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
/* Initialize the next directive. */
dp->dir_start = cp - 1;
dp->flags = 0;
dp->width_start = NULL;
dp->width_end = NULL;
dp->width_arg_index = ARG_NONE;
dp->precision_start = NULL;
dp->precision_end = NULL;
dp->precision_arg_index = ARG_NONE;
dp->arg_index = ARG_NONE;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */
goto error;
arg_index = n - 1;
cp = np + 1;
}
}
/* Read the flags. */
for (;;)
{
if (*cp == '\'')
{
dp->flags |= FLAG_GROUP;
cp++;
}
else if (*cp == '-')
{
dp->flags |= FLAG_LEFT;
cp++;
}
else if (*cp == '+')
{
dp->flags |= FLAG_SHOWSIGN;
cp++;
}
else if (*cp == ' ')
{
dp->flags |= FLAG_SPACE;
cp++;
}
else if (*cp == '#')
{
dp->flags |= FLAG_ALT;
cp++;
}
else if (*cp == '0')
{
dp->flags |= FLAG_ZERO;
cp++;
}
#if __GLIBC__ >= 2 && !defined __UCLIBC__
else if (*cp == 'I')
{
dp->flags |= FLAG_LOCALIZED;
cp++;
}
#endif
else
break;
}
/* Parse the field width. */
if (*cp == '*')
{
dp->width_start = cp;
cp++;
dp->width_end = cp;
if (max_width_length < 1)
max_width_length = 1;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */
goto error;
dp->width_arg_index = n - 1;
cp = np + 1;
}
}
if (dp->width_arg_index == ARG_NONE)
{
dp->width_arg_index = arg_posn++;
if (dp->width_arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->width_arg_index, TYPE_INT);
}
else if (*cp >= '0' && *cp <= '9')
{
size_t width_length;
dp->width_start = cp;
for (; *cp >= '0' && *cp <= '9'; cp++)
;
dp->width_end = cp;
width_length = dp->width_end - dp->width_start;
if (max_width_length < width_length)
max_width_length = width_length;
}
/* Parse the precision. */
if (*cp == '.')
{
cp++;
if (*cp == '*')
{
dp->precision_start = cp - 1;
cp++;
dp->precision_end = cp;
if (max_precision_length < 2)
max_precision_length = 2;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory
later. */
goto error;
dp->precision_arg_index = n - 1;
cp = np + 1;
}
}
if (dp->precision_arg_index == ARG_NONE)
{
dp->precision_arg_index = arg_posn++;
if (dp->precision_arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
}
else
{
size_t precision_length;
dp->precision_start = cp - 1;
for (; *cp >= '0' && *cp <= '9'; cp++)
;
dp->precision_end = cp;
precision_length = dp->precision_end - dp->precision_start;
if (max_precision_length < precision_length)
max_precision_length = precision_length;
}
}
{
arg_type type;
/* Parse argument type/size specifiers. */
{
int flags = 0;
for (;;)
{
if (*cp == 'h')
{
flags |= (1 << (flags & 1));
cp++;
}
else if (*cp == 'L')
{
flags |= 4;
cp++;
}
else if (*cp == 'l')
{
flags += 8;
cp++;
}
else if (*cp == 'j')
{
if (sizeof (intmax_t) > sizeof (long))
{
/* intmax_t = long long */
flags += 16;
}
else if (sizeof (intmax_t) > sizeof (int))
{
/* intmax_t = long */
flags += 8;
}
cp++;
}
else if (*cp == 'z' || *cp == 'Z')
{
/* 'z' is standardized in ISO C 99, but glibc uses 'Z'
because the warning facility in gcc-2.95.2 understands
only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
if (sizeof (size_t) > sizeof (long))
{
/* size_t = long long */
flags += 16;
}
else if (sizeof (size_t) > sizeof (int))
{
/* size_t = long */
flags += 8;
}
cp++;
}
else if (*cp == 't')
{
if (sizeof (ptrdiff_t) > sizeof (long))
{
/* ptrdiff_t = long long */
flags += 16;
}
else if (sizeof (ptrdiff_t) > sizeof (int))
{
/* ptrdiff_t = long */
flags += 8;
}
cp++;
}
#if defined __APPLE__ && defined __MACH__
/* On MacOS X 10.3, PRIdMAX is defined as "qd".
We cannot change it to "lld" because PRIdMAX must also
be understood by the system's printf routines. */
else if (*cp == 'q')
{
if (64 / 8 > sizeof (long))
{
/* int64_t = long long */
flags += 16;
}
else
{
/* int64_t = long */
flags += 8;
}
cp++;
}
#endif
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* On native Win32, PRIdMAX is defined as "I64d".
We cannot change it to "lld" because PRIdMAX must also
be understood by the system's printf routines. */
else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
{
if (64 / 8 > sizeof (long))
{
/* __int64 = long long */
flags += 16;
}
else
{
/* __int64 = long */
flags += 8;
}
cp += 3;
}
#endif
else
break;
}
/* Read the conversion character. */
c = *cp++;
switch (c)
{
case 'd': case 'i':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_LONGLONGINT;
else
#endif
/* If 'long long' exists and is the same as 'long', we parse
"lld" into TYPE_LONGINT. */
if (flags >= 8)
type = TYPE_LONGINT;
else if (flags & 2)
type = TYPE_SCHAR;
else if (flags & 1)
type = TYPE_SHORT;
else
type = TYPE_INT;
break;
case 'o': case 'u': case 'x': case 'X':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_ULONGLONGINT;
else
#endif
/* If 'unsigned long long' exists and is the same as
'unsigned long', we parse "llu" into TYPE_ULONGINT. */
if (flags >= 8)
type = TYPE_ULONGINT;
else if (flags & 2)
type = TYPE_UCHAR;
else if (flags & 1)
type = TYPE_USHORT;
else
type = TYPE_UINT;
break;
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
case 'a': case 'A':
if (flags >= 16 || (flags & 4))
type = TYPE_LONGDOUBLE;
else
type = TYPE_DOUBLE;
break;
case 'c':
if (flags >= 8)
#if HAVE_WINT_T
type = TYPE_WIDE_CHAR;
#else
goto error;
#endif
else
type = TYPE_CHAR;
break;
#if HAVE_WINT_T
case 'C':
type = TYPE_WIDE_CHAR;
c = 'c';
break;
#endif
case 's':
if (flags >= 8)
#if HAVE_WCHAR_T
type = TYPE_WIDE_STRING;
#else
goto error;
#endif
else
type = TYPE_STRING;
break;
#if HAVE_WCHAR_T
case 'S':
type = TYPE_WIDE_STRING;
c = 's';
break;
#endif
case 'p':
type = TYPE_POINTER;
break;
case 'n':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_COUNT_LONGLONGINT_POINTER;
else
#endif
/* If 'long long' exists and is the same as 'long', we parse
"lln" into TYPE_COUNT_LONGINT_POINTER. */
if (flags >= 8)
type = TYPE_COUNT_LONGINT_POINTER;
else if (flags & 2)
type = TYPE_COUNT_SCHAR_POINTER;
else if (flags & 1)
type = TYPE_COUNT_SHORT_POINTER;
else
type = TYPE_COUNT_INT_POINTER;
break;
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
case 'U':
if (flags >= 16)
type = TYPE_U32_STRING;
else if (flags >= 8)
type = TYPE_U16_STRING;
else
type = TYPE_U8_STRING;
break;
#endif
case '%':
type = TYPE_NONE;
break;
default:
/* Unknown conversion character. */
goto error;
}
}
if (type != TYPE_NONE)
{
dp->arg_index = arg_index;
if (dp->arg_index == ARG_NONE)
{
dp->arg_index = arg_posn++;
if (dp->arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->arg_index, type);
}
dp->conversion = c;
dp->dir_end = cp;
}
d->count++;
if (d->count >= d_allocated)
{
size_t memory_size;
DIRECTIVE *memory;
d_allocated = xtimes (d_allocated, 2);
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
if (size_overflow_p (memory_size))
/* Overflow, would lead to out of memory. */
goto out_of_memory;
memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
? realloc (d->dir, memory_size)
: malloc (memory_size));
if (memory == NULL)
/* Out of memory. */
goto out_of_memory;
if (d->dir == d->direct_alloc_dir)
memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE));
d->dir = memory;
}
}
#if CHAR_T_ONLY_ASCII
else if (!c_isascii (c))
{
/* Non-ASCII character. Not supported. */
goto error;
}
#endif
}
d->dir[d->count].dir_start = cp;
d->max_width_length = max_width_length;
d->max_precision_length = max_precision_length;
return 0;
error:
if (a->arg != a->direct_alloc_arg)
free (a->arg);
if (d->dir != d->direct_alloc_dir)
free (d->dir);
errno = EINVAL;
return -1;
out_of_memory:
if (a->arg != a->direct_alloc_arg)
free (a->arg);
if (d->dir != d->direct_alloc_dir)
free (d->dir);
errno = ENOMEM;
return -1;
}
#undef PRINTF_PARSE
#undef DIRECTIVES
#undef DIRECTIVE
#undef CHAR_T_ONLY_ASCII
#undef CHAR_T
plptools-1.0.13/intl/locale.alias 0000644 0001750 0001750 00000005017 12417352631 013620 0000000 0000000 # Locale name alias data base.
# Copyright (C) 1996-2001,2003,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 2.1 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 .
# The format of this file is the same as for the corresponding file of
# the X Window System, which normally can be found in
# /usr/lib/X11/locale/locale.alias
# A single line contains two fields: an alias and a substitution value.
# All entries are case independent.
# Note: This file is obsolete and is kept around for the time being for
# backward compatibility. Nobody should rely on the names defined here.
# Locales should always be specified by their full name.
# Packages using this file:
bokmal nb_NO.ISO-8859-1
bokm�l nb_NO.ISO-8859-1
catalan ca_ES.ISO-8859-1
croatian hr_HR.ISO-8859-2
czech cs_CZ.ISO-8859-2
danish da_DK.ISO-8859-1
dansk da_DK.ISO-8859-1
deutsch de_DE.ISO-8859-1
dutch nl_NL.ISO-8859-1
eesti et_EE.ISO-8859-1
estonian et_EE.ISO-8859-1
finnish fi_FI.ISO-8859-1
fran�ais fr_FR.ISO-8859-1
french fr_FR.ISO-8859-1
galego gl_ES.ISO-8859-1
galician gl_ES.ISO-8859-1
german de_DE.ISO-8859-1
greek el_GR.ISO-8859-7
hebrew he_IL.ISO-8859-8
hrvatski hr_HR.ISO-8859-2
hungarian hu_HU.ISO-8859-2
icelandic is_IS.ISO-8859-1
italian it_IT.ISO-8859-1
japanese ja_JP.eucJP
japanese.euc ja_JP.eucJP
ja_JP ja_JP.eucJP
ja_JP.ujis ja_JP.eucJP
japanese.sjis ja_JP.SJIS
korean ko_KR.eucKR
korean.euc ko_KR.eucKR
ko_KR ko_KR.eucKR
lithuanian lt_LT.ISO-8859-13
no_NO nb_NO.ISO-8859-1
no_NO.ISO-8859-1 nb_NO.ISO-8859-1
norwegian nb_NO.ISO-8859-1
nynorsk nn_NO.ISO-8859-1
polish pl_PL.ISO-8859-2
portuguese pt_PT.ISO-8859-1
romanian ro_RO.ISO-8859-2
russian ru_RU.ISO-8859-5
slovak sk_SK.ISO-8859-2
slovene sl_SI.ISO-8859-2
slovenian sl_SI.ISO-8859-2
spanish es_ES.ISO-8859-1
swedish sv_SE.ISO-8859-1
thai th_TH.TIS-620
turkish tr_TR.ISO-8859-9
plptools-1.0.13/intl/ref-add.sin 0000644 0001750 0001750 00000002006 12417352631 013356 0000000 0000000 # 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.1 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 .
#
# Written by Bruno Haible .
#
/^# Packages using this file: / {
s/# Packages using this file://
ta
:a
s/ @PACKAGE@ / @PACKAGE@ /
tb
s/ $/ @PACKAGE@ /
:b
s/^/# Packages using this file:/
}
plptools-1.0.13/intl/version.c 0000644 0001750 0001750 00000001634 12417352631 013200 0000000 0000000 /* libintl library version.
Copyright (C) 2005 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "libgnuintl.h"
/* Version number: (major<<16) + (minor<<8) + subminor */
int libintl_version = LIBINTL_VERSION;
plptools-1.0.13/intl/localename.c 0000644 0001750 0001750 00000241314 12417352631 013614 0000000 0000000 /* Determine name of the currently selected locale.
Copyright (C) 1995-2012 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.1 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 . */
/* Written by Ulrich Drepper , 1995. */
/* Native Windows code written by Tor Lillqvist . */
/* Mac OS X code written by Bruno Haible . */
#include
/* Specification. */
#ifdef IN_LIBINTL
# include "gettextP.h"
#else
# include "localename.h"
#endif
#include
#include
#include
#include
#include
#if HAVE_USELOCALE
/* Mac OS X 10.5 defines the locale_t type in . */
# if defined __APPLE__ && defined __MACH__
# include
# endif
# include
# if !defined IN_LIBINTL
# include "glthread/lock.h"
# endif
#endif
#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
# include
# if HAVE_CFLOCALECOPYCURRENT
# include
# elif HAVE_CFPREFERENCESCOPYAPPVALUE
# include
# endif
#endif
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_NATIVE
#endif
#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
# define WIN32_LEAN_AND_MEAN
# include
/* List of language codes, sorted by value:
0x01 LANG_ARABIC
0x02 LANG_BULGARIAN
0x03 LANG_CATALAN
0x04 LANG_CHINESE
0x05 LANG_CZECH
0x06 LANG_DANISH
0x07 LANG_GERMAN
0x08 LANG_GREEK
0x09 LANG_ENGLISH
0x0a LANG_SPANISH
0x0b LANG_FINNISH
0x0c LANG_FRENCH
0x0d LANG_HEBREW
0x0e LANG_HUNGARIAN
0x0f LANG_ICELANDIC
0x10 LANG_ITALIAN
0x11 LANG_JAPANESE
0x12 LANG_KOREAN
0x13 LANG_DUTCH
0x14 LANG_NORWEGIAN
0x15 LANG_POLISH
0x16 LANG_PORTUGUESE
0x17 LANG_ROMANSH
0x18 LANG_ROMANIAN
0x19 LANG_RUSSIAN
0x1a LANG_CROATIAN == LANG_SERBIAN
0x1b LANG_SLOVAK
0x1c LANG_ALBANIAN
0x1d LANG_SWEDISH
0x1e LANG_THAI
0x1f LANG_TURKISH
0x20 LANG_URDU
0x21 LANG_INDONESIAN
0x22 LANG_UKRAINIAN
0x23 LANG_BELARUSIAN
0x24 LANG_SLOVENIAN
0x25 LANG_ESTONIAN
0x26 LANG_LATVIAN
0x27 LANG_LITHUANIAN
0x28 LANG_TAJIK
0x29 LANG_FARSI
0x2a LANG_VIETNAMESE
0x2b LANG_ARMENIAN
0x2c LANG_AZERI
0x2d LANG_BASQUE
0x2e LANG_SORBIAN
0x2f LANG_MACEDONIAN
0x30 LANG_SUTU
0x31 LANG_TSONGA
0x32 LANG_TSWANA
0x33 LANG_VENDA
0x34 LANG_XHOSA
0x35 LANG_ZULU
0x36 LANG_AFRIKAANS
0x37 LANG_GEORGIAN
0x38 LANG_FAEROESE
0x39 LANG_HINDI
0x3a LANG_MALTESE
0x3b LANG_SAMI
0x3c LANG_GAELIC
0x3d LANG_YIDDISH
0x3e LANG_MALAY
0x3f LANG_KAZAK
0x40 LANG_KYRGYZ
0x41 LANG_SWAHILI
0x42 LANG_TURKMEN
0x43 LANG_UZBEK
0x44 LANG_TATAR
0x45 LANG_BENGALI
0x46 LANG_PUNJABI
0x47 LANG_GUJARATI
0x48 LANG_ORIYA
0x49 LANG_TAMIL
0x4a LANG_TELUGU
0x4b LANG_KANNADA
0x4c LANG_MALAYALAM
0x4d LANG_ASSAMESE
0x4e LANG_MARATHI
0x4f LANG_SANSKRIT
0x50 LANG_MONGOLIAN
0x51 LANG_TIBETAN
0x52 LANG_WELSH
0x53 LANG_CAMBODIAN
0x54 LANG_LAO
0x55 LANG_BURMESE
0x56 LANG_GALICIAN
0x57 LANG_KONKANI
0x58 LANG_MANIPURI
0x59 LANG_SINDHI
0x5a LANG_SYRIAC
0x5b LANG_SINHALESE
0x5c LANG_CHEROKEE
0x5d LANG_INUKTITUT
0x5e LANG_AMHARIC
0x5f LANG_TAMAZIGHT
0x60 LANG_KASHMIRI
0x61 LANG_NEPALI
0x62 LANG_FRISIAN
0x63 LANG_PASHTO
0x64 LANG_TAGALOG
0x65 LANG_DIVEHI
0x66 LANG_EDO
0x67 LANG_FULFULDE
0x68 LANG_HAUSA
0x69 LANG_IBIBIO
0x6a LANG_YORUBA
0x6d LANG_BASHKIR
0x6e LANG_LUXEMBOURGISH
0x6f LANG_GREENLANDIC
0x70 LANG_IGBO
0x71 LANG_KANURI
0x72 LANG_OROMO
0x73 LANG_TIGRINYA
0x74 LANG_GUARANI
0x75 LANG_HAWAIIAN
0x76 LANG_LATIN
0x77 LANG_SOMALI
0x78 LANG_YI
0x79 LANG_PAPIAMENTU
0x7a LANG_MAPUDUNGUN
0x7c LANG_MOHAWK
0x7e LANG_BRETON
0x82 LANG_OCCITAN
0x83 LANG_CORSICAN
0x84 LANG_ALSATIAN
0x85 LANG_YAKUT
0x86 LANG_KICHE
0x87 LANG_KINYARWANDA
0x88 LANG_WOLOF
0x8c LANG_DARI
0x91 LANG_SCOTTISH_GAELIC
*/
/* Mingw headers don't have latest language and sublanguage codes. */
# ifndef LANG_AFRIKAANS
# define LANG_AFRIKAANS 0x36
# endif
# ifndef LANG_ALBANIAN
# define LANG_ALBANIAN 0x1c
# endif
# ifndef LANG_ALSATIAN
# define LANG_ALSATIAN 0x84
# endif
# ifndef LANG_AMHARIC
# define LANG_AMHARIC 0x5e
# endif
# ifndef LANG_ARABIC
# define LANG_ARABIC 0x01
# endif
# ifndef LANG_ARMENIAN
# define LANG_ARMENIAN 0x2b
# endif
# ifndef LANG_ASSAMESE
# define LANG_ASSAMESE 0x4d
# endif
# ifndef LANG_AZERI
# define LANG_AZERI 0x2c
# endif
# ifndef LANG_BASHKIR
# define LANG_BASHKIR 0x6d
# endif
# ifndef LANG_BASQUE
# define LANG_BASQUE 0x2d
# endif
# ifndef LANG_BELARUSIAN
# define LANG_BELARUSIAN 0x23
# endif
# ifndef LANG_BENGALI
# define LANG_BENGALI 0x45
# endif
# ifndef LANG_BRETON
# define LANG_BRETON 0x7e
# endif
# ifndef LANG_BURMESE
# define LANG_BURMESE 0x55
# endif
# ifndef LANG_CAMBODIAN
# define LANG_CAMBODIAN 0x53
# endif
# ifndef LANG_CATALAN
# define LANG_CATALAN 0x03
# endif
# ifndef LANG_CHEROKEE
# define LANG_CHEROKEE 0x5c
# endif
# ifndef LANG_CORSICAN
# define LANG_CORSICAN 0x83
# endif
# ifndef LANG_DARI
# define LANG_DARI 0x8c
# endif
# ifndef LANG_DIVEHI
# define LANG_DIVEHI 0x65
# endif
# ifndef LANG_EDO
# define LANG_EDO 0x66
# endif
# ifndef LANG_ESTONIAN
# define LANG_ESTONIAN 0x25
# endif
# ifndef LANG_FAEROESE
# define LANG_FAEROESE 0x38
# endif
# ifndef LANG_FARSI
# define LANG_FARSI 0x29
# endif
# ifndef LANG_FRISIAN
# define LANG_FRISIAN 0x62
# endif
# ifndef LANG_FULFULDE
# define LANG_FULFULDE 0x67
# endif
# ifndef LANG_GAELIC
# define LANG_GAELIC 0x3c
# endif
# ifndef LANG_GALICIAN
# define LANG_GALICIAN 0x56
# endif
# ifndef LANG_GEORGIAN
# define LANG_GEORGIAN 0x37
# endif
# ifndef LANG_GREENLANDIC
# define LANG_GREENLANDIC 0x6f
# endif
# ifndef LANG_GUARANI
# define LANG_GUARANI 0x74
# endif
# ifndef LANG_GUJARATI
# define LANG_GUJARATI 0x47
# endif
# ifndef LANG_HAUSA
# define LANG_HAUSA 0x68
# endif
# ifndef LANG_HAWAIIAN
# define LANG_HAWAIIAN 0x75
# endif
# ifndef LANG_HEBREW
# define LANG_HEBREW 0x0d
# endif
# ifndef LANG_HINDI
# define LANG_HINDI 0x39
# endif
# ifndef LANG_IBIBIO
# define LANG_IBIBIO 0x69
# endif
# ifndef LANG_IGBO
# define LANG_IGBO 0x70
# endif
# ifndef LANG_INDONESIAN
# define LANG_INDONESIAN 0x21
# endif
# ifndef LANG_INUKTITUT
# define LANG_INUKTITUT 0x5d
# endif
# ifndef LANG_KANNADA
# define LANG_KANNADA 0x4b
# endif
# ifndef LANG_KANURI
# define LANG_KANURI 0x71
# endif
# ifndef LANG_KASHMIRI
# define LANG_KASHMIRI 0x60
# endif
# ifndef LANG_KAZAK
# define LANG_KAZAK 0x3f
# endif
# ifndef LANG_KICHE
# define LANG_KICHE 0x86
# endif
# ifndef LANG_KINYARWANDA
# define LANG_KINYARWANDA 0x87
# endif
# ifndef LANG_KONKANI
# define LANG_KONKANI 0x57
# endif
# ifndef LANG_KYRGYZ
# define LANG_KYRGYZ 0x40
# endif
# ifndef LANG_LAO
# define LANG_LAO 0x54
# endif
# ifndef LANG_LATIN
# define LANG_LATIN 0x76
# endif
# ifndef LANG_LATVIAN
# define LANG_LATVIAN 0x26
# endif
# ifndef LANG_LITHUANIAN
# define LANG_LITHUANIAN 0x27
# endif
# ifndef LANG_LUXEMBOURGISH
# define LANG_LUXEMBOURGISH 0x6e
# endif
# ifndef LANG_MACEDONIAN
# define LANG_MACEDONIAN 0x2f
# endif
# ifndef LANG_MALAY
# define LANG_MALAY 0x3e
# endif
# ifndef LANG_MALAYALAM
# define LANG_MALAYALAM 0x4c
# endif
# ifndef LANG_MALTESE
# define LANG_MALTESE 0x3a
# endif
# ifndef LANG_MANIPURI
# define LANG_MANIPURI 0x58
# endif
# ifndef LANG_MAORI
# define LANG_MAORI 0x81
# endif
# ifndef LANG_MAPUDUNGUN
# define LANG_MAPUDUNGUN 0x7a
# endif
# ifndef LANG_MARATHI
# define LANG_MARATHI 0x4e
# endif
# ifndef LANG_MOHAWK
# define LANG_MOHAWK 0x7c
# endif
# ifndef LANG_MONGOLIAN
# define LANG_MONGOLIAN 0x50
# endif
# ifndef LANG_NEPALI
# define LANG_NEPALI 0x61
# endif
# ifndef LANG_OCCITAN
# define LANG_OCCITAN 0x82
# endif
# ifndef LANG_ORIYA
# define LANG_ORIYA 0x48
# endif
# ifndef LANG_OROMO
# define LANG_OROMO 0x72
# endif
# ifndef LANG_PAPIAMENTU
# define LANG_PAPIAMENTU 0x79
# endif
# ifndef LANG_PASHTO
# define LANG_PASHTO 0x63
# endif
# ifndef LANG_PUNJABI
# define LANG_PUNJABI 0x46
# endif
# ifndef LANG_QUECHUA
# define LANG_QUECHUA 0x6b
# endif
# ifndef LANG_ROMANSH
# define LANG_ROMANSH 0x17
# endif
# ifndef LANG_SAMI
# define LANG_SAMI 0x3b
# endif
# ifndef LANG_SANSKRIT
# define LANG_SANSKRIT 0x4f
# endif
# ifndef LANG_SCOTTISH_GAELIC
# define LANG_SCOTTISH_GAELIC 0x91
# endif
# ifndef LANG_SERBIAN
# define LANG_SERBIAN 0x1a
# endif
# ifndef LANG_SINDHI
# define LANG_SINDHI 0x59
# endif
# ifndef LANG_SINHALESE
# define LANG_SINHALESE 0x5b
# endif
# ifndef LANG_SLOVAK
# define LANG_SLOVAK 0x1b
# endif
# ifndef LANG_SOMALI
# define LANG_SOMALI 0x77
# endif
# ifndef LANG_SORBIAN
# define LANG_SORBIAN 0x2e
# endif
# ifndef LANG_SOTHO
# define LANG_SOTHO 0x6c
# endif
# ifndef LANG_SUTU
# define LANG_SUTU 0x30
# endif
# ifndef LANG_SWAHILI
# define LANG_SWAHILI 0x41
# endif
# ifndef LANG_SYRIAC
# define LANG_SYRIAC 0x5a
# endif
# ifndef LANG_TAGALOG
# define LANG_TAGALOG 0x64
# endif
# ifndef LANG_TAJIK
# define LANG_TAJIK 0x28
# endif
# ifndef LANG_TAMAZIGHT
# define LANG_TAMAZIGHT 0x5f
# endif
# ifndef LANG_TAMIL
# define LANG_TAMIL 0x49
# endif
# ifndef LANG_TATAR
# define LANG_TATAR 0x44
# endif
# ifndef LANG_TELUGU
# define LANG_TELUGU 0x4a
# endif
# ifndef LANG_THAI
# define LANG_THAI 0x1e
# endif
# ifndef LANG_TIBETAN
# define LANG_TIBETAN 0x51
# endif
# ifndef LANG_TIGRINYA
# define LANG_TIGRINYA 0x73
# endif
# ifndef LANG_TSONGA
# define LANG_TSONGA 0x31
# endif
# ifndef LANG_TSWANA
# define LANG_TSWANA 0x32
# endif
# ifndef LANG_TURKMEN
# define LANG_TURKMEN 0x42
# endif
# ifndef LANG_UIGHUR
# define LANG_UIGHUR 0x80
# endif
# ifndef LANG_UKRAINIAN
# define LANG_UKRAINIAN 0x22
# endif
# ifndef LANG_URDU
# define LANG_URDU 0x20
# endif
# ifndef LANG_UZBEK
# define LANG_UZBEK 0x43
# endif
# ifndef LANG_VENDA
# define LANG_VENDA 0x33
# endif
# ifndef LANG_VIETNAMESE
# define LANG_VIETNAMESE 0x2a
# endif
# ifndef LANG_WELSH
# define LANG_WELSH 0x52
# endif
# ifndef LANG_WOLOF
# define LANG_WOLOF 0x88
# endif
# ifndef LANG_XHOSA
# define LANG_XHOSA 0x34
# endif
# ifndef LANG_YAKUT
# define LANG_YAKUT 0x85
# endif
# ifndef LANG_YI
# define LANG_YI 0x78
# endif
# ifndef LANG_YIDDISH
# define LANG_YIDDISH 0x3d
# endif
# ifndef LANG_YORUBA
# define LANG_YORUBA 0x6a
# endif
# ifndef LANG_ZULU
# define LANG_ZULU 0x35
# endif
# ifndef SUBLANG_AFRIKAANS_SOUTH_AFRICA
# define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
# endif
# ifndef SUBLANG_ALBANIAN_ALBANIA
# define SUBLANG_ALBANIAN_ALBANIA 0x01
# endif
# ifndef SUBLANG_ALSATIAN_FRANCE
# define SUBLANG_ALSATIAN_FRANCE 0x01
# endif
# ifndef SUBLANG_AMHARIC_ETHIOPIA
# define SUBLANG_AMHARIC_ETHIOPIA 0x01
# endif
# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
# endif
# ifndef SUBLANG_ARABIC_IRAQ
# define SUBLANG_ARABIC_IRAQ 0x02
# endif
# ifndef SUBLANG_ARABIC_EGYPT
# define SUBLANG_ARABIC_EGYPT 0x03
# endif
# ifndef SUBLANG_ARABIC_LIBYA
# define SUBLANG_ARABIC_LIBYA 0x04
# endif
# ifndef SUBLANG_ARABIC_ALGERIA
# define SUBLANG_ARABIC_ALGERIA 0x05
# endif
# ifndef SUBLANG_ARABIC_MOROCCO
# define SUBLANG_ARABIC_MOROCCO 0x06
# endif
# ifndef SUBLANG_ARABIC_TUNISIA
# define SUBLANG_ARABIC_TUNISIA 0x07
# endif
# ifndef SUBLANG_ARABIC_OMAN
# define SUBLANG_ARABIC_OMAN 0x08
# endif
# ifndef SUBLANG_ARABIC_YEMEN
# define SUBLANG_ARABIC_YEMEN 0x09
# endif
# ifndef SUBLANG_ARABIC_SYRIA
# define SUBLANG_ARABIC_SYRIA 0x0a
# endif
# ifndef SUBLANG_ARABIC_JORDAN
# define SUBLANG_ARABIC_JORDAN 0x0b
# endif
# ifndef SUBLANG_ARABIC_LEBANON
# define SUBLANG_ARABIC_LEBANON 0x0c
# endif
# ifndef SUBLANG_ARABIC_KUWAIT
# define SUBLANG_ARABIC_KUWAIT 0x0d
# endif
# ifndef SUBLANG_ARABIC_UAE
# define SUBLANG_ARABIC_UAE 0x0e
# endif
# ifndef SUBLANG_ARABIC_BAHRAIN
# define SUBLANG_ARABIC_BAHRAIN 0x0f
# endif
# ifndef SUBLANG_ARABIC_QATAR
# define SUBLANG_ARABIC_QATAR 0x10
# endif
# ifndef SUBLANG_ARMENIAN_ARMENIA
# define SUBLANG_ARMENIAN_ARMENIA 0x01
# endif
# ifndef SUBLANG_ASSAMESE_INDIA
# define SUBLANG_ASSAMESE_INDIA 0x01
# endif
# ifndef SUBLANG_AZERI_LATIN
# define SUBLANG_AZERI_LATIN 0x01
# endif
# ifndef SUBLANG_AZERI_CYRILLIC
# define SUBLANG_AZERI_CYRILLIC 0x02
# endif
# ifndef SUBLANG_BASHKIR_RUSSIA
# define SUBLANG_BASHKIR_RUSSIA 0x01
# endif
# ifndef SUBLANG_BASQUE_BASQUE
# define SUBLANG_BASQUE_BASQUE 0x01
# endif
# ifndef SUBLANG_BELARUSIAN_BELARUS
# define SUBLANG_BELARUSIAN_BELARUS 0x01
# endif
# ifndef SUBLANG_BENGALI_INDIA
# define SUBLANG_BENGALI_INDIA 0x01
# endif
# ifndef SUBLANG_BENGALI_BANGLADESH
# define SUBLANG_BENGALI_BANGLADESH 0x02
# endif
# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
# endif
# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC
# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
# endif
# ifndef SUBLANG_BRETON_FRANCE
# define SUBLANG_BRETON_FRANCE 0x01
# endif
# ifndef SUBLANG_BULGARIAN_BULGARIA
# define SUBLANG_BULGARIAN_BULGARIA 0x01
# endif
# ifndef SUBLANG_CAMBODIAN_CAMBODIA
# define SUBLANG_CAMBODIAN_CAMBODIA 0x01
# endif
# ifndef SUBLANG_CATALAN_SPAIN
# define SUBLANG_CATALAN_SPAIN 0x01
# endif
# ifndef SUBLANG_CORSICAN_FRANCE
# define SUBLANG_CORSICAN_FRANCE 0x01
# endif
# ifndef SUBLANG_CROATIAN_CROATIA
# define SUBLANG_CROATIAN_CROATIA 0x01
# endif
# ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
# define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
# endif
# ifndef SUBLANG_CHINESE_MACAU
# define SUBLANG_CHINESE_MACAU 0x05
# endif
# ifndef SUBLANG_CZECH_CZECH_REPUBLIC
# define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
# endif
# ifndef SUBLANG_DANISH_DENMARK
# define SUBLANG_DANISH_DENMARK 0x01
# endif
# ifndef SUBLANG_DARI_AFGHANISTAN
# define SUBLANG_DARI_AFGHANISTAN 0x01
# endif
# ifndef SUBLANG_DIVEHI_MALDIVES
# define SUBLANG_DIVEHI_MALDIVES 0x01
# endif
# ifndef SUBLANG_DUTCH_SURINAM
# define SUBLANG_DUTCH_SURINAM 0x03
# endif
# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
# endif
# ifndef SUBLANG_ENGLISH_JAMAICA
# define SUBLANG_ENGLISH_JAMAICA 0x08
# endif
# ifndef SUBLANG_ENGLISH_CARIBBEAN
# define SUBLANG_ENGLISH_CARIBBEAN 0x09
# endif
# ifndef SUBLANG_ENGLISH_BELIZE
# define SUBLANG_ENGLISH_BELIZE 0x0a
# endif
# ifndef SUBLANG_ENGLISH_TRINIDAD
# define SUBLANG_ENGLISH_TRINIDAD 0x0b
# endif
# ifndef SUBLANG_ENGLISH_ZIMBABWE
# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
# endif
# ifndef SUBLANG_ENGLISH_PHILIPPINES
# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
# endif
# ifndef SUBLANG_ENGLISH_INDONESIA
# define SUBLANG_ENGLISH_INDONESIA 0x0e
# endif
# ifndef SUBLANG_ENGLISH_HONGKONG
# define SUBLANG_ENGLISH_HONGKONG 0x0f
# endif
# ifndef SUBLANG_ENGLISH_INDIA
# define SUBLANG_ENGLISH_INDIA 0x10
# endif
# ifndef SUBLANG_ENGLISH_MALAYSIA
# define SUBLANG_ENGLISH_MALAYSIA 0x11
# endif
# ifndef SUBLANG_ENGLISH_SINGAPORE
# define SUBLANG_ENGLISH_SINGAPORE 0x12
# endif
# ifndef SUBLANG_ESTONIAN_ESTONIA
# define SUBLANG_ESTONIAN_ESTONIA 0x01
# endif
# ifndef SUBLANG_FAEROESE_FAROE_ISLANDS
# define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
# endif
# ifndef SUBLANG_FARSI_IRAN
# define SUBLANG_FARSI_IRAN 0x01
# endif
# ifndef SUBLANG_FINNISH_FINLAND
# define SUBLANG_FINNISH_FINLAND 0x01
# endif
# ifndef SUBLANG_FRENCH_LUXEMBOURG
# define SUBLANG_FRENCH_LUXEMBOURG 0x05
# endif
# ifndef SUBLANG_FRENCH_MONACO
# define SUBLANG_FRENCH_MONACO 0x06
# endif
# ifndef SUBLANG_FRENCH_WESTINDIES
# define SUBLANG_FRENCH_WESTINDIES 0x07
# endif
# ifndef SUBLANG_FRENCH_REUNION
# define SUBLANG_FRENCH_REUNION 0x08
# endif
# ifndef SUBLANG_FRENCH_CONGO
# define SUBLANG_FRENCH_CONGO 0x09
# endif
# ifndef SUBLANG_FRENCH_SENEGAL
# define SUBLANG_FRENCH_SENEGAL 0x0a
# endif
# ifndef SUBLANG_FRENCH_CAMEROON
# define SUBLANG_FRENCH_CAMEROON 0x0b
# endif
# ifndef SUBLANG_FRENCH_COTEDIVOIRE
# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
# endif
# ifndef SUBLANG_FRENCH_MALI
# define SUBLANG_FRENCH_MALI 0x0d
# endif
# ifndef SUBLANG_FRENCH_MOROCCO
# define SUBLANG_FRENCH_MOROCCO 0x0e
# endif
# ifndef SUBLANG_FRENCH_HAITI
# define SUBLANG_FRENCH_HAITI 0x0f
# endif
# ifndef SUBLANG_FRISIAN_NETHERLANDS
# define SUBLANG_FRISIAN_NETHERLANDS 0x01
# endif
# ifndef SUBLANG_GALICIAN_SPAIN
# define SUBLANG_GALICIAN_SPAIN 0x01
# endif
# ifndef SUBLANG_GEORGIAN_GEORGIA
# define SUBLANG_GEORGIAN_GEORGIA 0x01
# endif
# ifndef SUBLANG_GERMAN_LUXEMBOURG
# define SUBLANG_GERMAN_LUXEMBOURG 0x04
# endif
# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
# endif
# ifndef SUBLANG_GREEK_GREECE
# define SUBLANG_GREEK_GREECE 0x01
# endif
# ifndef SUBLANG_GREENLANDIC_GREENLAND
# define SUBLANG_GREENLANDIC_GREENLAND 0x01
# endif
# ifndef SUBLANG_GUJARATI_INDIA
# define SUBLANG_GUJARATI_INDIA 0x01
# endif
# ifndef SUBLANG_HAUSA_NIGERIA_LATIN
# define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
# endif
# ifndef SUBLANG_HEBREW_ISRAEL
# define SUBLANG_HEBREW_ISRAEL 0x01
# endif
# ifndef SUBLANG_HINDI_INDIA
# define SUBLANG_HINDI_INDIA 0x01
# endif
# ifndef SUBLANG_HUNGARIAN_HUNGARY
# define SUBLANG_HUNGARIAN_HUNGARY 0x01
# endif
# ifndef SUBLANG_ICELANDIC_ICELAND
# define SUBLANG_ICELANDIC_ICELAND 0x01
# endif
# ifndef SUBLANG_IGBO_NIGERIA
# define SUBLANG_IGBO_NIGERIA 0x01
# endif
# ifndef SUBLANG_INDONESIAN_INDONESIA
# define SUBLANG_INDONESIAN_INDONESIA 0x01
# endif
# ifndef SUBLANG_INUKTITUT_CANADA
# define SUBLANG_INUKTITUT_CANADA 0x01
# endif
# undef SUBLANG_INUKTITUT_CANADA_LATIN
# define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
# undef SUBLANG_IRISH_IRELAND
# define SUBLANG_IRISH_IRELAND 0x02
# ifndef SUBLANG_JAPANESE_JAPAN
# define SUBLANG_JAPANESE_JAPAN 0x01
# endif
# ifndef SUBLANG_KANNADA_INDIA
# define SUBLANG_KANNADA_INDIA 0x01
# endif
# ifndef SUBLANG_KASHMIRI_INDIA
# define SUBLANG_KASHMIRI_INDIA 0x02
# endif
# ifndef SUBLANG_KAZAK_KAZAKHSTAN
# define SUBLANG_KAZAK_KAZAKHSTAN 0x01
# endif
# ifndef SUBLANG_KICHE_GUATEMALA
# define SUBLANG_KICHE_GUATEMALA 0x01
# endif
# ifndef SUBLANG_KINYARWANDA_RWANDA
# define SUBLANG_KINYARWANDA_RWANDA 0x01
# endif
# ifndef SUBLANG_KONKANI_INDIA
# define SUBLANG_KONKANI_INDIA 0x01
# endif
# ifndef SUBLANG_KYRGYZ_KYRGYZSTAN
# define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
# endif
# ifndef SUBLANG_LAO_LAOS
# define SUBLANG_LAO_LAOS 0x01
# endif
# ifndef SUBLANG_LATVIAN_LATVIA
# define SUBLANG_LATVIAN_LATVIA 0x01
# endif
# ifndef SUBLANG_LITHUANIAN_LITHUANIA
# define SUBLANG_LITHUANIAN_LITHUANIA 0x01
# endif
# undef SUBLANG_LOWER_SORBIAN_GERMANY
# define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
# ifndef SUBLANG_LUXEMBOURGISH_LUXEMBOURG
# define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
# endif
# ifndef SUBLANG_MACEDONIAN_MACEDONIA
# define SUBLANG_MACEDONIAN_MACEDONIA 0x01
# endif
# ifndef SUBLANG_MALAY_MALAYSIA
# define SUBLANG_MALAY_MALAYSIA 0x01
# endif
# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
# endif
# ifndef SUBLANG_MALAYALAM_INDIA
# define SUBLANG_MALAYALAM_INDIA 0x01
# endif
# ifndef SUBLANG_MALTESE_MALTA
# define SUBLANG_MALTESE_MALTA 0x01
# endif
# ifndef SUBLANG_MAORI_NEW_ZEALAND
# define SUBLANG_MAORI_NEW_ZEALAND 0x01
# endif
# ifndef SUBLANG_MAPUDUNGUN_CHILE
# define SUBLANG_MAPUDUNGUN_CHILE 0x01
# endif
# ifndef SUBLANG_MARATHI_INDIA
# define SUBLANG_MARATHI_INDIA 0x01
# endif
# ifndef SUBLANG_MOHAWK_CANADA
# define SUBLANG_MOHAWK_CANADA 0x01
# endif
# ifndef SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA
# define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
# endif
# ifndef SUBLANG_MONGOLIAN_PRC
# define SUBLANG_MONGOLIAN_PRC 0x02
# endif
# ifndef SUBLANG_NEPALI_NEPAL
# define SUBLANG_NEPALI_NEPAL 0x01
# endif
# ifndef SUBLANG_NEPALI_INDIA
# define SUBLANG_NEPALI_INDIA 0x02
# endif
# ifndef SUBLANG_OCCITAN_FRANCE
# define SUBLANG_OCCITAN_FRANCE 0x01
# endif
# ifndef SUBLANG_ORIYA_INDIA
# define SUBLANG_ORIYA_INDIA 0x01
# endif
# ifndef SUBLANG_PASHTO_AFGHANISTAN
# define SUBLANG_PASHTO_AFGHANISTAN 0x01
# endif
# ifndef SUBLANG_POLISH_POLAND
# define SUBLANG_POLISH_POLAND 0x01
# endif
# ifndef SUBLANG_PUNJABI_INDIA
# define SUBLANG_PUNJABI_INDIA 0x01
# endif
# ifndef SUBLANG_PUNJABI_PAKISTAN
# define SUBLANG_PUNJABI_PAKISTAN 0x02
# endif
# ifndef SUBLANG_QUECHUA_BOLIVIA
# define SUBLANG_QUECHUA_BOLIVIA 0x01
# endif
# ifndef SUBLANG_QUECHUA_ECUADOR
# define SUBLANG_QUECHUA_ECUADOR 0x02
# endif
# ifndef SUBLANG_QUECHUA_PERU
# define SUBLANG_QUECHUA_PERU 0x03
# endif
# ifndef SUBLANG_ROMANIAN_ROMANIA
# define SUBLANG_ROMANIAN_ROMANIA 0x01
# endif
# ifndef SUBLANG_ROMANIAN_MOLDOVA
# define SUBLANG_ROMANIAN_MOLDOVA 0x02
# endif
# ifndef SUBLANG_ROMANSH_SWITZERLAND
# define SUBLANG_ROMANSH_SWITZERLAND 0x01
# endif
# ifndef SUBLANG_RUSSIAN_RUSSIA
# define SUBLANG_RUSSIAN_RUSSIA 0x01
# endif
# ifndef SUBLANG_RUSSIAN_MOLDAVIA
# define SUBLANG_RUSSIAN_MOLDAVIA 0x02
# endif
# ifndef SUBLANG_SAMI_NORTHERN_NORWAY
# define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
# endif
# ifndef SUBLANG_SAMI_NORTHERN_SWEDEN
# define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
# endif
# ifndef SUBLANG_SAMI_NORTHERN_FINLAND
# define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
# endif
# ifndef SUBLANG_SAMI_LULE_NORWAY
# define SUBLANG_SAMI_LULE_NORWAY 0x04
# endif
# ifndef SUBLANG_SAMI_LULE_SWEDEN
# define SUBLANG_SAMI_LULE_SWEDEN 0x05
# endif
# ifndef SUBLANG_SAMI_SOUTHERN_NORWAY
# define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
# endif
# ifndef SUBLANG_SAMI_SOUTHERN_SWEDEN
# define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
# endif
# undef SUBLANG_SAMI_SKOLT_FINLAND
# define SUBLANG_SAMI_SKOLT_FINLAND 0x08
# undef SUBLANG_SAMI_INARI_FINLAND
# define SUBLANG_SAMI_INARI_FINLAND 0x09
# ifndef SUBLANG_SANSKRIT_INDIA
# define SUBLANG_SANSKRIT_INDIA 0x01
# endif
# ifndef SUBLANG_SERBIAN_LATIN
# define SUBLANG_SERBIAN_LATIN 0x02
# endif
# ifndef SUBLANG_SERBIAN_CYRILLIC
# define SUBLANG_SERBIAN_CYRILLIC 0x03
# endif
# ifndef SUBLANG_SINDHI_INDIA
# define SUBLANG_SINDHI_INDIA 0x01
# endif
# undef SUBLANG_SINDHI_PAKISTAN
# define SUBLANG_SINDHI_PAKISTAN 0x02
# ifndef SUBLANG_SINDHI_AFGHANISTAN
# define SUBLANG_SINDHI_AFGHANISTAN 0x02
# endif
# ifndef SUBLANG_SINHALESE_SRI_LANKA
# define SUBLANG_SINHALESE_SRI_LANKA 0x01
# endif
# ifndef SUBLANG_SLOVAK_SLOVAKIA
# define SUBLANG_SLOVAK_SLOVAKIA 0x01
# endif
# ifndef SUBLANG_SLOVENIAN_SLOVENIA
# define SUBLANG_SLOVENIAN_SLOVENIA 0x01
# endif
# ifndef SUBLANG_SOTHO_SOUTH_AFRICA
# define SUBLANG_SOTHO_SOUTH_AFRICA 0x01
# endif
# ifndef SUBLANG_SPANISH_GUATEMALA
# define SUBLANG_SPANISH_GUATEMALA 0x04
# endif
# ifndef SUBLANG_SPANISH_COSTA_RICA
# define SUBLANG_SPANISH_COSTA_RICA 0x05
# endif
# ifndef SUBLANG_SPANISH_PANAMA
# define SUBLANG_SPANISH_PANAMA 0x06
# endif
# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
# endif
# ifndef SUBLANG_SPANISH_VENEZUELA
# define SUBLANG_SPANISH_VENEZUELA 0x08
# endif
# ifndef SUBLANG_SPANISH_COLOMBIA
# define SUBLANG_SPANISH_COLOMBIA 0x09
# endif
# ifndef SUBLANG_SPANISH_PERU
# define SUBLANG_SPANISH_PERU 0x0a
# endif
# ifndef SUBLANG_SPANISH_ARGENTINA
# define SUBLANG_SPANISH_ARGENTINA 0x0b
# endif
# ifndef SUBLANG_SPANISH_ECUADOR
# define SUBLANG_SPANISH_ECUADOR 0x0c
# endif
# ifndef SUBLANG_SPANISH_CHILE
# define SUBLANG_SPANISH_CHILE 0x0d
# endif
# ifndef SUBLANG_SPANISH_URUGUAY
# define SUBLANG_SPANISH_URUGUAY 0x0e
# endif
# ifndef SUBLANG_SPANISH_PARAGUAY
# define SUBLANG_SPANISH_PARAGUAY 0x0f
# endif
# ifndef SUBLANG_SPANISH_BOLIVIA
# define SUBLANG_SPANISH_BOLIVIA 0x10
# endif
# ifndef SUBLANG_SPANISH_EL_SALVADOR
# define SUBLANG_SPANISH_EL_SALVADOR 0x11
# endif
# ifndef SUBLANG_SPANISH_HONDURAS
# define SUBLANG_SPANISH_HONDURAS 0x12
# endif
# ifndef SUBLANG_SPANISH_NICARAGUA
# define SUBLANG_SPANISH_NICARAGUA 0x13
# endif
# ifndef SUBLANG_SPANISH_PUERTO_RICO
# define SUBLANG_SPANISH_PUERTO_RICO 0x14
# endif
# ifndef SUBLANG_SPANISH_US
# define SUBLANG_SPANISH_US 0x15
# endif
# ifndef SUBLANG_SWAHILI_KENYA
# define SUBLANG_SWAHILI_KENYA 0x01
# endif
# ifndef SUBLANG_SWEDISH_SWEDEN
# define SUBLANG_SWEDISH_SWEDEN 0x01
# endif
# ifndef SUBLANG_SWEDISH_FINLAND
# define SUBLANG_SWEDISH_FINLAND 0x02
# endif
# ifndef SUBLANG_SYRIAC_SYRIA
# define SUBLANG_SYRIAC_SYRIA 0x01
# endif
# ifndef SUBLANG_TAGALOG_PHILIPPINES
# define SUBLANG_TAGALOG_PHILIPPINES 0x01
# endif
# ifndef SUBLANG_TAJIK_TAJIKISTAN
# define SUBLANG_TAJIK_TAJIKISTAN 0x01
# endif
# ifndef SUBLANG_TAMAZIGHT_ARABIC
# define SUBLANG_TAMAZIGHT_ARABIC 0x01
# endif
# ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN
# define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
# endif
# ifndef SUBLANG_TAMIL_INDIA
# define SUBLANG_TAMIL_INDIA 0x01
# endif
# ifndef SUBLANG_TATAR_RUSSIA
# define SUBLANG_TATAR_RUSSIA 0x01
# endif
# ifndef SUBLANG_TELUGU_INDIA
# define SUBLANG_TELUGU_INDIA 0x01
# endif
# ifndef SUBLANG_THAI_THAILAND
# define SUBLANG_THAI_THAILAND 0x01
# endif
# ifndef SUBLANG_TIBETAN_PRC
# define SUBLANG_TIBETAN_PRC 0x01
# endif
# undef SUBLANG_TIBETAN_BHUTAN
# define SUBLANG_TIBETAN_BHUTAN 0x02
# ifndef SUBLANG_TIGRINYA_ETHIOPIA
# define SUBLANG_TIGRINYA_ETHIOPIA 0x01
# endif
# ifndef SUBLANG_TIGRINYA_ERITREA
# define SUBLANG_TIGRINYA_ERITREA 0x02
# endif
# ifndef SUBLANG_TSWANA_SOUTH_AFRICA
# define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
# endif
# ifndef SUBLANG_TURKISH_TURKEY
# define SUBLANG_TURKISH_TURKEY 0x01
# endif
# ifndef SUBLANG_TURKMEN_TURKMENISTAN
# define SUBLANG_TURKMEN_TURKMENISTAN 0x01
# endif
# ifndef SUBLANG_UIGHUR_PRC
# define SUBLANG_UIGHUR_PRC 0x01
# endif
# ifndef SUBLANG_UKRAINIAN_UKRAINE
# define SUBLANG_UKRAINIAN_UKRAINE 0x01
# endif
# ifndef SUBLANG_UPPER_SORBIAN_GERMANY
# define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
# endif
# ifndef SUBLANG_URDU_PAKISTAN
# define SUBLANG_URDU_PAKISTAN 0x01
# endif
# ifndef SUBLANG_URDU_INDIA
# define SUBLANG_URDU_INDIA 0x02
# endif
# ifndef SUBLANG_UZBEK_LATIN
# define SUBLANG_UZBEK_LATIN 0x01
# endif
# ifndef SUBLANG_UZBEK_CYRILLIC
# define SUBLANG_UZBEK_CYRILLIC 0x02
# endif
# ifndef SUBLANG_VIETNAMESE_VIETNAM
# define SUBLANG_VIETNAMESE_VIETNAM 0x01
# endif
# ifndef SUBLANG_WELSH_UNITED_KINGDOM
# define SUBLANG_WELSH_UNITED_KINGDOM 0x01
# endif
# ifndef SUBLANG_WOLOF_SENEGAL
# define SUBLANG_WOLOF_SENEGAL 0x01
# endif
# ifndef SUBLANG_XHOSA_SOUTH_AFRICA
# define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
# endif
# ifndef SUBLANG_YAKUT_RUSSIA
# define SUBLANG_YAKUT_RUSSIA 0x01
# endif
# ifndef SUBLANG_YI_PRC
# define SUBLANG_YI_PRC 0x01
# endif
# ifndef SUBLANG_YORUBA_NIGERIA
# define SUBLANG_YORUBA_NIGERIA 0x01
# endif
# ifndef SUBLANG_ZULU_SOUTH_AFRICA
# define SUBLANG_ZULU_SOUTH_AFRICA 0x01
# endif
/* GetLocaleInfoA operations. */
# ifndef LOCALE_SNAME
# define LOCALE_SNAME 0x5c
# endif
#endif
#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
/* Mac OS X 10.2 or newer */
/* Canonicalize a Mac OS X locale name to a Unix locale name.
NAME is a sufficiently large buffer.
On input, it contains the Mac OS X locale name.
On output, it contains the Unix locale name. */
# if !defined IN_LIBINTL
static
# endif
void
gl_locale_name_canonicalize (char *name)
{
/* This conversion is based on a posting by
Deborah GoldSmith on 2005-03-08,
http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
/* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
ISO 3166) names. Prior to Mac OS X 10.3, there is no API for doing this.
Therefore we do it ourselves, using a table based on the results of the
Mac OS X 10.3.8 function
CFLocaleCreateCanonicalLocaleIdentifierFromString(). */
typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
legacy_entry;
static const legacy_entry legacy_table[] = {
{ "Afrikaans", "af" },
{ "Albanian", "sq" },
{ "Amharic", "am" },
{ "Arabic", "ar" },
{ "Armenian", "hy" },
{ "Assamese", "as" },
{ "Aymara", "ay" },
{ "Azerbaijani", "az" },
{ "Basque", "eu" },
{ "Belarusian", "be" },
{ "Belorussian", "be" },
{ "Bengali", "bn" },
{ "Brazilian Portugese", "pt_BR" },
{ "Brazilian Portuguese", "pt_BR" },
{ "Breton", "br" },
{ "Bulgarian", "bg" },
{ "Burmese", "my" },
{ "Byelorussian", "be" },
{ "Catalan", "ca" },
{ "Chewa", "ny" },
{ "Chichewa", "ny" },
{ "Chinese", "zh" },
{ "Chinese, Simplified", "zh_CN" },
{ "Chinese, Traditional", "zh_TW" },
{ "Chinese, Tradtional", "zh_TW" },
{ "Croatian", "hr" },
{ "Czech", "cs" },
{ "Danish", "da" },
{ "Dutch", "nl" },
{ "Dzongkha", "dz" },
{ "English", "en" },
{ "Esperanto", "eo" },
{ "Estonian", "et" },
{ "Faroese", "fo" },
{ "Farsi", "fa" },
{ "Finnish", "fi" },
{ "Flemish", "nl_BE" },
{ "French", "fr" },
{ "Galician", "gl" },
{ "Gallegan", "gl" },
{ "Georgian", "ka" },
{ "German", "de" },
{ "Greek", "el" },
{ "Greenlandic", "kl" },
{ "Guarani", "gn" },
{ "Gujarati", "gu" },
{ "Hawaiian", "haw" }, /* Yes, "haw", not "cpe". */
{ "Hebrew", "he" },
{ "Hindi", "hi" },
{ "Hungarian", "hu" },
{ "Icelandic", "is" },
{ "Indonesian", "id" },
{ "Inuktitut", "iu" },
{ "Irish", "ga" },
{ "Italian", "it" },
{ "Japanese", "ja" },
{ "Javanese", "jv" },
{ "Kalaallisut", "kl" },
{ "Kannada", "kn" },
{ "Kashmiri", "ks" },
{ "Kazakh", "kk" },
{ "Khmer", "km" },
{ "Kinyarwanda", "rw" },
{ "Kirghiz", "ky" },
{ "Korean", "ko" },
{ "Kurdish", "ku" },
{ "Latin", "la" },
{ "Latvian", "lv" },
{ "Lithuanian", "lt" },
{ "Macedonian", "mk" },
{ "Malagasy", "mg" },
{ "Malay", "ms" },
{ "Malayalam", "ml" },
{ "Maltese", "mt" },
{ "Manx", "gv" },
{ "Marathi", "mr" },
{ "Moldavian", "mo" },
{ "Mongolian", "mn" },
{ "Nepali", "ne" },
{ "Norwegian", "nb" }, /* Yes, "nb", not the obsolete "no". */
{ "Nyanja", "ny" },
{ "Nynorsk", "nn" },
{ "Oriya", "or" },
{ "Oromo", "om" },
{ "Panjabi", "pa" },
{ "Pashto", "ps" },
{ "Persian", "fa" },
{ "Polish", "pl" },
{ "Portuguese", "pt" },
{ "Portuguese, Brazilian", "pt_BR" },
{ "Punjabi", "pa" },
{ "Pushto", "ps" },
{ "Quechua", "qu" },
{ "Romanian", "ro" },
{ "Ruanda", "rw" },
{ "Rundi", "rn" },
{ "Russian", "ru" },
{ "Sami", "se_NO" }, /* Not just "se". */
{ "Sanskrit", "sa" },
{ "Scottish", "gd" },
{ "Serbian", "sr" },
{ "Simplified Chinese", "zh_CN" },
{ "Sindhi", "sd" },
{ "Sinhalese", "si" },
{ "Slovak", "sk" },
{ "Slovenian", "sl" },
{ "Somali", "so" },
{ "Spanish", "es" },
{ "Sundanese", "su" },
{ "Swahili", "sw" },
{ "Swedish", "sv" },
{ "Tagalog", "tl" },
{ "Tajik", "tg" },
{ "Tajiki", "tg" },
{ "Tamil", "ta" },
{ "Tatar", "tt" },
{ "Telugu", "te" },
{ "Thai", "th" },
{ "Tibetan", "bo" },
{ "Tigrinya", "ti" },
{ "Tongan", "to" },
{ "Traditional Chinese", "zh_TW" },
{ "Turkish", "tr" },
{ "Turkmen", "tk" },
{ "Uighur", "ug" },
{ "Ukrainian", "uk" },
{ "Urdu", "ur" },
{ "Uzbek", "uz" },
{ "Vietnamese", "vi" },
{ "Welsh", "cy" },
{ "Yiddish", "yi" }
};
/* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
to Unix (ISO 639 and ISO 3166) names. */
typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
langtag_entry;
static const langtag_entry langtag_table[] = {
/* Mac OS X has "az-Arab", "az-Cyrl", "az-Latn".
The default script for az on Unix is Latin. */
{ "az-Latn", "az" },
/* Mac OS X has "ga-dots". Does not yet exist on Unix. */
{ "ga-dots", "ga" },
/* Mac OS X has "kk-Cyrl". Does not yet exist on Unix. */
/* Mac OS X has "mn-Cyrl", "mn-Mong".
The default script for mn on Unix is Cyrillic. */
{ "mn-Cyrl", "mn" },
/* Mac OS X has "ms-Arab", "ms-Latn".
The default script for ms on Unix is Latin. */
{ "ms-Latn", "ms" },
/* Mac OS X has "tg-Cyrl".
The default script for tg on Unix is Cyrillic. */
{ "tg-Cyrl", "tg" },
/* Mac OS X has "tk-Cyrl". Does not yet exist on Unix. */
/* Mac OS X has "tt-Cyrl".
The default script for tt on Unix is Cyrillic. */
{ "tt-Cyrl", "tt" },
/* Mac OS X has "zh-Hans", "zh-Hant".
Country codes are used to distinguish these on Unix. */
{ "zh-Hans", "zh_CN" },
{ "zh-Hant", "zh_TW" }
};
/* Convert script names (ISO 15924) to Unix conventions.
See http://www.unicode.org/iso15924/iso15924-codes.html */
typedef struct { const char script[4+1]; const char unixy[9+1]; }
script_entry;
static const script_entry script_table[] = {
{ "Arab", "arabic" },
{ "Cyrl", "cyrillic" },
{ "Mong", "mongolian" }
};
/* Step 1: Convert using legacy_table. */
if (name[0] >= 'A' && name[0] <= 'Z')
{
unsigned int i1, i2;
i1 = 0;
i2 = sizeof (legacy_table) / sizeof (legacy_entry);
while (i2 - i1 > 1)
{
/* At this point we know that if name occurs in legacy_table,
its index must be >= i1 and < i2. */
unsigned int i = (i1 + i2) >> 1;
const legacy_entry *p = &legacy_table[i];
if (strcmp (name, p->legacy) < 0)
i2 = i;
else
i1 = i;
}
if (strcmp (name, legacy_table[i1].legacy) == 0)
{
strcpy (name, legacy_table[i1].unixy);
return;
}
}
/* Step 2: Convert using langtag_table and script_table. */
if (strlen (name) == 7 && name[2] == '-')
{
unsigned int i1, i2;
i1 = 0;
i2 = sizeof (langtag_table) / sizeof (langtag_entry);
while (i2 - i1 > 1)
{
/* At this point we know that if name occurs in langtag_table,
its index must be >= i1 and < i2. */
unsigned int i = (i1 + i2) >> 1;
const langtag_entry *p = &langtag_table[i];
if (strcmp (name, p->langtag) < 0)
i2 = i;
else
i1 = i;
}
if (strcmp (name, langtag_table[i1].langtag) == 0)
{
strcpy (name, langtag_table[i1].unixy);
return;
}
i1 = 0;
i2 = sizeof (script_table) / sizeof (script_entry);
while (i2 - i1 > 1)
{
/* At this point we know that if (name + 3) occurs in script_table,
its index must be >= i1 and < i2. */
unsigned int i = (i1 + i2) >> 1;
const script_entry *p = &script_table[i];
if (strcmp (name + 3, p->script) < 0)
i2 = i;
else
i1 = i;
}
if (strcmp (name + 3, script_table[i1].script) == 0)
{
name[2] = '@';
strcpy (name + 3, script_table[i1].unixy);
return;
}
}
/* Step 3: Convert new-style dash to Unix underscore. */
{
char *p;
for (p = name; *p != '\0'; p++)
if (*p == '-')
*p = '_';
}
}
#endif
#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
/* Canonicalize a Windows native locale name to a Unix locale name.
NAME is a sufficiently large buffer.
On input, it contains the Windows locale name.
On output, it contains the Unix locale name. */
# if !defined IN_LIBINTL
static
# endif
void
gl_locale_name_canonicalize (char *name)
{
/* FIXME: This is probably incomplete: it does not handle "zh-Hans" and
"zh-Hant". */
char *p;
for (p = name; *p != '\0'; p++)
if (*p == '-')
{
*p = '_';
p++;
for (; *p != '\0'; p++)
{
if (*p >= 'a' && *p <= 'z')
*p += 'A' - 'a';
if (*p == '-')
{
*p = '\0';
return;
}
}
return;
}
}
# if !defined IN_LIBINTL
static
# endif
const char *
gl_locale_name_from_win32_LANGID (LANGID langid)
{
/* Activate the new code only when the GETTEXT_MUI environment variable is
set, for the time being, since the new code is not well tested. */
if (getenv ("GETTEXT_MUI") != NULL)
{
static char namebuf[256];
/* Query the system's notion of locale name.
On Windows95/98/ME, GetLocaleInfoA returns some incorrect results.
But we don't need to support systems that are so old. */
if (GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), LOCALE_SNAME,
namebuf, sizeof (namebuf) - 1))
{
/* Convert it to a Unix locale name. */
gl_locale_name_canonicalize (namebuf);
return namebuf;
}
}
/* Internet Explorer has an LCID to RFC3066 name mapping stored in
HKEY_CLASSES_ROOT\Mime\Database\Rfc1766. But we better don't use that
since IE's i18n subsystem is known to be inconsistent with the native
Windows base (e.g. they have different character conversion facilities
that produce different results). */
/* Use our own table. */
{
int primary, sub;
/* Split into language and territory part. */
primary = PRIMARYLANGID (langid);
sub = SUBLANGID (langid);
/* Dispatch on language.
See also http://www.unicode.org/unicode/onlinedat/languages.html .
For details about languages, see http://www.ethnologue.com/ . */
switch (primary)
{
case LANG_AFRIKAANS:
switch (sub)
{
case SUBLANG_AFRIKAANS_SOUTH_AFRICA: return "af_ZA";
}
return "af";
case LANG_ALBANIAN:
switch (sub)
{
case SUBLANG_ALBANIAN_ALBANIA: return "sq_AL";
}
return "sq";
case LANG_ALSATIAN:
switch (sub)
{
case SUBLANG_ALSATIAN_FRANCE: return "gsw_FR";
}
return "gsw";
case LANG_AMHARIC:
switch (sub)
{
case SUBLANG_AMHARIC_ETHIOPIA: return "am_ET";
}
return "am";
case LANG_ARABIC:
switch (sub)
{
case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
case SUBLANG_ARABIC_EGYPT: return "ar_EG";
case SUBLANG_ARABIC_LIBYA: return "ar_LY";
case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
case SUBLANG_ARABIC_OMAN: return "ar_OM";
case SUBLANG_ARABIC_YEMEN: return "ar_YE";
case SUBLANG_ARABIC_SYRIA: return "ar_SY";
case SUBLANG_ARABIC_JORDAN: return "ar_JO";
case SUBLANG_ARABIC_LEBANON: return "ar_LB";
case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
case SUBLANG_ARABIC_UAE: return "ar_AE";
case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
case SUBLANG_ARABIC_QATAR: return "ar_QA";
}
return "ar";
case LANG_ARMENIAN:
switch (sub)
{
case SUBLANG_ARMENIAN_ARMENIA: return "hy_AM";
}
return "hy";
case LANG_ASSAMESE:
switch (sub)
{
case SUBLANG_ASSAMESE_INDIA: return "as_IN";
}
return "as";
case LANG_AZERI:
switch (sub)
{
/* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
case 0x1e: return "az@latin";
case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
case 0x1d: return "az@cyrillic";
case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
}
return "az";
case LANG_BASHKIR:
switch (sub)
{
case SUBLANG_BASHKIR_RUSSIA: return "ba_RU";
}
return "ba";
case LANG_BASQUE:
switch (sub)
{
case SUBLANG_BASQUE_BASQUE: return "eu_ES";
}
return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
case LANG_BELARUSIAN:
switch (sub)
{
case SUBLANG_BELARUSIAN_BELARUS: return "be_BY";
}
return "be";
case LANG_BENGALI:
switch (sub)
{
case SUBLANG_BENGALI_INDIA: return "bn_IN";
case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
}
return "bn";
case LANG_BRETON:
switch (sub)
{
case SUBLANG_BRETON_FRANCE: return "br_FR";
}
return "br";
case LANG_BULGARIAN:
switch (sub)
{
case SUBLANG_BULGARIAN_BULGARIA: return "bg_BG";
}
return "bg";
case LANG_BURMESE:
switch (sub)
{
case SUBLANG_DEFAULT: return "my_MM";
}
return "my";
case LANG_CAMBODIAN:
switch (sub)
{
case SUBLANG_CAMBODIAN_CAMBODIA: return "km_KH";
}
return "km";
case LANG_CATALAN:
switch (sub)
{
case SUBLANG_CATALAN_SPAIN: return "ca_ES";
}
return "ca";
case LANG_CHEROKEE:
switch (sub)
{
case SUBLANG_DEFAULT: return "chr_US";
}
return "chr";
case LANG_CHINESE:
switch (sub)
{
case SUBLANG_CHINESE_TRADITIONAL: case 0x1f: return "zh_TW";
case SUBLANG_CHINESE_SIMPLIFIED: case 0x00: return "zh_CN";
case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; /* traditional */
case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; /* simplified */
case SUBLANG_CHINESE_MACAU: return "zh_MO"; /* traditional */
}
return "zh";
case LANG_CORSICAN:
switch (sub)
{
case SUBLANG_CORSICAN_FRANCE: return "co_FR";
}
return "co";
case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN
* What used to be called Serbo-Croatian
* should really now be two separate
* languages because of political reasons.
* (Says tml, who knows nothing about Serbian
* or Croatian.)
* (I can feel those flames coming already.)
*/
switch (sub)
{
/* Croatian */
case 0x00: return "hr";
case SUBLANG_CROATIAN_CROATIA: return "hr_HR";
case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: return "hr_BA";
/* Serbian */
case 0x1f: return "sr";
case 0x1c: return "sr"; /* latin */
case SUBLANG_SERBIAN_LATIN: return "sr_CS"; /* latin */
case 0x09: return "sr_RS"; /* latin */
case 0x0b: return "sr_ME"; /* latin */
case 0x06: return "sr_BA"; /* latin */
case 0x1b: return "sr@cyrillic";
case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
case 0x0a: return "sr_RS@cyrillic";
case 0x0c: return "sr_ME@cyrillic";
case 0x07: return "sr_BA@cyrillic";
/* Bosnian */
case 0x1e: return "bs";
case 0x1a: return "bs"; /* latin */
case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: return "bs_BA"; /* latin */
case 0x19: return "bs@cyrillic";
case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: return "bs_BA@cyrillic";
}
return "hr";
case LANG_CZECH:
switch (sub)
{
case SUBLANG_CZECH_CZECH_REPUBLIC: return "cs_CZ";
}
return "cs";
case LANG_DANISH:
switch (sub)
{
case SUBLANG_DANISH_DENMARK: return "da_DK";
}
return "da";
case LANG_DARI:
/* FIXME: Adjust this when such locales appear on Unix. */
switch (sub)
{
case SUBLANG_DARI_AFGHANISTAN: return "prs_AF";
}
return "prs";
case LANG_DIVEHI:
switch (sub)
{
case SUBLANG_DIVEHI_MALDIVES: return "dv_MV";
}
return "dv";
case LANG_DUTCH:
switch (sub)
{
case SUBLANG_DUTCH: return "nl_NL";
case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
case SUBLANG_DUTCH_SURINAM: return "nl_SR";
}
return "nl";
case LANG_EDO:
switch (sub)
{
case SUBLANG_DEFAULT: return "bin_NG";
}
return "bin";
case LANG_ENGLISH:
switch (sub)
{
/* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
* English was the language spoken in England.
* Oh well.
*/
case SUBLANG_ENGLISH_US: return "en_US";
case SUBLANG_ENGLISH_UK: return "en_GB";
case SUBLANG_ENGLISH_AUS: return "en_AU";
case SUBLANG_ENGLISH_CAN: return "en_CA";
case SUBLANG_ENGLISH_NZ: return "en_NZ";
case SUBLANG_ENGLISH_EIRE: return "en_IE";
case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
case SUBLANG_ENGLISH_INDIA: return "en_IN";
case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
}
return "en";
case LANG_ESTONIAN:
switch (sub)
{
case SUBLANG_ESTONIAN_ESTONIA: return "et_EE";
}
return "et";
case LANG_FAEROESE:
switch (sub)
{
case SUBLANG_FAEROESE_FAROE_ISLANDS: return "fo_FO";
}
return "fo";
case LANG_FARSI:
switch (sub)
{
case SUBLANG_FARSI_IRAN: return "fa_IR";
}
return "fa";
case LANG_FINNISH:
switch (sub)
{
case SUBLANG_FINNISH_FINLAND: return "fi_FI";
}
return "fi";
case LANG_FRENCH:
switch (sub)
{
case SUBLANG_FRENCH: return "fr_FR";
case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
case SUBLANG_FRENCH_SWISS: return "fr_CH";
case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
case SUBLANG_FRENCH_MONACO: return "fr_MC";
case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
case SUBLANG_FRENCH_REUNION: return "fr_RE";
case SUBLANG_FRENCH_CONGO: return "fr_CG";
case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
case SUBLANG_FRENCH_MALI: return "fr_ML";
case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
case SUBLANG_FRENCH_HAITI: return "fr_HT";
}
return "fr";
case LANG_FRISIAN:
switch (sub)
{
case SUBLANG_FRISIAN_NETHERLANDS: return "fy_NL";
}
return "fy";
case LANG_FULFULDE:
/* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */
switch (sub)
{
case SUBLANG_DEFAULT: return "ff_NG";
}
return "ff";
case LANG_GAELIC:
switch (sub)
{
case 0x01: /* SCOTTISH */
/* old, superseded by LANG_SCOTTISH_GAELIC */
return "gd_GB";
case SUBLANG_IRISH_IRELAND: return "ga_IE";
}
return "ga";
case LANG_GALICIAN:
switch (sub)
{
case SUBLANG_GALICIAN_SPAIN: return "gl_ES";
}
return "gl";
case LANG_GEORGIAN:
switch (sub)
{
case SUBLANG_GEORGIAN_GEORGIA: return "ka_GE";
}
return "ka";
case LANG_GERMAN:
switch (sub)
{
case SUBLANG_GERMAN: return "de_DE";
case SUBLANG_GERMAN_SWISS: return "de_CH";
case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
}
return "de";
case LANG_GREEK:
switch (sub)
{
case SUBLANG_GREEK_GREECE: return "el_GR";
}
return "el";
case LANG_GREENLANDIC:
switch (sub)
{
case SUBLANG_GREENLANDIC_GREENLAND: return "kl_GL";
}
return "kl";
case LANG_GUARANI:
switch (sub)
{
case SUBLANG_DEFAULT: return "gn_PY";
}
return "gn";
case LANG_GUJARATI:
switch (sub)
{
case SUBLANG_GUJARATI_INDIA: return "gu_IN";
}
return "gu";
case LANG_HAUSA:
switch (sub)
{
case 0x1f: return "ha";
case SUBLANG_HAUSA_NIGERIA_LATIN: return "ha_NG";
}
return "ha";
case LANG_HAWAIIAN:
/* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
or Hawaii Creole English ("cpe_US", 600000 speakers)? */
switch (sub)
{
case SUBLANG_DEFAULT: return "cpe_US";
}
return "cpe";
case LANG_HEBREW:
switch (sub)
{
case SUBLANG_HEBREW_ISRAEL: return "he_IL";
}
return "he";
case LANG_HINDI:
switch (sub)
{
case SUBLANG_HINDI_INDIA: return "hi_IN";
}
return "hi";
case LANG_HUNGARIAN:
switch (sub)
{
case SUBLANG_HUNGARIAN_HUNGARY: return "hu_HU";
}
return "hu";
case LANG_IBIBIO:
switch (sub)
{
case SUBLANG_DEFAULT: return "nic_NG";
}
return "nic";
case LANG_ICELANDIC:
switch (sub)
{
case SUBLANG_ICELANDIC_ICELAND: return "is_IS";
}
return "is";
case LANG_IGBO:
switch (sub)
{
case SUBLANG_IGBO_NIGERIA: return "ig_NG";
}
return "ig";
case LANG_INDONESIAN:
switch (sub)
{
case SUBLANG_INDONESIAN_INDONESIA: return "id_ID";
}
return "id";
case LANG_INUKTITUT:
switch (sub)
{
case 0x1e: return "iu"; /* syllabic */
case SUBLANG_INUKTITUT_CANADA: return "iu_CA"; /* syllabic */
case 0x1f: return "iu@latin";
case SUBLANG_INUKTITUT_CANADA_LATIN: return "iu_CA@latin";
}
return "iu";
case LANG_ITALIAN:
switch (sub)
{
case SUBLANG_ITALIAN: return "it_IT";
case SUBLANG_ITALIAN_SWISS: return "it_CH";
}
return "it";
case LANG_JAPANESE:
switch (sub)
{
case SUBLANG_JAPANESE_JAPAN: return "ja_JP";
}
return "ja";
case LANG_KANNADA:
switch (sub)
{
case SUBLANG_KANNADA_INDIA: return "kn_IN";
}
return "kn";
case LANG_KANURI:
switch (sub)
{
case SUBLANG_DEFAULT: return "kr_NG";
}
return "kr";
case LANG_KASHMIRI:
switch (sub)
{
case SUBLANG_DEFAULT: return "ks_PK";
case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
}
return "ks";
case LANG_KAZAK:
switch (sub)
{
case SUBLANG_KAZAK_KAZAKHSTAN: return "kk_KZ";
}
return "kk";
case LANG_KICHE:
/* FIXME: Adjust this when such locales appear on Unix. */
switch (sub)
{
case SUBLANG_KICHE_GUATEMALA: return "qut_GT";
}
return "qut";
case LANG_KINYARWANDA:
switch (sub)
{
case SUBLANG_KINYARWANDA_RWANDA: return "rw_RW";
}
return "rw";
case LANG_KONKANI:
/* FIXME: Adjust this when such locales appear on Unix. */
switch (sub)
{
case SUBLANG_KONKANI_INDIA: return "kok_IN";
}
return "kok";
case LANG_KOREAN:
switch (sub)
{
case SUBLANG_DEFAULT: return "ko_KR";
}
return "ko";
case LANG_KYRGYZ:
switch (sub)
{
case SUBLANG_KYRGYZ_KYRGYZSTAN: return "ky_KG";
}
return "ky";
case LANG_LAO:
switch (sub)
{
case SUBLANG_LAO_LAOS: return "lo_LA";
}
return "lo";
case LANG_LATIN:
switch (sub)
{
case SUBLANG_DEFAULT: return "la_VA";
}
return "la";
case LANG_LATVIAN:
switch (sub)
{
case SUBLANG_LATVIAN_LATVIA: return "lv_LV";
}
return "lv";
case LANG_LITHUANIAN:
switch (sub)
{
case SUBLANG_LITHUANIAN_LITHUANIA: return "lt_LT";
}
return "lt";
case LANG_LUXEMBOURGISH:
switch (sub)
{
case SUBLANG_LUXEMBOURGISH_LUXEMBOURG: return "lb_LU";
}
return "lb";
case LANG_MACEDONIAN:
switch (sub)
{
case SUBLANG_MACEDONIAN_MACEDONIA: return "mk_MK";
}
return "mk";
case LANG_MALAY:
switch (sub)
{
case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
}
return "ms";
case LANG_MALAYALAM:
switch (sub)
{
case SUBLANG_MALAYALAM_INDIA: return "ml_IN";
}
return "ml";
case LANG_MALTESE:
switch (sub)
{
case SUBLANG_MALTESE_MALTA: return "mt_MT";
}
return "mt";
case LANG_MANIPURI:
/* FIXME: Adjust this when such locales appear on Unix. */
switch (sub)
{
case SUBLANG_DEFAULT: return "mni_IN";
}
return "mni";
case LANG_MAORI:
switch (sub)
{
case SUBLANG_MAORI_NEW_ZEALAND: return "mi_NZ";
}
return "mi";
case LANG_MAPUDUNGUN:
switch (sub)
{
case SUBLANG_MAPUDUNGUN_CHILE: return "arn_CL";
}
return "arn";
case LANG_MARATHI:
switch (sub)
{
case SUBLANG_MARATHI_INDIA: return "mr_IN";
}
return "mr";
case LANG_MOHAWK:
switch (sub)
{
case SUBLANG_MOHAWK_CANADA: return "moh_CA";
}
return "moh";
case LANG_MONGOLIAN:
switch (sub)
{
case SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: case 0x1e: return "mn_MN";
case SUBLANG_MONGOLIAN_PRC: case 0x1f: return "mn_CN";
}
return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
case LANG_NEPALI:
switch (sub)
{
case SUBLANG_NEPALI_NEPAL: return "ne_NP";
case SUBLANG_NEPALI_INDIA: return "ne_IN";
}
return "ne";
case LANG_NORWEGIAN:
switch (sub)
{
case 0x1f: return "nb";
case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO";
case 0x1e: return "nn";
case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
}
return "no";
case LANG_OCCITAN:
switch (sub)
{
case SUBLANG_OCCITAN_FRANCE: return "oc_FR";
}
return "oc";
case LANG_ORIYA:
switch (sub)
{
case SUBLANG_ORIYA_INDIA: return "or_IN";
}
return "or";
case LANG_OROMO:
switch (sub)
{
case SUBLANG_DEFAULT: return "om_ET";
}
return "om";
case LANG_PAPIAMENTU:
switch (sub)
{
case SUBLANG_DEFAULT: return "pap_AN";
}
return "pap";
case LANG_PASHTO:
switch (sub)
{
case SUBLANG_PASHTO_AFGHANISTAN: return "ps_AF";
}
return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
case LANG_POLISH:
switch (sub)
{
case SUBLANG_POLISH_POLAND: return "pl_PL";
}
return "pl";
case LANG_PORTUGUESE:
switch (sub)
{
/* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
case SUBLANG_PORTUGUESE: return "pt_PT";
}
return "pt";
case LANG_PUNJABI:
switch (sub)
{
case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
}
return "pa";
case LANG_QUECHUA:
/* Note: Microsoft uses the non-ISO language code "quz". */
switch (sub)
{
case SUBLANG_QUECHUA_BOLIVIA: return "qu_BO";
case SUBLANG_QUECHUA_ECUADOR: return "qu_EC";
case SUBLANG_QUECHUA_PERU: return "qu_PE";
}
return "qu";
case LANG_ROMANIAN:
switch (sub)
{
case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
}
return "ro";
case LANG_ROMANSH:
switch (sub)
{
case SUBLANG_ROMANSH_SWITZERLAND: return "rm_CH";
}
return "rm";
case LANG_RUSSIAN:
switch (sub)
{
case SUBLANG_RUSSIAN_RUSSIA: return "ru_RU";
case SUBLANG_RUSSIAN_MOLDAVIA: return "ru_MD";
}
return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
case LANG_SAMI:
switch (sub)
{
/* Northern Sami */
case 0x00: return "se";
case SUBLANG_SAMI_NORTHERN_NORWAY: return "se_NO";
case SUBLANG_SAMI_NORTHERN_SWEDEN: return "se_SE";
case SUBLANG_SAMI_NORTHERN_FINLAND: return "se_FI";
/* Lule Sami */
case 0x1f: return "smj";
case SUBLANG_SAMI_LULE_NORWAY: return "smj_NO";
case SUBLANG_SAMI_LULE_SWEDEN: return "smj_SE";
/* Southern Sami */
case 0x1e: return "sma";
case SUBLANG_SAMI_SOUTHERN_NORWAY: return "sma_NO";
case SUBLANG_SAMI_SOUTHERN_SWEDEN: return "sma_SE";
/* Skolt Sami */
case 0x1d: return "sms";
case SUBLANG_SAMI_SKOLT_FINLAND: return "sms_FI";
/* Inari Sami */
case 0x1c: return "smn";
case SUBLANG_SAMI_INARI_FINLAND: return "smn_FI";
}
return "se"; /* or "smi"? */
case LANG_SANSKRIT:
switch (sub)
{
case SUBLANG_SANSKRIT_INDIA: return "sa_IN";
}
return "sa";
case LANG_SCOTTISH_GAELIC:
switch (sub)
{
case SUBLANG_DEFAULT: return "gd_GB";
}
return "gd";
case LANG_SINDHI:
switch (sub)
{
case SUBLANG_SINDHI_INDIA: return "sd_IN";
case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
/*case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF";*/
}
return "sd";
case LANG_SINHALESE:
switch (sub)
{
case SUBLANG_SINHALESE_SRI_LANKA: return "si_LK";
}
return "si";
case LANG_SLOVAK:
switch (sub)
{
case SUBLANG_SLOVAK_SLOVAKIA: return "sk_SK";
}
return "sk";
case LANG_SLOVENIAN:
switch (sub)
{
case SUBLANG_SLOVENIAN_SLOVENIA: return "sl_SI";
}
return "sl";
case LANG_SOMALI:
switch (sub)
{
case SUBLANG_DEFAULT: return "so_SO";
}
return "so";
case LANG_SORBIAN:
/* FIXME: Adjust this when such locales appear on Unix. */
switch (sub)
{
/* Upper Sorbian */
case 0x00: return "hsb";
case SUBLANG_UPPER_SORBIAN_GERMANY: return "hsb_DE";
/* Lower Sorbian */
case 0x1f: return "dsb";
case SUBLANG_LOWER_SORBIAN_GERMANY: return "dsb_DE";
}
return "wen";
case LANG_SOTHO:
/* calls
it "Sepedi"; according to
it's the same as Northern Sotho. */
switch (sub)
{
case SUBLANG_SOTHO_SOUTH_AFRICA: return "nso_ZA";
}
return "nso";
case LANG_SPANISH:
switch (sub)
{
case SUBLANG_SPANISH: return "es_ES";
case SUBLANG_SPANISH_MEXICAN: return "es_MX";
case SUBLANG_SPANISH_MODERN:
return "es_ES@modern"; /* not seen on Unix */
case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
case SUBLANG_SPANISH_PANAMA: return "es_PA";
case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
case SUBLANG_SPANISH_PERU: return "es_PE";
case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
case SUBLANG_SPANISH_ECUADOR: return "es_EC";
case SUBLANG_SPANISH_CHILE: return "es_CL";
case SUBLANG_SPANISH_URUGUAY: return "es_UY";
case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
case SUBLANG_SPANISH_HONDURAS: return "es_HN";
case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
case SUBLANG_SPANISH_US: return "es_US";
}
return "es";
case LANG_SUTU:
switch (sub)
{
case SUBLANG_DEFAULT: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
}
return "bnt";
case LANG_SWAHILI:
switch (sub)
{
case SUBLANG_SWAHILI_KENYA: return "sw_KE";
}
return "sw";
case LANG_SWEDISH:
switch (sub)
{
case SUBLANG_SWEDISH_SWEDEN: return "sv_SE";
case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
}
return "sv";
case LANG_SYRIAC:
switch (sub)
{
case SUBLANG_SYRIAC_SYRIA: return "syr_SY"; /* An extinct language. */
}
return "syr";
case LANG_TAGALOG:
switch (sub)
{
case SUBLANG_TAGALOG_PHILIPPINES: return "tl_PH"; /* or "fil_PH"? */
}
return "tl"; /* or "fil"? */
case LANG_TAJIK:
switch (sub)
{
case 0x1f: return "tg";
case SUBLANG_TAJIK_TAJIKISTAN: return "tg_TJ";
}
return "tg";
case LANG_TAMAZIGHT:
/* Note: Microsoft uses the non-ISO language code "tmz". */
switch (sub)
{
/* FIXME: Adjust this when Tamazight locales appear on Unix. */
case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
case 0x1f: return "ber@latin";
case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin";
}
return "ber";
case LANG_TAMIL:
switch (sub)
{
case SUBLANG_TAMIL_INDIA: return "ta_IN";
}
return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
case LANG_TATAR:
switch (sub)
{
case SUBLANG_TATAR_RUSSIA: return "tt_RU";
}
return "tt";
case LANG_TELUGU:
switch (sub)
{
case SUBLANG_TELUGU_INDIA: return "te_IN";
}
return "te";
case LANG_THAI:
switch (sub)
{
case SUBLANG_THAI_THAILAND: return "th_TH";
}
return "th";
case LANG_TIBETAN:
switch (sub)
{
case SUBLANG_TIBETAN_PRC:
/* Most Tibetans would not like "bo_CN". But Tibet does not yet
have a country code of its own. */
return "bo";
case SUBLANG_TIBETAN_BHUTAN: return "bo_BT";
}
return "bo";
case LANG_TIGRINYA:
switch (sub)
{
case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
}
return "ti";
case LANG_TSONGA:
switch (sub)
{
case SUBLANG_DEFAULT: return "ts_ZA";
}
return "ts";
case LANG_TSWANA:
/* Spoken in South Africa, Botswana. */
switch (sub)
{
case SUBLANG_TSWANA_SOUTH_AFRICA: return "tn_ZA";
}
return "tn";
case LANG_TURKISH:
switch (sub)
{
case SUBLANG_TURKISH_TURKEY: return "tr_TR";
}
return "tr";
case LANG_TURKMEN:
switch (sub)
{
case SUBLANG_TURKMEN_TURKMENISTAN: return "tk_TM";
}
return "tk";
case LANG_UIGHUR:
switch (sub)
{
case SUBLANG_UIGHUR_PRC: return "ug_CN";
}
return "ug";
case LANG_UKRAINIAN:
switch (sub)
{
case SUBLANG_UKRAINIAN_UKRAINE: return "uk_UA";
}
return "uk";
case LANG_URDU:
switch (sub)
{
case SUBLANG_URDU_PAKISTAN: return "ur_PK";
case SUBLANG_URDU_INDIA: return "ur_IN";
}
return "ur";
case LANG_UZBEK:
switch (sub)
{
case 0x1f: return "uz";
case SUBLANG_UZBEK_LATIN: return "uz_UZ";
case 0x1e: return "uz@cyrillic";
case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
}
return "uz";
case LANG_VENDA:
switch (sub)
{
case SUBLANG_DEFAULT: return "ve_ZA";
}
return "ve";
case LANG_VIETNAMESE:
switch (sub)
{
case SUBLANG_VIETNAMESE_VIETNAM: return "vi_VN";
}
return "vi";
case LANG_WELSH:
switch (sub)
{
case SUBLANG_WELSH_UNITED_KINGDOM: return "cy_GB";
}
return "cy";
case LANG_WOLOF:
switch (sub)
{
case SUBLANG_WOLOF_SENEGAL: return "wo_SN";
}
return "wo";
case LANG_XHOSA:
switch (sub)
{
case SUBLANG_XHOSA_SOUTH_AFRICA: return "xh_ZA";
}
return "xh";
case LANG_YAKUT:
switch (sub)
{
case SUBLANG_YAKUT_RUSSIA: return "sah_RU";
}
return "sah";
case LANG_YI:
switch (sub)
{
case SUBLANG_YI_PRC: return "ii_CN";
}
return "ii";
case LANG_YIDDISH:
switch (sub)
{
case SUBLANG_DEFAULT: return "yi_IL";
}
return "yi";
case LANG_YORUBA:
switch (sub)
{
case SUBLANG_YORUBA_NIGERIA: return "yo_NG";
}
return "yo";
case LANG_ZULU:
switch (sub)
{
case SUBLANG_ZULU_SOUTH_AFRICA: return "zu_ZA";
}
return "zu";
default: return "C";
}
}
}
# if !defined IN_LIBINTL
static
# endif
const char *
gl_locale_name_from_win32_LCID (LCID lcid)
{
LANGID langid;
/* Strip off the sorting rules, keep only the language part. */
langid = LANGIDFROMLCID (lcid);
return gl_locale_name_from_win32_LANGID (langid);
}
#endif
#if HAVE_USELOCALE /* glibc or Mac OS X */
/* Simple hash set of strings. We don't want to drag in lots of hash table
code here. */
# define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
/* A hash function for NUL-terminated char* strings using
the method described by Bruno Haible.
See http://www.haible.de/bruno/hashfunc.html. */
static size_t
string_hash (const void *x)
{
const char *s = (const char *) x;
size_t h = 0;
for (; *s; s++)
h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
return h;
}
/* A hash table of fixed size. Multiple threads can access it read-only
simultaneously, but only one thread can insert into it at the same time. */
/* A node in a hash bucket collision list. */
struct hash_node
{
struct hash_node * volatile next;
char contents[100]; /* has variable size */
};
# define HASH_TABLE_SIZE 257
static struct hash_node * volatile struniq_hash_table[HASH_TABLE_SIZE]
/* = { NULL, ..., NULL } */;
/* This lock protects the struniq_hash_table against multiple simultaneous
insertions. */
gl_lock_define_initialized(static, struniq_lock)
/* Store a copy of the given string in a string pool with indefinite extent.
Return a pointer to this copy. */
static const char *
struniq (const char *string)
{
size_t hashcode = string_hash (string);
size_t slot = hashcode % HASH_TABLE_SIZE;
size_t size;
struct hash_node *new_node;
struct hash_node *p;
for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
if (strcmp (p->contents, string) == 0)
return p->contents;
size = strlen (string) + 1;
new_node =
(struct hash_node *)
malloc (offsetof (struct hash_node, contents[0]) + size);
if (new_node == NULL)
/* Out of memory. Return a statically allocated string. */
return "C";
memcpy (new_node->contents, string, size);
/* Lock while inserting new_node. */
gl_lock_lock (struniq_lock);
/* Check whether another thread already added the string while we were
waiting on the lock. */
for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
if (strcmp (p->contents, string) == 0)
{
free (new_node);
new_node = p;
goto done;
}
/* Really insert new_node into the hash table. Fill new_node entirely first,
because other threads may be iterating over the linked list. */
new_node->next = struniq_hash_table[slot];
struniq_hash_table[slot] = new_node;
done:
/* Unlock after new_node is inserted. */
gl_lock_unlock (struniq_lock);
return new_node->contents;
}
#endif
#if defined IN_LIBINTL || HAVE_USELOCALE
/* Like gl_locale_name_thread, except that the result is not in storage of
indefinite extent. */
# if !defined IN_LIBINTL
static
# endif
const char *
gl_locale_name_thread_unsafe (int category, const char *categoryname)
{
# if HAVE_USELOCALE
{
locale_t thread_locale = uselocale (NULL);
if (thread_locale != LC_GLOBAL_LOCALE)
{
# if __GLIBC__ >= 2 && !defined __UCLIBC__
/* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
glibc < 2.12.
See . */
const char *name =
nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
if (name[0] == '\0')
/* Fallback code for glibc < 2.4, which did not implement
nl_langinfo (_NL_LOCALE_NAME (category)). */
name = thread_locale->__names[category];
return name;
# elif defined __FreeBSD__ || (defined __APPLE__ && defined __MACH__)
/* FreeBSD, Mac OS X */
int mask;
switch (category)
{
case LC_CTYPE:
mask = LC_CTYPE_MASK;
break;
case LC_NUMERIC:
mask = LC_NUMERIC_MASK;
break;
case LC_TIME:
mask = LC_TIME_MASK;
break;
case LC_COLLATE:
mask = LC_COLLATE_MASK;
break;
case LC_MONETARY:
mask = LC_MONETARY_MASK;
break;
case LC_MESSAGES:
mask = LC_MESSAGES_MASK;
break;
default: /* We shouldn't get here. */
return "";
}
return querylocale (mask, thread_locale);
# endif
}
}
# endif
return NULL;
}
#endif
const char *
gl_locale_name_thread (int category, const char *categoryname)
{
#if HAVE_USELOCALE
const char *name = gl_locale_name_thread_unsafe (category, categoryname);
if (name != NULL)
return struniq (name);
#endif
return NULL;
}
/* XPG3 defines the result of 'setlocale (category, NULL)' as:
"Directs 'setlocale()' to query 'category' and return the current
setting of 'local'."
However it does not specify the exact format. Neither do SUSV2 and
ISO C 99. So we can use this feature only on selected systems (e.g.
those using GNU C Library). */
#if defined _LIBC || ((defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__)
# define HAVE_LOCALE_NULL
#endif
const char *
gl_locale_name_posix (int category, const char *categoryname)
{
/* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
On some systems this can be done by the 'setlocale' function itself. */
#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
return setlocale (category, NULL);
#else
/* On other systems we ignore what setlocale reports and instead look at the
environment variables directly. This is necessary
1. on systems which have a facility for customizing the default locale
(Mac OS X, native Windows, Cygwin) and where the system's setlocale()
function ignores this default locale (Mac OS X, Cygwin), in two cases:
a. when the user missed to use the setlocale() override from libintl
(for example by not including ),
b. when setlocale supports only the "C" locale, such as on Cygwin
1.5.x. In this case even the override from libintl cannot help.
2. on all systems where setlocale supports only the "C" locale. */
/* Strictly speaking, it is a POSIX violation to look at the environment
variables regardless whether setlocale has been called or not. POSIX
says:
"For C-language programs, the POSIX locale shall be the
default locale when the setlocale() function is not called."
But we assume that all programs that use internationalized APIs call
setlocale (LC_ALL, ""). */
return gl_locale_name_environ (category, categoryname);
#endif
}
const char *
gl_locale_name_environ (int category, const char *categoryname)
{
const char *retval;
/* Setting of LC_ALL overrides all other. */
retval = getenv ("LC_ALL");
if (retval != NULL && retval[0] != '\0')
return retval;
/* Next comes the name of the desired category. */
retval = getenv (categoryname);
if (retval != NULL && retval[0] != '\0')
return retval;
/* Last possibility is the LANG environment variable. */
retval = getenv ("LANG");
if (retval != NULL && retval[0] != '\0')
{
#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
/* Mac OS X 10.2 or newer.
Ignore invalid LANG value set by the Terminal application. */
if (strcmp (retval, "UTF-8") != 0)
#endif
#if defined __CYGWIN__
/* Cygwin.
Ignore dummy LANG value set by ~/.profile. */
if (strcmp (retval, "C.UTF-8") != 0)
#endif
return retval;
}
return NULL;
}
const char *
gl_locale_name_default (void)
{
/* POSIX:2001 says:
"All implementations shall define a locale as the default locale, to be
invoked when no environment variables are set, or set to the empty
string. This default locale can be the POSIX locale or any other
implementation-defined locale. Some implementations may provide
facilities for local installation administrators to set the default
locale, customizing it for each location. POSIX:2001 does not require
such a facility.
The systems with such a facility are Mac OS X and Windows: They provide a
GUI that allows the user to choose a locale.
- On Mac OS X, by default, none of LC_* or LANG are set. Starting with
Mac OS X 10.4 or 10.5, LANG is set for processes launched by the
'Terminal' application (but sometimes to an incorrect value "UTF-8").
When no environment variable is set, setlocale (LC_ALL, "") uses the
"C" locale.
- On native Windows, by default, none of LC_* or LANG are set.
When no environment variable is set, setlocale (LC_ALL, "") uses the
locale chosen by the user.
- On Cygwin 1.5.x, by default, none of LC_* or LANG are set.
When no environment variable is set, setlocale (LC_ALL, "") uses the
"C" locale.
- On Cygwin 1.7, by default, LANG is set to "C.UTF-8" when the default
~/.profile is executed.
When no environment variable is set, setlocale (LC_ALL, "") uses the
"C.UTF-8" locale, which operates in the same way as the "C" locale.
*/
#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined WINDOWS_NATIVE || defined __CYGWIN__)
/* The system does not have a way of setting the locale, other than the
POSIX specified environment variables. We use C as default locale. */
return "C";
#else
/* Return an XPG style locale name language[_territory][@modifier].
Don't even bother determining the codeset; it's not useful in this
context, because message catalogs are not specific to a single
codeset. */
# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
/* Mac OS X 10.2 or newer */
{
/* Cache the locale name, since CoreFoundation calls are expensive. */
static const char *cached_localename;
if (cached_localename == NULL)
{
char namebuf[256];
# if HAVE_CFLOCALECOPYCURRENT /* Mac OS X 10.3 or newer */
CFLocaleRef locale = CFLocaleCopyCurrent ();
CFStringRef name = CFLocaleGetIdentifier (locale);
if (CFStringGetCString (name, namebuf, sizeof (namebuf),
kCFStringEncodingASCII))
{
gl_locale_name_canonicalize (namebuf);
cached_localename = strdup (namebuf);
}
CFRelease (locale);
# elif HAVE_CFPREFERENCESCOPYAPPVALUE /* Mac OS X 10.2 or newer */
CFTypeRef value =
CFPreferencesCopyAppValue (CFSTR ("AppleLocale"),
kCFPreferencesCurrentApplication);
if (value != NULL
&& CFGetTypeID (value) == CFStringGetTypeID ()
&& CFStringGetCString ((CFStringRef)value,
namebuf, sizeof (namebuf),
kCFStringEncodingASCII))
{
gl_locale_name_canonicalize (namebuf);
cached_localename = strdup (namebuf);
}
# endif
if (cached_localename == NULL)
cached_localename = "C";
}
return cached_localename;
}
# endif
# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
{
LCID lcid;
/* Use native Windows API locale ID. */
lcid = GetThreadLocale ();
return gl_locale_name_from_win32_LCID (lcid);
}
# endif
#endif
}
/* Determine the current locale's name, and canonicalize it into XPG syntax
language[_territory][.codeset][@modifier]
The codeset part in the result is not reliable; the locale_charset()
should be used for codeset information instead.
The result must not be freed; it is statically allocated. */
const char *
gl_locale_name (int category, const char *categoryname)
{
const char *retval;
retval = gl_locale_name_thread (category, categoryname);
if (retval != NULL)
return retval;
retval = gl_locale_name_posix (category, categoryname);
if (retval != NULL)
return retval;
return gl_locale_name_default ();
}
plptools-1.0.13/intl/relocatable.c 0000644 0001750 0001750 00000037245 12417352631 013777 0000000 0000000 /* Provide relocatable packages.
Copyright (C) 2003-2006, 2008-2011 Free Software Foundation, Inc.
Written by Bruno Haible , 2003.
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.1 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 . */
/* Tell glibc's to provide a prototype for getline().
This must come before because may include
, and once has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#define _GL_USE_STDLIB_ALLOC 1
#include
/* Specification. */
#include "relocatable.h"
#if ENABLE_RELOCATABLE
#include
#include
#include
#include
#ifdef NO_XMALLOC
# define xmalloc malloc
#else
# include "xalloc.h"
#endif
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include
#endif
#if DEPENDS_ON_LIBCHARSET
# include
#endif
#if DEPENDS_ON_LIBICONV && HAVE_ICONV
# include
#endif
#if DEPENDS_ON_LIBINTL && ENABLE_NLS
# include
#endif
/* Faked cheap 'bool'. */
#undef bool
#undef false
#undef true
#define bool int
#define false 0
#define true 1
/* Pathname support.
ISSLASH(C) tests whether C is a directory separator character.
IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
*/
#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
/* Native Windows, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define HAS_DEVICE(P) \
((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
&& (P)[1] == ':')
# define IS_PATH_WITH_DIR(P) \
(strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
#else
/* Unix */
# define ISSLASH(C) ((C) == '/')
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
# define FILE_SYSTEM_PREFIX_LEN(P) 0
#endif
/* Whether to enable the more costly support for relocatable libraries.
It allows libraries to be have been installed with a different original
prefix than the program. But it is quite costly, especially on Cygwin
platforms, see below. Therefore we enable it by default only on native
Windows platforms. */
#ifndef ENABLE_COSTLY_RELOCATABLE
# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define ENABLE_COSTLY_RELOCATABLE 1
# else
# define ENABLE_COSTLY_RELOCATABLE 0
# endif
#endif
/* Original installation prefix. */
static char *orig_prefix;
static size_t orig_prefix_len;
/* Current installation prefix. */
static char *curr_prefix;
static size_t curr_prefix_len;
/* These prefixes do not end in a slash. Anything that will be concatenated
to them must start with a slash. */
/* Sets the original and the current installation prefix of this module.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
static void
set_this_relocation_prefix (const char *orig_prefix_arg,
const char *curr_prefix_arg)
{
if (orig_prefix_arg != NULL && curr_prefix_arg != NULL
/* Optimization: if orig_prefix and curr_prefix are equal, the
relocation is a nop. */
&& strcmp (orig_prefix_arg, curr_prefix_arg) != 0)
{
/* Duplicate the argument strings. */
char *memory;
orig_prefix_len = strlen (orig_prefix_arg);
curr_prefix_len = strlen (curr_prefix_arg);
memory = (char *) xmalloc (orig_prefix_len + 1 + curr_prefix_len + 1);
#ifdef NO_XMALLOC
if (memory != NULL)
#endif
{
memcpy (memory, orig_prefix_arg, orig_prefix_len + 1);
orig_prefix = memory;
memory += orig_prefix_len + 1;
memcpy (memory, curr_prefix_arg, curr_prefix_len + 1);
curr_prefix = memory;
return;
}
}
orig_prefix = NULL;
curr_prefix = NULL;
/* Don't worry about wasted memory here - this function is usually only
called once. */
}
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
void
set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg)
{
set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
/* Now notify all dependent libraries. */
#if DEPENDS_ON_LIBCHARSET
libcharset_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
#endif
#if DEPENDS_ON_LIBICONV && HAVE_ICONV && _LIBICONV_VERSION >= 0x0109
libiconv_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
#endif
#if DEPENDS_ON_LIBINTL && ENABLE_NLS && defined libintl_set_relocation_prefix
libintl_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
#endif
}
#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE)
/* Convenience function:
Computes the current installation prefix, based on the original
installation prefix, the original installation directory of a particular
file, and the current pathname of this file.
Returns it, freshly allocated. Returns NULL upon failure. */
#ifdef IN_LIBRARY
#define compute_curr_prefix local_compute_curr_prefix
static
#endif
char *
compute_curr_prefix (const char *orig_installprefix,
const char *orig_installdir,
const char *curr_pathname)
{
char *curr_installdir;
const char *rel_installdir;
if (curr_pathname == NULL)
return NULL;
/* Determine the relative installation directory, relative to the prefix.
This is simply the difference between orig_installprefix and
orig_installdir. */
if (strncmp (orig_installprefix, orig_installdir, strlen (orig_installprefix))
!= 0)
/* Shouldn't happen - nothing should be installed outside $(prefix). */
return NULL;
rel_installdir = orig_installdir + strlen (orig_installprefix);
/* Determine the current installation directory. */
{
const char *p_base = curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname);
const char *p = curr_pathname + strlen (curr_pathname);
char *q;
while (p > p_base)
{
p--;
if (ISSLASH (*p))
break;
}
q = (char *) xmalloc (p - curr_pathname + 1);
#ifdef NO_XMALLOC
if (q == NULL)
return NULL;
#endif
memcpy (q, curr_pathname, p - curr_pathname);
q[p - curr_pathname] = '\0';
curr_installdir = q;
}
/* Compute the current installation prefix by removing the trailing
rel_installdir from it. */
{
const char *rp = rel_installdir + strlen (rel_installdir);
const char *cp = curr_installdir + strlen (curr_installdir);
const char *cp_base =
curr_installdir + FILE_SYSTEM_PREFIX_LEN (curr_installdir);
while (rp > rel_installdir && cp > cp_base)
{
bool same = false;
const char *rpi = rp;
const char *cpi = cp;
while (rpi > rel_installdir && cpi > cp_base)
{
rpi--;
cpi--;
if (ISSLASH (*rpi) || ISSLASH (*cpi))
{
if (ISSLASH (*rpi) && ISSLASH (*cpi))
same = true;
break;
}
/* Do case-insensitive comparison if the file system is always or
often case-insensitive. It's better to accept the comparison
if the difference is only in case, rather than to fail. */
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Native Windows, Cygwin, OS/2, DOS - case insignificant file system */
if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
!= (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
break;
#else
if (*rpi != *cpi)
break;
#endif
}
if (!same)
break;
/* The last pathname component was the same. opi and cpi now point
to the slash before it. */
rp = rpi;
cp = cpi;
}
if (rp > rel_installdir)
{
/* Unexpected: The curr_installdir does not end with rel_installdir. */
free (curr_installdir);
return NULL;
}
{
size_t curr_prefix_len = cp - curr_installdir;
char *curr_prefix;
curr_prefix = (char *) xmalloc (curr_prefix_len + 1);
#ifdef NO_XMALLOC
if (curr_prefix == NULL)
{
free (curr_installdir);
return NULL;
}
#endif
memcpy (curr_prefix, curr_installdir, curr_prefix_len);
curr_prefix[curr_prefix_len] = '\0';
free (curr_installdir);
return curr_prefix;
}
}
}
#endif /* !IN_LIBRARY || PIC */
#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
/* Full pathname of shared library, or NULL. */
static char *shared_library_fullname;
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
/* Native Windows only.
On Cygwin, it is better to use the Cygwin provided /proc interface, than
to use native Windows API and cygwin_conv_to_posix_path, because it
supports longer file names
(see ). */
/* Determine the full pathname of the shared library when it is loaded. */
BOOL WINAPI
DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
{
(void) reserved;
if (event == DLL_PROCESS_ATTACH)
{
/* The DLL is being loaded into an application's address range. */
static char location[MAX_PATH];
if (!GetModuleFileName (module_handle, location, sizeof (location)))
/* Shouldn't happen. */
return FALSE;
if (!IS_PATH_WITH_DIR (location))
/* Shouldn't happen. */
return FALSE;
shared_library_fullname = strdup (location);
}
return TRUE;
}
#else /* Unix */
static void
find_shared_library_fullname ()
{
#if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined __CYGWIN__
/* Linux has /proc/self/maps. glibc 2 and uClibc have the getline()
function.
Cygwin >= 1.5 has /proc/self/maps and the getline() function too.
But it is costly: ca. 0.3 ms on Linux, 3 ms on Cygwin 1.5, and 5 ms on
Cygwin 1.7. */
FILE *fp;
/* Open the current process' maps file. It describes one VMA per line. */
fp = fopen ("/proc/self/maps", "r");
if (fp)
{
unsigned long address = (unsigned long) &find_shared_library_fullname;
for (;;)
{
unsigned long start, end;
int c;
if (fscanf (fp, "%lx-%lx", &start, &end) != 2)
break;
if (address >= start && address <= end - 1)
{
/* Found it. Now see if this line contains a filename. */
while (c = getc (fp), c != EOF && c != '\n' && c != '/')
continue;
if (c == '/')
{
size_t size;
int len;
ungetc (c, fp);
shared_library_fullname = NULL; size = 0;
len = getline (&shared_library_fullname, &size, fp);
if (len >= 0)
{
/* Success: filled shared_library_fullname. */
if (len > 0 && shared_library_fullname[len - 1] == '\n')
shared_library_fullname[len - 1] = '\0';
}
}
break;
}
while (c = getc (fp), c != EOF && c != '\n')
continue;
}
fclose (fp);
}
#endif
}
#endif /* Native Windows / Unix */
/* Return the full pathname of the current shared library.
Return NULL if unknown.
Guaranteed to work only on Linux, Cygwin, and native Windows. */
static char *
get_shared_library_fullname ()
{
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
static bool tried_find_shared_library_fullname;
if (!tried_find_shared_library_fullname)
{
find_shared_library_fullname ();
tried_find_shared_library_fullname = true;
}
#endif
return shared_library_fullname;
}
#endif /* PIC */
/* Returns the pathname, relocated according to the current installation
directory.
The returned string is either PATHNAME unmodified or a freshly allocated
string that you can free with free() after casting it to 'char *'. */
const char *
relocate (const char *pathname)
{
#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
static int initialized;
/* Initialization code for a shared library. */
if (!initialized)
{
/* At this point, orig_prefix and curr_prefix likely have already been
set through the main program's set_program_name_and_installdir
function. This is sufficient in the case that the library has
initially been installed in the same orig_prefix. But we can do
better, to also cover the cases that 1. it has been installed
in a different prefix before being moved to orig_prefix and (later)
to curr_prefix, 2. unlike the program, it has not moved away from
orig_prefix. */
const char *orig_installprefix = INSTALLPREFIX;
const char *orig_installdir = INSTALLDIR;
char *curr_prefix_better;
curr_prefix_better =
compute_curr_prefix (orig_installprefix, orig_installdir,
get_shared_library_fullname ());
set_relocation_prefix (orig_installprefix,
curr_prefix_better != NULL
? curr_prefix_better
: curr_prefix);
if (curr_prefix_better != NULL)
free (curr_prefix_better);
initialized = 1;
}
#endif
/* Note: It is not necessary to perform case insensitive comparison here,
even for DOS-like file systems, because the pathname argument was
typically created from the same Makefile variable as orig_prefix came
from. */
if (orig_prefix != NULL && curr_prefix != NULL
&& strncmp (pathname, orig_prefix, orig_prefix_len) == 0)
{
if (pathname[orig_prefix_len] == '\0')
{
/* pathname equals orig_prefix. */
char *result = (char *) xmalloc (strlen (curr_prefix) + 1);
#ifdef NO_XMALLOC
if (result != NULL)
#endif
{
strcpy (result, curr_prefix);
return result;
}
}
else if (ISSLASH (pathname[orig_prefix_len]))
{
/* pathname starts with orig_prefix. */
const char *pathname_tail = &pathname[orig_prefix_len];
char *result =
(char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);
#ifdef NO_XMALLOC
if (result != NULL)
#endif
{
memcpy (result, curr_prefix, curr_prefix_len);
strcpy (result + curr_prefix_len, pathname_tail);
return result;
}
}
}
/* Nothing to relocate. */
return pathname;
}
#endif
plptools-1.0.13/intl/vasnwprintf.h 0000644 0001750 0001750 00000003211 12417352631 014072 0000000 0000000 /* vswprintf with automatic memory allocation.
Copyright (C) 2002-2003 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.1 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 . */
#ifndef _VASNWPRINTF_H
#define _VASNWPRINTF_H
/* Get va_list. */
#include
/* Get wchar_t, size_t. */
#include
#ifdef __cplusplus
extern "C" {
#endif
/* Write formatted output to a string dynamically allocated with malloc().
You can pass a preallocated buffer for the result in RESULTBUF and its
size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
If successful, return the address of the string (this may be = RESULTBUF
if no dynamic memory allocation was necessary) and set *LENGTHP to the
number of resulting bytes, excluding the trailing NUL. Upon error, set
errno and return NULL. */
extern wchar_t * asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...);
extern wchar_t * vasnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, va_list args);
#ifdef __cplusplus
}
#endif
#endif /* _VASNWPRINTF_H */
plptools-1.0.13/intl/xsize.h 0000644 0001750 0001750 00000006765 12417352631 012674 0000000 0000000 /* xsize.h -- Checked size_t computations.
Copyright (C) 2003, 2008-2013 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.1, 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 . */
#ifndef _XSIZE_H
#define _XSIZE_H
/* Get size_t. */
#include
/* Get SIZE_MAX. */
#include
#if HAVE_STDINT_H
# include
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef XSIZE_INLINE
# define XSIZE_INLINE _GL_INLINE
#endif
/* The size of memory objects is often computed through expressions of
type size_t. Example:
void* p = malloc (header_size + n * element_size).
These computations can lead to overflow. When this happens, malloc()
returns a piece of memory that is way too small, and the program then
crashes while attempting to fill the memory.
To avoid this, the functions and macros in this file check for overflow.
The convention is that SIZE_MAX represents overflow.
malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
implementation that uses mmap --, it's recommended to use size_overflow_p()
or size_in_bounds_p() before invoking malloc().
The example thus becomes:
size_t size = xsum (header_size, xtimes (n, element_size));
void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
*/
/* Convert an arbitrary value >= 0 to type size_t. */
#define xcast_size_t(N) \
((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
/* Sum of two sizes, with overflow check. */
XSIZE_INLINE size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum (size_t size1, size_t size2)
{
size_t sum = size1 + size2;
return (sum >= size1 ? sum : SIZE_MAX);
}
/* Sum of three sizes, with overflow check. */
XSIZE_INLINE size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum3 (size_t size1, size_t size2, size_t size3)
{
return xsum (xsum (size1, size2), size3);
}
/* Sum of four sizes, with overflow check. */
XSIZE_INLINE size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
{
return xsum (xsum (xsum (size1, size2), size3), size4);
}
/* Maximum of two sizes, with overflow check. */
XSIZE_INLINE size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xmax (size_t size1, size_t size2)
{
/* No explicit check is needed here, because for any n:
max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
return (size1 >= size2 ? size1 : size2);
}
/* Multiplication of a count with an element size, with overflow check.
The count must be >= 0 and the element size must be > 0.
This is a macro, not a function, so that it works correctly even
when N is of a wider type and N > SIZE_MAX. */
#define xtimes(N, ELSIZE) \
((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
/* Check for overflow. */
#define size_overflow_p(SIZE) \
((SIZE) == SIZE_MAX)
/* Check against overflow. */
#define size_in_bounds_p(SIZE) \
((SIZE) != SIZE_MAX)
_GL_INLINE_HEADER_END
#endif /* _XSIZE_H */
plptools-1.0.13/intl/plural-exp.h 0000644 0001750 0001750 00000010034 12417352631 013603 0000000 0000000 /* Expression parsing and evaluation for plural form selection.
Copyright (C) 2000-2003, 2005-2007 Free Software Foundation, Inc.
Written by Ulrich Drepper , 2000.
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.1 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 . */
#ifndef _PLURAL_EXP_H
#define _PLURAL_EXP_H
#ifndef internal_function
# define internal_function
#endif
#ifndef attribute_hidden
# define attribute_hidden
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum expression_operator
{
/* Without arguments: */
var, /* The variable "n". */
num, /* Decimal number. */
/* Unary operators: */
lnot, /* Logical NOT. */
/* Binary operators: */
mult, /* Multiplication. */
divide, /* Division. */
module, /* Modulo operation. */
plus, /* Addition. */
minus, /* Subtraction. */
less_than, /* Comparison. */
greater_than, /* Comparison. */
less_or_equal, /* Comparison. */
greater_or_equal, /* Comparison. */
equal, /* Comparison for equality. */
not_equal, /* Comparison for inequality. */
land, /* Logical AND. */
lor, /* Logical OR. */
/* Ternary operators: */
qmop /* Question mark operator. */
};
/* This is the representation of the expressions to determine the
plural form. */
struct expression
{
int nargs; /* Number of arguments. */
enum expression_operator operation;
union
{
unsigned long int num; /* Number value for `num'. */
struct expression *args[3]; /* Up to three arguments. */
} val;
};
/* This is the data structure to pass information to the parser and get
the result in a thread-safe way. */
struct parse_args
{
const char *cp;
struct expression *res;
};
/* Names for the libintl functions are a problem. This source code is used
1. in the GNU C Library library,
2. in the GNU libintl library,
3. in the GNU gettext tools.
The function names in each situation must be different, to allow for
binary incompatible changes in 'struct expression'. Furthermore,
1. in the GNU C Library library, the names have a __ prefix,
2.+3. in the GNU libintl library and in the GNU gettext tools, the names
must follow ANSI C and not start with __.
So we have to distinguish the three cases. */
#ifdef _LIBC
# define FREE_EXPRESSION __gettext_free_exp
# define PLURAL_PARSE __gettextparse
# define GERMANIC_PLURAL __gettext_germanic_plural
# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
#elif defined (IN_LIBINTL)
# define FREE_EXPRESSION libintl_gettext_free_exp
# define PLURAL_PARSE libintl_gettextparse
# define GERMANIC_PLURAL libintl_gettext_germanic_plural
# define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
#else
# define FREE_EXPRESSION free_plural_expression
# define PLURAL_PARSE parse_plural_expression
# define GERMANIC_PLURAL germanic_plural
# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
#endif
extern void FREE_EXPRESSION (struct expression *exp)
internal_function;
extern int PLURAL_PARSE (void *arg);
extern struct expression GERMANIC_PLURAL attribute_hidden;
extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
const struct expression **pluralp,
unsigned long int *npluralsp)
internal_function;
#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
extern unsigned long int plural_eval (const struct expression *pexp,
unsigned long int n);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _PLURAL_EXP_H */
plptools-1.0.13/intl/tsearch.c 0000644 0001750 0001750 00000051744 12417352631 013153 0000000 0000000 /* Copyright (C) 1995, 1996, 1997, 2000, 2006 Free Software Foundation, Inc.
Contributed by Bernd Schmidt , 1997.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@gnu.org.
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.1 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 . */
/* Tree search for red/black trees.
The algorithm for adding nodes is taken from one of the many "Algorithms"
books by Robert Sedgewick, although the implementation differs.
The algorithm for deleting nodes can probably be found in a book named
"Introduction to Algorithms" by Cormen/Leiserson/Rivest. At least that's
the book that my professor took most algorithms from during the "Data
Structures" course...
Totally public domain. */
/* Red/black trees are binary trees in which the edges are colored either red
or black. They have the following properties:
1. The number of black edges on every path from the root to a leaf is
constant.
2. No two red edges are adjacent.
Therefore there is an upper bound on the length of every path, it's
O(log n) where n is the number of nodes in the tree. No path can be longer
than 1+2*P where P is the length of the shortest path in the tree.
Useful for the implementation:
3. If one of the children of a node is NULL, then the other one is red
(if it exists).
In the implementation, not the edges are colored, but the nodes. The color
interpreted as the color of the edge leading to this node. The color is
meaningless for the root node, but we color the root node black for
convenience. All added nodes are red initially.
Adding to a red/black tree is rather easy. The right place is searched
with a usual binary tree search. Additionally, whenever a node N is
reached that has two red successors, the successors are colored black and
the node itself colored red. This moves red edges up the tree where they
pose less of a problem once we get to really insert the new node. Changing
N's color to red may violate rule 2, however, so rotations may become
necessary to restore the invariants. Adding a new red leaf may violate
the same rule, so afterwards an additional check is run and the tree
possibly rotated.
Deleting is hairy. There are mainly two nodes involved: the node to be
deleted (n1), and another node that is to be unchained from the tree (n2).
If n1 has a successor (the node with a smallest key that is larger than
n1), then the successor becomes n2 and its contents are copied into n1,
otherwise n1 becomes n2.
Unchaining a node may violate rule 1: if n2 is black, one subtree is
missing one black edge afterwards. The algorithm must try to move this
error upwards towards the root, so that the subtree that does not have
enough black edges becomes the whole tree. Once that happens, the error
has disappeared. It may not be necessary to go all the way up, since it
is possible that rotations and recoloring can fix the error before that.
Although the deletion algorithm must walk upwards through the tree, we
do not store parent pointers in the nodes. Instead, delete allocates a
small array of parent pointers and fills it while descending the tree.
Since we know that the length of a path is O(log n), where n is the number
of nodes, this is likely to use less memory. */
/* Tree rotations look like this:
A C
/ \ / \
B C A G
/ \ / \ --> / \
D E F G B F
/ \
D E
In this case, A has been rotated left. This preserves the ordering of the
binary tree. */
#include
/* Specification. */
#ifdef IN_LIBINTL
# include "tsearch.h"
#else
# include
#endif
#include
typedef int (*__compar_fn_t) (const void *, const void *);
typedef void (*__action_fn_t) (const void *, VISIT, int);
#ifndef weak_alias
# define __tsearch tsearch
# define __tfind tfind
# define __tdelete tdelete
# define __twalk twalk
#endif
#ifndef internal_function
/* Inside GNU libc we mark some function in a special way. In other
environments simply ignore the marking. */
# define internal_function
#endif
typedef struct node_t
{
/* Callers expect this to be the first element in the structure - do not
move! */
const void *key;
struct node_t *left;
struct node_t *right;
unsigned int red:1;
} *node;
typedef const struct node_t *const_node;
#undef DEBUGGING
#ifdef DEBUGGING
/* Routines to check tree invariants. */
#include
#define CHECK_TREE(a) check_tree(a)
static void
check_tree_recurse (node p, int d_sofar, int d_total)
{
if (p == NULL)
{
assert (d_sofar == d_total);
return;
}
check_tree_recurse (p->left, d_sofar + (p->left && !p->left->red), d_total);
check_tree_recurse (p->right, d_sofar + (p->right && !p->right->red), d_total);
if (p->left)
assert (!(p->left->red && p->red));
if (p->right)
assert (!(p->right->red && p->red));
}
static void
check_tree (node root)
{
int cnt = 0;
node p;
if (root == NULL)
return;
root->red = 0;
for(p = root->left; p; p = p->left)
cnt += !p->red;
check_tree_recurse (root, 0, cnt);
}
#else
#define CHECK_TREE(a)
#endif
/* Possibly "split" a node with two red successors, and/or fix up two red
edges in a row. ROOTP is a pointer to the lowest node we visited, PARENTP
and GPARENTP pointers to its parent/grandparent. P_R and GP_R contain the
comparison values that determined which way was taken in the tree to reach
ROOTP. MODE is 1 if we need not do the split, but must check for two red
edges between GPARENTP and ROOTP. */
static void
maybe_split_for_insert (node *rootp, node *parentp, node *gparentp,
int p_r, int gp_r, int mode)
{
node root = *rootp;
node *rp, *lp;
rp = &(*rootp)->right;
lp = &(*rootp)->left;
/* See if we have to split this node (both successors red). */
if (mode == 1
|| ((*rp) != NULL && (*lp) != NULL && (*rp)->red && (*lp)->red))
{
/* This node becomes red, its successors black. */
root->red = 1;
if (*rp)
(*rp)->red = 0;
if (*lp)
(*lp)->red = 0;
/* If the parent of this node is also red, we have to do
rotations. */
if (parentp != NULL && (*parentp)->red)
{
node gp = *gparentp;
node p = *parentp;
/* There are two main cases:
1. The edge types (left or right) of the two red edges differ.
2. Both red edges are of the same type.
There exist two symmetries of each case, so there is a total of
4 cases. */
if ((p_r > 0) != (gp_r > 0))
{
/* Put the child at the top of the tree, with its parent
and grandparent as successors. */
p->red = 1;
gp->red = 1;
root->red = 0;
if (p_r < 0)
{
/* Child is left of parent. */
p->left = *rp;
*rp = p;
gp->right = *lp;
*lp = gp;
}
else
{
/* Child is right of parent. */
p->right = *lp;
*lp = p;
gp->left = *rp;
*rp = gp;
}
*gparentp = root;
}
else
{
*gparentp = *parentp;
/* Parent becomes the top of the tree, grandparent and
child are its successors. */
p->red = 0;
gp->red = 1;
if (p_r < 0)
{
/* Left edges. */
gp->left = p->right;
p->right = gp;
}
else
{
/* Right edges. */
gp->right = p->left;
p->left = gp;
}
}
}
}
}
/* Find or insert datum into search tree.
KEY is the key to be located, ROOTP is the address of tree root,
COMPAR the ordering function. */
void *
__tsearch (const void *key, void **vrootp, __compar_fn_t compar)
{
node q;
node *parentp = NULL, *gparentp = NULL;
node *rootp = (node *) vrootp;
node *nextp;
int r = 0, p_r = 0, gp_r = 0; /* No they might not, Mr Compiler. */
if (rootp == NULL)
return NULL;
/* This saves some additional tests below. */
if (*rootp != NULL)
(*rootp)->red = 0;
CHECK_TREE (*rootp);
nextp = rootp;
while (*nextp != NULL)
{
node root = *rootp;
r = (*compar) (key, root->key);
if (r == 0)
return root;
maybe_split_for_insert (rootp, parentp, gparentp, p_r, gp_r, 0);
/* If that did any rotations, parentp and gparentp are now garbage.
That doesn't matter, because the values they contain are never
used again in that case. */
nextp = r < 0 ? &root->left : &root->right;
if (*nextp == NULL)
break;
gparentp = parentp;
parentp = rootp;
rootp = nextp;
gp_r = p_r;
p_r = r;
}
q = (struct node_t *) malloc (sizeof (struct node_t));
if (q != NULL)
{
*nextp = q; /* link new node to old */
q->key = key; /* initialize new node */
q->red = 1;
q->left = q->right = NULL;
if (nextp != rootp)
/* There may be two red edges in a row now, which we must avoid by
rotating the tree. */
maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1);
}
return q;
}
#ifdef weak_alias
weak_alias (__tsearch, tsearch)
#endif
/* Find datum in search tree.
KEY is the key to be located, ROOTP is the address of tree root,
COMPAR the ordering function. */
void *
__tfind (key, vrootp, compar)
const void *key;
void *const *vrootp;
__compar_fn_t compar;
{
node *rootp = (node *) vrootp;
if (rootp == NULL)
return NULL;
CHECK_TREE (*rootp);
while (*rootp != NULL)
{
node root = *rootp;
int r;
r = (*compar) (key, root->key);
if (r == 0)
return root;
rootp = r < 0 ? &root->left : &root->right;
}
return NULL;
}
#ifdef weak_alias
weak_alias (__tfind, tfind)
#endif
/* Delete node with given key.
KEY is the key to be deleted, ROOTP is the address of the root of tree,
COMPAR the comparison function. */
void *
__tdelete (const void *key, void **vrootp, __compar_fn_t compar)
{
node p, q, r, retval;
int cmp;
node *rootp = (node *) vrootp;
node root, unchained;
/* Stack of nodes so we remember the parents without recursion. It's
_very_ unlikely that there are paths longer than 40 nodes. The tree
would need to have around 250.000 nodes. */
int stacksize = 100;
int sp = 0;
node *nodestack[100];
if (rootp == NULL)
return NULL;
p = *rootp;
if (p == NULL)
return NULL;
CHECK_TREE (p);
while ((cmp = (*compar) (key, (*rootp)->key)) != 0)
{
if (sp == stacksize)
abort ();
nodestack[sp++] = rootp;
p = *rootp;
rootp = ((cmp < 0)
? &(*rootp)->left
: &(*rootp)->right);
if (*rootp == NULL)
return NULL;
}
/* This is bogus if the node to be deleted is the root... this routine
really should return an integer with 0 for success, -1 for failure
and errno = ESRCH or something. */
retval = p;
/* We don't unchain the node we want to delete. Instead, we overwrite
it with its successor and unchain the successor. If there is no
successor, we really unchain the node to be deleted. */
root = *rootp;
r = root->right;
q = root->left;
if (q == NULL || r == NULL)
unchained = root;
else
{
node *parent = rootp, *up = &root->right;
for (;;)
{
if (sp == stacksize)
abort ();
nodestack[sp++] = parent;
parent = up;
if ((*up)->left == NULL)
break;
up = &(*up)->left;
}
unchained = *up;
}
/* We know that either the left or right successor of UNCHAINED is NULL.
R becomes the other one, it is chained into the parent of UNCHAINED. */
r = unchained->left;
if (r == NULL)
r = unchained->right;
if (sp == 0)
*rootp = r;
else
{
q = *nodestack[sp-1];
if (unchained == q->right)
q->right = r;
else
q->left = r;
}
if (unchained != root)
root->key = unchained->key;
if (!unchained->red)
{
/* Now we lost a black edge, which means that the number of black
edges on every path is no longer constant. We must balance the
tree. */
/* NODESTACK now contains all parents of R. R is likely to be NULL
in the first iteration. */
/* NULL nodes are considered black throughout - this is necessary for
correctness. */
while (sp > 0 && (r == NULL || !r->red))
{
node *pp = nodestack[sp - 1];
p = *pp;
/* Two symmetric cases. */
if (r == p->left)
{
/* Q is R's brother, P is R's parent. The subtree with root
R has one black edge less than the subtree with root Q. */
q = p->right;
if (q->red)
{
/* If Q is red, we know that P is black. We rotate P left
so that Q becomes the top node in the tree, with P below
it. P is colored red, Q is colored black.
This action does not change the black edge count for any
leaf in the tree, but we will be able to recognize one
of the following situations, which all require that Q
is black. */
q->red = 0;
p->red = 1;
/* Left rotate p. */
p->right = q->left;
q->left = p;
*pp = q;
/* Make sure pp is right if the case below tries to use
it. */
nodestack[sp++] = pp = &q->left;
q = p->right;
}
/* We know that Q can't be NULL here. We also know that Q is
black. */
if ((q->left == NULL || !q->left->red)
&& (q->right == NULL || !q->right->red))
{
/* Q has two black successors. We can simply color Q red.
The whole subtree with root P is now missing one black
edge. Note that this action can temporarily make the
tree invalid (if P is red). But we will exit the loop
in that case and set P black, which both makes the tree
valid and also makes the black edge count come out
right. If P is black, we are at least one step closer
to the root and we'll try again the next iteration. */
q->red = 1;
r = p;
}
else
{
/* Q is black, one of Q's successors is red. We can
repair the tree with one operation and will exit the
loop afterwards. */
if (q->right == NULL || !q->right->red)
{
/* The left one is red. We perform the same action as
in maybe_split_for_insert where two red edges are
adjacent but point in different directions:
Q's left successor (let's call it Q2) becomes the
top of the subtree we are looking at, its parent (Q)
and grandparent (P) become its successors. The former
successors of Q2 are placed below P and Q.
P becomes black, and Q2 gets the color that P had.
This changes the black edge count only for node R and
its successors. */
node q2 = q->left;
q2->red = p->red;
p->right = q2->left;
q->left = q2->right;
q2->right = q;
q2->left = p;
*pp = q2;
p->red = 0;
}
else
{
/* It's the right one. Rotate P left. P becomes black,
and Q gets the color that P had. Q's right successor
also becomes black. This changes the black edge
count only for node R and its successors. */
q->red = p->red;
p->red = 0;
q->right->red = 0;
/* left rotate p */
p->right = q->left;
q->left = p;
*pp = q;
}
/* We're done. */
sp = 1;
r = NULL;
}
}
else
{
/* Comments: see above. */
q = p->left;
if (q->red)
{
q->red = 0;
p->red = 1;
p->left = q->right;
q->right = p;
*pp = q;
nodestack[sp++] = pp = &q->right;
q = p->left;
}
if ((q->right == NULL || !q->right->red)
&& (q->left == NULL || !q->left->red))
{
q->red = 1;
r = p;
}
else
{
if (q->left == NULL || !q->left->red)
{
node q2 = q->right;
q2->red = p->red;
p->left = q2->right;
q->right = q2->left;
q2->left = q;
q2->right = p;
*pp = q2;
p->red = 0;
}
else
{
q->red = p->red;
p->red = 0;
q->left->red = 0;
p->left = q->right;
q->right = p;
*pp = q;
}
sp = 1;
r = NULL;
}
}
--sp;
}
if (r != NULL)
r->red = 0;
}
free (unchained);
return retval;
}
#ifdef weak_alias
weak_alias (__tdelete, tdelete)
#endif
/* Walk the nodes of a tree.
ROOT is the root of the tree to be walked, ACTION the function to be
called at each node. LEVEL is the level of ROOT in the whole tree. */
static void
internal_function
trecurse (const void *vroot, __action_fn_t action, int level)
{
const_node root = (const_node) vroot;
if (root->left == NULL && root->right == NULL)
(*action) (root, leaf, level);
else
{
(*action) (root, preorder, level);
if (root->left != NULL)
trecurse (root->left, action, level + 1);
(*action) (root, postorder, level);
if (root->right != NULL)
trecurse (root->right, action, level + 1);
(*action) (root, endorder, level);
}
}
/* Walk the nodes of a tree.
ROOT is the root of the tree to be walked, ACTION the function to be
called at each node. */
void
__twalk (const void *vroot, __action_fn_t action)
{
const_node root = (const_node) vroot;
CHECK_TREE (root);
if (root != NULL && action != NULL)
trecurse (root, action, 0);
}
#ifdef weak_alias
weak_alias (__twalk, twalk)
#endif
#ifdef _LIBC
/* The standardized functions miss an important functionality: the
tree cannot be removed easily. We provide a function to do this. */
static void
internal_function
tdestroy_recurse (node root, __free_fn_t freefct)
{
if (root->left != NULL)
tdestroy_recurse (root->left, freefct);
if (root->right != NULL)
tdestroy_recurse (root->right, freefct);
(*freefct) ((void *) root->key);
/* Free the node itself. */
free (root);
}
void
__tdestroy (void *vroot, __free_fn_t freefct)
{
node root = (node) vroot;
CHECK_TREE (root);
if (root != NULL)
tdestroy_recurse (root, freefct);
}
weak_alias (__tdestroy, tdestroy)
#endif /* _LIBC */
plptools-1.0.13/intl/gettext.c 0000644 0001750 0001750 00000003457 12417352630 013203 0000000 0000000 /* Implementation of gettext(3) function.
Copyright (C) 1995, 1997, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#ifdef _LIBC
# define __need_NULL
# include
#else
# include /* Just for NULL. */
#endif
#include "gettextP.h"
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define GETTEXT __gettext
# define DCGETTEXT INTUSE(__dcgettext)
#else
# define GETTEXT libintl_gettext
# define DCGETTEXT libintl_dcgettext
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
char *
GETTEXT (const char *msgid)
{
return DCGETTEXT (NULL, msgid, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__gettext, gettext);
#endif
plptools-1.0.13/intl/osdep.c 0000644 0001750 0001750 00000001673 12417352631 012630 0000000 0000000 /* OS dependent parts of libintl.
Copyright (C) 2001-2002, 2006 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.1 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 . */
#if defined __CYGWIN__ || defined __MINGW32__
# include "intl-exports.c"
#elif defined __EMX__
# include "os2compat.c"
#else
/* Avoid AIX compiler warning. */
typedef int dummy;
#endif
plptools-1.0.13/intl/lock.h 0000644 0001750 0001750 00000106721 12417352631 012453 0000000 0000000 /* Locking in multithreaded situations.
Copyright (C) 2005-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.1 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 . */
/* Written by Bruno Haible , 2005.
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
gthr-win32.h. */
/* This file contains locking primitives for use with a given thread library.
It does not contain primitives for creating threads or for other
synchronization primitives.
Normal (non-recursive) locks:
Type: gl_lock_t
Declaration: gl_lock_define(extern, name)
Initializer: gl_lock_define_initialized(, name)
Initialization: gl_lock_init (name);
Taking the lock: gl_lock_lock (name);
Releasing the lock: gl_lock_unlock (name);
De-initialization: gl_lock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_lock_init (&name);
Taking the lock: err = glthread_lock_lock (&name);
Releasing the lock: err = glthread_lock_unlock (&name);
De-initialization: err = glthread_lock_destroy (&name);
Read-Write (non-recursive) locks:
Type: gl_rwlock_t
Declaration: gl_rwlock_define(extern, name)
Initializer: gl_rwlock_define_initialized(, name)
Initialization: gl_rwlock_init (name);
Taking the lock: gl_rwlock_rdlock (name);
gl_rwlock_wrlock (name);
Releasing the lock: gl_rwlock_unlock (name);
De-initialization: gl_rwlock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_rwlock_init (&name);
Taking the lock: err = glthread_rwlock_rdlock (&name);
err = glthread_rwlock_wrlock (&name);
Releasing the lock: err = glthread_rwlock_unlock (&name);
De-initialization: err = glthread_rwlock_destroy (&name);
Recursive locks:
Type: gl_recursive_lock_t
Declaration: gl_recursive_lock_define(extern, name)
Initializer: gl_recursive_lock_define_initialized(, name)
Initialization: gl_recursive_lock_init (name);
Taking the lock: gl_recursive_lock_lock (name);
Releasing the lock: gl_recursive_lock_unlock (name);
De-initialization: gl_recursive_lock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_recursive_lock_init (&name);
Taking the lock: err = glthread_recursive_lock_lock (&name);
Releasing the lock: err = glthread_recursive_lock_unlock (&name);
De-initialization: err = glthread_recursive_lock_destroy (&name);
Once-only execution:
Type: gl_once_t
Initializer: gl_once_define(extern, name)
Execution: gl_once (name, initfunction);
Equivalent functions with control of error handling:
Execution: err = glthread_once (&name, initfunction);
*/
#ifndef _LOCK_H
#define _LOCK_H
#include
#include
/* ========================================================================= */
#if USE_POSIX_THREADS
/* Use the POSIX threads library. */
# include
# ifdef __cplusplus
extern "C" {
# endif
# if PTHREAD_IN_USE_DETECTION_HARD
/* The pthread_in_use() detection needs to be done at runtime. */
# define pthread_in_use() \
glthread_in_use ()
extern int glthread_in_use (void);
# endif
# if USE_POSIX_THREADS_WEAK
/* Use weak references to the POSIX threads library. */
/* Weak references avoid dragging in external libraries if the other parts
of the program don't use them. Here we use them, because we don't want
every program that uses libintl to depend on libpthread. This assumes
that libpthread would not be loaded after libintl; i.e. if libintl is
loaded first, by an executable that does not depend on libpthread, and
then a module is dynamically loaded that depends on libpthread, libintl
will not be multithread-safe. */
/* The way to test at runtime whether libpthread is present is to test
whether a function pointer's value, such as &pthread_mutex_init, is
non-NULL. However, some versions of GCC have a bug through which, in
PIC mode, &foo != NULL always evaluates to true if there is a direct
call to foo(...) in the same function. To avoid this, we test the
address of a function in libpthread that we don't use. */
# pragma weak pthread_mutex_init
# pragma weak pthread_mutex_lock
# pragma weak pthread_mutex_unlock
# pragma weak pthread_mutex_destroy
# pragma weak pthread_rwlock_init
# pragma weak pthread_rwlock_rdlock
# pragma weak pthread_rwlock_wrlock
# pragma weak pthread_rwlock_unlock
# pragma weak pthread_rwlock_destroy
# pragma weak pthread_once
# pragma weak pthread_cond_init
# pragma weak pthread_cond_wait
# pragma weak pthread_cond_signal
# pragma weak pthread_cond_broadcast
# pragma weak pthread_cond_destroy
# pragma weak pthread_mutexattr_init
# pragma weak pthread_mutexattr_settype
# pragma weak pthread_mutexattr_destroy
# ifndef pthread_self
# pragma weak pthread_self
# endif
# if !PTHREAD_IN_USE_DETECTION_HARD
# pragma weak pthread_cancel
# define pthread_in_use() (pthread_cancel != NULL)
# endif
# else
# if !PTHREAD_IN_USE_DETECTION_HARD
# define pthread_in_use() 1
# endif
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef pthread_mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
PTHREAD_MUTEX_INITIALIZER
# define glthread_lock_init(LOCK) \
(pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
# define glthread_lock_lock(LOCK) \
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
# define glthread_lock_unlock(LOCK) \
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
# define glthread_lock_destroy(LOCK) \
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
# if HAVE_PTHREAD_RWLOCK
# ifdef PTHREAD_RWLOCK_INITIALIZER
typedef pthread_rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_INITIALIZER
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
# else
typedef struct
{
int initialized;
pthread_mutex_t guard; /* protects the initialization */
pthread_rwlock_t rwlock; /* read-write lock */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ 0, PTHREAD_MUTEX_INITIALIZER }
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
# endif
# else
typedef struct
{
pthread_mutex_t lock; /* protects the remaining fields */
pthread_cond_t waiting_readers; /* waiting readers */
pthread_cond_t waiting_writers; /* waiting writers */
unsigned int waiting_writers_count; /* number of waiting writers */
int runcount; /* number of readers running, or -1 when a writer runs */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
# endif
/* --------------------- gl_recursive_lock_t datatype --------------------- */
# if HAVE_PTHREAD_MUTEX_RECURSIVE
# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
typedef pthread_mutex_t gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
# define gl_recursive_lock_initializer \
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
# else
# define gl_recursive_lock_initializer \
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
# endif
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
# else
typedef struct
{
pthread_mutex_t recmutex; /* recursive mutex */
pthread_mutex_t guard; /* protects the initialization */
int initialized;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
# endif
# else
/* Old versions of POSIX threads on Solaris did not have recursive locks.
We have to implement them ourselves. */
typedef struct
{
pthread_mutex_t mutex;
pthread_t owner;
unsigned long depth;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
# endif
/* -------------------------- gl_once_t datatype -------------------------- */
typedef pthread_once_t gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(pthread_in_use () \
? pthread_once (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_singlethreaded (pthread_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_PTH_THREADS
/* Use the GNU Pth threads library. */
# include
# ifdef __cplusplus
extern "C" {
# endif
# if USE_PTH_THREADS_WEAK
/* Use weak references to the GNU Pth threads library. */
# pragma weak pth_mutex_init
# pragma weak pth_mutex_acquire
# pragma weak pth_mutex_release
# pragma weak pth_rwlock_init
# pragma weak pth_rwlock_acquire
# pragma weak pth_rwlock_release
# pragma weak pth_once
# pragma weak pth_cancel
# define pth_in_use() (pth_cancel != NULL)
# else
# define pth_in_use() 1
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef pth_mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
PTH_MUTEX_INIT
# define glthread_lock_init(LOCK) \
(pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
# define glthread_lock_lock(LOCK) \
(pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
# define glthread_lock_unlock(LOCK) \
(pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
# define glthread_lock_destroy(LOCK) \
((void)(LOCK), 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef pth_rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
PTH_RWLOCK_INIT
# define glthread_rwlock_init(LOCK) \
(pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
# define glthread_rwlock_unlock(LOCK) \
(pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
# define glthread_rwlock_destroy(LOCK) \
((void)(LOCK), 0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* In Pth, mutexes are recursive by default. */
typedef pth_mutex_t gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
PTH_MUTEX_INIT
# define glthread_recursive_lock_init(LOCK) \
(pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
# define glthread_recursive_lock_destroy(LOCK) \
((void)(LOCK), 0)
/* -------------------------- gl_once_t datatype -------------------------- */
typedef pth_once_t gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(pth_in_use () \
? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
extern int glthread_once_singlethreaded (pth_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_SOLARIS_THREADS
/* Use the old Solaris threads library. */
# include
# include
# ifdef __cplusplus
extern "C" {
# endif
# if USE_SOLARIS_THREADS_WEAK
/* Use weak references to the old Solaris threads library. */
# pragma weak mutex_init
# pragma weak mutex_lock
# pragma weak mutex_unlock
# pragma weak mutex_destroy
# pragma weak rwlock_init
# pragma weak rw_rdlock
# pragma weak rw_wrlock
# pragma weak rw_unlock
# pragma weak rwlock_destroy
# pragma weak thr_self
# pragma weak thr_suspend
# define thread_in_use() (thr_suspend != NULL)
# else
# define thread_in_use() 1
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
DEFAULTMUTEX
# define glthread_lock_init(LOCK) \
(thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
# define glthread_lock_lock(LOCK) \
(thread_in_use () ? mutex_lock (LOCK) : 0)
# define glthread_lock_unlock(LOCK) \
(thread_in_use () ? mutex_unlock (LOCK) : 0)
# define glthread_lock_destroy(LOCK) \
(thread_in_use () ? mutex_destroy (LOCK) : 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
DEFAULTRWLOCK
# define glthread_rwlock_init(LOCK) \
(thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(thread_in_use () ? rw_rdlock (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(thread_in_use () ? rw_wrlock (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(thread_in_use () ? rw_unlock (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(thread_in_use () ? rwlock_destroy (LOCK) : 0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* Old Solaris threads did not have recursive locks.
We have to implement them ourselves. */
typedef struct
{
mutex_t mutex;
thread_t owner;
unsigned long depth;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ DEFAULTMUTEX, (thread_t) 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
/* -------------------------- gl_once_t datatype -------------------------- */
typedef struct
{
volatile int inited;
mutex_t mutex;
}
gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(thread_in_use () \
? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
extern int glthread_once_singlethreaded (gl_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_WINDOWS_THREADS
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include
# ifdef __cplusplus
extern "C" {
# endif
/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
Mutex, Semaphore types, because
- we need only to synchronize inside a single process (address space),
not inter-process locking,
- we don't need to support trylock operations. (TryEnterCriticalSection
does not work on Windows 95/98/ME. Packages that need trylock usually
define their own mutex type.) */
/* There is no way to statically initialize a CRITICAL_SECTION. It needs
to be done lazily, once only. For this we need spinlocks. */
typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
CRITICAL_SECTION lock;
}
gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_lock_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
{ { 0, -1 } }
# define glthread_lock_init(LOCK) \
(glthread_lock_init_func (LOCK), 0)
# define glthread_lock_lock(LOCK) \
glthread_lock_lock_func (LOCK)
# define glthread_lock_unlock(LOCK) \
glthread_lock_unlock_func (LOCK)
# define glthread_lock_destroy(LOCK) \
glthread_lock_destroy_func (LOCK)
extern void glthread_lock_init_func (gl_lock_t *lock);
extern int glthread_lock_lock_func (gl_lock_t *lock);
extern int glthread_lock_unlock_func (gl_lock_t *lock);
extern int glthread_lock_destroy_func (gl_lock_t *lock);
/* ------------------------- gl_rwlock_t datatype ------------------------- */
/* It is impossible to implement read-write locks using plain locks, without
introducing an extra thread dedicated to managing read-write locks.
Therefore here we need to use the low-level Event type. */
typedef struct
{
HANDLE *array; /* array of waiting threads, each represented by an event */
unsigned int count; /* number of waiting threads */
unsigned int alloc; /* length of allocated array */
unsigned int offset; /* index of first waiting thread in array */
}
gl_carray_waitqueue_t;
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
CRITICAL_SECTION lock; /* protects the remaining fields */
gl_carray_waitqueue_t waiting_readers; /* waiting readers */
gl_carray_waitqueue_t waiting_writers; /* waiting writers */
int runcount; /* number of readers running, or -1 when a writer runs */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ { 0, -1 } }
# define glthread_rwlock_init(LOCK) \
(glthread_rwlock_init_func (LOCK), 0)
# define glthread_rwlock_rdlock(LOCK) \
glthread_rwlock_rdlock_func (LOCK)
# define glthread_rwlock_wrlock(LOCK) \
glthread_rwlock_wrlock_func (LOCK)
# define glthread_rwlock_unlock(LOCK) \
glthread_rwlock_unlock_func (LOCK)
# define glthread_rwlock_destroy(LOCK) \
glthread_rwlock_destroy_func (LOCK)
extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* The native Windows documentation says that CRITICAL_SECTION already
implements a recursive lock. But we need not rely on it: It's easy to
implement a recursive lock without this assumption. */
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
DWORD owner;
unsigned long depth;
CRITICAL_SECTION lock;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ { 0, -1 }, 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(glthread_recursive_lock_init_func (LOCK), 0)
# define glthread_recursive_lock_lock(LOCK) \
glthread_recursive_lock_lock_func (LOCK)
# define glthread_recursive_lock_unlock(LOCK) \
glthread_recursive_lock_unlock_func (LOCK)
# define glthread_recursive_lock_destroy(LOCK) \
glthread_recursive_lock_destroy_func (LOCK)
extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
/* -------------------------- gl_once_t datatype -------------------------- */
typedef struct
{
volatile int inited;
volatile long started;
CRITICAL_SECTION lock;
}
gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = { -1, -1 };
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
/* Provide dummy implementation if threads are not supported. */
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef int gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME)
# define gl_lock_define_initialized(STORAGECLASS, NAME)
# define glthread_lock_init(NAME) 0
# define glthread_lock_lock(NAME) 0
# define glthread_lock_unlock(NAME) 0
# define glthread_lock_destroy(NAME) 0
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef int gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME)
# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
# define glthread_rwlock_init(NAME) 0
# define glthread_rwlock_rdlock(NAME) 0
# define glthread_rwlock_wrlock(NAME) 0
# define glthread_rwlock_unlock(NAME) 0
# define glthread_rwlock_destroy(NAME) 0
/* --------------------- gl_recursive_lock_t datatype --------------------- */
typedef int gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME)
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
# define glthread_recursive_lock_init(NAME) 0
# define glthread_recursive_lock_lock(NAME) 0
# define glthread_recursive_lock_unlock(NAME) 0
# define glthread_recursive_lock_destroy(NAME) 0
/* -------------------------- gl_once_t datatype -------------------------- */
typedef int gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = 0;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
#endif
/* ========================================================================= */
/* Macros with built-in error handling. */
/* -------------------------- gl_lock_t datatype -------------------------- */
#define gl_lock_init(NAME) \
do \
{ \
if (glthread_lock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_lock(NAME) \
do \
{ \
if (glthread_lock_lock (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_unlock(NAME) \
do \
{ \
if (glthread_lock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_destroy(NAME) \
do \
{ \
if (glthread_lock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
#define gl_rwlock_init(NAME) \
do \
{ \
if (glthread_rwlock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_rdlock(NAME) \
do \
{ \
if (glthread_rwlock_rdlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_wrlock(NAME) \
do \
{ \
if (glthread_rwlock_wrlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_unlock(NAME) \
do \
{ \
if (glthread_rwlock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_destroy(NAME) \
do \
{ \
if (glthread_rwlock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
#define gl_recursive_lock_init(NAME) \
do \
{ \
if (glthread_recursive_lock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_lock(NAME) \
do \
{ \
if (glthread_recursive_lock_lock (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_unlock(NAME) \
do \
{ \
if (glthread_recursive_lock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_destroy(NAME) \
do \
{ \
if (glthread_recursive_lock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* -------------------------- gl_once_t datatype -------------------------- */
#define gl_once(NAME, INITFUNCTION) \
do \
{ \
if (glthread_once (&NAME, INITFUNCTION)) \
abort (); \
} \
while (0)
/* ========================================================================= */
#endif /* _LOCK_H */
plptools-1.0.13/intl/dgettext.c 0000644 0001750 0001750 00000003274 12417352630 013344 0000000 0000000 /* Implementation of the dgettext(3) function.
Copyright (C) 1995-1997, 2000-2003 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.1 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 . */
#ifdef HAVE_CONFIG_H
# include
#endif
#include "gettextP.h"
#include
#ifdef _LIBC
# include
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DGETTEXT __dgettext
# define DCGETTEXT INTUSE(__dcgettext)
#else
# define DGETTEXT libintl_dgettext
# define DCGETTEXT libintl_dcgettext
#endif
/* Look up MSGID in the DOMAINNAME message catalog of the current
LC_MESSAGES locale. */
char *
DGETTEXT (const char *domainname, const char *msgid)
{
return DCGETTEXT (domainname, msgid, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dgettext, dgettext);
#endif
plptools-1.0.13/intl/langprefs.c 0000644 0001750 0001750 00000030642 12417352631 013475 0000000 0000000 /* Determine the user's language preferences.
Copyright (C) 2004-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 2.1 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 . */
/* Written by Bruno Haible .
Win32 code originally by Michele Cicciotti