[RFA] Make word-break-characters language dependent (3/3)

Joel Brobecker brobecker@gnat.com
Thu Oct 2 05:47:00 GMT 2003


[Grrr, I just noticed the typo in the subject. I corrected it for this message]

This is the last patch of the series. My many thanks to Eli who
discussed this issue with me.

This time, I replaced all usage of gdb_completer_word_break_characters
and get_gdb_completer_word_break_characters mostly by a call to
the current_language la_word_break_characters function.

There is one instance in top.c where I used default_word_break_characters
instead of the language dependent one, because I wasn't completely sure
if the current language would be already set or not, and whether the
current language one was appropriate. I prefered to leave it the way it
is now, and deal with a potential latent bug later, rather than
introduce one...

Since the word_break_characters of all language without exception is
set to the default_word_break_characters, the is no behavior change.
Only when a language starts defining its own word_break_characters
(we will do that for Ada) can the completer code behavior be slightly
tuned.

2003-10-01  J. Brobecker  <brobecker@gnat.com>

        * completer.h (get_gdb_completer_word_break_characters): Delete.
        * completer.c: include language.h.
        (gdb_completer_word_break_characters): Delete.
        (get_gdb_completer_word_break_characters): Delete.
        (location_completer): Use the word break characters of the current
        language.
        (complete_line): Likewise.
        (line_completion_function): Likewise.
        (skip_quoted_chars): Likewise.
        * Makefile.in (completer.o): Add dependency on language.h.
        * top.c (init_main): Set the readline word break characters
        to GDB's default word break characters.

Tested on x86-linux, no regressions.

Ok to apply?

Thanks,
-- 
Joel
-------------- next part --------------
diff -up ../gdb.2/completer.h ./completer.h
--- ../gdb.2/completer.h	Wed Oct  1 16:54:45 2003
+++ ./completer.h	Thu Oct  2 00:43:41 2003
@@ -31,8 +31,6 @@ extern char **location_completer (char *
 
 extern char **command_completer (char *, char *);
 
-extern char *get_gdb_completer_word_break_characters (void); 
-
 extern char *get_gdb_completer_quote_characters (void);
 
 /* Exported to linespec.c */
diff -up ../gdb.2/completer.c ./completer.c
--- ../gdb.2/completer.c	Wed Oct  1 16:54:45 2003
+++ ./completer.c	Thu Oct  2 00:43:33 2003
@@ -23,6 +23,7 @@
 #include "gdbtypes.h"
 #include "expression.h"
 #include "filenames.h"		/* for DOSish file names */
+#include "language.h"
 
 #include "cli/cli-decode.h"
 
@@ -51,13 +52,11 @@ char *line_completion_function (const ch
    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
-   gdb_completer_word_break_characters and
+   current_language->la_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?).  */
 
 /* Variables which are necessary for fancy command line editing.  */
-static char *gdb_completer_word_break_characters =
-" \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
 
 /* When completing on command names, we remove '-' from the list of
    word break characters, since we use it in command names.  If the
@@ -91,12 +90,6 @@ static char *gdb_completer_quote_charact
 /* Accessor for some completer data that may interest other files. */
 
 char *
-get_gdb_completer_word_break_characters (void)
-{
-  return gdb_completer_word_break_characters;
-}
-
-char *
 get_gdb_completer_quote_characters (void)
 {
   return gdb_completer_quote_characters;
@@ -251,7 +244,7 @@ location_completer (char *text, char *wo
 	  colon = p;
 	  symbol_start = p + 1;
 	}
-      else if (strchr (gdb_completer_word_break_characters, *p))
+      else if (strchr (current_language->la_word_break_characters(), *p))
 	symbol_start = p + 1;
     }
 
@@ -399,7 +392,7 @@ complete_line (const char *text, char *l
      '-' character used in some commands.  */
 
   rl_completer_word_break_characters =
-    gdb_completer_word_break_characters;
+    current_language->la_word_break_characters();
 
       /* Decide whether to complete on a list of gdb commands or on symbols. */
   tmp_command = (char *) alloca (point + 1);
@@ -674,7 +667,7 @@ line_completion_function (const char *te
     /* Make sure the word break characters are set back to normal for the
        next time that readline tries to complete something.  */
     rl_completer_word_break_characters =
-      gdb_completer_word_break_characters;
+      current_language->la_word_break_characters();
 #endif
 
   return (output);
@@ -696,7 +689,7 @@ skip_quoted_chars (char *str, char *quot
     quotechars = gdb_completer_quote_characters;
 
   if (breakchars == NULL)
-    breakchars = gdb_completer_word_break_characters;
+    breakchars = current_language->la_word_break_characters();
 
   for (scan = str; *scan != '\0'; scan++)
     {
diff -up ../gdb.2/Makefile.in ./Makefile.in
--- ../gdb.2/Makefile.in	Wed Oct  1 16:54:44 2003
+++ ./Makefile.in	Thu Oct  2 00:37:10 2003
@@ -1639,7 +1639,8 @@ coff-solib.o: coff-solib.c $(defs_h) $(f
 complaints.o: complaints.c $(defs_h) $(complaints_h) $(gdb_assert_h) \
 	$(command_h) $(gdbcmd_h)
 completer.o: completer.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
-	$(filenames_h) $(cli_decode_h) $(gdbcmd_h) $(completer_h)
+	$(filenames_h) $(cli_decode_h) $(gdbcmd_h) $(completer_h) \
+	$(language_h)
 copying.o: copying.c $(defs_h) $(command_h) $(gdbcmd_h)
 core-aout.o: core-aout.c $(defs_h) $(gdbcore_h) $(value_h) $(regcache_h) \
 	$(gdb_dirent_h) $(gdb_stat_h)
diff -up ../gdb.2/top.c ./top.c
--- ../gdb.2/top.c	Wed Oct  1 16:54:52 2003
+++ ./top.c	Wed Oct  1 21:18:54 2003
@@ -1719,8 +1719,7 @@ init_main (void)
 
   /* Setup important stuff for command line editing.  */
   rl_completion_entry_function = readline_line_completion_function;
-  rl_completer_word_break_characters =
-				 get_gdb_completer_word_break_characters ();
+  rl_completer_word_break_characters = default_word_break_characters ();
   rl_completer_quote_characters = get_gdb_completer_quote_characters ();
   rl_readline_name = "gdb";
   rl_terminal_name = getenv ("TERM");


More information about the Gdb-patches mailing list