gdb: fix python/lib/gdb/__init__.py formatting
[deliverable/binutils-gdb.git] / gdb / source.c
index dc30dac6d78056a241d55f64285603b864f22185..c993e25a892e0abbcc1d87a4a0eb180b2bb75fd7 100644 (file)
@@ -342,8 +342,7 @@ select_source_symtab (struct symtab *s)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      if (objfile->sf)
-       s = objfile->sf->qf->find_last_source_symtab (objfile);
+      s = objfile->find_last_source_symtab ();
       if (s)
        new_symtab = s;
     }
@@ -417,8 +416,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile)
        }
     }
 
-  if (objfile->sf)
-    objfile->sf->qf->forget_cached_source_info (objfile);
+  objfile->forget_cached_source_info ();
 }
 
 /* See source.h.  */
@@ -539,6 +537,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
       /* On MS-DOS and MS-Windows, h:\ is different from h: */
             && !(p == name + 3 && name[1] == ':')              /* "d:/" */
 #endif
+            && p > name
             && IS_DIR_SEPARATOR (p[-1]))
        /* Sigh.  "foo/" => "foo" */
        --p;
@@ -572,6 +571,8 @@ add_path (const char *dirname, char **which_path, int parse_separators)
            break;
        }
 
+      if (name[0] == '\0')
+        goto skip_dup;
       if (name[0] == '~')
        new_name_holder.reset (tilde_expand (name));
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
@@ -1321,7 +1322,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
            uiout->field_string ("file", symtab_to_filename_for_display (s),
                                 file_name_style.style ());
          if (uiout->is_mi_like_p () || !uiout->test_flags (ui_source_list))
-           {
+           {
              const char *s_fullname = symtab_to_fullname (s);
              char *local_fullname;
 
@@ -1332,7 +1333,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
              strcpy (local_fullname, s_fullname);
 
              uiout->field_string ("fullname", local_fullname);
-           }
+           }
 
          uiout->text ("\n");
        }
@@ -1393,7 +1394,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
          if (iter > start)
            {
              std::string text (start, iter);
-             uiout->text (text.c_str ());
+             uiout->text (text);
            }
          if (*iter == '\r')
            {
@@ -1903,8 +1904,6 @@ void _initialize_source ();
 void
 _initialize_source ()
 {
-  struct cmd_list_element *c;
-
   init_source_path ();
 
   /* The intention is to use POSIX Basic Regular Expressions.
@@ -1913,7 +1912,8 @@ _initialize_source ()
      just an approximation.  */
   re_set_syntax (RE_SYNTAX_GREP);
 
-  c = add_cmd ("directory", class_files, directory_command, _("\
+  cmd_list_element *directory_cmd
+    = add_cmd ("directory", class_files, directory_command, _("\
 Add directory DIR to beginning of search path for source files.\n\
 Forget cached info on source file locations and line positions.\n\
 DIR can also be $cwd for the current working directory, or $cdir for the\n\
@@ -1922,9 +1922,9 @@ With no argument, reset the search path to $cdir:$cwd, the default."),
               &cmdlist);
 
   if (dbx_commands)
-    add_com_alias ("use", "directory", class_files, 0);
+    add_com_alias ("use", directory_cmd, class_files, 0);
 
-  set_cmd_completer (c, filename_completer);
+  set_cmd_completer (directory_cmd, filename_completer);
 
   add_setshow_optional_filename_cmd ("directories",
                                     class_files,
@@ -1958,16 +1958,18 @@ This sets the default address for \"x\" to the line's first instruction\n\
 so that \"x/i\" suffices to start examining the machine code.\n\
 The address is also stored as the value of \"$_\"."));
 
-  add_com ("forward-search", class_files, forward_search_command, _("\
+  cmd_list_element *forward_search_cmd
+    = add_com ("forward-search", class_files, forward_search_command, _("\
 Search for regular expression (see regex(3)) from last line listed.\n\
 The matching line number is also stored as the value of \"$_\"."));
-  add_com_alias ("search", "forward-search", class_files, 0);
-  add_com_alias ("fo", "forward-search", class_files, 1);
+  add_com_alias ("search", forward_search_cmd, class_files, 0);
+  add_com_alias ("fo", forward_search_cmd, class_files, 1);
 
-  add_com ("reverse-search", class_files, reverse_search_command, _("\
+  cmd_list_element *reverse_search_cmd
+    = add_com ("reverse-search", class_files, reverse_search_command, _("\
 Search backward for regular expression (see regex(3)) from last line listed.\n\
 The matching line number is also stored as the value of \"$_\"."));
-  add_com_alias ("rev", "reverse-search", class_files, 1);
+  add_com_alias ("rev", reverse_search_cmd, class_files, 1);
 
   add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\
 Set number of source lines gdb will list by default."), _("\
This page took 0.024932 seconds and 4 git commands to generate.