[gdb/testsuite] Fix gdb.dwarf2/fission-relative-dwo.exp with cc-with-gdb-index
[binutils-gdb.git] / gdb / charset.c
index 7568e47cf9ab436bf2c28bbaecfd7a99ed393801..9fb1a1f0b67e775afbe006012942353369e8f976 100644 (file)
@@ -1,6 +1,6 @@
 /* Character set conversion support for GDB.
 
-   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -247,7 +247,7 @@ show_target_charset_name (struct ui_file *file, int from_tty,
   if (!strcmp (value, "auto"))
     fprintf_filtered (file,
                      _("The target character set is \"auto; "
-                       "currently %s\".\n"),
+                       "currently %s\".\n"),
                      gdbarch_auto_charset (get_current_arch ()));
   else
     fprintf_filtered (file, _("The target character set is \"%s\".\n"),
@@ -264,20 +264,20 @@ show_target_wide_charset_name (struct ui_file *file,
   if (!strcmp (value, "auto"))
     fprintf_filtered (file,
                      _("The target wide character set is \"auto; "
-                       "currently %s\".\n"),
+                       "currently %s\".\n"),
                      gdbarch_auto_wide_charset (get_current_arch ()));
   else
     fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
                      value);
 }
 
-static const char *default_charset_names[] =
+static const char * const default_charset_names[] =
 {
   DEFAULT_CHARSET_NAMES
   0
 };
 
-static const char **charset_enum;
+static const char * const *charset_enum;
 
 \f
 /* If the target wide character set has big- or little-endian
@@ -816,10 +816,10 @@ find_charset_names (void)
 
 #ifdef ICONV_BIN
   {
-    char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
-                                             ICONV_BIN_RELOCATABLE);
-    iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
-    xfree (iconv_dir);
+    std::string iconv_dir = relocate_gdb_directory (ICONV_BIN,
+                                                   ICONV_BIN_RELOCATABLE);
+    iconv_program
+      = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", (char *) NULL);
   }
 #else
   iconv_program = xstrdup ("iconv");
@@ -990,20 +990,21 @@ intermediate_encoding (void)
   /* Not valid, free the allocated memory.  */
   xfree (result);
   /* No valid charset found, generate error here.  */
-  error (_("Unable to find a vaild charset for string conversions"));
+  error (_("Unable to find a valid charset for string conversions"));
 }
 
 #endif /* USE_INTERMEDIATE_ENCODING_FUNCTION */
 
+void _initialize_charset ();
 void
-_initialize_charset (void)
+_initialize_charset ()
 {
   /* The first element is always "auto".  */
   charsets.charsets.push_back (xstrdup ("auto"));
   find_charset_names ();
 
   if (charsets.charsets.size () > 1)
-    charset_enum = (const char **) charsets.charsets.data ();
+    charset_enum = (const char * const *) charsets.charsets.data ();
   else
     charset_enum = default_charset_names;