Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / gdb / completer.c
index bc0501abf0a79f8b96a5f7faef782ff67af16f8e..7d26774e851f95a573018f7b4d418ad894a48d89 100644 (file)
@@ -31,7 +31,6 @@
 #include <algorithm>
 #include "linespec.h"
 #include "cli/cli-decode.h"
-#include "cli/cli-style.h"
 
 /* FIXME: This is needed because of lookup_cmd_1 ().  We should be
    calling a hook instead so we eliminate the CLI dependency.  */
@@ -156,7 +155,7 @@ enum explicit_location_match_type
    but it does affect how much stuff M-? lists.
    (2) If one of the matches contains a word break character, readline
    will quote it.  That's why we switch between
-   current_language->la_word_break_characters() and
+   current_language->word_break_characters () and
    gdb_completer_command_word_break_characters.  I'm not sure when
    we need this behavior (perhaps for funky characters in C++ 
    symbols?).  */
@@ -449,7 +448,7 @@ const char *
 advance_to_expression_complete_word_point (completion_tracker &tracker,
                                           const char *text)
 {
-  const char *brk_chars = current_language->la_word_break_characters ();
+  const char *brk_chars = current_language->word_break_characters ();
   return advance_to_completion_word (tracker, brk_chars, text);
 }
 
@@ -574,7 +573,7 @@ complete_files_symbols (completion_tracker &tracker,
          colon = p;
          symbol_start = p + 1;
        }
-      else if (strchr (current_language->la_word_break_characters(), *p))
+      else if (strchr (current_language->word_break_characters (), *p))
        symbol_start = p + 1;
     }
 
@@ -1104,10 +1103,10 @@ add_struct_fields (struct type *type, completion_list &output,
                             fieldname, namelen))
                output.emplace_back (xstrdup (TYPE_FIELD_NAME (type, i)));
            }
-         else if (TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_UNION)
+         else if (type->field (i).type ()->code () == TYPE_CODE_UNION)
            {
              /* Recurse into anonymous unions.  */
-             add_struct_fields (TYPE_FIELD_TYPE (type, i),
+             add_struct_fields (type->field (i).type (),
                                 output, fieldname, namelen);
            }
        }
@@ -1349,7 +1348,7 @@ complete_line_internal_1 (completion_tracker &tracker,
      strings, which leaves out the '-' and '.' character used in some
      commands.  */
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters());
+    (current_language->word_break_characters ());
 
   /* Decide whether to complete on a list of gdb commands or on
      symbols.  */
@@ -1386,7 +1385,7 @@ complete_line_internal_1 (completion_tracker &tracker,
     }
   else
     {
-      c = lookup_cmd_1 (&p, cmdlist, &result_list, ignore_help_classes);
+      c = lookup_cmd_1 (&p, cmdlist, &result_list, NULL, ignore_help_classes);
     }
 
   /* Move p up to the next interesting thing.  */
@@ -1965,7 +1964,7 @@ default_completer_handle_brkchars (struct cmd_list_element *ignore,
                                   const char *text, const char *word)
 {
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters ());
+    (current_language->word_break_characters ());
 }
 
 /* See definition in completer.h.  */
@@ -2474,7 +2473,7 @@ skip_quoted_chars (const char *str, const char *quotechars,
     quotechars = gdb_completer_quote_characters;
 
   if (breakchars == NULL)
-    breakchars = current_language->la_word_break_characters();
+    breakchars = current_language->word_break_characters ();
 
   for (scan = str; *scan != '\0'; scan++)
     {
@@ -2715,8 +2714,6 @@ gdb_fnwidth (const char *string)
   return width;
 }
 
-extern int _rl_completion_prefix_display_length;
-
 /* Print TO_PRINT, one matching completion.
    PREFIX_BYTES is number of common prefix bytes.
    Based on readline/complete.c:fnprint.  */
@@ -2725,7 +2722,7 @@ static int
 gdb_fnprint (const char *to_print, int prefix_bytes,
             const struct match_list_displayer *displayer)
 {
-  int common_prefix_len, printed_len, w;
+  int printed_len, w;
   const char *s;
 #if defined (HANDLE_MULTIBYTE)
   mbstate_t ps;
@@ -2738,18 +2735,14 @@ gdb_fnprint (const char *to_print, int prefix_bytes,
   memset (&ps, 0, sizeof (mbstate_t));
 #endif
 
-  printed_len = common_prefix_len = 0;
+  printed_len = 0;
 
   /* Don't print only the ellipsis if the common prefix is one of the
      possible completions */
   if (to_print[prefix_bytes] == '\0')
     prefix_bytes = 0;
 
-  ui_file_style style = completion_prefix_style.style ();
-  if (!style.is_default ())
-    displayer->puts (displayer, style.to_ansi ().c_str ());
-
-  if (prefix_bytes && _rl_completion_prefix_display_length > 0)
+  if (prefix_bytes)
     {
       char ellipsis;
 
@@ -2758,16 +2751,6 @@ gdb_fnprint (const char *to_print, int prefix_bytes,
        displayer->putch (displayer, ellipsis);
       printed_len = ELLIPSIS_LEN;
     }
-  else if (prefix_bytes && !style.is_default ())
-    {
-      common_prefix_len = prefix_bytes;
-      prefix_bytes = 0;
-    }
-
-  /* There are 3 states: the initial state (#0), when we use the
-     prefix style; the difference state (#1), which lasts a single
-     character; and then the suffix state (#2).  */
-  int state = 0;
 
   s = to_print + prefix_bytes;
   while (*s)
@@ -2819,31 +2802,8 @@ gdb_fnprint (const char *to_print, int prefix_bytes,
          printed_len++;
 #endif
        }
-      if (common_prefix_len > 0 && (s - to_print) >= common_prefix_len)
-       {
-         if (!style.is_default ())
-           displayer->puts (displayer, ui_file_style ().to_ansi ().c_str ());
-
-         ++state;
-         if (state == 1)
-           {
-             common_prefix_len = 1;
-             style = completion_difference_style.style ();
-           }
-         else
-           {
-             common_prefix_len = 0;
-             style = completion_suffix_style.style ();
-           }
-
-         if (!style.is_default ())
-           displayer->puts (displayer, style.to_ansi ().c_str ());
-       }
     }
 
-  if (!style.is_default ())
-    displayer->puts (displayer, ui_file_style ().to_ansi ().c_str ());
-
   return printed_len;
 }
 
@@ -2952,6 +2912,7 @@ gdb_complete_get_screenwidth (const struct match_list_displayer *displayer)
   return displayer->width;
 }
 
+extern int _rl_completion_prefix_display_length;
 extern int _rl_print_completions_horizontally;
 
 EXTERN_C int _rl_qsort_string_compare (const void *, const void *);
@@ -2970,23 +2931,19 @@ gdb_display_match_list_1 (char **matches, int len, int max,
   char *temp, *t;
   int page_completions = displayer->height != INT_MAX && pagination_enabled;
 
-  bool want_style = !completion_prefix_style.style ().is_default ();
-
   /* Find the length of the prefix common to all items: length as displayed
      characters (common_length) and as a byte index into the matches (sind) */
   common_length = sind = 0;
-  if (_rl_completion_prefix_display_length > 0 || want_style)
+  if (_rl_completion_prefix_display_length > 0)
     {
       t = gdb_printable_part (matches[0]);
       temp = strrchr (t, '/');
       common_length = temp ? gdb_fnwidth (temp) : gdb_fnwidth (t);
       sind = temp ? strlen (temp) : strlen (t);
 
-      if (_rl_completion_prefix_display_length > 0
-         && common_length > _rl_completion_prefix_display_length
-         && common_length > ELLIPSIS_LEN)
+      if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
        max -= common_length - ELLIPSIS_LEN;
-      else if (!want_style || common_length > max || sind > max)
+      else
        common_length = sind = 0;
     }
 
This page took 0.037176 seconds and 4 git commands to generate.