+2001-01-06 Bruno Haible <haible@clisp.cons.org>
+
+ * configure.in: Use AC_CHECK_HEADERS instead of AC_HAVE_HEADERS.
+ Call gt_SETLOCALE.
+
2000-12-30 Bruno Haible <haible@clisp.cons.org>
* ltconfig, ltmain.sh: Update from libtool-1.3.5.
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.12)
-AC_REVISION($Revision: 1.5 $)
+AC_REVISION($Revision: 1.6 $)
AC_INIT(src/msgfmt.c)
AM_INIT_AUTOMAKE(gettext, 0.10.36)
AM_CONFIG_HEADER(config.h)
dnl Checks for header files.
AC_HEADER_STDC
-AC_HAVE_HEADERS(limits.h malloc.h string.h unistd.h values.h)
+AC_CHECK_HEADERS(limits.h malloc.h string.h unistd.h values.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AM_FUNC_ERROR_AT_LINE
+gt_SETLOCALE
+
dnl These are the only lines required to internationalize the package.
dnl (OK, not quite, the AC_OUTPUT has also some parts.)
AM_GNU_GETTEXT
+2001-01-06 Bruno Haible <haible@clisp.cons.org>
+
+ * setlocale.m4: New file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
2001-01-06 Bruno Haible <haible@clisp.cons.org>
* gettext.m4 (AM_WITH_NLS): Look for GNU gettext in libc and libintl,
# |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
EXTRA_DIST = README \
c-bs-a.m4 codeset.m4 gettext.m4 iconv.m4 inttypes_h.m4 isc-posix.m4 \
-lcmessage.m4 progtest.m4 uintmax_t.m4 ulonglong.m4
+lcmessage.m4 progtest.m4 setlocale.m4 uintmax_t.m4 ulonglong.m4
--- /dev/null
+#serial 1
+
+# Check for setlocale declaration.
+
+AC_DEFUN(gt_SETLOCALE,[
+AC_CHECK_HEADERS([locale.h])
+AC_MSG_CHECKING([for setlocale declaration])
+AC_CACHE_VAL(gt_cv_proto_setlocale, [
+AC_TRY_COMPILE([
+#include <stdlib.h>
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+char* setlocale (int category, char* locale);
+#else
+char* setlocale();
+#endif
+], [], gt_cv_proto_setlocale_arg1="", gt_cv_proto_setlocale_arg1="const")
+gt_cv_proto_setlocale="extern char* setlocale (int, $gt_cv_proto_setlocale_arg1 char*);"])
+gt_cv_proto_setlocale=`echo "[$]gt_cv_proto_setlocale" | tr -s ' ' | sed -e 's/( /(/'`
+AC_MSG_RESULT([$]{ac_t:-
+ }[$]gt_cv_proto_setlocale)
+AC_DEFINE_UNQUOTED(SETLOCALE_CONST,$gt_cv_proto_setlocale_arg1,
+ [Define as const if the declaration of setlocale() needs const.])
+])
+2001-01-06 Bruno Haible <haible@clisp.cons.org>
+
+ * setlocale.c: New file.
+ * Makefile.am (EXTRA_PROGRAMS): New variable.
+ (all-local): New target.
+ (CLEANFILES): New variable.
+ (tstgettext_SOURCES): New variable.
+
2001-01-05 Bruno Haible <haible@clisp.cons.org>
* Makefile.am (po-gram-gen.h): Don't use $^, not supported by the
SED = sed
YACC = @YACC@ -d
-# Source dependecies.
+EXTRA_PROGRAMS = tstgettext
+all-local: $(EXTRA_PROGRAMS)
+CLEANFILES = $(EXTRA_PROGRAMS)
+
+# Source dependencies.
gettext_SOURCES = gettextp.c
+tstgettext_SOURCES = gettextp.c setlocale.c
msgcmp_SOURCES = message.c msgcmp.c open-po.c po-gram-gen.y po-hash-gen.y \
po-lex.c po.c str-list.c dir-list.c
msgfmt_SOURCES = msgfmt.c open-po.c po-gram-gen.y po-hash-gen.y po-lex.c po.c \
--- /dev/null
+/* Fake setlocale - platform independent, for testing purposes.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# endif
+extern char *getenv ();
+#endif
+
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
+/* Return string representation of locale CATEGORY. */
+static const char *
+category_to_name (category)
+ int category;
+{
+ const char *retval;
+
+ switch (category)
+ {
+#ifdef LC_COLLATE
+ case LC_COLLATE:
+ retval = "LC_COLLATE";
+ break;
+#endif
+#ifdef LC_CTYPE
+ case LC_CTYPE:
+ retval = "LC_CTYPE";
+ break;
+#endif
+#ifdef LC_MONETARY
+ case LC_MONETARY:
+ retval = "LC_MONETARY";
+ break;
+#endif
+#ifdef LC_NUMERIC
+ case LC_NUMERIC:
+ retval = "LC_NUMERIC";
+ break;
+#endif
+#ifdef LC_TIME
+ case LC_TIME:
+ retval = "LC_TIME";
+ break;
+#endif
+#ifdef LC_MESSAGES
+ case LC_MESSAGES:
+ retval = "LC_MESSAGES";
+ break;
+#endif
+#ifdef LC_RESPONSE
+ case LC_RESPONSE:
+ retval = "LC_RESPONSE";
+ break;
+#endif
+#ifdef LC_ALL
+ case LC_ALL:
+ /* This might not make sense but is perhaps better than any other
+ value. */
+ retval = "LC_ALL";
+ break;
+#endif
+ default:
+ /* If you have a better idea for a default value let me know. */
+ retval = "LC_XXX";
+ }
+
+ return retval;
+}
+
+/* An implementation of setlocale that always succeeds, but doesn't
+ actually change the behaviour of locale dependent functions.
+ Assumes setenv()/putenv() is not called. */
+char *
+setlocale (category, locale)
+ int category;
+ SETLOCALE_CONST char *locale;
+{
+ char *retval;
+ static char C_string[] = "C";
+ static char *current_locale = C_string;
+#ifdef HAVE_LOCALE_H
+ struct list
+ {
+ int category;
+ char *current_locale;
+ struct list *next;
+ };
+ static struct list *facets = NULL;
+ struct list *facetp;
+
+ if (locale != NULL)
+ {
+ char *copy;
+
+ copy = (char *) malloc (strlen (locale) + 1);
+ strcpy (copy, locale);
+
+ if (category == LC_ALL)
+ {
+ while ((facetp = facets) != NULL)
+ {
+ facets = facetp->next;
+ free (facetp->current_locale);
+ free (facetp);
+ }
+ if (current_locale != C_string)
+ free (current_locale);
+ current_locale = copy;
+ }
+ else
+ {
+ for (facetp = facets; facetp != NULL; facetp = facetp->next)
+ if (category == facetp->category)
+ {
+ free (facetp->current_locale);
+ facetp->current_locale = copy;
+ break;
+ }
+ if (facetp == NULL)
+ {
+ facetp = (struct list *) malloc (sizeof (struct list));
+ facetp->category = category;
+ facetp->current_locale = copy;
+ facetp->next = facets;
+ facets = facetp;
+ }
+ }
+ }
+
+ retval = current_locale;
+ for (facetp = facets; facetp != NULL; facetp = facetp->next)
+ if (category == facetp->category)
+ {
+ retval = facetp->current_locale;
+ break;
+ }
+#else
+ if (locale != NULL)
+ {
+ if (current_locale != C_string)
+ free (current_locale);
+ current_locale = (char *) malloc (strlen (locale) + 1);
+ strcpy (current_locale, locale);
+ }
+
+ retval = current_locale;
+#endif
+
+ if (retval[0] == '\0')
+ {
+ retval = getenv ("LC_ALL");
+ if (retval == NULL || retval[0] == '\0')
+ {
+ retval = getenv (category_to_name (category));
+ if (retval == NULL || retval[0] == '\0')
+ {
+ retval = getenv ("LANG");
+ if (retval == NULL || retval[0] == '\0')
+ retval = "C";
+ }
+ }
+ }
+ return retval;
+}
+2001-01-06 Bruno Haible <haible@clisp.cons.org>
+
+ Translations are now disabled in C locale.
+ * Makefile.am (TESTS_ENVIRONMENT): Use tstgettext for $GETTEXT.
+ (cake_LDADD): Add ../src/setlocale.o.
+ * gettext-1: Set LC_ALL to a nonempty value.
+ * gettext-2: Likewise.
+ * msgfmt-1: Likewise.
+ * msgfmt-2: Likewise.
+ * plural-1: Set LC_ALL, not LANGUAGE, to "fr".
+ * plural-1-prg.c: Include locale.h or declare setlocale.
+ (main): Call setlocale.
+
2001-01-04 Bruno Haible <haible@clisp.cons.org>
* plural-1-prg.c: Include config.h. Needed for C compilers lacking
XGETTEXT = ../src/xgettext
TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=../src:$$PATH \
- GETTEXT=`echo gettext|sed '$(transform)'` \
+ GETTEXT=tstgettext \
XGETTEXT=`echo xgettext|sed '$(transform)'` \
MSGFMT=`echo msgfmt|sed '$(transform)'` \
MSGCMP=`echo msgcmp|sed '$(transform)'` \
INCLUDES = -I${top_srcdir}/intl
EXTRA_PROGRAMS = cake
cake_SOURCES = plural-1-prg.c
-cake_LDADD = ../intl/libintl.a
+cake_LDADD = ../src/setlocale.o ../intl/libintl.a
all-local: cake
CLEANFILES = cake
TEXTDOMAINDIR=..
LANGUAGE=tests
-LC_ALL=
+LC_ALL=en
LC_MESSAGES=
LANG=
export TEXTDOMAINDIR LANGUAGE LC_ALL LC_MESSAGES LANG
TEXTDOMAINDIR=..
LANGUAGE=tests
-LC_ALL=
+LC_ALL=en
LC_MESSAGES=
LANG=
export TEXTDOMAINDIR LANGUAGE LC_ALL LC_MESSAGES LANG
TEXTDOMAINDIR=..
LANGUAGE=tests
-LC_ALL=
+LC_ALL=en
LC_MESSAGES=
LANG=
export TEXTDOMAINDIR LANGUAGE LC_ALL LC_MESSAGES LANG
TEXTDOMAINDIR=..
LANGUAGE=tests
-LC_ALL=
+LC_ALL=en
LC_MESSAGES=
LANG=
export TEXTDOMAINDIR LANGUAGE LC_ALL LC_MESSAGES LANG
: ${DIFF=diff}
${DIFF} fr.po.strip fr.po.tmp || exit 1
-LANGUAGE=fr
-LC_ALL=
+LANGUAGE=
+LC_ALL=fr
LC_MESSAGES=
LANG=
export LANGUAGE LC_ALL LC_MESSAGES LANG
#include <stdlib.h>
#include <stdio.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#else
+extern char *setlocale ();
+#endif
+
/* Make sure we use the included libintl, not the system's one. */
#if 0
#include <libintl.h>
char *argv[];
{
int n = atoi (argv[1]);
+
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
textdomain ("cake");
bindtextdomain ("cake", ".");
printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);