aboutsummaryrefslogtreecommitdiff
path: root/gdb/completer.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-04-05 19:21:34 +0100
committerPedro Alves <palves@redhat.com>2017-04-05 19:21:34 +0100
commit67cb5b2da285175d37782f3606992b8052234b00 (patch)
tree65d0d4fa604cbe93e9650687ee66f211353a89ae /gdb/completer.h
parent7a1149643d8621541025e2c70e6391e901c8c7ef (diff)
downloadbinutils-67cb5b2da285175d37782f3606992b8052234b00.zip
binutils-67cb5b2da285175d37782f3606992b8052234b00.tar.gz
binutils-67cb5b2da285175d37782f3606992b8052234b00.tar.bz2
-Wwrite-strings: Constify word break character arrays
-Wwrite-strings flags several cases of missing casts around initializations like: static char *gdb_completer_command_word_break_characters = " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,"; Obviously these could/should be const. However, while at it, there's no need for these variables to be pointers instead of arrays. They are never changed to point to anything else. Unfortunately, readline's rl_completer_word_break_characters is "char *", not "const char *". So we always need a cast somewhere. The approach taken here is to add a new set_rl_completer_word_break_characters function that becomes the only place that writes to rl_completer_word_break_characters, and thus the single place that needs the cast. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_completer_word_break_characters): Now a const array. (ada_get_gdb_completer_word_break_characters): Constify. * completer.c (gdb_completer_command_word_break_characters) (gdb_completer_file_name_break_characters) (gdb_completer_quote_characters): Now const arrays. (get_gdb_completer_quote_characters): Constify. (set_rl_completer_word_break_characters): New function. (set_gdb_completion_word_break_characters) (complete_line_internal): Use it. * completer.h (get_gdb_completer_quote_characters): Constify. (set_rl_completer_word_break_characters): Declare. * f-lang.c (f_word_break_characters): Constify. * language.c (default_word_break_characters): Constify. * language.h (language_defn::la_word_break_characters): Constify. (default_word_break_characters): Constify. * top.c (init_main): Use set_rl_completer_word_break_characters.
Diffstat (limited to 'gdb/completer.h')
-rw-r--r--gdb/completer.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/gdb/completer.h b/gdb/completer.h
index 416b313..2aa1987 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -99,10 +99,16 @@ extern VEC (char_ptr) *reg_or_group_completer (struct cmd_list_element *,
extern VEC (char_ptr) *reggroup_completer (struct cmd_list_element *,
const char *, const char *);
-extern char *get_gdb_completer_quote_characters (void);
+extern const char *get_gdb_completer_quote_characters (void);
extern char *gdb_completion_word_break_characters (void);
+/* Set the word break characters array to BREAK_CHARS. This function
+ is useful as const-correct alternative to direct assignment to
+ rl_completer_word_break_characters, which is "char *",
+ not "const char *". */
+extern void set_rl_completer_word_break_characters (const char *break_chars);
+
/* Set the word break characters array to the corresponding set of
chars, based on FN. This function is useful for cases when the
completer doesn't know the type of the completion until some