+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.
+ 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. */
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;
/* 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
# 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);
}
/* 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
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
{
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,
/* 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
((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++)
{
/* 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
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;
/* 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
#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
/* 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'. */
%{
/* 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
%union {
unsigned long int num;
- enum operator op;
+ enum expression_operator op;
struct expression *exp;
}
/* 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;
}
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];
}
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];
}
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];
+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.
/* 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
/* Delete a position from a set. */
static void
-delete (position p, position_set *s)
+remove (position p, position_set *s)
{
int i;
{
old = s->elems[i];
p.constraint = old.constraint;
- delete(s->elems[i], s);
+ remove(s->elems[i], s);
if (visited[old.index])
{
--i;
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)
{
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)
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. */
char *lcopy;
int i;
- lcopy = malloc(len);
+ lcopy = (char *) malloc(len);
if (!lcopy)
dfaerror(_("out of memory"));
'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;
}
}
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
{
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;
}
}
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;
}
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;
if (mp < &musts[2])
goto done; /* "cannot happen" */
{
- char **new;
+ char **common;
must *lmp;
must *rmp;
int j, ln, rn, n;
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:
{
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;
/* 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
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
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). */
/* 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
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;
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;
}
/* 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
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;
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)
#endif /* MBS_SUPPORT */
return offset;
}
- try = beg + offset;
+ curr = beg + offset;
len = kwsmatch.size[0];
}
else
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;
/* 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;
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
do
{
size_t len;
- sep = memchr (motif, '\n', total);
+ sep = (const char *) memchr (motif, '\n', total);
if (sep)
{
len = sep - motif;
do
{
size_t len;
- sep = memchr (motif, '\n', total);
+ sep = (const char *) memchr (motif, '\n', total);
if (sep)
{
len = sep - motif;
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
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
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. */ \
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");
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
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 ();
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");
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;
+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.
/* 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>
free (directory);
}
- directory = saved_value;
+ directory = (string_list_ty *) saved_value;
}
| 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
{
/* 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++;
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;
/* 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
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))
{
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;
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
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
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
/* 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++;
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;
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
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
#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
{
/* 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 *
}
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++;
}
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++;
/* 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;
/* 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
}
#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
const char *filename;
char *data;
size_t size;
- enum { MO_LITTLE_ENDIAN, MO_BIG_ENDIAN } endian;
+ enum mo_endianness endian;
};
#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
#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
/* 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
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. */
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;
/* Allocate the initial buffer. Later on, bufmax > 0. */
if (bufmax == 0)
{
- buffer = xrealloc (NULL, 1);
+ buffer = (char *) xmalloc (1);
buffer[0] = '\0';
bufmax = 1;
}
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)
case '@':
case '?':
case '%':
- name = xmalloc (3);
+ name = (char *) xmalloc (3);
name[0] = c;
name[1] = c2;
name[2] = '\0';
phase1_ungetc (c2);
break;
}
- name = xmalloc (2);
+ name = (char *) xmalloc (2);
name[0] = c;
name[1] = '\0';
tp->type = token_type_symbol;
+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.
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);
/* 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
char *
xstrdup (const char *string)
{
- return strcpy (xmalloc (strlen (string) + 1), string);
+ return strcpy ((char *) xmalloc (strlen (string) + 1), string);
}