summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'gettext-tools/src')
-rw-r--r--gettext-tools/src/ChangeLog28
-rw-r--r--gettext-tools/src/dir-list.c4
-rw-r--r--gettext-tools/src/format-c.c19
-rw-r--r--gettext-tools/src/format-gcc-internal.c17
-rw-r--r--gettext-tools/src/format-lisp.c21
-rw-r--r--gettext-tools/src/format-perl.c17
-rw-r--r--gettext-tools/src/format-scheme.c21
-rw-r--r--gettext-tools/src/message.h22
-rw-r--r--gettext-tools/src/msgl-equal.c8
-rw-r--r--gettext-tools/src/po-lex.c10
-rw-r--r--gettext-tools/src/read-mo.c8
-rw-r--r--gettext-tools/src/read-po.c6
-rw-r--r--gettext-tools/src/read-properties.c6
-rw-r--r--gettext-tools/src/write-mo.c4
-rw-r--r--gettext-tools/src/x-glade.c48
-rw-r--r--gettext-tools/src/x-perl.c2
-rw-r--r--gettext-tools/src/x-po.c36
-rw-r--r--gettext-tools/src/x-smalltalk.c4
18 files changed, 188 insertions, 93 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 3ddacf6..463c7a2 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,33 @@
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.
* x-c.h: Likewise.
* x-csharp.h: Likewise.
diff --git a/gettext-tools/src/dir-list.c b/gettext-tools/src/dir-list.c
index e0ca78e..cf9d158 100644
--- a/gettext-tools/src/dir-list.c
+++ b/gettext-tools/src/dir-list.c
@@ -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;
}
diff --git a/gettext-tools/src/format-c.c b/gettext-tools/src/format-c.c
index 31d27bc..df34701 100644
--- a/gettext-tools/src/format-c.c
+++ b/gettext-tools/src/format-c.c
@@ -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;
diff --git a/gettext-tools/src/format-gcc-internal.c b/gettext-tools/src/format-gcc-internal.c
index a0137e9..d2a006b 100644
--- a/gettext-tools/src/format-gcc-internal.c
+++ b/gettext-tools/src/format-gcc-internal.c
@@ -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;
diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c
index c431439..b9b6ad7 100644
--- a/gettext-tools/src/format-lisp.c
+++ b/gettext-tools/src/format-lisp.c
@@ -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
diff --git a/gettext-tools/src/format-perl.c b/gettext-tools/src/format-perl.c
index 7539810..f20c49d 100644
--- a/gettext-tools/src/format-perl.c
+++ b/gettext-tools/src/format-perl.c
@@ -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;
diff --git a/gettext-tools/src/format-scheme.c b/gettext-tools/src/format-scheme.c
index 5005b02..b4300c4 100644
--- a/gettext-tools/src/format-scheme.c
+++ b/gettext-tools/src/format-scheme.c
@@ -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
diff --git a/gettext-tools/src/message.h b/gettext-tools/src/message.h
index 1e04049..dc7a234 100644
--- a/gettext-tools/src/message.h
+++ b/gettext-tools/src/message.h
@@ -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 *
diff --git a/gettext-tools/src/msgl-equal.c b/gettext-tools/src/msgl-equal.c
index 3485709..209ee16 100644
--- a/gettext-tools/src/msgl-equal.c
+++ b/gettext-tools/src/msgl-equal.c
@@ -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;
diff --git a/gettext-tools/src/po-lex.c b/gettext-tools/src/po-lex.c
index e806e9e..57acaaf 100644
--- a/gettext-tools/src/po-lex.c
+++ b/gettext-tools/src/po-lex.c
@@ -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
}
diff --git a/gettext-tools/src/read-mo.c b/gettext-tools/src/read-mo.c
index a7524c4..c6bc9d0 100644
--- a/gettext-tools/src/read-mo.c
+++ b/gettext-tools/src/read-mo.c
@@ -44,6 +44,12 @@
#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;
};
diff --git a/gettext-tools/src/read-po.c b/gettext-tools/src/read-po.c
index 61a73a2..8cdfa0b 100644
--- a/gettext-tools/src/read-po.c
+++ b/gettext-tools/src/read-po.c
@@ -25,6 +25,12 @@
#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
diff --git a/gettext-tools/src/read-properties.c b/gettext-tools/src/read-properties.c
index fc20c1e..19fa539 100644
--- a/gettext-tools/src/read-properties.c
+++ b/gettext-tools/src/read-properties.c
@@ -44,6 +44,12 @@
#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
diff --git a/gettext-tools/src/write-mo.c b/gettext-tools/src/write-mo.c
index 8c4cf1c..2ef6810 100644
--- a/gettext-tools/src/write-mo.c
+++ b/gettext-tools/src/write-mo.c
@@ -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. */
diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c
index 76ef510..bcb259e 100644
--- a/gettext-tools/src/x-glade.c
+++ b/gettext-tools/src/x-glade.c
@@ -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;
diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c
index 4cb058b..4886926 100644
--- a/gettext-tools/src/x-perl.c
+++ b/gettext-tools/src/x-perl.c
@@ -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;
}
diff --git a/gettext-tools/src/x-po.c b/gettext-tools/src/x-po.c
index 7f980a9..5142802 100644
--- a/gettext-tools/src/x-po.c
+++ b/gettext-tools/src/x-po.c
@@ -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)
diff --git a/gettext-tools/src/x-smalltalk.c b/gettext-tools/src/x-smalltalk.c
index 0f759d2..371baab 100644
--- a/gettext-tools/src/x-smalltalk.c
+++ b/gettext-tools/src/x-smalltalk.c
@@ -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;