[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++ support (1)
From: |
Bruno Haible |
Subject: |
C++ support (1) |
Date: |
Tue, 31 Oct 2006 20:18:53 +0100 |
User-agent: |
KMail/1.9.1 |
Hi,
Compiling GNU gettext with a C++ compiler revealed a bug: an assignment
between an 'int' variable and an 'enum' variable that was not intended.
This confirms once again that the ability to compile a C package in C++ mode
on at least one platform is useful. I'm therefore applying this patch.
2006-10-29 Bruno Haible <address@hidden>
Make it compile in C++ mode.
* lib/striconv.c (mem_cd_iconv): Cast malloc/realloc result.
* lib/strnlen1.c (strnlen1): Cast memchr result.
* lib/mbchar.h (mb_copy): Rename arguments to 'new_mbc', 'old_mbc'.
* lib/clean-temp.c (string_equals, string_hash): Add casts.
(create_temp_dir): Rename local variable 'template'.
(compile_csharp_using_sscli): Add cast.
* lib/fatal-signal.c (at_fatal_signal): Cast xmalloc result.
* lib/findprog.c (find_in_path): Likewise.
* lib/linebreak.c (mbs_width_linebreaks): Cast malloc result.
* lib/wait-process.c (register_slave_subprocess): Likewise.
*** gnulib-20061026/lib/striconv.c 2006-10-27 00:15:12.000000000 +0200
--- gnulib-20061026-modified/lib/striconv.c 2006-10-29 20:21:36.000000000
+0100
***************
*** 114,120 ****
*lengthp = 0;
return 0;
}
! result = (*resultp != NULL ? realloc (*resultp, length) : malloc (length));
if (result == NULL)
{
errno = ENOMEM;
--- 114,121 ----
*lengthp = 0;
return 0;
}
! result =
! (char *) (*resultp != NULL ? realloc (*resultp, length) : malloc
(length));
if (result == NULL)
{
errno = ENOMEM;
*** gnulib-20061026/lib/strnlen1.c 2006-09-19 00:51:16.000000000 +0200
--- gnulib-20061026-modified/lib/strnlen1.c 2006-10-29 20:22:40.000000000
+0100
***************
*** 28,34 ****
size_t
strnlen1 (const char *string, size_t maxlen)
{
! const char *end = memchr (string, '\0', maxlen);
if (end != NULL)
return end - string + 1;
else
--- 28,34 ----
size_t
strnlen1 (const char *string, size_t maxlen)
{
! const char *end = (const char *) memchr (string, '\0', maxlen);
if (end != NULL)
return end - string + 1;
else
*** gnulib-20061026/lib/mbchar.h 2006-08-21 20:21:25.000000000 +0200
--- gnulib-20061026-modified/lib/mbchar.h 2006-10-29 20:26:32.000000000
+0100
***************
*** 385,402 ****
/* Copying a character. */
static inline void
! mb_copy (mbchar_t *new, const mbchar_t *old)
{
! if (old->ptr == &old->buf[0])
{
! memcpy (&new->buf[0], &old->buf[0], old->bytes);
! new->ptr = &new->buf[0];
}
else
! new->ptr = old->ptr;
! new->bytes = old->bytes;
! if ((new->wc_valid = old->wc_valid))
! new->wc = old->wc;
}
--- 385,402 ----
/* Copying a character. */
static inline void
! mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc)
{
! if (old_mbc->ptr == &old_mbc->buf[0])
{
! memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes);
! new_mbc->ptr = &new_mbc->buf[0];
}
else
! new_mbc->ptr = old_mbc->ptr;
! new_mbc->bytes = old_mbc->bytes;
! if ((new_mbc->wc_valid = old_mbc->wc_valid))
! new_mbc->wc = old_mbc->wc;
}
*** gnulib-20061026/lib/clean-temp.c 2006-10-20 00:23:38.000000000 +0200
--- gnulib-20061026-modified/lib/clean-temp.c 2006-10-29 20:43:23.000000000
+0100
***************
*** 154,161 ****
static bool
string_equals (const void *x1, const void *x2)
{
! const char *s1 = x1;
! const char *s2 = x2;
return strcmp (s1, s2) == 0;
}
--- 154,161 ----
static bool
string_equals (const void *x1, const void *x2)
{
! const char *s1 = (const char *) x1;
! const char *s2 = (const char *) x2;
return strcmp (s1, s2) == 0;
}
***************
*** 167,173 ****
static size_t
string_hash (const void *x)
{
! const char *s = x;
size_t h = 0;
for (; *s; s++)
--- 167,173 ----
static size_t
string_hash (const void *x)
{
! const char *s = (const char *) x;
size_t h = 0;
for (; *s; s++)
***************
*** 251,257 ****
struct tempdir * volatile *tmpdirp = NULL;
struct tempdir *tmpdir;
size_t i;
! char *template;
char *tmpdirname;
/* See whether it can take the slot of an earlier temporary directory
--- 251,257 ----
struct tempdir * volatile *tmpdirp = NULL;
struct tempdir *tmpdir;
size_t i;
! char *xtemplate;
char *tmpdirname;
/* See whether it can take the slot of an earlier temporary directory
***************
*** 315,329 ****
string_equals, string_hash, false);
/* Create the temporary directory. */
! template = (char *) xallocsa (PATH_MAX);
! if (path_search (template, PATH_MAX, parentdir, prefix, parentdir == NULL))
{
error (0, errno,
_("cannot find a temporary directory, try setting $TMPDIR"));
goto quit;
}
block_fatal_signals ();
! tmpdirname = mkdtemp (template);
if (tmpdirname != NULL)
{
tmpdir->dirname = tmpdirname;
--- 315,329 ----
string_equals, string_hash, false);
/* Create the temporary directory. */
! xtemplate = (char *) xallocsa (PATH_MAX);
! if (path_search (xtemplate, PATH_MAX, parentdir, prefix, parentdir == NULL))
{
error (0, errno,
_("cannot find a temporary directory, try setting $TMPDIR"));
goto quit;
}
block_fatal_signals ();
! tmpdirname = mkdtemp (xtemplate);
if (tmpdirname != NULL)
{
tmpdir->dirname = tmpdirname;
***************
*** 334,340 ****
{
error (0, errno,
_("cannot create a temporary directory using template \"%s\""),
! template);
goto quit;
}
/* Replace tmpdir->dirname with a copy that has indefinite extent.
--- 334,340 ----
{
error (0, errno,
_("cannot create a temporary directory using template \"%s\""),
! xtemplate);
goto quit;
}
/* Replace tmpdir->dirname with a copy that has indefinite extent.
***************
*** 342,352 ****
block because then the cleanup handler would not remove the directory
if xstrdup fails. */
tmpdir->dirname = xstrdup (tmpdirname);
! freesa (template);
return (struct temp_dir *) tmpdir;
quit:
! freesa (template);
return NULL;
}
--- 342,352 ----
block because then the cleanup handler would not remove the directory
if xstrdup fails. */
tmpdir->dirname = xstrdup (tmpdirname);
! freesa (xtemplate);
return (struct temp_dir *) tmpdir;
quit:
! freesa (xtemplate);
return NULL;
}
*** gnulib-20061026/lib/csharpcomp.c 2006-09-19 00:51:16.000000000 +0200
--- gnulib-20061026-modified/lib/csharpcomp.c 2006-10-29 20:44:59.000000000
+0100
***************
*** 400,406 ****
argp = argv;
*argp++ = "csc";
! *argp++ = (output_is_library ? "-target:library" : "-target:exe");
{
char *option = (char *) xallocsa (5 + strlen (output_file) + 1);
memcpy (option, "-out:", 5);
--- 400,407 ----
argp = argv;
*argp++ = "csc";
! *argp++ =
! (char *) (output_is_library ? "-target:library" : "-target:exe");
{
char *option = (char *) xallocsa (5 + strlen (output_file) + 1);
memcpy (option, "-out:", 5);
*** gnulib-20061026/lib/fatal-signal.c 2006-10-14 13:33:04.000000000 +0200
--- gnulib-20061026-modified/lib/fatal-signal.c 2006-10-29 20:46:07.000000000
+0100
***************
*** 206,211 ****
--- 206,212 ----
size_t old_actions_allocated = actions_allocated;
size_t new_actions_allocated = 2 * actions_allocated;
actions_entry_t *new_actions =
+ (actions_entry_t *)
xmalloc (new_actions_allocated * sizeof (actions_entry_t));
size_t k;
*** gnulib-20061026/lib/findprog.c 2006-10-20 00:23:38.000000000 +0200
--- gnulib-20061026-modified/lib/findprog.c 2006-10-29 20:46:53.000000000
+0100
***************
*** 92,98 ****
/* Add the "./" prefix for real, that concatenated_pathname()
optimized away. This avoids a second PATH search when the
caller uses execlp/execvp. */
! progpathname = xmalloc (2 + strlen (progname) + 1);
progpathname[0] = '.';
progpathname[1] = '/';
memcpy (progpathname + 2, progname, strlen (progname) + 1);
--- 92,98 ----
/* Add the "./" prefix for real, that concatenated_pathname()
optimized away. This avoids a second PATH search when the
caller uses execlp/execvp. */
! progpathname = (char *) xmalloc (2 + strlen (progname) + 1);
progpathname[0] = '.';
progpathname[1] = '/';
memcpy (progpathname + 2, progname, strlen (progname) + 1);
*** gnulib-20061026/lib/linebreak.c 2006-09-19 00:51:16.000000000 +0200
--- gnulib-20061026-modified/lib/linebreak.c 2006-10-29 20:50:07.000000000
+0100
***************
*** 1617,1622 ****
--- 1617,1623 ----
xsum4 (xtimes (n, sizeof (size_t)), m, m,
(o != NULL ? m : 0));
char *memory =
+ (char *)
(size_in_bounds_p (memory_size) ? malloc (memory_size) : NULL);
if (memory != NULL)
{
*** gnulib-20061026/lib/wait-process.c 2006-09-19 00:51:16.000000000 +0200
--- gnulib-20061026-modified/lib/wait-process.c 2006-10-29 20:54:58.000000000
+0100
***************
*** 203,208 ****
--- 203,209 ----
slaves_entry_t *old_slaves = slaves;
size_t new_slaves_allocated = 2 * slaves_allocated;
slaves_entry_t *new_slaves =
+ (slaves_entry_t *)
malloc (new_slaves_allocated * sizeof (slaves_entry_t));
if (new_slaves == NULL)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- C++ support (1),
Bruno Haible <=