aboutsummaryrefslogtreecommitdiff
path: root/intl/loadmsgcat.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-03-20 01:00:20 +0000
committerUlrich Drepper <drepper@redhat.com>2001-03-20 01:00:20 +0000
commit4a4d50f3728ae901ad94e33ee53270906866371d (patch)
tree70901731cf88b75c9bb0291dd1bce0dc1204844f /intl/loadmsgcat.c
parentf2615995a753b80dd8d9fce55f5e87e8105f2d82 (diff)
downloadglibc-4a4d50f3728ae901ad94e33ee53270906866371d.zip
glibc-4a4d50f3728ae901ad94e33ee53270906866371d.tar.gz
glibc-4a4d50f3728ae901ad94e33ee53270906866371d.tar.bz2
Update.
2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/loadmsgcat.c (_nl_load_domain) [!_LIBC]: Use fstat, not fstat64. 2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/gettextP.h (struct expression): Add operators lnot, less_than, greater_than, less_or_equal, greater_or_equal. Replace args2/args3 union by a 'nargs' counter and an 'args[]' array. * intl/plural.y: Don't include stdarg.h. (new_exp): Take an array of arguments instead of varargs. (new_exp_0, new_exp_1, new_exp_2, new_exp_3): New functions. ('?' ':'): Make right-associative. (EQUOP2): New token, replaces '=' and '!'. (CMPOP2): New token. (ADDOP2): New token, replaces '+' and '-'. (MULOP2): New token, replaces '*', '/' and '%'. ('!'): New token. (exp): Add rules for CMPOP2 and '!'. Don't call YYABORT. (start): Call YYABORT here. (FREE_EXPRESSION): Update. (yylex): Don't skip "\\n". Recognize comparison and '!' operators. Update for new token symbols. * intl/loadmsgcat.c (plvar, plone, germanic_plural, init_germanic_plural): Update. * intl/dcigettext.c (_nl_find_msg): Optimize for space. (plural_eval): Recognize comparison and '!' operators. Optimize for space. 2001-03-10 Bruno Haible <haible@clisp.cons.org> * intl/loadmsgcat.c (_nl_load_domain): locale_charset() doesn't return NULL any more. 2001-01-05 Bruno Haible <haible@clisp.cons.org> * intl/loadmsgcat.c: Include headers needed for alloca(). (freea): New macro. (_nl_load_domain): Add fallback code for platforms lacking alloca. * intl/localealias.c: (ADD_BLOCK, FREE_BLOCK): Remove macros. (freea): New macro. (read_alias_file): Simplify fallback code for platforms lacking alloca. 2001-01-07 Bruno Haible <haible@clisp.cons.org> * intl/gettextP.h (__gettextdebug): Remove declaration. (__gettext_free_exp, __gettextparse): Convert prototype to K&R C syntax. (gettext_free_exp__, gettextparse__): New non-libc declarations. * intl/plural.y [!_LIBC]: Define gettextparse__, gettext_free_exp__, not __gettextparse, __gettext_free_exp. * intl/loadmsgcat.c [!_LIBC]: Use gettextparse__, not __gettextparse. 2001-02-24 Bruno Haible <haible@clisp.cons.org> * intl/dcigettext.c: Update comment about HAVE_LOCALE_NULL. 2001-01-05 Bruno Haible <haible@clisp.cons.org> * intl/loadmsgcat.c (_nl_load_domain): Add fallback code for platforms lacking strtoul, like SunOS4. 2001-01-05 Bruno Haible <haible@clisp.cons.org> * intl/l10nflist.c (_nl_normalize_codeset): Use tolower, not _tolower. 2001-01-05 Bruno Haible <haible@clisp.cons.org> * intl/bindtextdom.c (set_binding_values): Convert prototype to K&R C syntax. * intl/dcigettext.c (transcmp): Convert to K&R C syntax. * intl/explodename.c (_nl_find_language): Convert to K&R C syntax. * intl/plural.y (__gettext_free_exp, yylex, yyerror): Convert to K&R C syntax. 2001-01-07 Bruno Haible <haible@clisp.cons.org> * intl/gettextP.h (gettext__, dgettext__, dcgettext__, textdomain__, bindtextdomain__, bind_textdomain_codeset__): New declarations, from old libgettext.h. * intl/bindtextdom.c: Include libgnuintl.h instead of libgettext.h. * intl/dcgettext.c: Likewise. * intl/dcigettext.c: Likewise. * intl/dcngettext.c: Likewise. * intl/dngettext.c: Likewise. * intl/finddomain.c: Likewise. * intl/ngettext.c: Likewise. * intl/textdomain.c: Likewise. * intl/dgettext.c: Include libgnuintl.h instead of libgettext.h. Include gettextP.h. * intl/gettext.c: Likewise. Don't include locale.h. 2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/gettextP.h (ZERO): New macro. (struct binding): Always use ZERO. * intl/bindtextdom.c (offsetof): Provide fallback for platforms that lack it, like SunOS4. (set_binding_values): Use offsetof, not sizeof. * intl/dcigettext.c (offsetof): Provide fallback for platforms that lack it, like SunOS4. (ZERO): Remove macro. (struct transmem_list): Use ZERO. (DCIGETTEXT): Use offsetof, not sizeof. 2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/gettextP.h: Include <stddef.h>. Include gettext.h, for nls_uint32. * intl/bindtextdom.c: Don't include gettext.h. * intl/dcgettext.c: Likewise. * intl/dcigettext.c: Likewise. * intl/dcngettext.c: Likewise. * intl/dngettext.c: Likewise. * intl/finddomain.c: Likewise. * intl/localealias.c: Likewise. * intl/ngettext.c: Likewise. * intl/plural.y: Likewise. * intl/textdomain.c: Likewise. 2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/gettext.h: Don't include <stdio.h>. 2001-03-17 Bruno Haible <haible@clisp.cons.org> * intl/Makefile (CPPFLAGS): Set LOCALEDIR instead of GNULOCALEDIR. * intl/dcigettext.c (_nl_default_dirname): Initialize with LOCALEDIR.
Diffstat (limited to 'intl/loadmsgcat.c')
-rw-r--r--intl/loadmsgcat.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 6eed739..660dc7b 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -33,6 +33,23 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+#else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
#if defined STDC_HEADERS || defined _LIBC
# include <stdlib.h>
#endif
@@ -81,6 +98,25 @@
# define munmap __munmap
#endif
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define PLURAL_PARSE __gettextparse
+#else
+# define PLURAL_PARSE gettextparse__
+#endif
+
+/* For those losing systems which don't have `alloca' we have to add
+ some additional code emulating it. */
+#ifdef HAVE_ALLOCA
+# define freea(p) /* nothing */
+#else
+# define alloca(n) malloc (n)
+# define freea(p) free (p)
+#endif
+
/* We need a sign, whether a new catalog was loaded, which can be associated
with all translations. This is important if the translations are
cached by one of GCC's features. */
@@ -93,10 +129,12 @@ int _nl_msg_cat_cntr;
form determination. It represents the expression "n != 1". */
static const struct expression plvar =
{
+ .nargs = 0,
.operation = var,
};
static const struct expression plone =
{
+ .nargs = 0,
.operation = num,
.val =
{
@@ -105,13 +143,14 @@ static const struct expression plone =
};
static struct expression germanic_plural =
{
+ .nargs = 2,
.operation = not_equal,
.val =
{
- .args2 =
+ .args =
{
- .left = (struct expression *) &plvar,
- .right = (struct expression *) &plone
+ [0] = (struct expression *) &plvar,
+ [1] = (struct expression *) &plone
}
}
};
@@ -132,14 +171,17 @@ init_germanic_plural ()
{
if (plone.val.num == 0)
{
+ plvar.nargs = 0;
plvar.operation = var;
+ plone.nargs = 0;
plone.operation = num;
plone.val.num = 1;
+ germanic_plural.nargs = 2;
germanic_plural.operation = not_equal;
- germanic_plural.val.args2.left = &plvar;
- germanic_plural.val.args2.right = &plone;
+ germanic_plural.val.args[0] = &plvar;
+ germanic_plural.val.args[1] = &plone;
}
}
@@ -157,7 +199,11 @@ _nl_load_domain (domain_file)
{
int fd;
size_t size;
+#ifdef _LIBC
struct stat64 st;
+#else
+ struct stat st;
+#endif
struct mo_file_header *data = (struct mo_file_header *) -1;
int use_mmap = 0;
struct loaded_domain *domain;
@@ -180,7 +226,12 @@ _nl_load_domain (domain_file)
return;
/* We must know about the size of the file. */
- if (__builtin_expect (fstat64 (fd, &st) != 0, 0)
+ if (
+#ifdef _LIBC
+ __builtin_expect (fstat64 (fd, &st) != 0, 0)
+#else
+ __builtin_expect (fstat (fd, &st) != 0, 0)
+#endif
|| __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
|| __builtin_expect (size < sizeof (struct mo_file_header), 0))
{
@@ -343,8 +394,6 @@ _nl_load_domain (domain_file)
# if HAVE_ICONV
extern const char *locale_charset (void);
outcharset = locale_charset ();
- if (outcharset == NULL)
- outcharset = "";
# endif
# endif
}
@@ -363,6 +412,8 @@ _nl_load_domain (domain_file)
domain->conv = iconv_open (outcharset, charset);
# endif
# endif
+
+ freea (charset);
}
#endif /* _LIBC || HAVE_ICONV */
}
@@ -381,12 +432,19 @@ _nl_load_domain (domain_file)
{
/* First get the number. */
char *endp;
+ unsigned long int n;
struct parse_args args;
nplurals += 9;
while (*nplurals != '\0' && isspace (*nplurals))
++nplurals;
- domain->nplurals = strtoul (nplurals, &endp, 10);
+#if defined HAVE_STRTOUL || defined _LIBC
+ n = strtoul (nplurals, &endp, 10);
+#else
+ for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
+ n = n * 10 + (*endp - '0');
+#endif
+ domain->nplurals = n;
if (nplurals == endp)
goto no_plural;
@@ -396,7 +454,7 @@ _nl_load_domain (domain_file)
is passed down to the parser. */
plural += 7;
args.cp = plural;
- if (__gettextparse (&args) != 0)
+ if (PLURAL_PARSE (&args) != 0)
goto no_plural;
domain->plural = args.res;
}