This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libintl patches (3)


Again a patch for portability. It has no effect inside glibc.
But it's nice if gettext/intl and glibc/intl don't diverge.


2000-07-31  Bruno Haible  <haible@clisp.cons.org>

	* intl/plural.y: Include config.h. Needed to define 'inline' away for
	C compilers that don't support it.
	(yylex): Don't use gcc specific case range syntax.
	* intl/loadmsgcat.c (INIT_GERMANIC_PLURAL): New macro, for old
	compilers.

diff -c3 -r glibc-cvs/intl/plural.y glibc-cvs/intlnew/plural.y
*** glibc-cvs/intl/plural.y	Fri Aug 25 23:52:57 2000
--- glibc-cvs/intlnew/plural.y	Wed Jan  3 19:25:42 2001
***************
*** 18,23 ****
--- 18,27 ----
     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
+ 
  #include <stdarg.h>
  #include <stdlib.h>
  #include "gettext.h"
***************
*** 228,234 ****
    result = *exp++;
    switch (result)
      {
!     case '0' ... '9':
        {
  	unsigned long int n = exp[-1] - '0';
  	while (exp[0] >= '0' && exp[0] <= '9')
--- 232,239 ----
    result = *exp++;
    switch (result)
      {
!     case '0': case '1': case '2': case '3': case '4':
!     case '5': case '6': case '7': case '8': case '9':
        {
  	unsigned long int n = exp[-1] - '0';
  	while (exp[0] >= '0' && exp[0] <= '9')
diff -c3 -r glibc-cvs/intl/loadmsgcat.c glibc-cvs/intlnew/loadmsgcat.c
*** glibc-cvs/intl/loadmsgcat.c	Wed Nov 22 14:58:05 2000
--- glibc-cvs/intlnew/loadmsgcat.c	Wed Jan  3 19:25:42 2001
***************
*** 85,92 ****
     cached by one of GCC's features.  */
  int _nl_msg_cat_cntr;
  
  /* These structs are the constant expression for the germanic plural
!    form determination.  */
  static const struct expression plvar =
  {
    .operation = var,
--- 85,95 ----
     cached by one of GCC's features.  */
  int _nl_msg_cat_cntr;
  
+ #if defined __GNUC__ \
+     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+ 
  /* These structs are the constant expression for the germanic plural
!    form determination.  It represents the expression  "n != 1".  */
  static const struct expression plvar =
  {
    .operation = var,
***************
*** 111,116 ****
--- 114,150 ----
    }
  };
  
+ #define INIT_GERMANIC_PLURAL()
+ 
+ #else
+ 
+ /* For compilers without support for ISO C 99 struct/union initializers:
+    Initialization at run-time.  */
+ 
+ static struct expression plvar;
+ static struct expression plone;
+ static struct expression germanic_plural;
+ 
+ static void
+ init_germanic_plural ()
+ {
+   if (plone.val.num == 0)
+     {
+       plvar.operation = var;
+ 
+       plone.operation = num;
+       plone.val.num = 1;
+ 
+       germanic_plural.operation = not_equal;
+       germanic_plural.val.args2.left = &plvar;
+       germanic_plural.val.args2.right = &plone;
+     }
+ }
+ 
+ #define INIT_GERMANIC_PLURAL() init_germanic_plural ()
+ 
+ #endif
+ 
  
  /* Load the message catalogs specified by FILENAME.  If it is no valid
     message catalog do nothing.  */
***************
*** 370,375 ****
--- 415,421 ----
           for `one', the plural form otherwise.  Yes, this is also what
           English is using since English is a Germanic language.  */
      no_plural:
+       INIT_GERMANIC_PLURAL ();
        domain->plural = &germanic_plural;
        domain->nplurals = 2;
      }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]