mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Switched to GPLv3.
Updated gettext.
This commit is contained in:
parent
960ac80048
commit
9a2a818887
437 changed files with 50446 additions and 48211 deletions
|
@ -1,4 +1,4 @@
|
|||
2004-01-29 GNU <bug-gnu-gettext@gnu.org>
|
||||
2006-11-27 GNU <bug-gnu-gettext@gnu.org>
|
||||
|
||||
* Version 0.14.1 released.
|
||||
* Version 0.16.1 released.
|
||||
|
||||
|
|
139
intl/Makefile.in
139
intl/Makefile.in
|
@ -1,5 +1,5 @@
|
|||
# Makefile for directory with message catalog handling library of GNU gettext
|
||||
# Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Library General Public License as published
|
||||
|
@ -24,6 +24,17 @@ SHELL = /bin/sh
|
|||
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@
|
||||
|
@ -31,6 +42,7 @@ exec_prefix = @exec_prefix@
|
|||
transform = @program_transform_name@
|
||||
libdir = @libdir@
|
||||
includedir = @includedir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
localedir = $(datadir)/locale
|
||||
gettextsrcdir = $(datadir)/gettext/intl
|
||||
|
@ -39,8 +51,18 @@ subdir = intl
|
|||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
|
||||
|
||||
# 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@
|
||||
|
||||
|
@ -51,15 +73,19 @@ RANLIB = @RANLIB@
|
|||
YACC = @INTLBISON@ -y -d
|
||||
YFLAGS = --name-prefix=__gettext
|
||||
|
||||
# -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)\" -DIN_LIBINTL \
|
||||
-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@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
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)
|
||||
|
@ -72,6 +98,7 @@ HEADERS = \
|
|||
plural-exp.h \
|
||||
eval-plural.h \
|
||||
localcharset.h \
|
||||
lock.h \
|
||||
relocatable.h \
|
||||
xsize.h \
|
||||
printf-args.h printf-args.c \
|
||||
|
@ -85,6 +112,7 @@ SOURCES = \
|
|||
dgettext.c \
|
||||
gettext.c \
|
||||
finddomain.c \
|
||||
hash-string.c \
|
||||
loadmsgcat.c \
|
||||
localealias.c \
|
||||
textdomain.c \
|
||||
|
@ -97,12 +125,16 @@ SOURCES = \
|
|||
plural.y \
|
||||
plural-exp.c \
|
||||
localcharset.c \
|
||||
lock.c \
|
||||
relocatable.c \
|
||||
langprefs.c \
|
||||
localename.c \
|
||||
log.c \
|
||||
printf.c \
|
||||
version.c \
|
||||
osdep.c \
|
||||
os2compat.c \
|
||||
intl-exports.c \
|
||||
intl-compat.c
|
||||
OBJECTS = \
|
||||
bindtextdom.$lo \
|
||||
|
@ -110,6 +142,7 @@ OBJECTS = \
|
|||
dgettext.$lo \
|
||||
gettext.$lo \
|
||||
finddomain.$lo \
|
||||
hash-string.$lo \
|
||||
loadmsgcat.$lo \
|
||||
localealias.$lo \
|
||||
textdomain.$lo \
|
||||
|
@ -122,21 +155,25 @@ OBJECTS = \
|
|||
plural.$lo \
|
||||
plural-exp.$lo \
|
||||
localcharset.$lo \
|
||||
lock.$lo \
|
||||
relocatable.$lo \
|
||||
langprefs.$lo \
|
||||
localename.$lo \
|
||||
log.$lo \
|
||||
printf.$lo \
|
||||
version.$lo \
|
||||
osdep.$lo \
|
||||
intl-compat.$lo
|
||||
DISTFILES.common = Makefile.in \
|
||||
config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES)
|
||||
config.charset locale.alias ref-add.sin ref-del.sin export.h \
|
||||
$(HEADERS) $(SOURCES)
|
||||
DISTFILES.generated = plural.c
|
||||
DISTFILES.normal = VERSION
|
||||
DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc \
|
||||
libgnuintl.h_vms Makefile.vms \
|
||||
libgnuintl.h.msvc-static libgnuintl.h.msvc-shared README.woe32 Makefile.msvc
|
||||
DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc README.woe32
|
||||
DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \
|
||||
COPYING.LIB-2 gettext.h libgettext.h plural-eval.c libgnuintl.h
|
||||
COPYING.LIB-2 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
|
||||
|
@ -152,7 +189,7 @@ libintl.a libgnuintl.a: $(OBJECTS)
|
|||
libintl.la libgnuintl.la: $(OBJECTS)
|
||||
$(LIBTOOL) --mode=link \
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \
|
||||
$(OBJECTS) @LTLIBICONV@ $(LIBS) -lc \
|
||||
$(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) @LTLIBTHREAD@ -lc \
|
||||
-version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
|
||||
-rpath $(libdir) \
|
||||
-no-undefined
|
||||
|
@ -162,9 +199,9 @@ libintl.la libgnuintl.la: $(OBJECTS)
|
|||
# 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=7
|
||||
LTV_REVISION=0
|
||||
LTV_AGE=4
|
||||
LTV_CURRENT=8
|
||||
LTV_REVISION=1
|
||||
LTV_AGE=0
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .y .o .lo .sin .sed
|
||||
|
@ -186,6 +223,8 @@ gettext.lo: $(srcdir)/gettext.c
|
|||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/gettext.c
|
||||
finddomain.lo: $(srcdir)/finddomain.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/finddomain.c
|
||||
hash-string.lo: $(srcdir)/hash-string.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/hash-string.c
|
||||
loadmsgcat.lo: $(srcdir)/loadmsgcat.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c
|
||||
localealias.lo: $(srcdir)/localealias.c
|
||||
|
@ -210,14 +249,20 @@ plural-exp.lo: $(srcdir)/plural-exp.c
|
|||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c
|
||||
localcharset.lo: $(srcdir)/localcharset.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c
|
||||
lock.lo: $(srcdir)/lock.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c
|
||||
relocatable.lo: $(srcdir)/relocatable.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c
|
||||
langprefs.lo: $(srcdir)/langprefs.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/langprefs.c
|
||||
localename.lo: $(srcdir)/localename.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localename.c
|
||||
log.lo: $(srcdir)/log.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/log.c
|
||||
printf.lo: $(srcdir)/printf.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/printf.c
|
||||
version.lo: $(srcdir)/version.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/version.c
|
||||
osdep.lo: $(srcdir)/osdep.c
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/osdep.c
|
||||
intl-compat.lo: $(srcdir)/intl-compat.c
|
||||
|
@ -233,14 +278,29 @@ ref-del.sed: $(srcdir)/ref-del.sin
|
|||
INCLUDES = -I. -I$(srcdir) -I..
|
||||
|
||||
libgnuintl.h: $(srcdir)/libgnuintl.h.in
|
||||
sed -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
|
||||
sed -e '/IN_LIBGLOCALE/d' \
|
||||
-e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
|
||||
-e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
< $(srcdir)/libgnuintl.h.in > libgnuintl.h
|
||||
< $(srcdir)/libgnuintl.h.in \
|
||||
| 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: libgnuintl.h
|
||||
cp libgnuintl.h libintl.h
|
||||
libintl.h: $(srcdir)/libgnuintl.h.in
|
||||
sed -e '/IN_LIBGLOCALE/d' \
|
||||
-e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
|
||||
-e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
< $(srcdir)/libgnuintl.h.in > libintl.h
|
||||
|
||||
charset.alias: $(srcdir)/config.charset
|
||||
$(SHELL) $(srcdir)/config.charset '@host@' > t-$@
|
||||
|
@ -257,7 +317,7 @@ install: install-exec install-data
|
|||
install-exec: all
|
||||
if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = yes; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
|
||||
$(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; \
|
||||
|
@ -271,8 +331,9 @@ install-exec: all
|
|||
: ; \
|
||||
fi
|
||||
if test "$(PACKAGE)" = "gettext-tools" \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = no; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir); \
|
||||
&& 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; \
|
||||
|
@ -283,7 +344,7 @@ install-exec: all
|
|||
: ; \
|
||||
fi
|
||||
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
|
||||
test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
|
||||
test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \
|
||||
temp=$(DESTDIR)$(libdir)/t-charset.alias; \
|
||||
dest=$(DESTDIR)$(libdir)/charset.alias; \
|
||||
if test -f $(DESTDIR)$(libdir)/charset.alias; then \
|
||||
|
@ -299,7 +360,7 @@ install-exec: all
|
|||
rm -f $$temp; \
|
||||
fi; \
|
||||
fi; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(localedir); \
|
||||
$(mkdir_p) $(DESTDIR)$(localedir); \
|
||||
test -f $(DESTDIR)$(localedir)/locale.alias \
|
||||
&& orig=$(DESTDIR)$(localedir)/locale.alias \
|
||||
|| orig=$(srcdir)/locale.alias; \
|
||||
|
@ -313,7 +374,7 @@ install-exec: all
|
|||
fi
|
||||
install-data: all
|
||||
if test "$(PACKAGE)" = "gettext-tools"; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
|
||||
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
|
||||
$(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
|
||||
$(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
|
||||
dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \
|
||||
|
@ -341,24 +402,25 @@ install-strip: install
|
|||
installdirs:
|
||||
if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = yes; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
|
||||
$(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
if test "$(PACKAGE)" = "gettext-tools" \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = no; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir); \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = no \
|
||||
&& test @GLIBC2@ != no; then \
|
||||
$(mkdir_p) $(DESTDIR)$(libdir); \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
|
||||
test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
|
||||
$(mkinstalldirs) $(DESTDIR)$(localedir); \
|
||||
test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \
|
||||
$(mkdir_p) $(DESTDIR)$(localedir); \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
if test "$(PACKAGE)" = "gettext-tools"; then \
|
||||
$(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
|
||||
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
|
@ -376,7 +438,8 @@ uninstall:
|
|||
: ; \
|
||||
fi
|
||||
if test "$(PACKAGE)" = "gettext-tools" \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = no; then \
|
||||
&& test '@USE_INCLUDED_LIBINTL@' = no \
|
||||
&& test @GLIBC2@ != no; then \
|
||||
rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \
|
||||
else \
|
||||
: ; \
|
||||
|
@ -419,14 +482,20 @@ 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 textdomain.$lo: $(srcdir)/gettextP.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h
|
||||
dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.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)/printf-parse.c $(srcdir)/vasnprintf.h $(srcdir)/vasnwprintf.h $(srcdir)/vasnprintf.c
|
||||
|
||||
# A bison-2.1 generated plural.c includes <libintl.h> if ENABLE_NLS.
|
||||
PLURAL_DEPS_yes = libintl.h
|
||||
PLURAL_DEPS_no =
|
||||
plural.$lo: $(PLURAL_DEPS_@USE_INCLUDED_LIBINTL@)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES)
|
||||
|
@ -478,7 +547,7 @@ dist distdir: Makefile
|
|||
$(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); \
|
||||
cp -p $$dir/$$file $(distdir) || test $$file = Makefile.in || exit 1; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
|
@ -486,7 +555,7 @@ 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) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
# 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.
|
||||
|
|
|
@ -1 +1 @@
|
|||
GNU gettext library from gettext-0.14.1
|
||||
GNU gettext library from gettext-0.16.1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Implementation of the bindtextdomain(3) function
|
||||
Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
|
||||
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 Library General Public License as published
|
||||
|
@ -24,21 +24,21 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettextP.h"
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
#else
|
||||
# include "libgnuintl.h"
|
||||
#endif
|
||||
#include "gettextP.h"
|
||||
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
/* We have to handle multi-threaded applications. */
|
||||
# include <bits/libc-lock.h>
|
||||
# define gl_rwlock_define __libc_rwlock_define
|
||||
# define gl_rwlock_wrlock __libc_rwlock_wrlock
|
||||
# define gl_rwlock_unlock __libc_rwlock_unlock
|
||||
#else
|
||||
/* Provide dummy implementation if this is outside glibc. */
|
||||
# define __libc_rwlock_define(CLASS, NAME)
|
||||
# define __libc_rwlock_wrlock(NAME)
|
||||
# define __libc_rwlock_unlock(NAME)
|
||||
# include "lock.h"
|
||||
#endif
|
||||
|
||||
/* The internal variables in the standalone libintl.a must have different
|
||||
|
@ -59,16 +59,14 @@
|
|||
/* Contains the default location of the message catalogs. */
|
||||
extern const char _nl_default_dirname[];
|
||||
#ifdef _LIBC
|
||||
extern const char _nl_default_dirname_internal[] attribute_hidden;
|
||||
#else
|
||||
# define INTUSE(name) name
|
||||
libc_hidden_proto (_nl_default_dirname)
|
||||
#endif
|
||||
|
||||
/* List with bindings of specific domains. */
|
||||
extern struct binding *_nl_domain_bindings;
|
||||
|
||||
/* Lock variable to protect the global data in the gettext implementation. */
|
||||
__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
|
||||
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
|
||||
|
||||
|
||||
/* Names for the libintl functions are a problem. They must not clash
|
||||
|
@ -109,7 +107,7 @@ set_binding_values (const char *domainname,
|
|||
return;
|
||||
}
|
||||
|
||||
__libc_rwlock_wrlock (_nl_state_lock);
|
||||
gl_rwlock_wrlock (_nl_state_lock);
|
||||
|
||||
modified = 0;
|
||||
|
||||
|
@ -144,8 +142,8 @@ set_binding_values (const char *domainname,
|
|||
char *result = binding->dirname;
|
||||
if (strcmp (dirname, result) != 0)
|
||||
{
|
||||
if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
|
||||
result = (char *) INTUSE(_nl_default_dirname);
|
||||
if (strcmp (dirname, _nl_default_dirname) == 0)
|
||||
result = (char *) _nl_default_dirname;
|
||||
else
|
||||
{
|
||||
#if defined _LIBC || defined HAVE_STRDUP
|
||||
|
@ -160,7 +158,7 @@ set_binding_values (const char *domainname,
|
|||
|
||||
if (__builtin_expect (result != NULL, 1))
|
||||
{
|
||||
if (binding->dirname != INTUSE(_nl_default_dirname))
|
||||
if (binding->dirname != _nl_default_dirname)
|
||||
free (binding->dirname);
|
||||
|
||||
binding->dirname = result;
|
||||
|
@ -201,7 +199,6 @@ set_binding_values (const char *domainname,
|
|||
free (binding->codeset);
|
||||
|
||||
binding->codeset = result;
|
||||
binding->codeset_cntr++;
|
||||
modified = 1;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +211,7 @@ set_binding_values (const char *domainname,
|
|||
{
|
||||
/* Simply return the default values. */
|
||||
if (dirnamep)
|
||||
*dirnamep = INTUSE(_nl_default_dirname);
|
||||
*dirnamep = _nl_default_dirname;
|
||||
if (codesetp)
|
||||
*codesetp = NULL;
|
||||
}
|
||||
|
@ -236,11 +233,11 @@ set_binding_values (const char *domainname,
|
|||
|
||||
if (dirname == NULL)
|
||||
/* The default value. */
|
||||
dirname = INTUSE(_nl_default_dirname);
|
||||
dirname = _nl_default_dirname;
|
||||
else
|
||||
{
|
||||
if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
|
||||
dirname = INTUSE(_nl_default_dirname);
|
||||
if (strcmp (dirname, _nl_default_dirname) == 0)
|
||||
dirname = _nl_default_dirname;
|
||||
else
|
||||
{
|
||||
char *result;
|
||||
|
@ -263,9 +260,7 @@ set_binding_values (const char *domainname,
|
|||
}
|
||||
else
|
||||
/* The default value. */
|
||||
new_binding->dirname = (char *) INTUSE(_nl_default_dirname);
|
||||
|
||||
new_binding->codeset_cntr = 0;
|
||||
new_binding->dirname = (char *) _nl_default_dirname;
|
||||
|
||||
if (codesetp)
|
||||
{
|
||||
|
@ -287,7 +282,6 @@ set_binding_values (const char *domainname,
|
|||
memcpy (result, codeset, len);
|
||||
#endif
|
||||
codeset = result;
|
||||
new_binding->codeset_cntr++;
|
||||
}
|
||||
*codesetp = codeset;
|
||||
new_binding->codeset = (char *) codeset;
|
||||
|
@ -319,7 +313,7 @@ set_binding_values (const char *domainname,
|
|||
if (0)
|
||||
{
|
||||
failed_codeset:
|
||||
if (new_binding->dirname != INTUSE(_nl_default_dirname))
|
||||
if (new_binding->dirname != _nl_default_dirname)
|
||||
free (new_binding->dirname);
|
||||
failed_dirname:
|
||||
free (new_binding);
|
||||
|
@ -335,7 +329,7 @@ set_binding_values (const char *domainname,
|
|||
if (modified)
|
||||
++_nl_msg_cat_cntr;
|
||||
|
||||
__libc_rwlock_unlock (_nl_state_lock);
|
||||
gl_rwlock_unlock (_nl_state_lock);
|
||||
}
|
||||
|
||||
/* Specify that the DOMAINNAME message catalog will be found
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
# Output a system dependent table of character encoding aliases.
|
||||
#
|
||||
# Copyright (C) 2000-2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Library General Public License as published
|
||||
|
@ -31,21 +31,21 @@
|
|||
# The current list of GNU canonical charset names is as follows.
|
||||
#
|
||||
# name MIME? used by which systems
|
||||
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd darwin
|
||||
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd darwin
|
||||
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd darwin
|
||||
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin
|
||||
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# ISO-8859-3 Y glibc solaris
|
||||
# ISO-8859-4 Y osf solaris freebsd darwin
|
||||
# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd darwin
|
||||
# ISO-8859-4 Y osf solaris freebsd netbsd darwin
|
||||
# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# ISO-8859-6 Y glibc aix hpux solaris
|
||||
# ISO-8859-7 Y glibc aix hpux irix osf solaris
|
||||
# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd darwin
|
||||
# ISO-8859-8 Y glibc aix hpux osf solaris
|
||||
# ISO-8859-9 Y glibc aix hpux irix osf solaris
|
||||
# ISO-8859-13 glibc
|
||||
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin
|
||||
# ISO-8859-13 glibc netbsd darwin
|
||||
# ISO-8859-14 glibc
|
||||
# ISO-8859-15 glibc aix osf solaris freebsd
|
||||
# KOI8-R Y glibc solaris freebsd darwin
|
||||
# KOI8-U Y glibc freebsd darwin
|
||||
# ISO-8859-15 glibc aix osf solaris freebsd darwin
|
||||
# KOI8-R Y glibc solaris freebsd netbsd darwin
|
||||
# KOI8-U Y glibc freebsd netbsd darwin
|
||||
# KOI8-T glibc
|
||||
# CP437 dos
|
||||
# CP775 dos
|
||||
|
@ -58,7 +58,7 @@
|
|||
# CP862 dos
|
||||
# CP864 dos
|
||||
# CP865 dos
|
||||
# CP866 freebsd darwin dos
|
||||
# CP866 freebsd netbsd darwin dos
|
||||
# CP869 dos
|
||||
# CP874 woe32 dos
|
||||
# CP922 aix
|
||||
|
@ -71,22 +71,22 @@
|
|||
# CP1125 dos
|
||||
# CP1129 aix
|
||||
# CP1250 woe32
|
||||
# CP1251 glibc solaris darwin woe32
|
||||
# CP1251 glibc solaris netbsd darwin woe32
|
||||
# CP1252 aix woe32
|
||||
# CP1253 woe32
|
||||
# CP1254 woe32
|
||||
# CP1255 glibc woe32
|
||||
# CP1256 woe32
|
||||
# CP1257 woe32
|
||||
# GB2312 Y glibc aix hpux irix solaris freebsd darwin
|
||||
# EUC-JP Y glibc aix hpux irix osf solaris freebsd darwin
|
||||
# EUC-KR Y glibc aix hpux irix osf solaris freebsd darwin
|
||||
# EUC-TW glibc aix hpux irix osf solaris
|
||||
# BIG5 Y glibc aix hpux osf solaris freebsd darwin
|
||||
# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
|
||||
# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin
|
||||
# EUC-TW glibc aix hpux irix osf solaris netbsd
|
||||
# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin
|
||||
# BIG5-HKSCS glibc solaris
|
||||
# GBK glibc aix osf solaris woe32 dos
|
||||
# GB18030 glibc solaris
|
||||
# SHIFT_JIS Y hpux osf solaris freebsd darwin
|
||||
# GB18030 glibc solaris netbsd
|
||||
# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
|
||||
# JOHAB glibc solaris woe32
|
||||
# TIS-620 glibc aix hpux osf solaris
|
||||
# VISCII Y glibc
|
||||
|
@ -100,7 +100,7 @@
|
|||
# HP-KANA8 hpux
|
||||
# DEC-KANJI osf
|
||||
# DEC-HANYU osf
|
||||
# UTF-8 Y glibc aix hpux osf solaris
|
||||
# UTF-8 Y glibc aix hpux osf solaris netbsd darwin
|
||||
#
|
||||
# Note: Names which are not marked as being a MIME name should not be used in
|
||||
# Internet protocols for information interchange (mail, news, etc.).
|
||||
|
@ -388,6 +388,8 @@ case "$os" in
|
|||
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"
|
||||
|
@ -396,7 +398,7 @@ case "$os" in
|
|||
echo "BIG5 BIG5"
|
||||
echo "SJIS SHIFT_JIS"
|
||||
;;
|
||||
darwin*)
|
||||
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.
|
||||
|
@ -437,6 +439,36 @@ case "$os" in
|
|||
echo "ja_JP.SJIS SHIFT_JIS"
|
||||
echo "ko_KR.EUC EUC-KR"
|
||||
;;
|
||||
darwin*)
|
||||
# Darwin 7.5 has nl_langinfo(CODESET), but it is useless:
|
||||
# - It returns the empty string when LANG is set to a locale of the
|
||||
# form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
|
||||
# LC_CTYPE file.
|
||||
# - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
|
||||
# the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
|
||||
# - The documentation says:
|
||||
# "... all code that calls BSD system routines should ensure
|
||||
# that the const *char parameters of these routines are in UTF-8
|
||||
# encoding. All BSD system functions expect their string
|
||||
# parameters to be in UTF-8 encoding and nothing else."
|
||||
# It also says
|
||||
# "An additional caveat is that string parameters for files,
|
||||
# paths, and other file-system entities must be in canonical
|
||||
# UTF-8. In a canonical UTF-8 Unicode string, all decomposable
|
||||
# characters are decomposed ..."
|
||||
# but this is not true: You can pass non-decomposed UTF-8 strings
|
||||
# to file system functions, and it is the OS which will convert
|
||||
# them to decomposed UTF-8 before accessing the file system.
|
||||
# - The Apple Terminal application displays UTF-8 by default.
|
||||
# - However, other applications are free to use different encodings:
|
||||
# - xterm uses ISO-8859-1 by default.
|
||||
# - TextEdit uses MacRoman by default.
|
||||
# We prefer UTF-8 over decomposed UTF-8-MAC because one should
|
||||
# minimize the use of decomposed Unicode. Unfortunately, through the
|
||||
# Darwin file system, decomposed UTF-8 strings are leaked into user
|
||||
# space nevertheless.
|
||||
echo "* UTF-8"
|
||||
;;
|
||||
beos*)
|
||||
# BeOS has a single locale, and it has UTF-8 encoding.
|
||||
echo "* UTF-8"
|
||||
|
@ -450,7 +482,7 @@ case "$os" in
|
|||
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 <st001906@hrz1.hrz.tu-darmstadt.de>"
|
||||
echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
|
||||
echo "# and Bruno Haible <bruno@clisp.org>."
|
||||
echo "#"
|
||||
echo "C ASCII"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1995-1998, 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995-1998, 2000-2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,11 +37,15 @@
|
|||
|
||||
/* @@ end of prolog @@ */
|
||||
|
||||
char *
|
||||
/* 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[0] != ',')
|
||||
while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.')
|
||||
++name;
|
||||
|
||||
return (char *) name;
|
||||
|
@ -52,10 +56,8 @@ int
|
|||
_nl_explode_name (char *name,
|
||||
const char **language, const char **modifier,
|
||||
const char **territory, const char **codeset,
|
||||
const char **normalized_codeset, const char **special,
|
||||
const char **sponsor, const char **revision)
|
||||
const char **normalized_codeset)
|
||||
{
|
||||
enum { undecided, xpg, cen } syntax;
|
||||
char *cp;
|
||||
int mask;
|
||||
|
||||
|
@ -63,15 +65,10 @@ _nl_explode_name (char *name,
|
|||
*territory = NULL;
|
||||
*codeset = NULL;
|
||||
*normalized_codeset = NULL;
|
||||
*special = NULL;
|
||||
*sponsor = NULL;
|
||||
*revision = NULL;
|
||||
|
||||
/* Now we determine the single parts of the locale name. First
|
||||
look for the language. Termination symbols are `_' and `@' if
|
||||
we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
|
||||
look for the language. Termination symbols are `_', '.', and `@'. */
|
||||
mask = 0;
|
||||
syntax = undecided;
|
||||
*language = cp = name;
|
||||
cp = _nl_find_language (*language);
|
||||
|
||||
|
@ -79,22 +76,23 @@ _nl_explode_name (char *name,
|
|||
/* 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] == '_')
|
||||
else
|
||||
{
|
||||
/* Next is the territory. */
|
||||
cp[0] = '\0';
|
||||
*territory = ++cp;
|
||||
if (cp[0] == '_')
|
||||
{
|
||||
/* Next is the territory. */
|
||||
cp[0] = '\0';
|
||||
*territory = ++cp;
|
||||
|
||||
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
|
||||
&& cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
|
||||
++cp;
|
||||
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@')
|
||||
++cp;
|
||||
|
||||
mask |= TERRITORY;
|
||||
mask |= XPG_TERRITORY;
|
||||
}
|
||||
|
||||
if (cp[0] == '.')
|
||||
{
|
||||
/* Next is the codeset. */
|
||||
syntax = xpg;
|
||||
cp[0] = '\0';
|
||||
*codeset = ++cp;
|
||||
|
||||
|
@ -115,71 +113,21 @@ _nl_explode_name (char *name,
|
|||
}
|
||||
}
|
||||
|
||||
if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
|
||||
if (cp[0] == '@')
|
||||
{
|
||||
/* Next is the modifier. */
|
||||
syntax = cp[0] == '@' ? xpg : cen;
|
||||
cp[0] = '\0';
|
||||
*modifier = ++cp;
|
||||
|
||||
while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
|
||||
&& cp[0] != ',' && cp[0] != '_')
|
||||
++cp;
|
||||
|
||||
mask |= XPG_MODIFIER | CEN_AUDIENCE;
|
||||
if (cp[0] != '\0')
|
||||
mask |= XPG_MODIFIER;
|
||||
}
|
||||
|
||||
if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
|
||||
{
|
||||
syntax = cen;
|
||||
if (*territory != NULL && (*territory)[0] == '\0')
|
||||
mask &= ~XPG_TERRITORY;
|
||||
|
||||
if (cp[0] == '+')
|
||||
{
|
||||
/* Next is special application (CEN syntax). */
|
||||
cp[0] = '\0';
|
||||
*special = ++cp;
|
||||
|
||||
while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
|
||||
++cp;
|
||||
|
||||
mask |= CEN_SPECIAL;
|
||||
}
|
||||
|
||||
if (cp[0] == ',')
|
||||
{
|
||||
/* Next is sponsor (CEN syntax). */
|
||||
cp[0] = '\0';
|
||||
*sponsor = ++cp;
|
||||
|
||||
while (cp[0] != '\0' && cp[0] != '_')
|
||||
++cp;
|
||||
|
||||
mask |= CEN_SPONSOR;
|
||||
}
|
||||
|
||||
if (cp[0] == '_')
|
||||
{
|
||||
/* Next is revision (CEN syntax). */
|
||||
cp[0] = '\0';
|
||||
*revision = ++cp;
|
||||
|
||||
mask |= CEN_REVISION;
|
||||
}
|
||||
}
|
||||
|
||||
/* For CEN syntax values it might be important to have the
|
||||
separator character in the file name, not for XPG syntax. */
|
||||
if (syntax == xpg)
|
||||
{
|
||||
if (*territory != NULL && (*territory)[0] == '\0')
|
||||
mask &= ~TERRITORY;
|
||||
|
||||
if (*codeset != NULL && (*codeset)[0] == '\0')
|
||||
mask &= ~XPG_CODESET;
|
||||
|
||||
if (*modifier != NULL && (*modifier)[0] == '\0')
|
||||
mask &= ~XPG_MODIFIER;
|
||||
}
|
||||
if (*codeset != NULL && (*codeset)[0] == '\0')
|
||||
mask &= ~XPG_CODESET;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
|
6
intl/export.h
Normal file
6
intl/export.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
#if @HAVE_VISIBILITY@ && BUILDING_LIBINTL
|
||||
#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default")))
|
||||
#else
|
||||
#define LIBINTL_DLL_EXPORTED
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/* Handle list of needed message catalogs
|
||||
Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1999, 2000-2001, 2003-2006 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@gnu.org>, 1995.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,6 +37,17 @@
|
|||
# include "libgnuintl.h"
|
||||
#endif
|
||||
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
# include <bits/libc-lock.h>
|
||||
# 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;
|
||||
|
@ -56,44 +67,41 @@ _nl_find_domain (const char *dirname, char *locale,
|
|||
const char *territory;
|
||||
const char *codeset;
|
||||
const char *normalized_codeset;
|
||||
const char *special;
|
||||
const char *sponsor;
|
||||
const char *revision;
|
||||
const char *alias_value;
|
||||
int mask;
|
||||
|
||||
/* LOCALE can consist of up to four recognized parts for the XPG syntax:
|
||||
|
||||
language[_territory[.codeset]][@modifier]
|
||||
|
||||
and six parts for the CEN syntax:
|
||||
|
||||
language[_territory][+audience][+special][,[sponsor][_revision]]
|
||||
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) revision
|
||||
(2) sponsor
|
||||
(3) special
|
||||
(4) codeset
|
||||
(5) normalized codeset
|
||||
(6) territory
|
||||
(7) audience/modifier
|
||||
(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, NULL, NULL, NULL, domainname, 0);
|
||||
NULL, NULL, domainname, 0);
|
||||
|
||||
gl_rwlock_unlock (lock);
|
||||
|
||||
if (retval != NULL)
|
||||
{
|
||||
/* We know something about this locale. */
|
||||
int cnt;
|
||||
|
||||
if (retval->decided == 0)
|
||||
if (retval->decided <= 0)
|
||||
_nl_load_domain (retval, domainbinding);
|
||||
|
||||
if (retval->data != NULL)
|
||||
|
@ -101,13 +109,14 @@ _nl_find_domain (const char *dirname, char *locale,
|
|||
|
||||
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
|
||||
{
|
||||
if (retval->successor[cnt]->decided == 0)
|
||||
if (retval->successor[cnt]->decided <= 0)
|
||||
_nl_load_domain (retval->successor[cnt], domainbinding);
|
||||
|
||||
if (retval->successor[cnt]->data != NULL)
|
||||
break;
|
||||
}
|
||||
return cnt >= 0 ? retval : NULL;
|
||||
|
||||
return retval;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
@ -132,30 +141,34 @@ _nl_find_domain (const char *dirname, char *locale,
|
|||
}
|
||||
|
||||
/* Now we determine the single parts of the locale name. First
|
||||
look for the language. Termination symbols are `_' and `@' if
|
||||
we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
|
||||
look for the language. Termination symbols are `_', '.', and `@'. */
|
||||
mask = _nl_explode_name (locale, &language, &modifier, &territory,
|
||||
&codeset, &normalized_codeset, &special,
|
||||
&sponsor, &revision);
|
||||
&codeset, &normalized_codeset);
|
||||
|
||||
/* 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, special,
|
||||
sponsor, revision, domainname, 1);
|
||||
codeset, normalized_codeset, modifier,
|
||||
domainname, 1);
|
||||
|
||||
gl_rwlock_unlock (lock);
|
||||
|
||||
if (retval == NULL)
|
||||
/* This means we are out of core. */
|
||||
return NULL;
|
||||
|
||||
if (retval->decided == 0)
|
||||
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)
|
||||
if (retval->successor[cnt]->decided <= 0)
|
||||
_nl_load_domain (retval->successor[cnt], domainbinding);
|
||||
if (retval->successor[cnt]->data != NULL)
|
||||
break;
|
||||
|
@ -175,7 +188,10 @@ _nl_find_domain (const char *dirname, char *locale,
|
|||
|
||||
|
||||
#ifdef _LIBC
|
||||
libc_freeres_fn (free_mem)
|
||||
/* 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;
|
||||
|
||||
|
|
140
intl/gettextP.h
140
intl/gettextP.h
|
@ -1,5 +1,5 @@
|
|||
/* Header describing internals of libintl library.
|
||||
Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -30,6 +30,52 @@
|
|||
# endif
|
||||
#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. */
|
||||
|
@ -77,6 +123,26 @@ struct sysdep_string_desc
|
|||
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
|
||||
{
|
||||
|
@ -112,15 +178,9 @@ struct loaded_domain
|
|||
/* 1 if the hash table uses a different endianness than this machine. */
|
||||
int must_swap_hash_tab;
|
||||
|
||||
int codeset_cntr;
|
||||
#ifdef _LIBC
|
||||
__gconv_t conv;
|
||||
#else
|
||||
# if HAVE_ICONV
|
||||
iconv_t conv;
|
||||
# endif
|
||||
#endif
|
||||
char **conv_tab;
|
||||
/* Cache of charset conversions of the translated strings. */
|
||||
struct converted_domain *conversions;
|
||||
size_t nconversions;
|
||||
|
||||
struct expression *plural;
|
||||
unsigned long int nplurals;
|
||||
|
@ -140,7 +200,6 @@ struct binding
|
|||
{
|
||||
struct binding *next;
|
||||
char *dirname;
|
||||
int codeset_cntr; /* Incremented each time codeset changes. */
|
||||
char *codeset;
|
||||
char domainname[ZERO];
|
||||
};
|
||||
|
@ -148,9 +207,17 @@ struct binding
|
|||
/* A counter which is incremented each time some previous translations
|
||||
become invalid.
|
||||
This variable is part of the external ABI of the GNU libintl. */
|
||||
extern int _nl_msg_cat_cntr;
|
||||
#ifdef IN_LIBGLOCALE
|
||||
# include <glocale/config.h>
|
||||
extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
|
||||
#else
|
||||
extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBC
|
||||
const char *_nl_language_preferences_default (void);
|
||||
const char *_nl_locale_name_posix (int category, const char *categoryname);
|
||||
const char *_nl_locale_name_default (void);
|
||||
const char *_nl_locale_name (int category, const char *categoryname);
|
||||
#endif
|
||||
|
||||
|
@ -161,53 +228,18 @@ struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
|
|||
void _nl_load_domain (struct loaded_l10nfile *__domain,
|
||||
struct binding *__domainbinding)
|
||||
internal_function;
|
||||
void _nl_unload_domain (struct loaded_domain *__domain)
|
||||
internal_function;
|
||||
const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file,
|
||||
struct loaded_domain *__domain,
|
||||
struct binding *__domainbinding)
|
||||
internal_function;
|
||||
void _nl_free_domain_conv (struct loaded_domain *__domain)
|
||||
internal_function;
|
||||
|
||||
#ifdef IN_LIBGLOCALE
|
||||
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
|
||||
struct binding *domainbinding, const char *msgid,
|
||||
struct binding *domainbinding, const char *encoding,
|
||||
const char *msgid,
|
||||
size_t *lengthp)
|
||||
internal_function;
|
||||
|
||||
#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);
|
||||
#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"
|
||||
extern char *libintl_dcigettext (const char *__domainname,
|
||||
const char *__msgid1, const char *__msgid2,
|
||||
int __plural, unsigned long int __n,
|
||||
int __category);
|
||||
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
|
||||
struct binding *domainbinding, const char *msgid,
|
||||
int convert, size_t *lengthp)
|
||||
internal_function;
|
||||
#endif
|
||||
|
||||
/* @@ begin of epilog @@ */
|
||||
|
|
51
intl/hash-string.c
Normal file
51
intl/hash-string.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* Implements a string hashing function.
|
||||
Copyright (C) 1995, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library 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.
|
||||
|
||||
The GNU C Library 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 the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "hash-string.h"
|
||||
|
||||
|
||||
/* 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.] */
|
||||
unsigned long int
|
||||
__hash_string (const char *str_param)
|
||||
{
|
||||
unsigned long int hval, g;
|
||||
const char *str = str_param;
|
||||
|
||||
/* Compute the hash value for the given string. */
|
||||
hval = 0;
|
||||
while (*str != '\0')
|
||||
{
|
||||
hval <<= 4;
|
||||
hval += (unsigned char) *str++;
|
||||
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
|
||||
if (g != 0)
|
||||
{
|
||||
hval ^= g >> (HASHWORDBITS - 8);
|
||||
hval ^= g;
|
||||
}
|
||||
}
|
||||
return hval;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* Description of GNU message catalog format: string hashing function.
|
||||
Copyright (C) 1995, 1997-1998, 2000-2003 Free Software Foundation, Inc.
|
||||
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 Library General Public License as published
|
||||
|
@ -22,27 +22,15 @@
|
|||
#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.] */
|
||||
static inline unsigned long int
|
||||
hash_string (const char *str_param)
|
||||
{
|
||||
unsigned long int hval, g;
|
||||
const char *str = str_param;
|
||||
|
||||
/* Compute the hash value for the given string. */
|
||||
hval = 0;
|
||||
while (*str != '\0')
|
||||
{
|
||||
hval <<= 4;
|
||||
hval += (unsigned char) *str++;
|
||||
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
|
||||
if (g != 0)
|
||||
{
|
||||
hval ^= g >> (HASHWORDBITS - 8);
|
||||
hval ^= g;
|
||||
}
|
||||
}
|
||||
return hval;
|
||||
}
|
||||
extern unsigned long int __hash_string (const char *str_param);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* intl-compat.c - Stub functions to call gettext functions from GNU gettext
|
||||
Library.
|
||||
Copyright (C) 1995, 2000-2003 Software Foundation, Inc.
|
||||
Copyright (C) 1995, 2000-2003, 2005 Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -49,7 +49,9 @@
|
|||
/* 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 defined _MSC_VER && BUILDING_DLL
|
||||
#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
|
||||
|
|
36
intl/intl-exports.c
Normal file
36
intl/intl-exports.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* List of exported symbols of libintl on Cygwin.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2006.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* IMP(x) is a symbol that contains the address of x. */
|
||||
#define IMP(x) _imp__##x
|
||||
|
||||
/* 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)
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc.
|
||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -67,8 +67,8 @@ static char *stpcpy (char *dest, const char *src);
|
|||
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 __EMX__ || defined __DJGPP__
|
||||
/* Win32, OS/2, DOS */
|
||||
#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')) \
|
||||
|
@ -82,7 +82,12 @@ static char *stpcpy (char *dest, const char *src);
|
|||
|
||||
/* Define function which are usually not available. */
|
||||
|
||||
#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
|
||||
#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)
|
||||
|
@ -99,13 +104,15 @@ argz_count__ (const char *argz, size_t len)
|
|||
}
|
||||
# undef __argz_count
|
||||
# define __argz_count(argz, len) argz_count__ (argz, len)
|
||||
#else
|
||||
# ifdef _LIBC
|
||||
# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
|
||||
# endif
|
||||
#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
|
||||
#endif /* !_LIBC && !HAVE_ARGZ_COUNT */
|
||||
|
||||
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
|
||||
#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
|
||||
|
@ -122,14 +129,13 @@ argz_stringify__ (char *argz, size_t len, int sep)
|
|||
}
|
||||
# undef __argz_stringify
|
||||
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
|
||||
#else
|
||||
# ifdef _LIBC
|
||||
# define __argz_stringify(argz, len, sep) \
|
||||
INTUSE(__argz_stringify) (argz, len, sep)
|
||||
# endif
|
||||
#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
|
||||
#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */
|
||||
|
||||
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
|
||||
#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)
|
||||
{
|
||||
|
@ -148,7 +154,7 @@ argz_next__ (char *argz, size_t argz_len, const char *entry)
|
|||
}
|
||||
# undef __argz_next
|
||||
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
|
||||
#endif /* !_LIBC && !HAVE___ARGZ_NEXT */
|
||||
#endif /* !_LIBC && !HAVE_ARGZ_NEXT */
|
||||
|
||||
|
||||
/* Return number of bits set in X. */
|
||||
|
@ -170,8 +176,7 @@ _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 *special,
|
||||
const char *sponsor, const char *revision,
|
||||
const char *modifier,
|
||||
const char *filename, int do_allocate)
|
||||
{
|
||||
char *abs_filename;
|
||||
|
@ -190,23 +195,14 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
/* Allocate room for the full file name. */
|
||||
abs_filename = (char *) malloc (dirlist_len
|
||||
+ strlen (language)
|
||||
+ ((mask & TERRITORY) != 0
|
||||
+ ((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
|
||||
|| (mask & CEN_AUDIENCE) != 0)
|
||||
+ ((mask & XPG_MODIFIER) != 0
|
||||
? strlen (modifier) + 1 : 0)
|
||||
+ ((mask & CEN_SPECIAL) != 0
|
||||
? strlen (special) + 1 : 0)
|
||||
+ (((mask & CEN_SPONSOR) != 0
|
||||
|| (mask & CEN_REVISION) != 0)
|
||||
? (1 + ((mask & CEN_SPONSOR) != 0
|
||||
? strlen (sponsor) : 0)
|
||||
+ ((mask & CEN_REVISION) != 0
|
||||
? strlen (revision) + 1 : 0)) : 0)
|
||||
+ 1 + strlen (filename) + 1);
|
||||
|
||||
if (abs_filename == NULL)
|
||||
|
@ -224,7 +220,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
|
||||
cp = stpcpy (cp, language);
|
||||
|
||||
if ((mask & TERRITORY) != 0)
|
||||
if ((mask & XPG_TERRITORY) != 0)
|
||||
{
|
||||
*cp++ = '_';
|
||||
cp = stpcpy (cp, territory);
|
||||
|
@ -239,29 +235,11 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
*cp++ = '.';
|
||||
cp = stpcpy (cp, normalized_codeset);
|
||||
}
|
||||
if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
|
||||
if ((mask & XPG_MODIFIER) != 0)
|
||||
{
|
||||
/* This component can be part of both syntaces but has different
|
||||
leading characters. For CEN we use `+', else `@'. */
|
||||
*cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
|
||||
*cp++ = '@';
|
||||
cp = stpcpy (cp, modifier);
|
||||
}
|
||||
if ((mask & CEN_SPECIAL) != 0)
|
||||
{
|
||||
*cp++ = '+';
|
||||
cp = stpcpy (cp, special);
|
||||
}
|
||||
if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
|
||||
{
|
||||
*cp++ = ',';
|
||||
if ((mask & CEN_SPONSOR) != 0)
|
||||
cp = stpcpy (cp, sponsor);
|
||||
if ((mask & CEN_REVISION) != 0)
|
||||
{
|
||||
*cp++ = '_';
|
||||
cp = stpcpy (cp, revision);
|
||||
}
|
||||
}
|
||||
|
||||
*cp++ = '/';
|
||||
stpcpy (cp, filename);
|
||||
|
@ -301,7 +279,10 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
+ (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
|
||||
* sizeof (struct loaded_l10nfile *)));
|
||||
if (retval == NULL)
|
||||
return NULL;
|
||||
{
|
||||
free (abs_filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
retval->filename = abs_filename;
|
||||
|
||||
|
@ -332,8 +313,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
normalized_codeset. */
|
||||
for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
|
||||
if ((cnt & ~mask) == 0
|
||||
&& ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
|
||||
&& ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
|
||||
&& !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0))
|
||||
{
|
||||
if (dirlist_count > 1)
|
||||
{
|
||||
|
@ -345,15 +325,14 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
|||
retval->successor[entries++]
|
||||
= _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
|
||||
cnt, language, territory, codeset,
|
||||
normalized_codeset, modifier, special,
|
||||
sponsor, revision, filename, 1);
|
||||
normalized_codeset, modifier, filename,
|
||||
1);
|
||||
}
|
||||
else
|
||||
retval->successor[entries++]
|
||||
= _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
|
||||
cnt, language, territory, codeset,
|
||||
normalized_codeset, modifier, special,
|
||||
sponsor, revision, filename, 1);
|
||||
normalized_codeset, modifier, filename, 1);
|
||||
}
|
||||
retval->successor[entries] = NULL;
|
||||
|
||||
|
|
130
intl/langprefs.c
Normal file
130
intl/langprefs.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* Determine the user's language preferences.
|
||||
Copyright (C) 2004-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_CFPREFERENCESCOPYAPPVALUE
|
||||
# include <string.h>
|
||||
# include <CoreFoundation/CFPreferences.h>
|
||||
# include <CoreFoundation/CFPropertyList.h>
|
||||
# include <CoreFoundation/CFArray.h>
|
||||
# include <CoreFoundation/CFString.h>
|
||||
extern void _nl_locale_name_canonicalize (char *name);
|
||||
#endif
|
||||
|
||||
/* Determine the user's language preferences, as a colon separated list of
|
||||
locale names in XPG syntax
|
||||
language[_territory][.codeset][@modifier]
|
||||
The result must not be freed; it is statically allocated.
|
||||
The LANGUAGE environment variable does not need to be considered; it is
|
||||
already taken into account by the caller. */
|
||||
|
||||
const char *
|
||||
_nl_language_preferences_default (void)
|
||||
{
|
||||
#if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */
|
||||
{
|
||||
/* Cache the preferences list, since CoreFoundation calls are expensive. */
|
||||
static const char *cached_languages;
|
||||
static int cache_initialized;
|
||||
|
||||
if (!cache_initialized)
|
||||
{
|
||||
CFTypeRef preferences =
|
||||
CFPreferencesCopyAppValue (CFSTR ("AppleLanguages"),
|
||||
kCFPreferencesCurrentApplication);
|
||||
if (preferences != NULL
|
||||
&& CFGetTypeID (preferences) == CFArrayGetTypeID ())
|
||||
{
|
||||
CFArrayRef prefArray = (CFArrayRef)preferences;
|
||||
int n = CFArrayGetCount (prefArray);
|
||||
char buf[256];
|
||||
size_t size = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
CFTypeRef element = CFArrayGetValueAtIndex (prefArray, i);
|
||||
if (element != NULL
|
||||
&& CFGetTypeID (element) == CFStringGetTypeID ()
|
||||
&& CFStringGetCString ((CFStringRef)element,
|
||||
buf, sizeof (buf),
|
||||
kCFStringEncodingASCII))
|
||||
{
|
||||
_nl_locale_name_canonicalize (buf);
|
||||
size += strlen (buf) + 1;
|
||||
/* Most GNU programs use msgids in English and don't ship
|
||||
an en.mo message catalog. Therefore when we see "en"
|
||||
in the preferences list, arrange for gettext() to
|
||||
return the msgid, and ignore all further elements of
|
||||
the preferences list. */
|
||||
if (strcmp (buf, "en") == 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (size > 0)
|
||||
{
|
||||
char *languages = (char *) malloc (size);
|
||||
|
||||
if (languages != NULL)
|
||||
{
|
||||
char *p = languages;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
CFTypeRef element =
|
||||
CFArrayGetValueAtIndex (prefArray, i);
|
||||
if (element != NULL
|
||||
&& CFGetTypeID (element) == CFStringGetTypeID ()
|
||||
&& CFStringGetCString ((CFStringRef)element,
|
||||
buf, sizeof (buf),
|
||||
kCFStringEncodingASCII))
|
||||
{
|
||||
_nl_locale_name_canonicalize (buf);
|
||||
strcpy (p, buf);
|
||||
p += strlen (buf);
|
||||
*p++ = ':';
|
||||
if (strcmp (buf, "en") == 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
*--p = '\0';
|
||||
|
||||
cached_languages = languages;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache_initialized = 1;
|
||||
}
|
||||
if (cached_languages != NULL)
|
||||
return cached_languages;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* Message catalogs for internationalization.
|
||||
Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1997, 2000-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -39,7 +39,7 @@
|
|||
/* 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 ? 1 : -1)
|
||||
((major) == 0 || (major) == 1 ? 1 : -1)
|
||||
|
||||
/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
|
||||
precedence over _conio_gettext. */
|
||||
|
@ -52,6 +52,11 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/* Version number: (major<<16) + (minor<<8) + subminor */
|
||||
#define LIBINTL_VERSION 0x001000
|
||||
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).
|
||||
|
@ -83,7 +88,7 @@ extern "C" {
|
|||
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 __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
|
||||
# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
|
||||
# define _INTL_REDIRECT_ASM
|
||||
# else
|
||||
# ifdef __cplusplus
|
||||
|
@ -102,11 +107,21 @@ extern "C" {
|
|||
# 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 __GNUC__ >= 3 && !(__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);
|
||||
extern char *libintl_gettext (const char *__msgid)
|
||||
_INTL_MAY_RETURN_STRING_ARG (1);
|
||||
static inline char *gettext (const char *__msgid)
|
||||
{
|
||||
return libintl_gettext (__msgid);
|
||||
|
@ -116,13 +131,15 @@ static inline char *gettext (const char *__msgid)
|
|||
# define gettext libintl_gettext
|
||||
#endif
|
||||
extern char *gettext (const char *__msgid)
|
||||
_INTL_ASM (libintl_gettext);
|
||||
_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);
|
||||
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);
|
||||
|
@ -132,14 +149,16 @@ static inline char *dgettext (const char *__domainname, const char *__msgid)
|
|||
# define dgettext libintl_dgettext
|
||||
#endif
|
||||
extern char *dgettext (const char *__domainname, const char *__msgid)
|
||||
_INTL_ASM (libintl_dgettext);
|
||||
_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);
|
||||
int __category)
|
||||
_INTL_MAY_RETURN_STRING_ARG (2);
|
||||
static inline char *dcgettext (const char *__domainname, const char *__msgid,
|
||||
int __category)
|
||||
{
|
||||
|
@ -151,7 +170,8 @@ static inline char *dcgettext (const char *__domainname, const char *__msgid,
|
|||
#endif
|
||||
extern char *dcgettext (const char *__domainname, const char *__msgid,
|
||||
int __category)
|
||||
_INTL_ASM (libintl_dcgettext);
|
||||
_INTL_ASM (libintl_dcgettext)
|
||||
_INTL_MAY_RETURN_STRING_ARG (2);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -159,7 +179,8 @@ extern char *dcgettext (const char *__domainname, const char *__msgid,
|
|||
number N. */
|
||||
#ifdef _INTL_REDIRECT_INLINE
|
||||
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
|
||||
unsigned long int __n);
|
||||
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)
|
||||
{
|
||||
|
@ -171,14 +192,16 @@ static inline char *ngettext (const char *__msgid1, const char *__msgid2,
|
|||
#endif
|
||||
extern char *ngettext (const char *__msgid1, const char *__msgid2,
|
||||
unsigned long int __n)
|
||||
_INTL_ASM (libintl_ngettext);
|
||||
_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);
|
||||
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)
|
||||
{
|
||||
|
@ -191,7 +214,8 @@ static inline char *dngettext (const char *__domainname, const char *__msgid1,
|
|||
extern char *dngettext (const char *__domainname,
|
||||
const char *__msgid1, const char *__msgid2,
|
||||
unsigned long int __n)
|
||||
_INTL_ASM (libintl_dngettext);
|
||||
_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
|
||||
|
@ -199,7 +223,8 @@ extern char *dngettext (const char *__domainname,
|
|||
#ifdef _INTL_REDIRECT_INLINE
|
||||
extern char *libintl_dcngettext (const char *__domainname,
|
||||
const char *__msgid1, const char *__msgid2,
|
||||
unsigned long int __n, int __category);
|
||||
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)
|
||||
|
@ -213,10 +238,13 @@ static inline char *dcngettext (const char *__domainname,
|
|||
extern char *dcngettext (const char *__domainname,
|
||||
const char *__msgid1, const char *__msgid2,
|
||||
unsigned long int __n, int __category)
|
||||
_INTL_ASM (libintl_dcngettext);
|
||||
_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". */
|
||||
|
@ -271,6 +299,8 @@ extern char *bind_textdomain_codeset (const char *__domainname,
|
|||
_INTL_ASM (libintl_bind_textdomain_codeset);
|
||||
#endif
|
||||
|
||||
#endif /* IN_LIBGLOCALE */
|
||||
|
||||
|
||||
/* Support for format strings with positions in *printf(), following the
|
||||
POSIX/XSI specification.
|
||||
|
@ -300,6 +330,12 @@ extern int fprintf (FILE *, const char *, ...);
|
|||
extern int vfprintf (FILE *, const char *, va_list);
|
||||
|
||||
#undef printf
|
||||
#if defined __NetBSD__ || 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 printf libintl_printf
|
||||
extern int printf (const char *, ...);
|
||||
#undef vprintf
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1996-1999, 2000-2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-1999, 2000-2003, 2005-2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
|
||||
|
@ -36,6 +36,10 @@
|
|||
# define internal_function
|
||||
#endif
|
||||
|
||||
#ifndef LIBINTL_DLL_EXPORTED
|
||||
# define LIBINTL_DLL_EXPORTED
|
||||
#endif
|
||||
|
||||
/* Tell the compiler when a conditional or integer expression is
|
||||
almost always true or almost always false. */
|
||||
#ifndef HAVE_BUILTIN_EXPECT
|
||||
|
@ -43,7 +47,7 @@
|
|||
#endif
|
||||
|
||||
/* Separator in PATH like lists of pathnames. */
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
|
||||
#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, OS/2, DOS */
|
||||
# define PATH_SEPARATOR ';'
|
||||
#else
|
||||
|
@ -52,17 +56,10 @@
|
|||
#endif
|
||||
|
||||
/* Encoding of locale name parts. */
|
||||
#define CEN_REVISION 1
|
||||
#define CEN_SPONSOR 2
|
||||
#define CEN_SPECIAL 4
|
||||
#define XPG_NORM_CODESET 8
|
||||
#define XPG_CODESET 16
|
||||
#define TERRITORY 32
|
||||
#define CEN_AUDIENCE 64
|
||||
#define XPG_MODIFIER 128
|
||||
|
||||
#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)
|
||||
#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)
|
||||
#define XPG_NORM_CODESET 1
|
||||
#define XPG_CODESET 2
|
||||
#define XPG_TERRITORY 4
|
||||
#define XPG_MODIFIER 8
|
||||
|
||||
|
||||
struct loaded_l10nfile
|
||||
|
@ -89,9 +86,9 @@ extern const char *_nl_normalize_codeset (const char *codeset,
|
|||
files of the same kind, sorted in decreasing order of ->filename.
|
||||
DIRLIST and DIRLIST_LEN are an argz list of directories in which to
|
||||
look, containing at least one directory (i.e. DIRLIST_LEN > 0).
|
||||
MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER,
|
||||
SPECIAL, SPONSOR, REVISION are the pieces of the locale name, as
|
||||
produced by _nl_explode_name(). FILENAME is the filename suffix.
|
||||
MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER
|
||||
are the pieces of the locale name, as produced by _nl_explode_name().
|
||||
FILENAME is the filename suffix.
|
||||
The return value is the lookup result, either found in *L10NFILE_LIST,
|
||||
or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL.
|
||||
If the return value is non-NULL, it is added to *L10NFILE_LIST, and
|
||||
|
@ -103,43 +100,33 @@ _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 *special,
|
||||
const char *sponsor, const char *revision,
|
||||
const char *modifier,
|
||||
const char *filename, int do_allocate);
|
||||
|
||||
/* Lookup the real locale name for a locale alias NAME, or NULL if
|
||||
NAME is not a locale alias (but possibly a real locale name).
|
||||
The return value is statically allocated and must not be freed. */
|
||||
extern const char *_nl_expand_alias (const char *name);
|
||||
/* Part of the libintl ABI only for the sake of the gettext.m4 macro. */
|
||||
extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name);
|
||||
|
||||
/* Split a locale name NAME into its pieces: language, modifier,
|
||||
territory, codeset, special, sponsor, revision.
|
||||
territory, codeset.
|
||||
NAME gets destructively modified: NUL bytes are inserted here and
|
||||
there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY,
|
||||
*CODESET, *SPECIAL, *SPONSOR, *REVISION gets assigned either a
|
||||
pointer into the old NAME string, or NULL. *NORMALIZED_CODESET
|
||||
gets assigned the expanded *CODESET, if it is different from *CODESET;
|
||||
this one is dynamically allocated and has to be freed by the caller.
|
||||
*CODESET gets assigned either a pointer into the old NAME string, or
|
||||
NULL. *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it
|
||||
is different from *CODESET; this one is dynamically allocated and has
|
||||
to be freed by the caller.
|
||||
The return value is a bitmask, where each bit corresponds to one
|
||||
filled-in value:
|
||||
XPG_MODIFIER, CEN_AUDIENCE for *MODIFIER,
|
||||
TERRITORY for *TERRITORY,
|
||||
XPG_MODIFIER for *MODIFIER,
|
||||
XPG_TERRITORY for *TERRITORY,
|
||||
XPG_CODESET for *CODESET,
|
||||
XPG_NORM_CODESET for *NORMALIZED_CODESET,
|
||||
CEN_SPECIAL for *SPECIAL,
|
||||
CEN_SPONSOR for *SPONSOR,
|
||||
CEN_REVISION for *REVISION.
|
||||
XPG_NORM_CODESET for *NORMALIZED_CODESET.
|
||||
*/
|
||||
extern int _nl_explode_name (char *name, const char **language,
|
||||
const char **modifier, const char **territory,
|
||||
const char **codeset,
|
||||
const char **normalized_codeset,
|
||||
const char **special, const char **sponsor,
|
||||
const char **revision);
|
||||
|
||||
/* 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. */
|
||||
extern char *_nl_find_language (const char *name);
|
||||
const char **normalized_codeset);
|
||||
|
||||
#endif /* loadinfo.h */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Load needed message catalogs.
|
||||
Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -91,6 +91,14 @@ char *alloca ();
|
|||
|
||||
#ifdef _LIBC
|
||||
# include "../locale/localeinfo.h"
|
||||
# include <not-cancel.h>
|
||||
#endif
|
||||
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
# include <bits/libc-lock.h>
|
||||
#else
|
||||
# include "lock.h"
|
||||
#endif
|
||||
|
||||
/* Provide fallback values for macros that ought to be defined in <inttypes.h>.
|
||||
|
@ -457,11 +465,12 @@ char *alloca ();
|
|||
/* Rename the non ISO C functions. This is required by the standard
|
||||
because some ISO C functions will require linking with this object
|
||||
file and the name space must not be polluted. */
|
||||
# define open __open
|
||||
# define close __close
|
||||
# define read __read
|
||||
# define mmap __mmap
|
||||
# define munmap __munmap
|
||||
# define open(name, flags) open_not_cancel_2 (name, flags)
|
||||
# define close(fd) close_not_cancel_no_status (fd)
|
||||
# define read(fd, buf, n) read_not_cancel (fd, buf, n)
|
||||
# define mmap(addr, len, prot, flags, fd, offset) \
|
||||
__mmap (addr, len, prot, flags, fd, offset)
|
||||
# define munmap(addr, len) __munmap (addr, len)
|
||||
#endif
|
||||
|
||||
/* For those losing systems which don't have `alloca' we have to add
|
||||
|
@ -764,144 +773,6 @@ get_sysdep_segment_value (const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the codeset dependent parts of an opened message catalog.
|
||||
Return the header entry. */
|
||||
const char *
|
||||
internal_function
|
||||
_nl_init_domain_conv (struct loaded_l10nfile *domain_file,
|
||||
struct loaded_domain *domain,
|
||||
struct binding *domainbinding)
|
||||
{
|
||||
/* 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. */
|
||||
char *nullentry;
|
||||
size_t nullentrylen;
|
||||
|
||||
/* Preinitialize fields, to avoid recursion during _nl_find_msg. */
|
||||
domain->codeset_cntr =
|
||||
(domainbinding != NULL ? domainbinding->codeset_cntr : 0);
|
||||
#ifdef _LIBC
|
||||
domain->conv = (__gconv_t) -1;
|
||||
#else
|
||||
# if HAVE_ICONV
|
||||
domain->conv = (iconv_t) -1;
|
||||
# endif
|
||||
#endif
|
||||
domain->conv_tab = NULL;
|
||||
|
||||
/* Get the header entry. */
|
||||
nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen);
|
||||
|
||||
if (nullentry != NULL)
|
||||
{
|
||||
#if defined _LIBC || HAVE_ICONV
|
||||
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
|
||||
|
||||
/* 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. Moreover, the value specified through
|
||||
bind_textdomain_codeset overrides both. */
|
||||
if (domainbinding != NULL && domainbinding->codeset != NULL)
|
||||
outcharset = domainbinding->codeset;
|
||||
else
|
||||
{
|
||||
outcharset = getenv ("OUTPUT_CHARSET");
|
||||
if (outcharset == NULL || outcharset[0] == '\0')
|
||||
{
|
||||
# ifdef _LIBC
|
||||
outcharset = _NL_CURRENT (LC_CTYPE, CODESET);
|
||||
# else
|
||||
# if HAVE_ICONV
|
||||
extern const char *locale_charset (void);
|
||||
outcharset = locale_charset ();
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef _LIBC
|
||||
/* We always want to use transliteration. */
|
||||
outcharset = norm_add_slashes (outcharset, "TRANSLIT");
|
||||
charset = norm_add_slashes (charset, NULL);
|
||||
if (__gconv_open (outcharset, charset, &domain->conv,
|
||||
GCONV_AVOID_NOCONV)
|
||||
!= __GCONV_OK)
|
||||
domain->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 \
|
||||
|| _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;
|
||||
|
||||
domain->conv = iconv_open (outcharset, charset);
|
||||
|
||||
freea (outcharset);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
domain->conv = iconv_open (outcharset, charset);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
freea (charset);
|
||||
}
|
||||
#endif /* _LIBC || HAVE_ICONV */
|
||||
}
|
||||
|
||||
return nullentry;
|
||||
}
|
||||
|
||||
/* Frees the codeset dependent parts of an opened message catalog. */
|
||||
void
|
||||
internal_function
|
||||
_nl_free_domain_conv (struct loaded_domain *domain)
|
||||
{
|
||||
if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1)
|
||||
free (domain->conv_tab);
|
||||
|
||||
#ifdef _LIBC
|
||||
if (domain->conv != (__gconv_t) -1)
|
||||
__gconv_close (domain->conv);
|
||||
#else
|
||||
# if HAVE_ICONV
|
||||
if (domain->conv != (iconv_t) -1)
|
||||
iconv_close (domain->conv);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Load the message catalogs specified by FILENAME. If it is no valid
|
||||
message catalog do nothing. */
|
||||
void
|
||||
|
@ -909,7 +780,8 @@ internal_function
|
|||
_nl_load_domain (struct loaded_l10nfile *domain_file,
|
||||
struct binding *domainbinding)
|
||||
{
|
||||
int fd;
|
||||
__libc_lock_define_initialized_recursive (static, lock)
|
||||
int fd = -1;
|
||||
size_t size;
|
||||
#ifdef _LIBC
|
||||
struct stat64 st;
|
||||
|
@ -921,8 +793,24 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
struct loaded_domain *domain;
|
||||
int revision;
|
||||
const char *nullentry;
|
||||
size_t nullentrylen;
|
||||
|
||||
domain_file->decided = 1;
|
||||
__libc_lock_lock_recursive (lock);
|
||||
if (domain_file->decided != 0)
|
||||
{
|
||||
/* There are two possibilities:
|
||||
|
||||
+ this is the same thread calling again during this initialization
|
||||
via _nl_find_msg. We have initialized everything this call needs.
|
||||
|
||||
+ this is another thread which tried to initialize this object.
|
||||
Not necessary anymore since if the lock is available this
|
||||
is finished.
|
||||
*/
|
||||
goto done;
|
||||
}
|
||||
|
||||
domain_file->decided = -1;
|
||||
domain_file->data = NULL;
|
||||
|
||||
/* Note that it would be useless to store domainbinding in domain_file
|
||||
|
@ -934,12 +822,12 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
specification the locale file name is different for XPG and CEN
|
||||
syntax. */
|
||||
if (domain_file->filename == NULL)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
/* Try to open the addressed file. */
|
||||
fd = open (domain_file->filename, O_RDONLY | O_BINARY);
|
||||
if (fd == -1)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
/* We must know about the size of the file. */
|
||||
if (
|
||||
|
@ -950,11 +838,8 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
#endif
|
||||
|| __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
|
||||
|| __builtin_expect (size < sizeof (struct mo_file_header), 0))
|
||||
{
|
||||
/* Something went wrong. */
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
/* Something went wrong. */
|
||||
goto out;
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
/* Now we are ready to load the file. If mmap() is available we try
|
||||
|
@ -966,6 +851,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
{
|
||||
/* mmap() call was successful. */
|
||||
close (fd);
|
||||
fd = -1;
|
||||
use_mmap = 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -979,7 +865,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
|
||||
data = (struct mo_file_header *) malloc (size);
|
||||
if (data == NULL)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
to_read = size;
|
||||
read_ptr = (char *) data;
|
||||
|
@ -992,8 +878,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
if (nb == -1 && errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
close (fd);
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
read_ptr += nb;
|
||||
to_read -= nb;
|
||||
|
@ -1001,6 +886,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
while (to_read > 0);
|
||||
|
||||
close (fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
/* Using the magic number we can test whether it really is a message
|
||||
|
@ -1015,12 +901,12 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
else
|
||||
#endif
|
||||
free (data);
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
|
||||
if (domain == NULL)
|
||||
return;
|
||||
goto out;
|
||||
domain_file->data = domain;
|
||||
|
||||
domain->data = (char *) data;
|
||||
|
@ -1321,7 +1207,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
for (i = 0; i < n_inmem_sysdep_strings; i++)
|
||||
{
|
||||
const char *msgid = inmem_orig_sysdep_tab[i].pointer;
|
||||
nls_uint32 hash_val = hash_string (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));
|
||||
|
@ -1382,28 +1268,55 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
|
|||
free (data);
|
||||
free (domain);
|
||||
domain_file->data = NULL;
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Now initialize the character set converter from the character set
|
||||
the file is encoded with (found in the header entry) to the domain's
|
||||
specified character set or the locale's character set. */
|
||||
nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding);
|
||||
/* No caches of converted translations so far. */
|
||||
domain->conversions = NULL;
|
||||
domain->nconversions = 0;
|
||||
|
||||
/* Also look for a plural specification. */
|
||||
/* Get the header entry and look for a plural specification. */
|
||||
#ifdef IN_LIBGLOCALE
|
||||
nullentry =
|
||||
_nl_find_msg (domain_file, domainbinding, NULL, "", &nullentrylen);
|
||||
#else
|
||||
nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
|
||||
#endif
|
||||
EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
|
||||
|
||||
out:
|
||||
if (fd != -1)
|
||||
close (fd);
|
||||
|
||||
domain_file->decided = 1;
|
||||
|
||||
done:
|
||||
__libc_lock_unlock_recursive (lock);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _LIBC
|
||||
void
|
||||
internal_function
|
||||
internal_function __libc_freeres_fn_section
|
||||
_nl_unload_domain (struct loaded_domain *domain)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (domain->plural != &__gettext_germanic_plural)
|
||||
__gettext_free_exp (domain->plural);
|
||||
|
||||
_nl_free_domain_conv (domain);
|
||||
for (i = 0; i < domain->nconversions; i++)
|
||||
{
|
||||
struct converted_domain *convd = &domain->conversions[i];
|
||||
|
||||
free (convd->encoding);
|
||||
if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1)
|
||||
free (convd->conv_tab);
|
||||
if (convd->conv != (__gconv_t) -1)
|
||||
__gconv_close (convd->conv);
|
||||
}
|
||||
if (domain->conversions != NULL)
|
||||
free (domain->conversions);
|
||||
|
||||
if (domain->malloced)
|
||||
free (domain->malloced);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
|
||||
Copyright (C) 2000-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -19,30 +19,18 @@
|
|||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "localcharset.h"
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__
|
||||
# undef WIN32 /* avoid warning on mingw32 */
|
||||
# define WIN32
|
||||
# define WIN32_NATIVE
|
||||
#endif
|
||||
|
||||
#if defined __EMX__
|
||||
|
@ -50,15 +38,19 @@
|
|||
# define OS2
|
||||
#endif
|
||||
|
||||
#if !defined WIN32
|
||||
#if !defined WIN32_NATIVE
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
# else
|
||||
# if HAVE_SETLOCALE
|
||||
# if 0 /* see comment below */
|
||||
# include <locale.h>
|
||||
# endif
|
||||
# endif
|
||||
#elif defined WIN32
|
||||
# ifdef __CYGWIN__
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# endif
|
||||
#elif defined WIN32_NATIVE
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
@ -73,8 +65,13 @@
|
|||
# define relocate(pathname) (pathname)
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, OS/2, DOS */
|
||||
/* Get LIBDIR. */
|
||||
#ifndef LIBDIR
|
||||
# include "configmake.h"
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, Cygwin, OS/2, DOS */
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
#endif
|
||||
|
||||
|
@ -107,19 +104,25 @@ static const char * volatile charset_aliases;
|
|||
|
||||
/* Return a pointer to the contents of the charset.alias file. */
|
||||
static const char *
|
||||
get_charset_aliases ()
|
||||
get_charset_aliases (void)
|
||||
{
|
||||
const char *cp;
|
||||
|
||||
cp = charset_aliases;
|
||||
if (cp == NULL)
|
||||
{
|
||||
#if !(defined VMS || defined WIN32)
|
||||
#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
|
||||
FILE *fp;
|
||||
const char *dir = relocate (LIBDIR);
|
||||
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);
|
||||
|
@ -141,15 +144,17 @@ get_charset_aliases ()
|
|||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
size_t l1, l2;
|
||||
|
||||
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;
|
||||
|
@ -170,6 +175,7 @@ get_charset_aliases ()
|
|||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
|
@ -184,6 +190,8 @@ get_charset_aliases ()
|
|||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
|
@ -229,7 +237,7 @@ get_charset_aliases ()
|
|||
"DECKOREAN" "\0" "EUC-KR" "\0";
|
||||
# endif
|
||||
|
||||
# if defined WIN32
|
||||
# if defined WIN32_NATIVE || defined __CYGWIN__
|
||||
/* To avoid the troubles of installing a separate file in the same
|
||||
directory as the DLL and of retrieving the DLL's directory at
|
||||
runtime, simply inline the aliases here. */
|
||||
|
@ -238,6 +246,7 @@ get_charset_aliases ()
|
|||
"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"
|
||||
|
@ -248,7 +257,14 @@ get_charset_aliases ()
|
|||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\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
|
||||
|
||||
|
@ -268,18 +284,65 @@ get_charset_aliases ()
|
|||
STATIC
|
||||
#endif
|
||||
const char *
|
||||
locale_charset ()
|
||||
locale_charset (void)
|
||||
{
|
||||
const char *codeset;
|
||||
const char *aliases;
|
||||
|
||||
#if !(defined WIN32 || defined OS2)
|
||||
#if !(defined WIN32_NATIVE || defined OS2)
|
||||
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
|
||||
/* Most systems support nl_langinfo (CODESET) nowadays. */
|
||||
codeset = nl_langinfo (CODESET);
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
/* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
|
||||
returns "US-ASCII". As long as this is not fixed, return the suffix
|
||||
of the locale name from the environment variables (if present) or
|
||||
the codepage as a number. */
|
||||
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
|
||||
{
|
||||
const char *locale;
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
}
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
/* On old systems which lack it, use setlocale or getenv. */
|
||||
|
@ -289,7 +352,7 @@ locale_charset ()
|
|||
(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 HAVE_SETLOCALE && 0
|
||||
# if 0
|
||||
locale = setlocale (LC_CTYPE, NULL);
|
||||
# endif
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
|
@ -310,7 +373,7 @@ locale_charset ()
|
|||
|
||||
# endif
|
||||
|
||||
#elif defined WIN32
|
||||
#elif defined WIN32_NATIVE
|
||||
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Handle aliases for locale names.
|
||||
Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1999, 2000-2001, 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 Library General Public License as published
|
||||
|
@ -81,11 +81,13 @@ char *alloca ();
|
|||
# endif
|
||||
# define HAVE_MEMPCPY 1
|
||||
# define HAVE___FSETLOCKING 1
|
||||
#endif
|
||||
|
||||
/* We need locking here since we can be called from different places. */
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
# include <bits/libc-lock.h>
|
||||
|
||||
__libc_lock_define_initialized (static, lock);
|
||||
#else
|
||||
# include "lock.h"
|
||||
#endif
|
||||
|
||||
#ifndef internal_function
|
||||
|
@ -120,6 +122,9 @@ __libc_lock_define_initialized (static, lock);
|
|||
#endif
|
||||
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
|
||||
struct alias_map
|
||||
{
|
||||
const char *alias;
|
||||
|
@ -155,9 +160,7 @@ _nl_expand_alias (const char *name)
|
|||
const char *result = NULL;
|
||||
size_t added;
|
||||
|
||||
#ifdef _LIBC
|
||||
__libc_lock_lock (lock);
|
||||
#endif
|
||||
|
||||
if (locale_alias_path == NULL)
|
||||
locale_alias_path = LOCALE_ALIAS_PATH;
|
||||
|
@ -204,9 +207,7 @@ _nl_expand_alias (const char *name)
|
|||
}
|
||||
while (added != 0);
|
||||
|
||||
#ifdef _LIBC
|
||||
__libc_lock_unlock (lock);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -230,7 +231,13 @@ read_alias_file (const char *fname, int fname_len)
|
|||
memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Note the file is opened with cancellation in the I/O functions
|
||||
disabled. */
|
||||
fp = fopen (relocate (full_fname), "rc");
|
||||
#else
|
||||
fp = fopen (relocate (full_fname), "r");
|
||||
#endif
|
||||
freea (full_fname);
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
|
@ -254,11 +261,15 @@ read_alias_file (const char *fname, int fname_len)
|
|||
char *alias;
|
||||
char *value;
|
||||
char *cp;
|
||||
int complete_line;
|
||||
|
||||
if (FGETS (buf, sizeof buf, fp) == NULL)
|
||||
/* EOF reached. */
|
||||
break;
|
||||
|
||||
/* Determine whether the line is complete. */
|
||||
complete_line = strchr (buf, '\n') != NULL;
|
||||
|
||||
cp = buf;
|
||||
/* Ignore leading white space. */
|
||||
while (isspace ((unsigned char) cp[0]))
|
||||
|
@ -280,9 +291,6 @@ read_alias_file (const char *fname, int fname_len)
|
|||
|
||||
if (cp[0] != '\0')
|
||||
{
|
||||
size_t alias_len;
|
||||
size_t value_len;
|
||||
|
||||
value = cp++;
|
||||
while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
|
||||
++cp;
|
||||
|
@ -298,60 +306,75 @@ read_alias_file (const char *fname, int fname_len)
|
|||
else if (cp[0] != '\0')
|
||||
*cp++ = '\0';
|
||||
|
||||
if (nmap >= maxmap)
|
||||
if (__builtin_expect (extend_alias_table (), 0))
|
||||
return added;
|
||||
|
||||
alias_len = strlen (alias) + 1;
|
||||
value_len = strlen (value) + 1;
|
||||
|
||||
if (string_space_act + alias_len + value_len > string_space_max)
|
||||
#ifdef IN_LIBGLOCALE
|
||||
/* glibc's locale.alias contains entries for ja_JP and ko_KR
|
||||
that make it impossible to use a Japanese or Korean UTF-8
|
||||
locale under the name "ja_JP" or "ko_KR". Ignore these
|
||||
entries. */
|
||||
if (strchr (alias, '_') == NULL)
|
||||
#endif
|
||||
{
|
||||
/* Increase size of memory pool. */
|
||||
size_t new_size = (string_space_max
|
||||
+ (alias_len + value_len > 1024
|
||||
? alias_len + value_len : 1024));
|
||||
char *new_pool = (char *) realloc (string_space, new_size);
|
||||
if (new_pool == NULL)
|
||||
return added;
|
||||
size_t alias_len;
|
||||
size_t value_len;
|
||||
|
||||
if (__builtin_expect (string_space != new_pool, 0))
|
||||
if (nmap >= maxmap)
|
||||
if (__builtin_expect (extend_alias_table (), 0))
|
||||
goto out;
|
||||
|
||||
alias_len = strlen (alias) + 1;
|
||||
value_len = strlen (value) + 1;
|
||||
|
||||
if (string_space_act + alias_len + value_len > string_space_max)
|
||||
{
|
||||
size_t i;
|
||||
/* Increase size of memory pool. */
|
||||
size_t new_size = (string_space_max
|
||||
+ (alias_len + value_len > 1024
|
||||
? alias_len + value_len : 1024));
|
||||
char *new_pool = (char *) realloc (string_space, new_size);
|
||||
if (new_pool == NULL)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < nmap; i++)
|
||||
if (__builtin_expect (string_space != new_pool, 0))
|
||||
{
|
||||
map[i].alias += new_pool - string_space;
|
||||
map[i].value += new_pool - string_space;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nmap; i++)
|
||||
{
|
||||
map[i].alias += new_pool - string_space;
|
||||
map[i].value += new_pool - string_space;
|
||||
}
|
||||
}
|
||||
|
||||
string_space = new_pool;
|
||||
string_space_max = new_size;
|
||||
}
|
||||
|
||||
string_space = new_pool;
|
||||
string_space_max = new_size;
|
||||
map[nmap].alias = memcpy (&string_space[string_space_act],
|
||||
alias, alias_len);
|
||||
string_space_act += alias_len;
|
||||
|
||||
map[nmap].value = memcpy (&string_space[string_space_act],
|
||||
value, value_len);
|
||||
string_space_act += value_len;
|
||||
|
||||
++nmap;
|
||||
++added;
|
||||
}
|
||||
|
||||
map[nmap].alias = memcpy (&string_space[string_space_act],
|
||||
alias, alias_len);
|
||||
string_space_act += alias_len;
|
||||
|
||||
map[nmap].value = memcpy (&string_space[string_space_act],
|
||||
value, value_len);
|
||||
string_space_act += value_len;
|
||||
|
||||
++nmap;
|
||||
++added;
|
||||
}
|
||||
}
|
||||
|
||||
/* Possibly not the whole line fits into the buffer. Ignore
|
||||
the rest of the line. */
|
||||
while (strchr (buf, '\n') == NULL)
|
||||
if (FGETS (buf, sizeof buf, fp) == NULL)
|
||||
/* Make sure the inner loop will be left. The outer loop
|
||||
will exit at the `feof' test. */
|
||||
break;
|
||||
if (! complete_line)
|
||||
do
|
||||
if (FGETS (buf, sizeof buf, fp) == NULL)
|
||||
/* Make sure the inner loop will be left. The outer loop
|
||||
will exit at the `feof' test. */
|
||||
break;
|
||||
while (strchr (buf, '\n') == NULL);
|
||||
}
|
||||
|
||||
out:
|
||||
/* Should we test for ferror()? I think we have to silently ignore
|
||||
errors. --drepper */
|
||||
fclose (fp);
|
||||
|
|
1199
intl/localename.c
1199
intl/localename.c
File diff suppressed because it is too large
Load diff
922
intl/lock.c
Normal file
922
intl/lock.c
Normal file
|
@ -0,0 +1,922 @@
|
|||
/* Locking in multithreaded situations.
|
||||
Copyright (C) 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 Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
|
||||
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
|
||||
gthr-win32.h. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_POSIX_THREADS
|
||||
|
||||
/* Use the POSIX threads library. */
|
||||
|
||||
# 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
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_RWLOCK
|
||||
|
||||
# if !defined PTHREAD_RWLOCK_INITIALIZER
|
||||
|
||||
void
|
||||
glthread_rwlock_init (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_rwlock_init (&lock->rwlock, NULL) != 0)
|
||||
abort ();
|
||||
lock->initialized = 1;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_rdlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->guard) != 0)
|
||||
abort ();
|
||||
if (!lock->initialized)
|
||||
glthread_rwlock_init (lock);
|
||||
if (pthread_mutex_unlock (&lock->guard) != 0)
|
||||
abort ();
|
||||
}
|
||||
if (pthread_rwlock_rdlock (&lock->rwlock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_wrlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->guard) != 0)
|
||||
abort ();
|
||||
if (!lock->initialized)
|
||||
glthread_rwlock_init (lock);
|
||||
if (pthread_mutex_unlock (&lock->guard) != 0)
|
||||
abort ();
|
||||
}
|
||||
if (pthread_rwlock_wrlock (&lock->rwlock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_unlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
abort ();
|
||||
if (pthread_rwlock_unlock (&lock->rwlock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_destroy (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
abort ();
|
||||
if (pthread_rwlock_destroy (&lock->rwlock) != 0)
|
||||
abort ();
|
||||
lock->initialized = 0;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
void
|
||||
glthread_rwlock_init (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_init (&lock->lock, NULL) != 0)
|
||||
abort ();
|
||||
if (pthread_cond_init (&lock->waiting_readers, NULL) != 0)
|
||||
abort ();
|
||||
if (pthread_cond_init (&lock->waiting_writers, NULL) != 0)
|
||||
abort ();
|
||||
lock->waiting_writers_count = 0;
|
||||
lock->runcount = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_rdlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->lock) != 0)
|
||||
abort ();
|
||||
/* 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. */
|
||||
if (pthread_cond_wait (&lock->waiting_readers, &lock->lock) != 0)
|
||||
abort ();
|
||||
}
|
||||
lock->runcount++;
|
||||
if (pthread_mutex_unlock (&lock->lock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_wrlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->lock) != 0)
|
||||
abort ();
|
||||
/* 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++;
|
||||
if (pthread_cond_wait (&lock->waiting_writers, &lock->lock) != 0)
|
||||
abort ();
|
||||
lock->waiting_writers_count--;
|
||||
}
|
||||
lock->runcount--; /* runcount becomes -1 */
|
||||
if (pthread_mutex_unlock (&lock->lock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_unlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->lock) != 0)
|
||||
abort ();
|
||||
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))
|
||||
abort ();
|
||||
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. */
|
||||
if (pthread_cond_signal (&lock->waiting_writers) != 0)
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wake up all waiting readers. */
|
||||
if (pthread_cond_broadcast (&lock->waiting_readers) != 0)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
if (pthread_mutex_unlock (&lock->lock) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_destroy (gl_rwlock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_destroy (&lock->lock) != 0)
|
||||
abort ();
|
||||
if (pthread_cond_destroy (&lock->waiting_readers) != 0)
|
||||
abort ();
|
||||
if (pthread_cond_destroy (&lock->waiting_writers) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
# if HAVE_PTHREAD_MUTEX_RECURSIVE
|
||||
|
||||
# if !(defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
|
||||
|
||||
void
|
||||
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
|
||||
{
|
||||
pthread_mutexattr_t attributes;
|
||||
|
||||
if (pthread_mutexattr_init (&attributes) != 0)
|
||||
abort ();
|
||||
if (pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE) != 0)
|
||||
abort ();
|
||||
if (pthread_mutex_init (&lock->recmutex, &attributes) != 0)
|
||||
abort ();
|
||||
if (pthread_mutexattr_destroy (&attributes) != 0)
|
||||
abort ();
|
||||
lock->initialized = 1;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->guard) != 0)
|
||||
abort ();
|
||||
if (!lock->initialized)
|
||||
glthread_recursive_lock_init (lock);
|
||||
if (pthread_mutex_unlock (&lock->guard) != 0)
|
||||
abort ();
|
||||
}
|
||||
if (pthread_mutex_lock (&lock->recmutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
abort ();
|
||||
if (pthread_mutex_unlock (&lock->recmutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (!lock->initialized)
|
||||
abort ();
|
||||
if (pthread_mutex_destroy (&lock->recmutex) != 0)
|
||||
abort ();
|
||||
lock->initialized = 0;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
void
|
||||
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (pthread_mutex_init (&lock->mutex, NULL) != 0)
|
||||
abort ();
|
||||
lock->owner = (pthread_t) 0;
|
||||
lock->depth = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
pthread_t self = pthread_self ();
|
||||
if (lock->owner != self)
|
||||
{
|
||||
if (pthread_mutex_lock (&lock->mutex) != 0)
|
||||
abort ();
|
||||
lock->owner = self;
|
||||
}
|
||||
if (++(lock->depth) == 0) /* wraparound? */
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != pthread_self ())
|
||||
abort ();
|
||||
if (lock->depth == 0)
|
||||
abort ();
|
||||
if (--(lock->depth) == 0)
|
||||
{
|
||||
lock->owner = (pthread_t) 0;
|
||||
if (pthread_mutex_unlock (&lock->mutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != (pthread_t) 0)
|
||||
abort ();
|
||||
if (pthread_mutex_destroy (&lock->mutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
# 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 -------------------------- */
|
||||
|
||||
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_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 --------------------- */
|
||||
|
||||
void
|
||||
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (mutex_init (&lock->mutex, USYNC_THREAD, NULL) != 0)
|
||||
abort ();
|
||||
lock->owner = (thread_t) 0;
|
||||
lock->depth = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
thread_t self = thr_self ();
|
||||
if (lock->owner != self)
|
||||
{
|
||||
if (mutex_lock (&lock->mutex) != 0)
|
||||
abort ();
|
||||
lock->owner = self;
|
||||
}
|
||||
if (++(lock->depth) == 0) /* wraparound? */
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != thr_self ())
|
||||
abort ();
|
||||
if (lock->depth == 0)
|
||||
abort ();
|
||||
if (--(lock->depth) == 0)
|
||||
{
|
||||
lock->owner = (thread_t) 0;
|
||||
if (mutex_unlock (&lock->mutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != (thread_t) 0)
|
||||
abort ();
|
||||
if (mutex_destroy (&lock->mutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
void
|
||||
glthread_once (gl_once_t *once_control, void (*initfunction) (void))
|
||||
{
|
||||
if (!once_control->inited)
|
||||
{
|
||||
/* Use the mutex to guarantee that if another thread is already calling
|
||||
the initfunction, this thread waits until it's finished. */
|
||||
if (mutex_lock (&once_control->mutex) != 0)
|
||||
abort ();
|
||||
if (!once_control->inited)
|
||||
{
|
||||
once_control->inited = 1;
|
||||
initfunction ();
|
||||
}
|
||||
if (mutex_unlock (&once_control->mutex) != 0)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
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_WIN32_THREADS
|
||||
|
||||
/* -------------------------- gl_lock_t datatype -------------------------- */
|
||||
|
||||
void
|
||||
glthread_lock_init (gl_lock_t *lock)
|
||||
{
|
||||
InitializeCriticalSection (&lock->lock);
|
||||
lock->guard.done = 1;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_lock_lock (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);
|
||||
}
|
||||
|
||||
void
|
||||
glthread_lock_unlock (gl_lock_t *lock)
|
||||
{
|
||||
if (!lock->guard.done)
|
||||
abort ();
|
||||
LeaveCriticalSection (&lock->lock);
|
||||
}
|
||||
|
||||
void
|
||||
glthread_lock_destroy (gl_lock_t *lock)
|
||||
{
|
||||
if (!lock->guard.done)
|
||||
abort ();
|
||||
DeleteCriticalSection (&lock->lock);
|
||||
lock->guard.done = 0;
|
||||
}
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
static inline 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;
|
||||
}
|
||||
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 inline 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 inline 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 (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;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_rdlock (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;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Allocation failure. Weird. */
|
||||
do
|
||||
{
|
||||
LeaveCriticalSection (&lock->lock);
|
||||
Sleep (1);
|
||||
EnterCriticalSection (&lock->lock);
|
||||
}
|
||||
while (!(lock->runcount + 1 > 0));
|
||||
}
|
||||
}
|
||||
lock->runcount++;
|
||||
LeaveCriticalSection (&lock->lock);
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_wrlock (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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_unlock (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->guard.done)
|
||||
abort ();
|
||||
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))
|
||||
abort ();
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
glthread_rwlock_destroy (gl_rwlock_t *lock)
|
||||
{
|
||||
if (!lock->guard.done)
|
||||
abort ();
|
||||
if (lock->runcount != 0)
|
||||
abort ();
|
||||
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;
|
||||
}
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
void
|
||||
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
|
||||
{
|
||||
lock->owner = 0;
|
||||
lock->depth = 0;
|
||||
InitializeCriticalSection (&lock->lock);
|
||||
lock->guard.done = 1;
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_lock (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? */
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != GetCurrentThreadId ())
|
||||
abort ();
|
||||
if (lock->depth == 0)
|
||||
abort ();
|
||||
if (--(lock->depth) == 0)
|
||||
{
|
||||
lock->owner = 0;
|
||||
LeaveCriticalSection (&lock->lock);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
|
||||
{
|
||||
if (lock->owner != 0)
|
||||
abort ();
|
||||
DeleteCriticalSection (&lock->lock);
|
||||
lock->guard.done = 0;
|
||||
}
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
void
|
||||
glthread_once (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
|
||||
|
||||
/* ========================================================================= */
|
833
intl/lock.h
Normal file
833
intl/lock.h
Normal file
|
@ -0,0 +1,833 @@
|
|||
/* Locking in multithreaded situations.
|
||||
Copyright (C) 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 Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
Once-only execution:
|
||||
Type: gl_once_t
|
||||
Initializer: gl_once_define(extern, name)
|
||||
Execution: gl_once (name, initfunction);
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LOCK_H
|
||||
#define _LOCK_H
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_POSIX_THREADS
|
||||
|
||||
/* Use the POSIX threads library. */
|
||||
|
||||
# include <pthread.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# 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 gl_lock_init(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
|
||||
# define gl_lock_lock(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
|
||||
# define gl_lock_unlock(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
|
||||
# define gl_lock_destroy(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
|
||||
|
||||
/* ------------------------- 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 gl_rwlock_init(NAME) \
|
||||
if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) abort ()
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) abort ()
|
||||
|
||||
# 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 gl_rwlock_init(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_init (&NAME)
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
|
||||
extern void glthread_rwlock_init (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_destroy (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 gl_rwlock_init(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_init (&NAME)
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
|
||||
extern void glthread_rwlock_init (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_destroy (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 gl_recursive_lock_init(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
|
||||
|
||||
# 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 gl_recursive_lock_init(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
|
||||
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_destroy (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 gl_recursive_lock_init(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
|
||||
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_destroy (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 gl_once(NAME, INITFUNCTION) \
|
||||
do \
|
||||
{ \
|
||||
if (pthread_in_use ()) \
|
||||
{ \
|
||||
if (pthread_once (&NAME, INITFUNCTION) != 0) \
|
||||
abort (); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (glthread_once_singlethreaded (&NAME)) \
|
||||
INITFUNCTION (); \
|
||||
} \
|
||||
} \
|
||||
while (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 <pth.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# 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 gl_lock_init(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
|
||||
# define gl_lock_lock(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
|
||||
# define gl_lock_unlock(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
|
||||
# define gl_lock_destroy(NAME) \
|
||||
(void)(&NAME)
|
||||
|
||||
/* ------------------------- 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 gl_rwlock_init(NAME) \
|
||||
if (pth_in_use() && !pth_rwlock_init (&NAME)) abort ()
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) abort ()
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) abort ()
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
if (pth_in_use() && !pth_rwlock_release (&NAME)) abort ()
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
(void)(&NAME)
|
||||
|
||||
/* --------------------- 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 gl_recursive_lock_init(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
(void)(&NAME)
|
||||
|
||||
/* -------------------------- 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 gl_once(NAME, INITFUNCTION) \
|
||||
do \
|
||||
{ \
|
||||
if (pth_in_use ()) \
|
||||
{ \
|
||||
void (*gl_once_temp) (void) = INITFUNCTION; \
|
||||
if (!pth_once (&NAME, glthread_once_call, &gl_once_temp)) \
|
||||
abort (); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (glthread_once_singlethreaded (&NAME)) \
|
||||
INITFUNCTION (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
extern void glthread_once_call (void *arg);
|
||||
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 <thread.h>
|
||||
# include <synch.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
# 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 gl_lock_init(NAME) \
|
||||
if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
|
||||
# define gl_lock_lock(NAME) \
|
||||
if (thread_in_use () && mutex_lock (&NAME) != 0) abort ()
|
||||
# define gl_lock_unlock(NAME) \
|
||||
if (thread_in_use () && mutex_unlock (&NAME) != 0) abort ()
|
||||
# define gl_lock_destroy(NAME) \
|
||||
if (thread_in_use () && mutex_destroy (&NAME) != 0) abort ()
|
||||
|
||||
/* ------------------------- 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 gl_rwlock_init(NAME) \
|
||||
if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
if (thread_in_use () && rw_rdlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
if (thread_in_use () && rw_wrlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
if (thread_in_use () && rw_unlock (&NAME) != 0) abort ()
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
if (thread_in_use () && rwlock_destroy (&NAME) != 0) abort ()
|
||||
|
||||
/* --------------------- 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 gl_recursive_lock_init(NAME) \
|
||||
if (thread_in_use ()) glthread_recursive_lock_init (&NAME)
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
if (thread_in_use ()) glthread_recursive_lock_lock (&NAME)
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
if (thread_in_use ()) glthread_recursive_lock_unlock (&NAME)
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
if (thread_in_use ()) glthread_recursive_lock_destroy (&NAME)
|
||||
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_destroy (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 gl_once(NAME, INITFUNCTION) \
|
||||
do \
|
||||
{ \
|
||||
if (thread_in_use ()) \
|
||||
{ \
|
||||
glthread_once (&NAME, INITFUNCTION); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (glthread_once_singlethreaded (&NAME)) \
|
||||
INITFUNCTION (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void));
|
||||
extern int glthread_once_singlethreaded (gl_once_t *once_control);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if USE_WIN32_THREADS
|
||||
|
||||
# include <windows.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* We can use CRITICAL_SECTION directly, rather than the Win32 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 gl_lock_init(NAME) \
|
||||
glthread_lock_init (&NAME)
|
||||
# define gl_lock_lock(NAME) \
|
||||
glthread_lock_lock (&NAME)
|
||||
# define gl_lock_unlock(NAME) \
|
||||
glthread_lock_unlock (&NAME)
|
||||
# define gl_lock_destroy(NAME) \
|
||||
glthread_lock_destroy (&NAME)
|
||||
extern void glthread_lock_init (gl_lock_t *lock);
|
||||
extern void glthread_lock_lock (gl_lock_t *lock);
|
||||
extern void glthread_lock_unlock (gl_lock_t *lock);
|
||||
extern void glthread_lock_destroy (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_waitqueue_t;
|
||||
typedef struct
|
||||
{
|
||||
gl_spinlock_t guard; /* protects the initialization */
|
||||
CRITICAL_SECTION lock; /* protects the remaining fields */
|
||||
gl_waitqueue_t waiting_readers; /* waiting readers */
|
||||
gl_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 gl_rwlock_init(NAME) \
|
||||
glthread_rwlock_init (&NAME)
|
||||
# define gl_rwlock_rdlock(NAME) \
|
||||
glthread_rwlock_rdlock (&NAME)
|
||||
# define gl_rwlock_wrlock(NAME) \
|
||||
glthread_rwlock_wrlock (&NAME)
|
||||
# define gl_rwlock_unlock(NAME) \
|
||||
glthread_rwlock_unlock (&NAME)
|
||||
# define gl_rwlock_destroy(NAME) \
|
||||
glthread_rwlock_destroy (&NAME)
|
||||
extern void glthread_rwlock_init (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
|
||||
extern void glthread_rwlock_destroy (gl_rwlock_t *lock);
|
||||
|
||||
/* --------------------- gl_recursive_lock_t datatype --------------------- */
|
||||
|
||||
/* The Win32 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 gl_recursive_lock_init(NAME) \
|
||||
glthread_recursive_lock_init (&NAME)
|
||||
# define gl_recursive_lock_lock(NAME) \
|
||||
glthread_recursive_lock_lock (&NAME)
|
||||
# define gl_recursive_lock_unlock(NAME) \
|
||||
glthread_recursive_lock_unlock (&NAME)
|
||||
# define gl_recursive_lock_destroy(NAME) \
|
||||
glthread_recursive_lock_destroy (&NAME)
|
||||
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
|
||||
extern void glthread_recursive_lock_destroy (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 gl_once(NAME, INITFUNCTION) \
|
||||
glthread_once (&NAME, INITFUNCTION)
|
||||
extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void));
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_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 gl_lock_init(NAME)
|
||||
# define gl_lock_lock(NAME)
|
||||
# define gl_lock_unlock(NAME)
|
||||
|
||||
/* ------------------------- gl_rwlock_t datatype ------------------------- */
|
||||
|
||||
typedef int gl_rwlock_t;
|
||||
# define gl_rwlock_define(STORAGECLASS, NAME)
|
||||
# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
|
||||
# define gl_rwlock_init(NAME)
|
||||
# define gl_rwlock_rdlock(NAME)
|
||||
# define gl_rwlock_wrlock(NAME)
|
||||
# define gl_rwlock_unlock(NAME)
|
||||
|
||||
/* --------------------- 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 gl_recursive_lock_init(NAME)
|
||||
# define gl_recursive_lock_lock(NAME)
|
||||
# define gl_recursive_lock_unlock(NAME)
|
||||
|
||||
/* -------------------------- gl_once_t datatype -------------------------- */
|
||||
|
||||
typedef int gl_once_t;
|
||||
# define gl_once_define(STORAGECLASS, NAME) \
|
||||
STORAGECLASS gl_once_t NAME = 0;
|
||||
# define gl_once(NAME, INITFUNCTION) \
|
||||
do \
|
||||
{ \
|
||||
if (NAME == 0) \
|
||||
{ \
|
||||
NAME = ~ 0; \
|
||||
INITFUNCTION (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#endif /* _LOCK_H */
|
32
intl/log.c
32
intl/log.c
|
@ -1,5 +1,5 @@
|
|||
/* Log file output.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 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 Library General Public License as published
|
||||
|
@ -26,6 +26,13 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
# include <bits/libc-lock.h>
|
||||
#else
|
||||
# include "lock.h"
|
||||
#endif
|
||||
|
||||
/* Print an ASCII string with quotes and escape sequences where needed. */
|
||||
static void
|
||||
print_escaped (FILE *stream, const char *str)
|
||||
|
@ -48,13 +55,14 @@ print_escaped (FILE *stream, const char *str)
|
|||
putc ('"', stream);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
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)
|
||||
{
|
||||
static char *last_logfilename = NULL;
|
||||
static FILE *last_logfile = NULL;
|
||||
FILE *logfile;
|
||||
|
||||
/* Can we reuse the last opened logfile? */
|
||||
|
@ -96,3 +104,13 @@ _nl_log_untranslated (const char *logfilename, const char *domainname,
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* OS dependent parts of libintl.
|
||||
Copyright (C) 2001-2002 Free Software Foundation, Inc.
|
||||
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 Library General Public License as published
|
||||
|
@ -16,7 +16,9 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#if defined __EMX__
|
||||
#if defined __CYGWIN__
|
||||
# include "intl-exports.c"
|
||||
#elif defined __EMX__
|
||||
# include "os2compat.c"
|
||||
#else
|
||||
/* Avoid AIX compiler warning. */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Expression parsing for plural form selection.
|
||||
Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "plural-exp.h"
|
||||
|
||||
#if (defined __GNUC__ && !defined __APPLE_CC__) \
|
||||
#if (defined __GNUC__ && !(__APPLE_CC__ > 1)) \
|
||||
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
|
||||
|
||||
/* These structs are the constant expression for the germanic plural
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Expression parsing and evaluation for plural form selection.
|
||||
Copyright (C) 2000-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -110,7 +110,7 @@ extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
|
|||
unsigned long int *npluralsp)
|
||||
internal_function;
|
||||
|
||||
#if !defined (_LIBC) && !defined (IN_LIBINTL)
|
||||
#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
|
||||
extern unsigned long int plural_eval (struct expression *pexp,
|
||||
unsigned long int n);
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#line 1 "plural.y"
|
||||
|
||||
/* Expression parsing for plural form selection.
|
||||
Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,10 +37,11 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* 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 <config.h>
|
||||
because <config.h> may include arbitrary system headers. */
|
||||
/* 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 <config.h>
|
||||
because <config.h> 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
|
||||
|
@ -51,6 +52,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "plural-exp.h"
|
||||
|
||||
/* The main function generated by the parser is called __gettextparse,
|
||||
|
@ -62,7 +64,7 @@
|
|||
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
|
||||
#define YYPARSE_PARAM arg
|
||||
|
||||
#line 49 "plural.y"
|
||||
#line 51 "plural.y"
|
||||
#ifndef YYSTYPE
|
||||
typedef union {
|
||||
unsigned long int num;
|
||||
|
@ -72,7 +74,7 @@ typedef union {
|
|||
# define YYSTYPE yystype
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
#line 55 "plural.y"
|
||||
#line 57 "plural.y"
|
||||
|
||||
/* Prototypes for local functions. */
|
||||
static int yylex (YYSTYPE *lval, const char **pexp);
|
||||
|
@ -212,8 +214,8 @@ static const short yyrhs[] =
|
|||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||
static const short yyrline[] =
|
||||
{
|
||||
0, 150, 158, 162, 166, 170, 174, 178, 182, 186,
|
||||
190, 194, 199
|
||||
0, 152, 160, 164, 168, 172, 176, 180, 184, 188,
|
||||
192, 196, 201
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -296,7 +298,7 @@ static const short yycheck[] =
|
|||
#define YYPURE 1
|
||||
|
||||
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
||||
#line 3 "/usr/local/share/bison/bison.simple"
|
||||
#line 3 "bison.simple"
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
|
||||
|
@ -315,8 +317,8 @@ static const short yycheck[] =
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
|
@ -609,7 +611,7 @@ yystpcpy (yydest, yysrc)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#line 315 "/usr/local/share/bison/bison.simple"
|
||||
#line 315 "bison.simple"
|
||||
|
||||
|
||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||
|
@ -1003,7 +1005,7 @@ yyreduce:
|
|||
switch (yyn) {
|
||||
|
||||
case 1:
|
||||
#line 151 "plural.y"
|
||||
#line 153 "plural.y"
|
||||
{
|
||||
if (yyvsp[0].exp == NULL)
|
||||
YYABORT;
|
||||
|
@ -1011,75 +1013,75 @@ case 1:
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
#line 159 "plural.y"
|
||||
#line 161 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
#line 163 "plural.y"
|
||||
#line 165 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
#line 167 "plural.y"
|
||||
#line 169 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
#line 171 "plural.y"
|
||||
#line 173 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
#line 175 "plural.y"
|
||||
#line 177 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
#line 179 "plural.y"
|
||||
#line 181 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
#line 183 "plural.y"
|
||||
#line 185 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
#line 187 "plural.y"
|
||||
#line 189 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
#line 191 "plural.y"
|
||||
#line 193 "plural.y"
|
||||
{
|
||||
yyval.exp = new_exp_0 (var);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
#line 195 "plural.y"
|
||||
#line 197 "plural.y"
|
||||
{
|
||||
if ((yyval.exp = new_exp_0 (num)) != NULL)
|
||||
yyval.exp->val.num = yyvsp[0].num;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
#line 200 "plural.y"
|
||||
#line 202 "plural.y"
|
||||
{
|
||||
yyval.exp = yyvsp[-1].exp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#line 705 "/usr/local/share/bison/bison.simple"
|
||||
#line 705 "bison.simple"
|
||||
|
||||
|
||||
yyvsp -= yylen;
|
||||
|
@ -1310,7 +1312,7 @@ yyreturn:
|
|||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 205 "plural.y"
|
||||
#line 207 "plural.y"
|
||||
|
||||
|
||||
void
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%{
|
||||
/* Expression parsing for plural form selection.
|
||||
Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -18,10 +18,11 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* 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 <config.h>
|
||||
because <config.h> may include arbitrary system headers. */
|
||||
/* 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 <config.h>
|
||||
because <config.h> 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
|
||||
|
@ -32,6 +33,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "plural-exp.h"
|
||||
|
||||
/* The main function generated by the parser is called __gettextparse,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Decomposed printf argument list.
|
||||
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002-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 Library General Public License as published
|
||||
|
@ -16,9 +16,7 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "printf-args.h"
|
||||
|
@ -59,7 +57,7 @@ printf_fetchargs (va_list args, arguments *a)
|
|||
case TYPE_ULONGINT:
|
||||
ap->a.a_ulongint = va_arg (args, unsigned long int);
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
ap->a.a_longlongint = va_arg (args, long long int);
|
||||
break;
|
||||
|
@ -80,15 +78,40 @@ printf_fetchargs (va_list args, arguments *a)
|
|||
break;
|
||||
#ifdef HAVE_WINT_T
|
||||
case TYPE_WIDE_CHAR:
|
||||
ap->a.a_wide_char = va_arg (args, wint_t);
|
||||
/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
|
||||
default argument promotions", this is not the case in mingw32,
|
||||
where wint_t is 'unsigned short'. */
|
||||
ap->a.a_wide_char =
|
||||
(sizeof (wint_t) < sizeof (int)
|
||||
? va_arg (args, int)
|
||||
: va_arg (args, wint_t));
|
||||
break;
|
||||
#endif
|
||||
case TYPE_STRING:
|
||||
ap->a.a_string = va_arg (args, const char *);
|
||||
/* A null pointer is an invalid argument for "%s", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_string == NULL)
|
||||
ap->a.a_string = "(NULL)";
|
||||
break;
|
||||
#ifdef HAVE_WCHAR_T
|
||||
case TYPE_WIDE_STRING:
|
||||
ap->a.a_wide_string = va_arg (args, const wchar_t *);
|
||||
/* A null pointer is an invalid argument for "%ls", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_wide_string == NULL)
|
||||
{
|
||||
static const wchar_t wide_null_string[] =
|
||||
{
|
||||
(wchar_t)'(',
|
||||
(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
|
||||
(wchar_t)')',
|
||||
(wchar_t)0
|
||||
};
|
||||
ap->a.a_wide_string = wide_null_string;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TYPE_POINTER:
|
||||
|
@ -106,7 +129,7 @@ printf_fetchargs (va_list args, arguments *a)
|
|||
case TYPE_COUNT_LONGINT_POINTER:
|
||||
ap->a.a_count_longint_pointer = va_arg (args, long int *);
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case TYPE_COUNT_LONGLONGINT_POINTER:
|
||||
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Decomposed printf argument list.
|
||||
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -48,7 +48,7 @@ typedef enum
|
|||
TYPE_UINT,
|
||||
TYPE_LONGINT,
|
||||
TYPE_ULONGINT,
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
TYPE_LONGLONGINT,
|
||||
TYPE_ULONGLONGINT,
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ typedef enum
|
|||
TYPE_COUNT_SHORT_POINTER,
|
||||
TYPE_COUNT_INT_POINTER,
|
||||
TYPE_COUNT_LONGINT_POINTER
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
, TYPE_COUNT_LONGLONGINT_POINTER
|
||||
#endif
|
||||
} arg_type;
|
||||
|
@ -88,7 +88,7 @@ typedef struct
|
|||
unsigned int a_uint;
|
||||
long int a_longint;
|
||||
unsigned long int a_ulongint;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
long long int a_longlongint;
|
||||
unsigned long long int a_ulonglongint;
|
||||
#endif
|
||||
|
@ -110,7 +110,7 @@ typedef struct
|
|||
short * a_count_short_pointer;
|
||||
int * a_count_int_pointer;
|
||||
long int * a_count_longint_pointer;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
long long int * a_count_longlongint_pointer;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2000, 2002-2003, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -16,9 +16,7 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#if WIDE_CHAR_VERSION
|
||||
|
@ -385,11 +383,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
|||
switch (c)
|
||||
{
|
||||
case 'd': case 'i':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef 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)
|
||||
|
@ -400,11 +401,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
|||
type = TYPE_INT;
|
||||
break;
|
||||
case 'o': case 'u': case 'x': case 'X':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef 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)
|
||||
|
@ -459,11 +463,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
|||
type = TYPE_POINTER;
|
||||
break;
|
||||
case 'n':
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef 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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings, using POSIX/XSI format strings with positions.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2006 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2003.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -47,9 +47,16 @@ char *alloca ();
|
|||
|
||||
#if !HAVE_POSIX_PRINTF
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* 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. */
|
||||
|
@ -61,6 +68,14 @@ char *alloca ();
|
|||
|
||||
#define STATIC static
|
||||
|
||||
/* This needs to be consistent with libgnuintl.h.in. */
|
||||
#if defined __NetBSD__ || 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"
|
||||
|
||||
|
@ -88,9 +103,15 @@ libintl_vfprintf (FILE *stream, const char *format, va_list args)
|
|||
int retval = -1;
|
||||
if (result != NULL)
|
||||
{
|
||||
if (fwrite (result, 1, length, stream) == length)
|
||||
retval = length;
|
||||
size_t written = fwrite (result, 1, length, stream);
|
||||
free (result);
|
||||
if (written == length)
|
||||
{
|
||||
if (length > INT_MAX)
|
||||
errno = EOVERFLOW;
|
||||
else
|
||||
retval = length;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -144,6 +165,11 @@ libintl_vsprintf (char *resultbuf, const char *format, va_list args)
|
|||
free (result);
|
||||
return -1;
|
||||
}
|
||||
if (length > INT_MAX)
|
||||
{
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return length;
|
||||
}
|
||||
|
@ -186,12 +212,16 @@ libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list a
|
|||
{
|
||||
if (maxlength > 0)
|
||||
{
|
||||
if (length < maxlength)
|
||||
abort ();
|
||||
memcpy (resultbuf, result, maxlength - 1);
|
||||
resultbuf[maxlength - 1] = '\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
|
||||
|
@ -224,6 +254,12 @@ libintl_vasprintf (char **resultp, const char *format, va_list args)
|
|||
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;
|
||||
}
|
||||
|
@ -285,9 +321,14 @@ libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args)
|
|||
for (i = 0; i < length; i++)
|
||||
if (fputwc (result[i], stream) == WEOF)
|
||||
break;
|
||||
if (i == length)
|
||||
retval = length;
|
||||
free (result);
|
||||
if (i == length)
|
||||
{
|
||||
if (length > INT_MAX)
|
||||
errno = EOVERFLOW;
|
||||
else
|
||||
retval = length;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -340,12 +381,22 @@ libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_
|
|||
{
|
||||
if (maxlength > 0)
|
||||
{
|
||||
if (length < maxlength)
|
||||
abort ();
|
||||
memcpy (resultbuf, result, (maxlength - 1) * sizeof (wchar_t));
|
||||
resultbuf[maxlength - 1] = 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Provide relocatable packages.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2006 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2003.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,9 +25,7 @@
|
|||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "relocatable.h"
|
||||
|
@ -45,7 +43,7 @@
|
|||
# include "xalloc.h"
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
@ -72,20 +70,20 @@
|
|||
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 __EMX__ || defined __DJGPP__
|
||||
/* Win32, OS/2, DOS */
|
||||
#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_PATH_WITH_DIR(P) \
|
||||
(strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
|
||||
# define FILESYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
|
||||
# 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 FILESYSTEM_PREFIX_LEN(P) 0
|
||||
# define FILE_SYSTEM_PREFIX_LEN(P) 0
|
||||
#endif
|
||||
|
||||
/* Original installation prefix. */
|
||||
|
@ -189,7 +187,7 @@ compute_curr_prefix (const char *orig_installprefix,
|
|||
|
||||
/* Determine the current installation directory. */
|
||||
{
|
||||
const char *p_base = curr_pathname + FILESYSTEM_PREFIX_LEN (curr_pathname);
|
||||
const char *p_base = curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname);
|
||||
const char *p = curr_pathname + strlen (curr_pathname);
|
||||
char *q;
|
||||
|
||||
|
@ -216,7 +214,7 @@ compute_curr_prefix (const char *orig_installprefix,
|
|||
const char *rp = rel_installdir + strlen (rel_installdir);
|
||||
const char *cp = curr_installdir + strlen (curr_installdir);
|
||||
const char *cp_base =
|
||||
curr_installdir + FILESYSTEM_PREFIX_LEN (curr_installdir);
|
||||
curr_installdir + FILE_SYSTEM_PREFIX_LEN (curr_installdir);
|
||||
|
||||
while (rp > rel_installdir && cp > cp_base)
|
||||
{
|
||||
|
@ -234,8 +232,11 @@ compute_curr_prefix (const char *orig_installprefix,
|
|||
same = true;
|
||||
break;
|
||||
}
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, OS/2, DOS - case insignificant filesystem */
|
||||
/* Do case-insensitive comparison if the filesystem 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__
|
||||
/* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
|
||||
if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
|
||||
!= (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
|
||||
break;
|
||||
|
@ -280,7 +281,7 @@ compute_curr_prefix (const char *orig_installprefix,
|
|||
/* Full pathname of shared library, or NULL. */
|
||||
static char *shared_library_fullname;
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
|
||||
|
||||
/* Determine the full pathname of the shared library when it is loaded. */
|
||||
|
||||
|
@ -302,13 +303,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
|
|||
/* Shouldn't happen. */
|
||||
return FALSE;
|
||||
|
||||
shared_library_fullname = strdup (location);
|
||||
{
|
||||
#if defined __CYGWIN__
|
||||
/* On Cygwin, we need to convert paths coming from Win32 system calls
|
||||
to the Unix-like slashified notation. */
|
||||
static char location_as_posix_path[2 * MAX_PATH];
|
||||
/* There's no error return defined for cygwin_conv_to_posix_path.
|
||||
See cygwin-api/func-cygwin-conv-to-posix-path.html.
|
||||
Does it overflow the buffer of expected size MAX_PATH or does it
|
||||
truncate the path? I don't know. Let's catch both. */
|
||||
cygwin_conv_to_posix_path (location, location_as_posix_path);
|
||||
location_as_posix_path[MAX_PATH - 1] = '\0';
|
||||
if (strlen (location_as_posix_path) >= MAX_PATH - 1)
|
||||
/* A sign of buffer overflow or path truncation. */
|
||||
return FALSE;
|
||||
shared_library_fullname = strdup (location_as_posix_path);
|
||||
#else
|
||||
shared_library_fullname = strdup (location);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else /* Unix */
|
||||
#else /* Unix except Cygwin */
|
||||
|
||||
static void
|
||||
find_shared_library_fullname ()
|
||||
|
@ -359,15 +378,15 @@ find_shared_library_fullname ()
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WIN32 / Unix */
|
||||
#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */
|
||||
|
||||
/* Return the full pathname of the current shared library.
|
||||
Return NULL if unknown.
|
||||
Guaranteed to work only on Linux and Woe32. */
|
||||
Guaranteed to work only on Linux, Cygwin and Woe32. */
|
||||
static char *
|
||||
get_shared_library_fullname ()
|
||||
{
|
||||
#if !(defined _WIN32 || defined __WIN32__)
|
||||
#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)
|
||||
static bool tried_find_shared_library_fullname;
|
||||
if (!tried_find_shared_library_fullname)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Provide relocatable packages.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2003.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,7 +31,9 @@ extern "C" {
|
|||
/* When building a DLL, we must export some functions. Note that because
|
||||
this is a private .h file, we don't need to use __declspec(dllimport)
|
||||
in any case. */
|
||||
#if defined _MSC_VER && BUILDING_DLL
|
||||
#if HAVE_VISIBILITY && BUILDING_DLL
|
||||
# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
|
||||
#elif defined _MSC_VER && BUILDING_DLL
|
||||
# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
|
||||
#else
|
||||
# define RELOCATABLE_DLL_EXPORTED
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Implementation of the textdomain(3) function.
|
||||
Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
|
||||
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 Library General Public License as published
|
||||
|
@ -23,21 +23,21 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettextP.h"
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
#else
|
||||
# include "libgnuintl.h"
|
||||
#endif
|
||||
#include "gettextP.h"
|
||||
|
||||
/* Handle multi-threaded applications. */
|
||||
#ifdef _LIBC
|
||||
/* We have to handle multi-threaded applications. */
|
||||
# include <bits/libc-lock.h>
|
||||
# define gl_rwlock_define __libc_rwlock_define
|
||||
# define gl_rwlock_wrlock __libc_rwlock_wrlock
|
||||
# define gl_rwlock_unlock __libc_rwlock_unlock
|
||||
#else
|
||||
/* Provide dummy implementation if this is outside glibc. */
|
||||
# define __libc_rwlock_define(CLASS, NAME)
|
||||
# define __libc_rwlock_wrlock(NAME)
|
||||
# define __libc_rwlock_unlock(NAME)
|
||||
# include "lock.h"
|
||||
#endif
|
||||
|
||||
/* The internal variables in the standalone libintl.a must have different
|
||||
|
@ -71,7 +71,7 @@ extern const char *_nl_current_default_domain attribute_hidden;
|
|||
#endif
|
||||
|
||||
/* Lock variable to protect the global data in the gettext implementation. */
|
||||
__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
|
||||
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.
|
||||
|
@ -86,7 +86,7 @@ TEXTDOMAIN (const char *domainname)
|
|||
if (domainname == NULL)
|
||||
return (char *) _nl_current_default_domain;
|
||||
|
||||
__libc_rwlock_wrlock (_nl_state_lock);
|
||||
gl_rwlock_wrlock (_nl_state_lock);
|
||||
|
||||
old_domain = (char *) _nl_current_default_domain;
|
||||
|
||||
|
@ -130,7 +130,7 @@ TEXTDOMAIN (const char *domainname)
|
|||
free (old_domain);
|
||||
}
|
||||
|
||||
__libc_rwlock_unlock (_nl_state_lock);
|
||||
gl_rwlock_unlock (_nl_state_lock);
|
||||
|
||||
return new_domain;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* vsprintf with automatic memory allocation.
|
||||
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 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 Library General Public License as published
|
||||
|
@ -23,9 +23,7 @@
|
|||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
#ifndef IN_LIBINTL
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
@ -251,7 +249,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
case TYPE_COUNT_LONGINT_POINTER:
|
||||
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case TYPE_COUNT_LONGLONGINT_POINTER:
|
||||
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
|
||||
break;
|
||||
|
@ -316,9 +314,8 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
const CHAR_T *digitp = dp->precision_start + 1;
|
||||
|
||||
precision = 0;
|
||||
do
|
||||
while (digitp != dp->precision_end)
|
||||
precision = xsum (xtimes (precision, 10), *digitp++ - '0');
|
||||
while (digitp != dp->precision_end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,44 +323,43 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
{
|
||||
|
||||
case 'd': case 'i': case 'u':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# ifdef HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
* 0.30103 /* binary -> decimal */
|
||||
* 2 /* estimate for FLAG_GROUP */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
# endif
|
||||
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
|
||||
* 0.30103 /* binary -> decimal */
|
||||
* 2 /* estimate for FLAG_GROUP */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
|
||||
* 0.30103 /* binary -> decimal */
|
||||
* 2 /* estimate for FLAG_GROUP */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
if (tmp_length < precision)
|
||||
tmp_length = precision;
|
||||
/* Multiply by 2, as an estimate for FLAG_GROUP. */
|
||||
tmp_length = xsum (tmp_length, tmp_length);
|
||||
/* Add 1, to account for a leading sign. */
|
||||
tmp_length = xsum (tmp_length, 1);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# ifdef HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
* 0.333334 /* binary -> octal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
# endif
|
||||
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
|
||||
|
@ -371,26 +367,27 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
|
||||
* 0.333334 /* binary -> octal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
|
||||
* 0.333334 /* binary -> octal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 1; /* account for leading sign */
|
||||
+ 1; /* turn floor into ceil */
|
||||
if (tmp_length < precision)
|
||||
tmp_length = precision;
|
||||
/* Add 1, to account for a leading sign. */
|
||||
tmp_length = xsum (tmp_length, 1);
|
||||
break;
|
||||
|
||||
case 'x': case 'X':
|
||||
# ifdef HAVE_LONG_LONG
|
||||
# ifdef HAVE_LONG_LONG_INT
|
||||
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
|
||||
* 0.25 /* binary -> hexadecimal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 2; /* account for leading sign or alternate form */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
# endif
|
||||
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
|
||||
|
@ -398,15 +395,17 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
|
||||
* 0.25 /* binary -> hexadecimal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 2; /* account for leading sign or alternate form */
|
||||
+ 1; /* turn floor into ceil */
|
||||
else
|
||||
tmp_length =
|
||||
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
|
||||
* 0.25 /* binary -> hexadecimal */
|
||||
)
|
||||
+ 1 /* turn floor into ceil */
|
||||
+ 2; /* account for leading sign or alternate form */
|
||||
+ 1; /* turn floor into ceil */
|
||||
if (tmp_length < precision)
|
||||
tmp_length = precision;
|
||||
/* Add 2, to account for a leading sign or alternate form. */
|
||||
tmp_length = xsum (tmp_length, 2);
|
||||
break;
|
||||
|
||||
case 'f': case 'F':
|
||||
|
@ -529,7 +528,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
|
||||
switch (type)
|
||||
{
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
case TYPE_ULONGLONGINT:
|
||||
*p++ = 'l';
|
||||
|
@ -683,7 +682,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
SNPRINTF_BUF (arg);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
{
|
||||
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
|
||||
|
@ -864,6 +863,10 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
|||
free (buf_malloced);
|
||||
CLEANUP ();
|
||||
*lengthp = length;
|
||||
/* Note that we can produce a big string of a length > INT_MAX. POSIX
|
||||
says that snprintf() fails with errno = EOVERFLOW in this case, but
|
||||
that's only because snprintf() returns an 'int'. This function does
|
||||
not have this limitation. */
|
||||
return result;
|
||||
|
||||
out_of_memory:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* vsprintf with automatic memory allocation.
|
||||
Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
|
@ -48,7 +48,24 @@ extern "C" {
|
|||
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. */
|
||||
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)
|
||||
|
|
26
intl/version.c
Normal file
26
intl/version.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* 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 Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "libgnuintl.h"
|
||||
|
||||
/* Version number: (major<<16) + (minor<<8) + subminor */
|
||||
int libintl_version = LIBINTL_VERSION;
|
Loading…
Add table
Add a link
Reference in a new issue