]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make it compile in C++ mode.
authorBruno Haible <bruno@clisp.org>
Tue, 31 Oct 2006 12:41:52 +0000 (12:41 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:17 +0000 (12:14 +0200)
38 files changed:
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/dcigettext.c
gettext-runtime/intl/gettextP.h
gettext-runtime/intl/gmo.h
gettext-runtime/intl/loadmsgcat.c
gettext-runtime/intl/localealias.c
gettext-runtime/intl/plural-exp.c
gettext-runtime/intl/plural-exp.h
gettext-runtime/intl/plural.y
gettext-tools/libgrep/ChangeLog
gettext-tools/libgrep/dfa.c
gettext-tools/libgrep/dfa.h
gettext-tools/libgrep/kwset.c
gettext-tools/libgrep/m-fgrep.c
gettext-tools/libgrep/m-regex.c
gettext-tools/libgrep/regex.c
gettext-tools/src/ChangeLog
gettext-tools/src/dir-list.c
gettext-tools/src/format-c.c
gettext-tools/src/format-gcc-internal.c
gettext-tools/src/format-lisp.c
gettext-tools/src/format-perl.c
gettext-tools/src/format-scheme.c
gettext-tools/src/message.h
gettext-tools/src/msgl-equal.c
gettext-tools/src/po-lex.c
gettext-tools/src/read-mo.c
gettext-tools/src/read-po.c
gettext-tools/src/read-properties.c
gettext-tools/src/write-mo.c
gettext-tools/src/x-glade.c
gettext-tools/src/x-perl.c
gettext-tools/src/x-po.c
gettext-tools/src/x-smalltalk.c
gnulib-local/ChangeLog
gnulib-local/lib/backupfile.c
gnulib-local/lib/xalloc.h
gnulib-local/lib/xstrdup.c

index 3d7b18762b8a3db01c7d8f8d60afb02ecf82d566..2b7f3c867341931dfa920ff9ef279a7239d97a36 100644 (file)
@@ -1,3 +1,19 @@
+2006-10-29  Bruno Haible  <bruno@clisp.org>
+
+       Make it compile in C++ mode.
+       * gettextP.h (SWAP): Don't use K&R syntax in C++ mode.
+       * gmo.h (struct segment_pair): Move out of the scope of struct
+       sysdep_string.
+       * dcigettext.c (DCIGETTEXT): Cast mempcpy results.
+       * loadmsgcat.c (_nl_load_domain): Cast alloca result.
+       * localealias.c (read_alias_file): Cast memcpy result.
+       * plural-exp.h (enum expression_operator): Move out of the scope of
+       struct expression. Rename from 'enum operator'.
+       * plural-exp.c (plvar, plone, GERMANIC_PLURAL): Don't use C99 named
+       initializer syntax in C++ mode.
+       * plural.y (%union, new_exp, new_exp_0, new_exp_1, new_exp_2,
+       new_exp_3): Update.
+
 2006-10-26  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.16 released.
index 583976821bee1f9dda36ca7365b5b25dc9b2d9a3..c3cf6eb53601cb5416450fb0900af392ea94b50f 100644 (file)
@@ -683,8 +683,8 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
                                 + domainname_len + 5);
   ADD_BLOCK (block_list, xdomainname);
 
-  stpcpy (mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
-                 domainname, domainname_len),
+  stpcpy ((char *) mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
+                           domainname, domainname_len),
          ".mo");
 
   /* Creating working area.  */
@@ -793,7 +793,8 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
                      char *new_localename;
 # endif
 
-                     new_domainname = mempcpy (newp->msgid, msgid1, msgid_len);
+                     new_domainname =
+                       (char *) mempcpy (newp->msgid, msgid1, msgid_len);
                      memcpy (new_domainname, domainname, domainname_len + 1);
 # ifdef HAVE_PER_THREAD_LOCALE
                      new_localename = new_domainname + domainname_len + 1;
index 8be38d2d7fba1bbde9d8e33093ffb504aa57860f..2c08d419861b963609e2ef5b02c6641b4bc06796 100644 (file)
@@ -1,5 +1,5 @@
 /* Header describing internals of libintl library.
-   Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000-2006 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
@@ -106,8 +106,12 @@ extern char *libintl_dcigettext (const char *__domainname,
 # define SWAP(i) bswap_32 (i)
 #else
 static inline nls_uint32
+# ifdef __cplusplus
+SWAP (nls_uint32 i)
+# else
 SWAP (i)
      nls_uint32 i;
+# endif
 {
   return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
 }
index 26515feb28df99518817b654330c27a6c7724419..da9dbaa9caf5341925a9c2eeb16205339b69a87c 100644 (file)
@@ -1,5 +1,5 @@
 /* Description of GNU message catalog format: general file layout.
-   Copyright (C) 1995, 1997, 2000-2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 2000-2002, 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
@@ -124,6 +124,15 @@ struct sysdep_segment
   nls_uint32 offset;
 };
 
+/* Pair of a static and a system dependent segment, in struct sysdep_string.  */
+struct segment_pair
+{
+  /* Size of static segment.  */
+  nls_uint32 segsize;
+  /* Reference to system dependent string segment, or ~0 at the end.  */
+  nls_uint32 sysdepref;
+};
+
 /* Descriptor for system dependent string.  */
 struct sysdep_string
 {
@@ -131,13 +140,7 @@ struct sysdep_string
   nls_uint32 offset;
   /* Alternating sequence of static and system dependent segments.
      The last segment is a static segment, including the trailing NUL.  */
-  struct segment_pair
-  {
-    /* Size of static segment.  */
-    nls_uint32 segsize;
-    /* Reference to system dependent string segment, or ~0 at the end.  */
-    nls_uint32 sysdepref;
-  } segments[1];
+  struct segment_pair segments[1];
 };
 
 /* Marker for the end of the segments[] array.  This has the value 0xFFFFFFFF,
index 2520c8c217eb88a9c515a8085eae696d69df50b4..8e01c53a5e476fc97003724c9839ce9a99234fa0 100644 (file)
@@ -1,5 +1,5 @@
 /* Load needed message catalogs.
-   Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 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
@@ -976,6 +976,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
                  ((char *) data
                   + W (domain->must_swap, data->sysdep_segments_offset));
                sysdep_segment_values =
+                 (const char **)
                  alloca (n_sysdep_segments * sizeof (const char *));
                for (i = 0; i < n_sysdep_segments; i++)
                  {
index 26122a01189c4ab44d1abce3ad5d5edc22db0d0c..910db53034d27c59f116d1d7ed0f420b01aecad0 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle aliases for locale names.
-   Copyright (C) 1995-1999, 2000-2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000-2001, 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
@@ -349,12 +349,14 @@ read_alias_file (const char *fname, int fname_len)
                      string_space_max = new_size;
                    }
 
-                 map[nmap].alias = memcpy (&string_space[string_space_act],
-                                           alias, alias_len);
+                 map[nmap].alias =
+                   (const char *) 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);
+                 map[nmap].value =
+                   (const char *) memcpy (&string_space[string_space_act],
+                                          value, value_len);
                  string_space_act += value_len;
 
                  ++nmap;
index f518bf1dc6f5ef6164939b7c86e00d87e1497020..46fa758112701b441af48253e3f5bf53a9fbdc08 100644 (file)
@@ -1,5 +1,5 @@
 /* Expression parsing for plural form selection.
-   Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2003, 2005-2006 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__ && !(__APPLE_CC__ > 1)) \
+#if (defined __GNUC__ && !(__APPLE_CC__ > 1) && !defined __cplusplus) \
     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
 
 /* These structs are the constant expression for the germanic plural
index dc590d374ee34b6863746aea3d6a3d4cd9350504..d062dd1dfc334558bfd12843ab82739366426af7 100644 (file)
@@ -1,5 +1,5 @@
 /* Expression parsing and evaluation for plural form selection.
-   Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2005-2006 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
 #endif
 
 
+enum expression_operator
+{
+  /* Without arguments:  */
+  var,                         /* The variable "n".  */
+  num,                         /* Decimal number.  */
+  /* Unary operators:  */
+  lnot,                                /* Logical NOT.  */
+  /* Binary operators:  */
+  mult,                                /* Multiplication.  */
+  divide,                      /* Division.  */
+  module,                      /* Modulo operation.  */
+  plus,                                /* Addition.  */
+  minus,                       /* Subtraction.  */
+  less_than,                   /* Comparison.  */
+  greater_than,                        /* Comparison.  */
+  less_or_equal,               /* Comparison.  */
+  greater_or_equal,            /* Comparison.  */
+  equal,                       /* Comparison for equality.  */
+  not_equal,                   /* Comparison for inequality.  */
+  land,                                /* Logical AND.  */
+  lor,                         /* Logical OR.  */
+  /* Ternary operators:  */
+  qmop                         /* Question mark operator.  */
+};
+
 /* This is the representation of the expressions to determine the
    plural form.  */
 struct expression
 {
   int nargs;                   /* Number of arguments.  */
-  enum operator
-  {
-    /* Without arguments:  */
-    var,                       /* The variable "n".  */
-    num,                       /* Decimal number.  */
-    /* Unary operators:  */
-    lnot,                      /* Logical NOT.  */
-    /* Binary operators:  */
-    mult,                      /* Multiplication.  */
-    divide,                    /* Division.  */
-    module,                    /* Modulo operation.  */
-    plus,                      /* Addition.  */
-    minus,                     /* Subtraction.  */
-    less_than,                 /* Comparison.  */
-    greater_than,              /* Comparison.  */
-    less_or_equal,             /* Comparison.  */
-    greater_or_equal,          /* Comparison.  */
-    equal,                     /* Comparison for equality.  */
-    not_equal,                 /* Comparison for inequality.  */
-    land,                      /* Logical AND.  */
-    lor,                       /* Logical OR.  */
-    /* Ternary operators:  */
-    qmop                       /* Question mark operator.  */
-  } operation;
+  enum expression_operator operation;
   union
   {
     unsigned long int num;     /* Number value for `num'.  */
index 45d68e949eb8534939b5fcff3ea499abc7a1af5b..ec36a09b8d786b7d921542d8933f904419e04b85 100644 (file)
@@ -1,6 +1,6 @@
 %{
 /* Expression parsing for plural form selection.
-   Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2003, 2005-2006 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
@@ -50,7 +50,7 @@
 
 %union {
   unsigned long int num;
-  enum operator op;
+  enum expression_operator op;
   struct expression *exp;
 }
 
@@ -62,7 +62,8 @@ static void yyerror (const char *str);
 /* Allocation of expressions.  */
 
 static struct expression *
-new_exp (int nargs, enum operator op, struct expression * const *args)
+new_exp (int nargs, enum expression_operator op,
+        struct expression * const *args)
 {
   int i;
   struct expression *newp;
@@ -91,13 +92,13 @@ new_exp (int nargs, enum operator op, struct expression * const *args)
 }
 
 static inline struct expression *
-new_exp_0 (enum operator op)
+new_exp_0 (enum expression_operator op)
 {
   return new_exp (0, op, NULL);
 }
 
 static inline struct expression *
-new_exp_1 (enum operator op, struct expression *right)
+new_exp_1 (enum expression_operator op, struct expression *right)
 {
   struct expression *args[1];
 
@@ -106,7 +107,8 @@ new_exp_1 (enum operator op, struct expression *right)
 }
 
 static struct expression *
-new_exp_2 (enum operator op, struct expression *left, struct expression *right)
+new_exp_2 (enum expression_operator op, struct expression *left,
+          struct expression *right)
 {
   struct expression *args[2];
 
@@ -116,7 +118,7 @@ new_exp_2 (enum operator op, struct expression *left, struct expression *right)
 }
 
 static inline struct expression *
-new_exp_3 (enum operator op, struct expression *bexp,
+new_exp_3 (enum expression_operator op, struct expression *bexp,
           struct expression *tbranch, struct expression *fbranch)
 {
   struct expression *args[3];
index 25b1513846d050e5c45b06a3c43cd7a20f6bad9e..c736ab78ed32aebbf6686cc76ab7e88d3dc9f207 100644 (file)
@@ -1,3 +1,28 @@
+2006-10-29  Bruno Haible  <bruno@clisp.org>
+
+       Make it compile in C++ mode.
+       * dfa.h (token): Typedef as int.
+       * dfa.c (remove): Renamed from delete.
+       (epsclosure): Update.
+       (match_mb_charset): Cast strncpy argument.
+       (dfaexec): Add cast.
+       (dfacomp): Cast malloc result.
+       (icatalloc): Rename argument names to 'stem', 'suffix'.
+       (enlist): Rename 'new' argument to 'suffix'.
+       (addlists): Rename 'new' argument to 'suffixes'.
+       (dfamust): Cast malloc results. Rename local variable 'new' to 'common'.
+       * kwset.c (kwsprep): Cast obstack_alloc result.
+       (bmexec): Cast memchr result.
+       * m-fgrep.c (Fexecute): Rename local variable 'try' to 'curr'. Cast
+       memchr result.
+       * m-regex.c (struct patterns): Move out of the scope of struct
+       compiled_regex.
+       (Gcompile, compile, EGexecute): Cast memchr results.
+       * regex.c (EXTEND_BUFFER): Cast REALLOC result.
+       (byte_re_match_2_internal): Limit the scope of same_str_p variable.
+       Rename local variable 'not' to 'invert'.
+       (regcomp): Cast malloc results.
+
 2006-10-26  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.16 released.
index f1046ad43ad9da63b72da6a899625f98b97021a2..443b8c70fe34b621b6ba5d39fbfeba65e62fa6fc 100644 (file)
@@ -1,5 +1,5 @@
 /* dfa.c - deterministic extended regexp routines for GNU
-   Copyright 1988, 1998, 2000, 2005 Free Software Foundation, Inc.
+   Copyright 1988, 1998, 2000, 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 General Public License as published by
@@ -1442,7 +1442,7 @@ merge (position_set const *s1, position_set const *s2, position_set *m)
 
 /* Delete a position from a set. */
 static void
-delete (position p, position_set *s)
+remove (position p, position_set *s)
 {
   int i;
 
@@ -1550,7 +1550,7 @@ epsclosure (position_set *s, struct dfa const *d)
       {
        old = s->elems[i];
        p.constraint = old.constraint;
-       delete(s->elems[i], s);
+       remove(s->elems[i], s);
        if (visited[old.index])
          {
            --i;
@@ -2489,14 +2489,14 @@ match_mb_charset (struct dfa *d, int s, position pos, int index)
        goto charset_matched;
     }
 
-  strncpy(buffer, buf_begin + index, match_len);
+  strncpy(buffer, (const char *) (buf_begin + index), match_len);
   buffer[match_len] = '\0';
 
   /* match with an equivalent class?  */
   for (i = 0; i<work_mbc->nequivs; i++)
     {
       op_len = strlen(work_mbc->equivs[i]);
-      strncpy(buffer, buf_begin + index, op_len);
+      strncpy(buffer, (const char *) (buf_begin + index), op_len);
       buffer[op_len] = '\0';
       if (strcoll(work_mbc->equivs[i], buffer) == 0)
        {
@@ -2509,7 +2509,7 @@ match_mb_charset (struct dfa *d, int s, position pos, int index)
   for (i = 0; i<work_mbc->ncoll_elems; i++)
     {
       op_len = strlen(work_mbc->coll_elems[i]);
-      strncpy(buffer, buf_begin + index, op_len);
+      strncpy(buffer, (const char *) (buf_begin + index), op_len);
       buffer[op_len] = '\0';
 
       if (strcoll(work_mbc->coll_elems[i], buffer) == 0)
@@ -2762,7 +2762,7 @@ dfaexec (struct dfa *d, char const *begin, size_t size, int *backref)
   if (MB_CUR_MAX > 1)
     {
       int remain_bytes, i;
-      buf_begin = begin;
+      buf_begin = (unsigned char const *)begin;
       buf_end = end;
 
       /* initialize mblen_buf, and inputwcs.  */
@@ -2943,7 +2943,7 @@ dfacomp (char const *s, size_t len, struct dfa *d, int searchflag)
       char *lcopy;
       int i;
 
-      lcopy = malloc(len);
+      lcopy = (char *) malloc(len);
       if (!lcopy)
        dfaerror(_("out of memory"));
 
@@ -3122,23 +3122,23 @@ dfafree (struct dfa *d)
    'psi|epsilon' is likelier)? */
 
 static char *
-icatalloc (char *old, char *new)
+icatalloc (char *stem, char *suffix)
 {
   char *result;
-  size_t oldsize, newsize;
-
-  newsize = (new == NULL) ? 0 : strlen(new);
-  if (old == NULL)
-    oldsize = 0;
-  else if (newsize == 0)
-    return old;
-  else oldsize = strlen(old);
-  if (old == NULL)
-    result = (char *) malloc(newsize + 1);
+  size_t stemsize, suffixsize;
+
+  suffixsize = (suffix == NULL) ? 0 : strlen(suffix);
+  if (stem == NULL)
+    stemsize = 0;
+  else if (suffixsize == 0)
+    return stem;
+  else stemsize = strlen(stem);
+  if (stem == NULL)
+    result = (char *) malloc(suffixsize + 1);
   else
-    result = (char *) realloc((void *) old, oldsize + newsize + 1);
-  if (result != NULL && new != NULL)
-    (void) strcpy(result + oldsize, new);
+    result = (char *) realloc((void *) stem, stemsize + suffixsize + 1);
+  if (result != NULL && suffix != NULL)
+    (void) strcpy(result + stemsize, suffix);
   return result;
 }
 
@@ -3183,29 +3183,29 @@ freelist (char **cpp)
 }
 
 static char **
-enlist (char **cpp, char *new, size_t len)
+enlist (char **cpp, char *suffix, size_t len)
 {
   int i, j;
 
   if (cpp == NULL)
     return NULL;
-  if ((new = icpyalloc(new)) == NULL)
+  if ((suffix = icpyalloc(suffix)) == NULL)
     {
       freelist(cpp);
       return NULL;
     }
-  new[len] = '\0';
-  /* Is there already something in the list that's new (or longer)? */
+  suffix[len] = '\0';
+  /* Is there already something in the list that's suffix (or longer)? */
   for (i = 0; cpp[i] != NULL; ++i)
-    if (istrstr(cpp[i], new) != NULL)
+    if (istrstr(cpp[i], suffix) != NULL)
       {
-       free(new);
+       free(suffix);
        return cpp;
       }
   /* Eliminate any obsoleted strings. */
   j = 0;
   while (cpp[j] != NULL)
-    if (istrstr(new, cpp[j]) == NULL)
+    if (istrstr(suffix, cpp[j]) == NULL)
       ++j;
     else
       {
@@ -3219,7 +3219,7 @@ enlist (char **cpp, char *new, size_t len)
   cpp = (char **) realloc((char *) cpp, (i + 2) * sizeof *cpp);
   if (cpp == NULL)
     return NULL;
-  cpp[i] = new;
+  cpp[i] = suffix;
   cpp[i + 1] = NULL;
   return cpp;
 }
@@ -3262,15 +3262,15 @@ comsubs (char *left, char *right)
 }
 
 static char **
-addlists (char **old, char **new)
+addlists (char **old, char **suffixes)
 {
   int i;
 
-  if (old == NULL || new == NULL)
+  if (old == NULL || suffixes == NULL)
     return NULL;
-  for (i = 0; new[i] != NULL; ++i)
+  for (i = 0; suffixes[i] != NULL; ++i)
     {
-      old = enlist(old, new[i], strlen(new[i]));
+      old = enlist(old, suffixes[i], strlen(suffixes[i]));
       if (old == NULL)
        break;
     }
@@ -3352,9 +3352,9 @@ dfamust (struct dfa *dfa)
   for (i = 0; i <= dfa->tindex; ++i)
     {
       mp[i].in = (char **) malloc(sizeof *mp[i].in);
-      mp[i].left = malloc(2);
-      mp[i].right = malloc(2);
-      mp[i].is = malloc(2);
+      mp[i].left = (char *) malloc(2);
+      mp[i].right = (char *) malloc(2);
+      mp[i].is = (char *) malloc(2);
       if (mp[i].in == NULL || mp[i].left == NULL ||
          mp[i].right == NULL || mp[i].is == NULL)
        goto done;
@@ -3399,7 +3399,7 @@ dfamust (struct dfa *dfa)
          if (mp < &musts[2])
            goto done;          /* "cannot happen" */
          {
-           char **new;
+           char **common;
            must *lmp;
            must *rmp;
            int j, ln, rn, n;
@@ -3426,12 +3426,12 @@ dfamust (struct dfa *dfa)
            for (j = 0; j < i; ++j)
              lmp->right[j] = lmp->right[(ln - i) + j];
            lmp->right[j] = '\0';
-           new = inboth(lmp->in, rmp->in);
-           if (new == NULL)
+           common = inboth(lmp->in, rmp->in);
+           if (common == NULL)
              goto done;
            freelist(lmp->in);
            free((char *) lmp->in);
-           lmp->in = new;
+           lmp->in = common;
          }
          break;
        case PLUS:
@@ -3556,7 +3556,7 @@ dfamust (struct dfa *dfa)
     {
       dm = (struct dfamust *) malloc(sizeof (struct dfamust));
       dm->exact = exact;
-      dm->must = malloc(strlen(result) + 1);
+      dm->must = (char *) malloc(strlen(result) + 1);
       strcpy(dm->must, result);
       dm->next = dfa->musts;
       dfa->musts = dm;
index 0b51a62176b398bdadff61f735fe39afcc46900d..387ef98c62358405c8de3e211664175f8522b9d1 100644 (file)
@@ -1,5 +1,5 @@
 /* dfa.h - declarations for GNU deterministic regexp compiler
-   Copyright (C) 1988, 1998, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1998, 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 General Public License as published by
@@ -49,7 +49,7 @@ typedef int charclass[CHARCLASS_INTS];
    are operators and others are terminal symbols.  Most (but not all) of these
    codes are returned by the lexical analyzer. */
 
-typedef enum
+enum
 {
   END = -1,                    /* END is a terminal symbol that matches the
                                   end of input; any value of END or less in
@@ -143,7 +143,8 @@ typedef enum
   CSET                         /* CSET and (and any value greater) is a
                                   terminal symbol that matches any of a
                                   class of characters. */
-} token;
+};
+typedef int token;
 
 /* Sets are stored in an array in the compiled dfa; the index of the
    array corresponding to a given set token is given by SET_INDEX(t). */
index 7e5f82ce4a2f3745366698bb47069f228ade1bdc..00076e084e9107db408c333bd235b18f42098585 100644 (file)
@@ -1,5 +1,5 @@
 /* kwset.c - search for any of a set of keywords.
-   Copyright 1989, 1998, 2000, 2005 Free Software Foundation, Inc.
+   Copyright 1989, 1998, 2000, 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 General Public License as published by
@@ -400,7 +400,7 @@ kwsprep (kwset_t kws)
   if (kwset->words == 1 && kwset->trans == 0)
     {
       /* Looking for just one string.  Extract it from the trie. */
-      kwset->target = obstack_alloc(&kwset->obstack, kwset->mind);
+      kwset->target = (char *) obstack_alloc(&kwset->obstack, kwset->mind);
       for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
        {
          kwset->target[i] = curr->links->label;
@@ -508,7 +508,7 @@ bmexec (kwset_t kws, char const *text, size_t size)
     return -1;
   if (len == 1)
     {
-      tp = memchr (text, kwset->target[0], size);
+      tp = (const char *) memchr (text, kwset->target[0], size);
       return tp ? tp - text : -1;
     }
 
index 28f900c80bdb06ec7ac77b94ce7047a35c46169e..305b997ac6ced81d2d2f0c29f0f6df8672ff614e 100644 (file)
@@ -1,5 +1,5 @@
 /* Pattern Matcher for Fixed String search.
-   Copyright (C) 1992, 1998, 2000, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1998, 2000, 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 General Public License as published by
@@ -72,7 +72,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
          size_t *match_size, bool exact)
 {
   struct compiled_kwset *ckwset = (struct compiled_kwset *) compiled_pattern;
-  register const char *beg, *try, *end;
+  register const char *beg, *curr, *end;
   register size_t len;
   char eol = ckwset->eolbyte;
   struct kwsmatch kwsmatch;
@@ -118,12 +118,12 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
          goto success;
        }
       else if (ckwset->match_words)
-       for (try = beg; len; )
+       for (curr = beg; len; )
          {
-           if (try > buf && IS_WORD_CONSTITUENT ((unsigned char) try[-1]))
+           if (curr > buf && IS_WORD_CONSTITUENT ((unsigned char) curr[-1]))
              break;
-           if (try + len < buf + buf_size
-               && IS_WORD_CONSTITUENT ((unsigned char) try[len]))
+           if (curr + len < buf + buf_size
+               && IS_WORD_CONSTITUENT ((unsigned char) curr[len]))
              {
                offset = kwsexec (ckwset->kwset, beg, --len, &kwsmatch);
                if (offset == (size_t) -1)
@@ -134,7 +134,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
 #endif /* MBS_SUPPORT */
                    return offset;
                  }
-               try = beg + offset;
+               curr = beg + offset;
                len = kwsmatch.size[0];
              }
            else
@@ -151,7 +151,7 @@ Fexecute (const void *compiled_pattern, const char *buf, size_t buf_size,
   return -1;
 
  success:
-  end = memchr (beg + len, eol, (buf + buf_size) - (beg + len));
+  end = (const char *) memchr (beg + len, eol, (buf + buf_size) - (beg + len));
   end++;
   while (buf < beg && beg[-1] != eol)
     --beg;
index 6f7aae376bfb922d3173e6ac60f4b2c4df8372ea..a53c96f4f43795dd751bad595f4c743e854b3e51 100644 (file)
@@ -1,5 +1,5 @@
 /* Pattern Matchers for Regular Expressions.
-   Copyright (C) 1992, 1998, 2000, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1998, 2000, 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 General Public License as published by
 #endif
 #define ISALNUM(C) (IN_CTYPE_DOMAIN (C) && isalnum (C))
 
+struct patterns
+{
+  /* Regex compiled regexp. */
+  struct re_pattern_buffer regexbuf;
+  struct re_registers regs; /* This is here on account of a BRAIN-DEAD
+                              Q@#%!# library interface in regex.c.  */
+};
+
 struct compiled_regex {
   bool match_words;
   bool match_lines;
@@ -50,13 +58,7 @@ struct compiled_regex {
   struct dfa dfa;
 
   /* The Regex compiled patterns.  */
-  struct patterns
-  {
-    /* Regex compiled regexp. */
-    struct re_pattern_buffer regexbuf;
-    struct re_registers regs; /* This is here on account of a BRAIN-DEAD
-                                Q@#%!# library interface in regex.c.  */
-  } *patterns;
+  struct patterns *patterns;
   size_t pcount;
 
   /* KWset compiled pattern.  We compile a list of strings, at least one of
@@ -143,7 +145,7 @@ Gcompile (const char *pattern, size_t pattern_size,
   do
     {
       size_t len;
-      sep = memchr (motif, '\n', total);
+      sep = (const char *) memchr (motif, '\n', total);
       if (sep)
        {
          len = sep - motif;
@@ -229,7 +231,7 @@ compile (const char *pattern, size_t pattern_size,
   do
     {
       size_t len;
-      sep = memchr (motif, '\n', total);
+      sep = (const char *) memchr (motif, '\n', total);
       if (sep)
        {
          len = sep - motif;
@@ -345,7 +347,7 @@ EGexecute (const void *compiled_pattern,
              beg += offset;
              /* Narrow down to the line containing the candidate, and
                 run it through DFA. */
-             end = memchr (beg, eol, buflim - beg);
+             end = (const char *) memchr (beg, eol, buflim - beg);
              if (end != NULL)
                end++;
              else
@@ -369,7 +371,7 @@ EGexecute (const void *compiled_pattern,
                break;
              /* Narrow down to the line we've found. */
              beg += offset;
-             end = memchr (beg, eol, buflim - beg);
+             end = (const char *) memchr (beg, eol, buflim - beg);
              if (end != NULL)
                end++;
              else
index aec323ae8de15592b8adfc14e4a57dbf0c0fc1f8..de19ca320e4f3ce2e65d2c547c6dc59df86e1029 100644 (file)
@@ -2080,7 +2080,7 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
     bufp->allocated <<= 1;                                             \
     if (bufp->allocated > MAX_BUF_SIZE)                                        \
       bufp->allocated = MAX_BUF_SIZE;                                  \
-    bufp->buffer = REALLOC (COMPILED_BUFFER_VAR, bufp->allocated);     \
+    bufp->buffer = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR, bufp->allocated); \
     if (COMPILED_BUFFER_VAR == NULL)                                   \
       return REG_ESPACE;                                               \
     /* If the buffer moved, move all the pointers into it.  */         \
@@ -6011,19 +6011,21 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
             longest match, try backtracking.  */
          if (d != end_match_2)
            {
-             /* 1 if this match ends in the same string (string1 or string2)
-                as the best previous match.  */
-             boolean same_str_p = (FIRST_STRING_P (match_end)
-                                   == MATCHING_IN_FIRST_STRING);
              /* 1 if this match is the best seen so far.  */
              boolean best_match_p;
-
-             /* AIX compiler got confused when this was combined
-                with the previous declaration.  */
-             if (same_str_p)
-               best_match_p = d > match_end;
-             else
-               best_match_p = !MATCHING_IN_FIRST_STRING;
+             {
+               /* 1 if this match ends in the same string (string1 or string2)
+                  as the best previous match.  */
+               boolean same_str_p = (FIRST_STRING_P (match_end)
+                                     == MATCHING_IN_FIRST_STRING);
+
+               /* AIX compiler got confused when this was combined
+                  with the previous declaration.  */
+               if (same_str_p)
+                 best_match_p = d > match_end;
+               else
+                 best_match_p = !MATCHING_IN_FIRST_STRING;
+             }
 
              DEBUG_PRINT1 ("backtracking.\n");
 
@@ -6278,9 +6280,9 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
            uint32_t nrules;
 # endif /* _LIBC */
 #endif /* WCHAR */
-           boolean not = (re_opcode_t) *(p - 1) == charset_not;
+           boolean invert = (re_opcode_t) *(p - 1) == charset_not;
 
-            DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
+            DEBUG_PRINT2 ("EXECUTING charset%s.\n", invert ? "_not" : "");
            PREFETCH ();
            c = TRANSLATE (*d); /* The character to match.  */
 #ifdef WCHAR
@@ -6613,20 +6615,20 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
              if (c == *workp)
                goto char_set_matched;
 
-           not = !not;
+           invert = !invert;
 
          char_set_matched:
-           if (not) goto fail;
+           if (invert) goto fail;
 #else
             /* Cast to `unsigned' instead of `unsigned char' in case the
                bit list is a full 32 bytes long.  */
            if (c < (unsigned) (*p * BYTEWIDTH)
                && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-             not = !not;
+             invert = !invert;
 
            p += 1 + *p;
 
-           if (!not) goto fail;
+           if (!invert) goto fail;
 #undef WORK_BUFFER_SIZE
 #endif /* WCHAR */
            SET_REGS_MATCHED ();
@@ -7126,15 +7128,15 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
                else if ((re_opcode_t) p1[3] == charset
                         || (re_opcode_t) p1[3] == charset_not)
                  {
-                   int not = (re_opcode_t) p1[3] == charset_not;
+                   int invert = (re_opcode_t) p1[3] == charset_not;
 
                    if (c < (unsigned) (p1[4] * BYTEWIDTH)
                        && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-                     not = !not;
+                     invert = !invert;
 
                     /* `not' is equal to 1 if c would match, which means
                         that we can't change to pop_failure_jump.  */
-                   if (!not)
+                   if (!invert)
                       {
                        p[-3] = (unsigned char) pop_failure_jump;
                         DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
@@ -8015,14 +8017,15 @@ regcomp (regex_t *preg, const char *pattern, int cflags)
   preg->used = 0;
 
   /* Try to allocate space for the fastmap.  */
-  preg->fastmap = malloc (1 << BYTEWIDTH);
+  preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
 
   if (cflags & REG_ICASE)
     {
       unsigned i;
 
-      preg->translate = malloc (CHAR_SET_SIZE
-                               * sizeof (*(RE_TRANSLATE_TYPE)0));
+      preg->translate =
+       (RE_TRANSLATE_TYPE)
+       malloc (CHAR_SET_SIZE * sizeof (*(RE_TRANSLATE_TYPE)0));
       if (preg->translate == NULL)
         return (int) REG_ESPACE;
 
index 3ddacf60c53f776ae71c71faaa6aa06107008f03..463c7a2f0f98d9f1cc8d7aece5a852beb0478291 100644 (file)
@@ -1,3 +1,31 @@
+2006-10-29  Bruno Haible  <bruno@clisp.org>
+
+       Make it compile in C++ mode.
+       * dir-list.c (dir_list_restore): Add cast.
+       * format-c.c (format_arg_type_t): New type. Use it instead of
+       'enum format_arg_type'.
+       * format-gcc-internal.c (format_arg_type_t): New type. Use it instead of
+       'enum format_arg_type'.
+       * format-perl.c (format_arg_type_t): New type. Use it instead of
+       'enum format_arg_type'.
+       * format-lisp.c (struct segment): Move out of the scope of struct
+       format_arg_list.
+       * format-scheme.c (struct segment): Likewise.
+       * message.h (struct altstr): Move out of the scope of struct message_ty.
+       * msgl-equal.c (msgstr_equal_ignoring_potcdate): Cast memchr results.
+       * po-lex.c (mb_copy): Rename arguments to new_mbc, old_mbc.
+       * read-mo.c (enum mo_endianness): Move out of the scope of struct
+       binary_mo_file.
+       * read-po.c (this): New macro.
+       * read-properties.c (this): New macro.
+       * write-mo.c (write_table): Cast alloca result.
+       * x-glade.c (load_libexpat): Cast dlsym results.
+       * x-perl.c (get_here_document): Use xmalloc instead of
+       xrealloc (NULL...). Cast its result.
+       * x-po.c (extract_add_message): Limit the scope of variable
+       'charsetstr'.
+       * x-smalltalk.c (phase2_get): Cast xmalloc results.
+
 2006-10-29  Bruno Haible  <bruno@clisp.org>
 
        * x-awk.h: Make includable without prerequisites.
index e0ca78ee494398ac794d08889f7ac248d9da8858..cf9d1580e450347720cc4e442fdcb2044d0dff66 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1996, 1998, 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1998, 2000-2002, 2006 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -82,5 +82,5 @@ dir_list_restore (void *saved_value)
       free (directory);
     }
 
-  directory = saved_value;
+  directory = (string_list_ty *) saved_value;
 }
index 31d27bc811a66d339cdb3483305c772a87b36c70..df34701827e6c8abb680b0e8e3c94e1bd8426f8f 100644 (file)
@@ -134,16 +134,21 @@ enum format_arg_type
                           | FAT_SIZE_INTMAX_T | FAT_SIZE_INTPTR_T
                           | FAT_SIZE_SIZE_T | FAT_SIZE_PTRDIFF_T)
 };
+#ifdef __cplusplus
+typedef int format_arg_type_t;
+#else
+typedef enum format_arg_type format_arg_type_t;
+#endif
 
 struct numbered_arg
 {
   unsigned int number;
-  enum format_arg_type type;
+  format_arg_type_t type;
 };
 
 struct unnumbered_arg
 {
-  enum format_arg_type type;
+  format_arg_type_t type;
 };
 
 struct spec
@@ -200,8 +205,8 @@ format_parse (const char *format, bool translated, bool objc_extensions,
       {
        /* A directive.  */
        unsigned int number = 0;
-       enum format_arg_type type;
-       enum format_arg_type size;
+       format_arg_type_t type;
+       format_arg_type_t size;
 
        spec.directives++;
 
@@ -733,9 +738,9 @@ format_parse (const char *format, bool translated, bool objc_extensions,
       for (i = j = 0; i < numbered_arg_count; i++)
        if (j > 0 && numbered[i].number == numbered[j-1].number)
          {
-           enum format_arg_type type1 = numbered[i].type;
-           enum format_arg_type type2 = numbered[j-1].type;
-           enum format_arg_type type_both;
+           format_arg_type_t type1 = numbered[i].type;
+           format_arg_type_t type2 = numbered[j-1].type;
+           format_arg_type_t type_both;
 
            if (type1 == type2)
              type_both = type1;
index a0137e9b95b5c27ecd04bc82fbf4172c59fca983..d2a006bddb2e9ea93b35ca7f6b576cb9ed8ce182 100644 (file)
@@ -119,11 +119,16 @@ enum format_arg_type
   /* Bitmasks */
   FAT_SIZE_MASK                = (FAT_SIZE_LONG | FAT_SIZE_LONGLONG | FAT_SIZE_WIDE)
 };
+#ifdef __cplusplus
+typedef int format_arg_type_t;
+#else
+typedef enum format_arg_type format_arg_type_t;
+#endif
 
 struct numbered_arg
 {
   unsigned int number;
-  enum format_arg_type type;
+  format_arg_type_t type;
 };
 
 struct spec
@@ -184,8 +189,8 @@ format_parse (const char *format, bool translated, char **invalid_reason)
            unsigned int flag_w = 0;
            unsigned int flag_plus = 0;
            unsigned int flag_sharp = 0;
-           enum format_arg_type size;
-           enum format_arg_type type;
+           format_arg_type_t size;
+           format_arg_type_t type;
 
            if (isdigit (*format))
              {
@@ -490,9 +495,9 @@ format_parse (const char *format, bool translated, char **invalid_reason)
       for (i = j = 0; i < spec.numbered_arg_count; i++)
        if (j > 0 && spec.numbered[i].number == spec.numbered[j-1].number)
          {
-           enum format_arg_type type1 = spec.numbered[i].type;
-           enum format_arg_type type2 = spec.numbered[j-1].type;
-           enum format_arg_type type_both;
+           format_arg_type_t type1 = spec.numbered[i].type;
+           format_arg_type_t type2 = spec.numbered[j-1].type;
+           format_arg_type_t type_both;
 
            if (type1 == type2)
              type_both = type1;
index c43143943768b174861c2c88c42a24842a3c9cf1..b9b6ad7287472a8be40ac23798581daab5cbaae2 100644 (file)
@@ -78,6 +78,15 @@ struct format_arg
   struct format_arg_list *list;        /* For FAT_LIST: List elements.  */
 };
 
+struct segment
+{
+  unsigned int count;  /* Number of format_arg records used.  */
+  unsigned int allocated;
+  struct format_arg *element;  /* Argument constraints.  */
+  unsigned int length; /* Number of arguments represented by this segment.
+                         This is the sum of all repcounts in the segment.  */
+};
+
 struct format_arg_list
 {
   /* The constraints for the potentially infinite argument list are assumed
@@ -90,16 +99,8 @@ struct format_arg_list
      A finite sequence is represented entirely in the initial segment; the
      loop segment is empty.  */
 
-  struct segment
-  {
-    unsigned int count;        /* Number of format_arg records used.  */
-    unsigned int allocated;
-    struct format_arg *element;        /* Argument constraints.  */
-    unsigned int length; /* Number of arguments represented by this segment.
-                           This is the sum of all repcounts in the segment.  */
-  }
-  initial,     /* Initial arguments segment.  */
-  repeated;    /* Endlessly repeated segment.  */
+  struct segment initial;      /* Initial arguments segment.  */
+  struct segment repeated;     /* Endlessly repeated segment.  */
 };
 
 struct spec
index 753981086ce88b547bc8ead7c4120bbf821557e1..f20c49d9e7e5ef176435999ba7bcf13c52885d41 100644 (file)
@@ -94,11 +94,16 @@ enum format_arg_type
   FAT_SIZE_MASK                = (FAT_SIZE_SHORT | FAT_SIZE_V | FAT_SIZE_PTR
                           | FAT_SIZE_LONG | FAT_SIZE_LONGLONG)
 };
+#ifdef __cplusplus
+typedef int format_arg_type_t;
+#else
+typedef enum format_arg_type format_arg_type_t;
+#endif
 
 struct numbered_arg
 {
   unsigned int number;
-  enum format_arg_type type;
+  format_arg_type_t type;
 };
 
 struct spec
@@ -150,8 +155,8 @@ format_parse (const char *format, bool translated, char **invalid_reason)
        /* A directive.  */
        unsigned int number = 0;
        bool vectorize = false;
-       enum format_arg_type type;
-       enum format_arg_type size;
+       format_arg_type_t type;
+       format_arg_type_t size;
 
        directives++;
 
@@ -472,9 +477,9 @@ format_parse (const char *format, bool translated, char **invalid_reason)
       for (i = j = 0; i < numbered_arg_count; i++)
        if (j > 0 && numbered[i].number == numbered[j-1].number)
          {
-           enum format_arg_type type1 = numbered[i].type;
-           enum format_arg_type type2 = numbered[j-1].type;
-           enum format_arg_type type_both;
+           format_arg_type_t type1 = numbered[i].type;
+           format_arg_type_t type2 = numbered[j-1].type;
+           format_arg_type_t type_both;
 
            if (type1 == type2)
              type_both = type1;
index 5005b02bc59cf0c489a23750341c1ae96e302e37..b4300c40166a734a7dae17bda4314baba4e1041c 100644 (file)
@@ -81,6 +81,15 @@ struct format_arg
   struct format_arg_list *list;        /* For FAT_LIST: List elements.  */
 };
 
+struct segment
+{
+  unsigned int count;  /* Number of format_arg records used.  */
+  unsigned int allocated;
+  struct format_arg *element;  /* Argument constraints.  */
+  unsigned int length; /* Number of arguments represented by this segment.
+                         This is the sum of all repcounts in the segment.  */
+};
+
 struct format_arg_list
 {
   /* The constraints for the potentially infinite argument list are assumed
@@ -93,16 +102,8 @@ struct format_arg_list
      A finite sequence is represented entirely in the initial segment; the
      loop segment is empty.  */
 
-  struct segment
-  {
-    unsigned int count;        /* Number of format_arg records used.  */
-    unsigned int allocated;
-    struct format_arg *element;        /* Argument constraints.  */
-    unsigned int length; /* Number of arguments represented by this segment.
-                           This is the sum of all repcounts in the segment.  */
-  }
-  initial,     /* Initial arguments segment.  */
-  repeated;    /* Endlessly repeated segment.  */
+  struct segment initial;      /* Initial arguments segment.  */
+  struct segment repeated;     /* Endlessly repeated segment.  */
 };
 
 struct spec
index 1e04049ad0551905419cc22bf5d2ab7507b91b01..dc7a234ee2ca26039b91f69f995a22c9ae0931c2 100644 (file)
@@ -98,6 +98,17 @@ enum is_wrap
 #endif
 
 
+struct altstr
+{
+  const char *msgstr;
+  size_t msgstr_len;
+  const char *msgstr_end;
+  string_list_ty *comment;
+  string_list_ty *comment_dot;
+  char *id;
+};
+
+
 typedef struct message_ty message_ty;
 struct message_ty
 {
@@ -156,16 +167,7 @@ struct message_ty
 
   /* Used for combining alternative translations, in the msgcat program.  */
   int alternative_count;
-  struct altstr
-    {
-      const char *msgstr;
-      size_t msgstr_len;
-      const char *msgstr_end;
-      string_list_ty *comment;
-      string_list_ty *comment_dot;
-      char *id;
-    }
-    *alternative;
+  struct altstr *alternative;
 };
 
 extern message_ty *
index 3485709e0f11727c722ef91cd9a13d3be0faaf97..209ee169ed50ecda1a73c7bc24338e5ca09c3662 100644 (file)
@@ -57,7 +57,7 @@ msgstr_equal_ignoring_potcdate (const char *msgstr1, size_t msgstr1_len,
        }
       if (memcmp (ptr1, field, fieldlen) == 0)
        break;
-      ptr1 = memchr (ptr1, '\n', msgstr1_end - ptr1);
+      ptr1 = (const char *) memchr (ptr1, '\n', msgstr1_end - ptr1);
       if (ptr1 == NULL)
        break;
       ptr1++;
@@ -73,7 +73,7 @@ msgstr_equal_ignoring_potcdate (const char *msgstr1, size_t msgstr1_len,
        }
       if (memcmp (ptr2, field, fieldlen) == 0)
        break;
-      ptr2 = memchr (ptr2, '\n', msgstr2_end - ptr2);
+      ptr2 = (const char *) memchr (ptr2, '\n', msgstr2_end - ptr2);
       if (ptr2 == NULL)
        break;
       ptr2++;
@@ -91,11 +91,11 @@ msgstr_equal_ignoring_potcdate (const char *msgstr1, size_t msgstr1_len,
          /* Compare, ignoring the lines starting at ptr1 and ptr2.  */
          if (msgstr_equal (msgstr1, ptr1 - msgstr1, msgstr2, ptr2 - msgstr2))
            {
-             ptr1 = memchr (ptr1, '\n', msgstr1_end - ptr1);
+             ptr1 = (const char *) memchr (ptr1, '\n', msgstr1_end - ptr1);
              if (ptr1 == NULL)
                ptr1 = msgstr1_end;
 
-             ptr2 = memchr (ptr2, '\n', msgstr2_end - ptr2);
+             ptr2 = (const char *) memchr (ptr2, '\n', msgstr2_end - ptr2);
              if (ptr2 == NULL)
                ptr2 = msgstr2_end;
 
index e806e9e886076d4dc6621d4afdc7c3930f9b5a6d..57acaaf2edc6e519969ebc91a0e007e2e4565079 100644 (file)
@@ -326,13 +326,13 @@ mb_setascii (mbchar_t mbc, char sc)
 
 /* Copying a character.  */
 static inline void
-mb_copy (mbchar_t new, const mbchar_t old)
+mb_copy (mbchar_t new_mbc, const mbchar_t old_mbc)
 {
-  memcpy_small (&new->buf[0], &old->buf[0], old->bytes);
-  new->bytes = old->bytes;
+  memcpy_small (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes);
+  new_mbc->bytes = old_mbc->bytes;
 #if HAVE_ICONV
-  if ((new->uc_valid = old->uc_valid))
-    new->uc = old->uc;
+  if ((new_mbc->uc_valid = old_mbc->uc_valid))
+    new_mbc->uc = old_mbc->uc;
 #endif
 }
 
index a7524c497dbbee1c3e5e2e92db5198735dde84a8..c6bc9d0e9d3feb14698ec13cd2c151cb51e3125f 100644 (file)
 #define _(str) gettext (str)
 
 
+enum mo_endianness
+{
+  MO_LITTLE_ENDIAN,
+  MO_BIG_ENDIAN
+};
+
 /* We read the file completely into memory.  This is more efficient than
    lots of lseek().  This struct represents the .mo file in memory.  */
 struct binary_mo_file
@@ -51,7 +57,7 @@ struct binary_mo_file
   const char *filename;
   char *data;
   size_t size;
-  enum { MO_LITTLE_ENDIAN, MO_BIG_ENDIAN } endian;
+  enum mo_endianness endian;
 };
 
 
index 61a73a2c4ece16e215c33a077a4b3f7e2fbbf086..8cdfa0bfb87d3e2708cbf1f015b2fc28169fd172 100644 (file)
 #include "po-lex.h"
 #include "po-gram.h"
 
+/* For compiling this file in C++ mode.  */
+#ifdef __cplusplus
+# define this thiss
+#endif
+
+
 /* Read a .po / .pot file from a stream, and dispatch to the various
    abstract_catalog_reader_class_ty methods.  */
 static void
index fc20c1edcbd4ae411e9b988274dbb7782a0843f2..19fa539c4ec704cffdcd03c003070c17c35556f4 100644 (file)
 
 #define _(str) gettext (str)
 
+/* For compiling this file in C++ mode.  */
+#ifdef __cplusplus
+# define this thiss
+#endif
+
+
 /* The format of the Java .properties files is documented in the JDK
    documentation for class java.util.Properties.  In the case of .properties
    files for PropertyResourceBundle, each non-comment line contains a
index 8c4cf1c4776c70dea762d9d712d9c7285c261168..2ef6810845994d5b34c88797e5c236bf0120e067 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing binary .mo files.
-   Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
 
    This program is free software; you can redistribute it and/or modify
@@ -706,7 +706,7 @@ write_table (FILE *output_file, message_list_ty *mlp)
   offset = end_offset;
 
   /* A few zero bytes for padding.  */
-  null = alloca (alignment);
+  null = (char *) alloca (alignment);
   memset (null, '\0', alignment);
 
   /* Now write the original strings.  */
index 76ef51046ef6dad38983516855dd2b3fcb82c09d..bcb259e112672866ad995879ca52f4f90bfe48da 100644 (file)
@@ -166,16 +166,44 @@ load_libexpat ()
       handle = dlopen ("libexpat.so.0", RTLD_LAZY);
 #endif
       if (handle != NULL
-         && (p_XML_ParserCreate = dlsym (handle, "XML_ParserCreate")) != NULL
-         && (p_XML_SetElementHandler = dlsym (handle, "XML_SetElementHandler")) != NULL
-         && (p_XML_SetCharacterDataHandler = dlsym (handle, "XML_SetCharacterDataHandler")) != NULL
-         && (p_XML_SetCommentHandler = dlsym (handle, "XML_SetCommentHandler")) != NULL
-         && (p_XML_Parse = dlsym (handle, "XML_Parse")) != NULL
-         && (p_XML_GetErrorCode = dlsym (handle, "XML_GetErrorCode")) != NULL
-         && (p_XML_GetCurrentLineNumber = dlsym (handle, "XML_GetCurrentLineNumber")) != NULL
-         && (p_XML_GetCurrentColumnNumber = dlsym (handle, "XML_GetCurrentColumnNumber")) != NULL
-         && (p_XML_ParserFree = dlsym (handle, "XML_ParserFree")) != NULL
-         && (p_XML_ErrorString = dlsym (handle, "XML_ErrorString")) != NULL)
+         && (p_XML_ParserCreate =
+               (XML_Parser (*) (const XML_Char *))
+               dlsym (handle, "XML_ParserCreate")) != NULL
+         && (p_XML_SetElementHandler =
+               (void (*) (XML_Parser, XML_StartElementHandler, XML_EndElementHandler))
+               dlsym (handle, "XML_SetElementHandler")) != NULL
+         && (p_XML_SetCharacterDataHandler =
+               (void (*) (XML_Parser, XML_CharacterDataHandler))
+               dlsym (handle, "XML_SetCharacterDataHandler")) != NULL
+         && (p_XML_SetCommentHandler =
+               (void (*) (XML_Parser, XML_CommentHandler))
+               dlsym (handle, "XML_SetCommentHandler")) != NULL
+         && (p_XML_Parse =
+               (int (*) (XML_Parser, const char *, int, int))
+               dlsym (handle, "XML_Parse")) != NULL
+         && (p_XML_GetErrorCode =
+               (enum XML_Error (*) (XML_Parser))
+               dlsym (handle, "XML_GetErrorCode")) != NULL
+         && (p_XML_GetCurrentLineNumber =
+#if XML_MAJOR_VERSION >= 2
+               (XML_Size (*) (XML_Parser))
+#else
+               (int (*) (XML_Parser))
+#endif
+               dlsym (handle, "XML_GetCurrentLineNumber")) != NULL
+         && (p_XML_GetCurrentColumnNumber =
+#if XML_MAJOR_VERSION >= 2
+               (XML_Size (*) (XML_Parser))
+#else
+               (int (*) (XML_Parser))
+#endif
+               dlsym (handle, "XML_GetCurrentColumnNumber")) != NULL
+         && (p_XML_ParserFree =
+               (void (*) (XML_Parser))
+               dlsym (handle, "XML_ParserFree")) != NULL
+         && (p_XML_ErrorString =
+               (const XML_LChar * (*) (int))
+               dlsym (handle, "XML_ErrorString")) != NULL)
        libexpat_loaded = 1;
       else
        libexpat_loaded = -1;
index 4cb058bb02b6b40b531ff5f826c46b6be99eebbb..488692633aa84311d4ddbc8047adf3789816d735 100644 (file)
@@ -286,7 +286,7 @@ get_here_document (const char *delimiter)
   /* Allocate the initial buffer.  Later on, bufmax > 0.  */
   if (bufmax == 0)
     {
-      buffer = xrealloc (NULL, 1);
+      buffer = (char *) xmalloc (1);
       buffer[0] = '\0';
       bufmax = 1;
     }
index 7f980a943ad7f2603995a4f0ede8f49cafab1cad..5142802d4ce88ce729a83d8e4b2c45a17bdbbf74 100644 (file)
@@ -76,23 +76,25 @@ extract_add_message (default_catalog_reader_ty *this,
      because the old header may contain a charset= directive.  */
   if (msgctxt == NULL && *msgid == '\0' && !xgettext_omit_header)
     {
-      const char *charsetstr = strstr (msgstr, "charset=");
-
-      if (charsetstr != NULL)
-       {
-         size_t len;
-         char *charset;
-
-         charsetstr += strlen ("charset=");
-         len = strcspn (charsetstr, " \t\n");
-         charset = (char *) xmalloc (len + 1);
-         memcpy (charset, charsetstr, len);
-         charset[len] = '\0';
-
-         if (header_charset != NULL)
-           free (header_charset);
-         header_charset = charset;
-       }
+      {
+       const char *charsetstr = strstr (msgstr, "charset=");
+
+       if (charsetstr != NULL)
+         {
+           size_t len;
+           char *charset;
+
+           charsetstr += strlen ("charset=");
+           len = strcspn (charsetstr, " \t\n");
+           charset = (char *) xmalloc (len + 1);
+           memcpy (charset, charsetstr, len);
+           charset[len] = '\0';
+
+           if (header_charset != NULL)
+             free (header_charset);
+           header_charset = charset;
+         }
+      }
 
      discard:
       if (msgctxt != NULL)
index 0f759d2a1ec1accbaa5d0f2eea9c8b7673fe233d..371baabefb0c0e7984ebc6a8243226bc7325d5bd 100644 (file)
@@ -326,7 +326,7 @@ phase2_get (token_ty *tp)
              case '@':
              case '?':
              case '%':
-               name = xmalloc (3);
+               name = (char *) xmalloc (3);
                name[0] = c;
                name[1] = c2;
                name[2] = '\0';
@@ -337,7 +337,7 @@ phase2_get (token_ty *tp)
                phase1_ungetc (c2);
                break;
              }
-           name = xmalloc (2);
+           name = (char *) xmalloc (2);
            name[0] = c;
            name[1] = '\0';
            tp->type = token_type_symbol;
index 20c3d7ec571fba769507236f068618bde0daefb2..1ddfb6bf081be2ac79180688540b723481fcbe32 100644 (file)
@@ -1,3 +1,11 @@
+2006-10-29  Bruno Haible  <bruno@clisp.org>
+
+       Make it compile in C++ mode.
+       * lib/backupfile.c (find_backup_file_name): Cast malloc result.
+       * lib/xalloc.h (xrealloc): Define as template with appropriate return
+       type.
+       * lib/xstrdup.c (xstrdup): Cast xmalloc result.
+
 2006-10-26  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.16 released.
index 25ee1194158b52fb9912159213ea8d0fa9d04c12..d1b962d40585417285bc307f09329f4b329727e4 100644 (file)
@@ -97,7 +97,8 @@ find_backup_file_name (const char *file, enum backup_type backup_type)
   if (HAVE_DIR && backup_suffix_size_max < numbered_suffix_size_max)
     backup_suffix_size_max = numbered_suffix_size_max;
 
-  s = malloc (file_len + backup_suffix_size_max + numbered_suffix_size_max);
+  s = (char *) malloc (file_len + backup_suffix_size_max
+                      + numbered_suffix_size_max);
   if (s)
     {
       strcpy (s, file);
index de230ebb8fc46cd1898ba0dbdc5ce14772a2c972..a12c984b94eb52353bf0ebe7dff2d6b38f58d7b0 100644 (file)
@@ -43,6 +43,15 @@ extern void *xcalloc (size_t nmemb, size_t size);
 /* Change the size of an allocated block of memory PTR to SIZE bytes,
    with error checking.  If PTR is NULL, run xmalloc.  */
 extern void *xrealloc (void *ptr, size_t size);
+#ifdef __cplusplus
+}
+template <typename T>
+  inline T * xrealloc (T * ptr, size_t size)
+  {
+    return (T *) xrealloc((void *) ptr, size);
+  }
+extern "C" {
+#endif
 
 /* This function is always triggered when memory is exhausted.  It is
    in charge of honoring the three previous items.  This is the
index d73a179c6ae539169799d1b57fa2dfb78bc67d2b..b63af6539beb93e285f7da863a52b9c20cd51d7f 100644 (file)
@@ -27,5 +27,5 @@
 char *
 xstrdup (const char *string)
 {
-  return strcpy (xmalloc (strlen (string) + 1), string);
+  return strcpy ((char *) xmalloc (strlen (string) + 1), string);
 }