Make it compile in C++ mode.
authorBruno Haible <bruno@clisp.org>
Tue, 31 Oct 2006 19:18:54 +0000 (19:18 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 31 Oct 2006 19:18:54 +0000 (19:18 +0000)
ChangeLog
lib/clean-temp.c
lib/csharpcomp.c
lib/fatal-signal.c
lib/findprog.c
lib/linebreak.c
lib/mbchar.h
lib/striconv.c
lib/strnlen1.c
lib/wait-process.c

index 918e05098488554980e8ccf12fb21f9b3cef7f1f..8a0818b3f6ee5e740d8469eb2504fc48cd50ca70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-10-29  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2006-10-22  Bruno Haible  <bruno@clisp.org>
 
        * modules/tsearch: New file.
index f3a0324518070acee69d27afc240759b9d1f74a1..97b26008f957d844f717725af1521cb85b8fb42c 100644 (file)
@@ -154,8 +154,8 @@ static gl_list_t /* <int> */ volatile descriptors;
 static bool
 string_equals (const void *x1, const void *x2)
 {
-  const char *s1 = x1;
-  const char *s2 = x2;
+  const char *s1 = (const char *) x1;
+  const char *s2 = (const char *) x2;
   return strcmp (s1, s2) == 0;
 }
 
@@ -167,7 +167,7 @@ string_equals (const void *x1, const void *x2)
 static size_t
 string_hash (const void *x)
 {
-  const char *s = x;
+  const char *s = (const char *) x;
   size_t h = 0;
 
   for (; *s; s++)
@@ -251,7 +251,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
   struct tempdir * volatile *tmpdirp = NULL;
   struct tempdir *tmpdir;
   size_t i;
-  char *template;
+  char *xtemplate;
   char *tmpdirname;
 
   /* See whether it can take the slot of an earlier temporary directory
@@ -315,15 +315,15 @@ create_temp_dir (const char *prefix, const char *parentdir,
                                        string_equals, string_hash, false);
 
   /* Create the temporary directory.  */
-  template = (char *) xallocsa (PATH_MAX);
-  if (path_search (template, PATH_MAX, parentdir, prefix, parentdir == NULL))
+  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 (template);
+  tmpdirname = mkdtemp (xtemplate);
   if (tmpdirname != NULL)
     {
       tmpdir->dirname = tmpdirname;
@@ -334,7 +334,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
     {
       error (0, errno,
             _("cannot create a temporary directory using template \"%s\""),
-            template);
+            xtemplate);
       goto quit;
     }
   /* Replace tmpdir->dirname with a copy that has indefinite extent.
@@ -342,11 +342,11 @@ create_temp_dir (const char *prefix, const char *parentdir,
      block because then the cleanup handler would not remove the directory
      if xstrdup fails.  */
   tmpdir->dirname = xstrdup (tmpdirname);
-  freesa (template);
+  freesa (xtemplate);
   return (struct temp_dir *) tmpdir;
 
  quit:
-  freesa (template);
+  freesa (xtemplate);
   return NULL;
 }
 
index eed0d15e36f5dd5447d3852b95fa81cb4d60659f..eb1574d9699434e8ed83dd2f2a8bf01107ae59ec 100644 (file)
@@ -400,7 +400,8 @@ compile_csharp_using_sscli (const char * const *sources,
 
       argp = argv;
       *argp++ = "csc";
-      *argp++ = (output_is_library ? "-target:library" : "-target:exe");
+      *argp++ =
+       (char *) (output_is_library ? "-target:library" : "-target:exe");
       {
        char *option = (char *) xallocsa (5 + strlen (output_file) + 1);
        memcpy (option, "-out:", 5);
index f85b60f41865a96c00c89a4dcdc4f85731c3ad1b..2b93b602ab2bf88cf2d287d5f3f56b36872f3763 100644 (file)
@@ -206,6 +206,7 @@ at_fatal_signal (action_t action)
       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;
 
index 1535dcef0427bcaf2b02666d4560624374dcbc85..5476b39d9b18e08de2522059c1ed4b3a48e50bc3 100644 (file)
@@ -92,7 +92,7 @@ find_in_path (const char *progname)
              /* 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 = (char *) xmalloc (2 + strlen (progname) + 1);
              progpathname[0] = '.';
              progpathname[1] = '/';
              memcpy (progpathname + 2, progname, strlen (progname) + 1);
index 82aba3c84240ea6e017b6d8be877d55199fd52dc..09f110cf190a09a15515e250e6246f2699cab502 100644 (file)
@@ -1617,6 +1617,7 @@ mbs_width_linebreaks (const char *s, size_t n,
                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)
                 {
index 13578356bdb5bd3e5660c2ca3cd7ee34656e1607..a0c2cdcb99fffec4fee358a21ab1b284ce388275 100644 (file)
@@ -385,18 +385,18 @@ mb_width_aux (wint_t wc)
 
 /* 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)
 {
-  if (old->ptr == &old->buf[0])
+  if (old_mbc->ptr == &old_mbc->buf[0])
     {
-      memcpy (&new->buf[0], &old->buf[0], old->bytes);
-      new->ptr = &new->buf[0];
+      memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes);
+      new_mbc->ptr = &new_mbc->buf[0];
     }
   else
-    new->ptr = old->ptr;
-  new->bytes = old->bytes;
-  if ((new->wc_valid = old->wc_valid))
-    new->wc = old->wc;
+    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;
 }
 
 
index fc02249356edb5597f866af3ef74b1de4f805be0..5326376883e15b364b9b7e7a28fe579c27127bd9 100644 (file)
@@ -114,7 +114,8 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
       *lengthp = 0;
       return 0;
     }
-  result = (*resultp != NULL ? realloc (*resultp, length) : malloc (length));
+  result =
+    (char *) (*resultp != NULL ? realloc (*resultp, length) : malloc (length));
   if (result == NULL)
     {
       errno = ENOMEM;
index f74e427b0f723fe9ebdd72439f4c5f5d31aa8089..422ed9e80ce793f6f281f897cb904ac4989c3799 100644 (file)
@@ -28,7 +28,7 @@
 size_t
 strnlen1 (const char *string, size_t maxlen)
 {
-  const char *end = memchr (string, '\0', maxlen);
+  const char *end = (const char *) memchr (string, '\0', maxlen);
   if (end != NULL)
     return end - string + 1;
   else
index 7593eeacb28d43e4977e90a67a4b160daf13dddb..f39b41bf0939ff0a77d180f06300899d40967f51 100644 (file)
@@ -203,6 +203,7 @@ register_slave_subprocess (pid_t child)
       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)
        {