From: Bruno Haible Date: Wed, 10 Jan 2001 18:26:44 +0000 (+0000) Subject: Minor tweaks. X-Git-Tag: v0.10.36~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42f53ec75e7de42861d0e886f347b441ed56f642;p=thirdparty%2Fgettext.git Minor tweaks. --- diff --git a/intl/ChangeLog b/intl/ChangeLog index 2139ef64c..2521469dc 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,17 @@ +2000-12-31 Bruno Haible + + * gettextP.h (ZERO): New macro. + (struct binding): Always use ZERO. + * bindtextdom.c (set_binding_values): Use offsetof, not sizeof. + Include whenever possible. + * dcigettext.c (ZERO): Remove macro. + (struct transmem_list): Use ZERO. + (DCIGETTEXT): Use offsetof, not sizeof. + Include whenever possible. + + * config.charset: Update from libiconv-1.5.1. + * localcharset.c: Likewise. + 2000-12-30 Bruno Haible * locale.alias: New file, moved here from ../misc/locale.alias. Add diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index 14e633b0e..673a06177 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -19,7 +19,10 @@ # include #endif -#if defined STDC_HEADERS || defined _LIBC +#if defined HAVE_STDDEF_H || defined _LIBC +# include +#endif +#if defined HAVE_STDLIB_H || defined _LIBC # include #else # ifdef HAVE_MALLOC_H @@ -233,7 +236,7 @@ set_binding_values (domainname, dirnamep, codesetp) /* We have to create a new binding. */ size_t len = strlen (domainname) + 1; struct binding *new_binding = - (struct binding *) malloc (sizeof (*new_binding) + len); + (struct binding *) malloc (offsetof (struct binding, domainname) + len); if (__builtin_expect (new_binding == NULL, 0)) goto failed; diff --git a/intl/dcigettext.c b/intl/dcigettext.c index 1ecc857f1..5dcb90a4c 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -53,8 +53,10 @@ extern int errno; # define __set_errno(val) errno = (val) #endif -#if defined STDC_HEADERS || defined _LIBC +#if defined HAVE_STDDEF_H || defined _LIBC # include +#endif +#if defined HAVE_STDLIB_H || defined _LIBC # include #else char *getenv (); @@ -196,14 +198,6 @@ static void *mempcpy PARAMS ((void *dest, const void *src, size_t n)); # define HAVE_LOCALE_NULL #endif -/* We want to allocate a string at the end of the struct. gcc makes - this easy. */ -#ifdef __GNUC__ -# define ZERO 0 -#else -# define ZERO 1 -#endif - /* This is the type used for the search tree where known translations are stored. */ struct known_translation_t @@ -329,7 +323,7 @@ struct block_list typedef struct transmem_list { struct transmem_list *next; - char data[0]; + char data[ZERO]; } transmem_block_t; static struct transmem_list *transmem_list; #else @@ -623,8 +617,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) struct known_translation_t *newp; newp = (struct known_translation_t *) - malloc (sizeof (*newp) + msgid_len - + domainname_len + 1 - ZERO); + malloc (offsetof (struct known_translation_t, msgid) + + msgid_len + domainname_len + 1); if (newp != NULL) { newp->domain = mempcpy (newp->msgid, msgid1, msgid_len); diff --git a/intl/gettextP.h b/intl/gettextP.h index 11d256ce5..8a3320c94 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -138,16 +138,20 @@ struct loaded_domain unsigned long int nplurals; }; +/* We want to allocate a string at the end of the struct. But ISO C + doesn't allow zero sized arrays. */ +#ifdef __GNUC__ +# define ZERO 0 +#else +# define ZERO 1 +#endif + struct binding { struct binding *next; char *dirname; char *codeset; -#ifdef __GNUC__ - char domainname[0]; -#else - char domainname[1]; -#endif + char domainname[ZERO]; }; extern int _nl_msg_cat_cntr; diff --git a/src/ChangeLog b/src/ChangeLog index 481f2d994..28faa9f03 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2000-12-31 Bruno Haible + + * msgunfmt.c (read_mo_file): Recognize "/dev/stdin", not "/dev/stdout". + 2000-12-31 Bruno Haible * str-list.h: Fix typo. Add comments. diff --git a/src/msgunfmt.c b/src/msgunfmt.c index 6c5b6b709..758cbedf4 100644 --- a/src/msgunfmt.c +++ b/src/msgunfmt.c @@ -1,5 +1,5 @@ /* msgunfmt - converts binary .mo files to Uniforum style .po files - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. Written by Ulrich Drepper , April 1995. This program is free software; you can redistribute it and/or modify @@ -329,14 +329,14 @@ string32 (fp, fn, offset) error (EXIT_FAILURE, errno, _("error while reading \"%s\""), fn); error (EXIT_FAILURE, 0, _("file \"%s\" truncated"), fn); } - buffer[length] = 0; + buffer[length] = '\0'; /* Return the string to the caller. */ return buffer; } -/* This function reads and existing .mo file. Return a message list. */ +/* This function reads an existing .mo file. Return a message list. */ static message_list_ty * read_mo_file (mlp, fn) message_list_ty *mlp; @@ -346,7 +346,7 @@ read_mo_file (mlp, fn) struct mo_file_header header; int j; - if (strcmp (fn, "-") == 0 || strcmp (fn, "/dev/stdout") == 0) + if (strcmp (fn, "-") == 0 || strcmp (fn, "/dev/stdin") == 0) fp = stdin; else {