diff options
author | Pedro Alves <palves@redhat.com> | 2017-04-05 19:21:34 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-04-05 19:21:34 +0100 |
commit | 67cb5b2da285175d37782f3606992b8052234b00 (patch) | |
tree | 65d0d4fa604cbe93e9650687ee66f211353a89ae /gdb/language.h | |
parent | 7a1149643d8621541025e2c70e6391e901c8c7ef (diff) | |
download | gdb-67cb5b2da285175d37782f3606992b8052234b00.zip gdb-67cb5b2da285175d37782f3606992b8052234b00.tar.gz gdb-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/language.h')
-rw-r--r-- | gdb/language.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/language.h b/gdb/language.h index 3d21e4e..96080ac 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -321,7 +321,7 @@ struct language_defn char string_lower_bound; /* The list of characters forming word boundaries. */ - char *(*la_word_break_characters) (void); + const char *(*la_word_break_characters) (void); /* Should return a vector of all symbols which are possible completions for TEXT. WORD is the entire command on which the @@ -583,7 +583,7 @@ extern char *language_class_name_from_physname (const struct language_defn *, const char *physname); /* Splitting strings into words. */ -extern char *default_word_break_characters (void); +extern const char *default_word_break_characters (void); /* Print the index of an array element using the C99 syntax. */ extern void default_print_array_index (struct value *index_value, |