]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* cli/cli-cmds.c (shell_escape): Use lbasename.
authorPedro Alves <palves@redhat.com>
Wed, 9 Mar 2011 12:48:56 +0000 (12:48 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 9 Mar 2011 12:48:56 +0000 (12:48 +0000)
* coffread.c (coff_start_symtab): Constify parameter.
(complete_symtab): Constify `name' parameter.
(coff_symtab_read): Constify `filestring' local.
(coff_getfilename): Constify return and `result' local.
Use lbasename.
* fbsd-nat.c (fbsd_make_corefile_notes): Use lbasename.
* linux-fork.c (info_checkpoints_command): Use lbasename.
* linux-nat.c (linux_nat_make_corefile_notes): Use lbasename.
* minsyms.c (lookup_minimal_symbol): Use lbasename.
* nto-tdep.c (nto_find_and_open_solib): Use lbasename.
* procfs.c (procfs_make_note_section): Use lbasename.
* tui/tui-io.c (printable_part): Constity return and parameter.
Use lbasename.
(print_filename): Constify parameters, and local `s'.
(tui_rl_display_match_list): Constify local `temp'.

gdb/ChangeLog
gdb/cli/cli-cmds.c
gdb/coffread.c
gdb/fbsd-nat.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/minsyms.c
gdb/nto-tdep.c
gdb/procfs.c
gdb/tui/tui-io.c

index 41546492be1dc786180d402439b6ba12caa0ee97..3a26f18e0d606b4670abf09fe9c8cff506608df3 100644 (file)
@@ -1,3 +1,22 @@
+2011-03-09  Pedro Alves  <pedro@codesourcery.com>
+
+       * cli/cli-cmds.c (shell_escape): Use lbasename.
+       * coffread.c (coff_start_symtab): Constify parameter.
+       (complete_symtab): Constify `name' parameter.
+       (coff_symtab_read): Constify `filestring' local.
+       (coff_getfilename): Constify return and `result' local.
+       Use lbasename.
+       * fbsd-nat.c (fbsd_make_corefile_notes): Use lbasename.
+       * linux-fork.c (info_checkpoints_command): Use lbasename.
+       * linux-nat.c (linux_nat_make_corefile_notes): Use lbasename.
+       * minsyms.c (lookup_minimal_symbol): Use lbasename.
+       * nto-tdep.c (nto_find_and_open_solib): Use lbasename.
+       * procfs.c (procfs_make_note_section): Use lbasename.
+       * tui/tui-io.c (printable_part): Constity return and parameter.
+       Use lbasename.
+       (print_filename): Constify parameters, and local `s'.
+       (tui_rl_display_match_list): Constify local `temp'.
+
 2011-03-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Revert:
index e3cccdfc2be57bd1f09259af9dc76a126b333c01..0fc5efc6fe921d101abbbf044b348c4855097484 100644 (file)
@@ -730,16 +730,13 @@ shell_escape (char *arg, int from_tty)
 
   if ((pid = vfork ()) == 0)
     {
-      char *p, *user_shell;
+      const char *p, *user_shell;
 
       if ((user_shell = (char *) getenv ("SHELL")) == NULL)
        user_shell = "/bin/sh";
 
       /* Get the name of the shell for arg0.  */
-      if ((p = strrchr (user_shell, '/')) == NULL)
-       p = user_shell;
-      else
-       p++;                    /* Get past '/' */
+      p = lbasename (user_shell);
 
       if (!arg)
        execl (user_shell, p, (char *) 0);
index 85a55536f7e98f3f73151ce6f4f29af2c4a94f5a..8ec87c14a4b741f866d2ac91ef123efa7041d1c7 100644 (file)
@@ -178,7 +178,7 @@ static int init_lineno (bfd *, long, int);
 
 static char *getsymname (struct internal_syment *);
 
-static char *coff_getfilename (union internal_auxent *);
+static const char *coff_getfilename (union internal_auxent *);
 
 static void free_stringtab (void);
 
@@ -366,7 +366,7 @@ coff_alloc_type (int index)
    it indicates the start of data for one original source file.  */
 
 static void
-coff_start_symtab (char *name)
+coff_start_symtab (const char *name)
 {
   start_symtab (
   /* We fill in the filename later.  start_symtab puts this pointer
@@ -388,7 +388,7 @@ coff_start_symtab (char *name)
    text.  */
 
 static void
-complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
+complete_symtab (const char *name, CORE_ADDR start_addr, unsigned int size)
 {
   if (last_source_file != NULL)
     xfree (last_source_file);
@@ -713,7 +713,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
   int in_source_file = 0;
   int next_file_symnum = -1;
   /* Name of the current file.  */
-  char *filestring = "";
+  const char *filestring = "";
   int depth = 0;
   int fcn_first_line = 0;
   CORE_ADDR fcn_first_line_addr = 0;
@@ -1308,12 +1308,12 @@ getsymname (struct internal_syment *symbol_entry)
    Return only the last component of the name.  Result is in static
    storage and is only good for temporary use.  */
 
-static char *
+static const char *
 coff_getfilename (union internal_auxent *aux_entry)
 {
   static char buffer[BUFSIZ];
   char *temp;
-  char *result;
+  const char *result;
 
   if (aux_entry->x_file.x_n.x_zeroes == 0)
     {
@@ -1331,8 +1331,7 @@ coff_getfilename (union internal_auxent *aux_entry)
   /* FIXME: We should not be throwing away the information about what
      directory.  It should go into dirname of the symtab, or some such
      place.  */
-  if ((temp = strrchr (result, '/')) != NULL)
-    result = temp + 1;
+  result = lbasename (result);
   return (result);
 }
 \f
index 2072e0e6f4f923f5e9797408d8fff5e7b2e04b2f..6b775a9651c5d1aac172313979cd6ea259b93101 100644 (file)
@@ -202,7 +202,7 @@ fbsd_make_corefile_notes (bfd *obfd, int *note_size)
 
   if (get_exec_file (0))
     {
-      char *fname = strrchr (get_exec_file (0), '/') + 1;
+      char *fname = lbasename (get_exec_file (0));
       char *psargs = xstrdup (fname);
 
       if (get_inferior_args ())
index a60975c36acd15eb470af667984691722195715c..7f654afedd6718e539124281a05bce7df61d84b5 100644 (file)
@@ -584,14 +584,7 @@ info_checkpoints_command (char *arg, int from_tty)
 
       sal = find_pc_line (pc, 0);
       if (sal.symtab)
-       {
-         char *tmp = strrchr (sal.symtab->filename, '/');
-
-         if (tmp)
-           printf_filtered (_(", file %s"), tmp + 1);
-         else
-           printf_filtered (_(", file %s"), sal.symtab->filename);
-       }
+       printf_filtered (_(", file %s"), lbasename (sal.symtab->filename));
       if (sal.line)
        printf_filtered (_(", line %d"), sal.line);
       if (!sal.symtab && !sal.line)
index 922a2cf952441af04c01de3becdcc2cd3c12b686..732812d0a171790cfb4431a08e7aff5276b908e5 100644 (file)
@@ -4491,7 +4491,7 @@ linux_nat_make_corefile_notes (bfd *obfd, int *note_size)
 
   if (get_exec_file (0))
     {
-      strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname));
+      strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname));
       strncpy (psargs, get_exec_file (0), sizeof (psargs));
       if (get_inferior_args ())
        {
index 8497991f04aad83e04656d0e43c8734210cdc15d..4ae7f2793934db88a266ad644429721a972defb9 100644 (file)
@@ -198,12 +198,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
   const char *modified_name;
 
   if (sfile != NULL)
-    {
-      char *p = strrchr (sfile, '/');
-
-      if (p != NULL)
-       sfile = p + 1;
-    }
+    sfile = lbasename (sfile);
 
   /* For C++, canonicalize the input name.  */
   modified_name = name;
index 5858dc26eceb26d57017a812de1c0bd0716a2baa..23bbd3122b01fcbb14cb2859f69479b8a4532367 100644 (file)
@@ -127,13 +127,7 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
   sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
           arch_path);
 
-  /* Don't assume basename() isn't destructive.  */
-  base = strrchr (solib, '/');
-  if (!base)
-    base = solib;
-  else
-    base++;                    /* Skip over '/'.  */
-
+  base = lbasename (solib);
   ret = openp (buf, 1, base, o_flags, temp_pathname);
   if (ret < 0 && base != solib)
     {
index af0fbaa0c0ac87f5d3d63327845e8e3b11a1b8c5..5d7cb2395426aae54df761583c429399438a97ff 100644 (file)
@@ -5734,7 +5734,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
 
   if (get_exec_file (0))
     {
-      strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname));
+      strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname));
       strncpy (psargs, get_exec_file (0),
               sizeof (psargs));
 
index 5b110bdfaf73c500d350c080812b2da6f8eceda1..e7b73707b2fbc47c53c36ec40fd17c0ed78c8dfe 100644 (file)
@@ -324,20 +324,10 @@ tui_readline_output (int error, gdb_client_data data)
    final slash.  Otherwise, we return what we were passed.
 
    Comes from readline/complete.c.  */
-static char *
-printable_part (char *pathname)
+static const char *
+printable_part (const char *pathname)
 {
-  char *temp;
-
-  temp = rl_filename_completion_desired
-    ? strrchr (pathname, '/') : (char *)NULL;
-#if defined (__MSDOS__)
-  if (rl_filename_completion_desired 
-      && temp == 0 && isalpha (pathname[0]) 
-      && pathname[1] == ':')
-    temp = pathname + 1;
-#endif
-  return (temp ? ++temp : pathname);
+  return rl_filename_completion_desired ? lbasename (pathname) : pathname;
 }
 
 /* Output TO_PRINT to rl_outstream.  If VISIBLE_STATS is defined and
@@ -366,10 +356,10 @@ printable_part (char *pathname)
     } while (0)
 
 static int
-print_filename (char *to_print, char *full_pathname)
+print_filename (const char *to_print, const char *full_pathname)
 {
   int printed_len = 0;
-  char *s;
+  const char *s;
 
   for (s = to_print; *s; s++)
     {
@@ -416,7 +406,7 @@ tui_rl_display_match_list (char **matches, int len, int max)
   
   int count, limit, printed_len;
   int i, j, k, l;
-  char *temp;
+  const char *temp;
 
   /* Screen dimension correspond to the TUI command window.  */
   int screenwidth = TUI_CMD_WIN->generic.width;