mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-03 21:34:46 +08:00
-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.
This commit is contained in:
@ -315,9 +315,7 @@ static void ada_free_symbol_cache (struct ada_symbol_cache *sym_cache);
|
||||
/* Maximum-sized dynamic type. */
|
||||
static unsigned int varsize_limit;
|
||||
|
||||
/* FIXME: brobecker/2003-09-17: No longer a const because it is
|
||||
returned by a function that does not return a const char *. */
|
||||
static char *ada_completer_word_break_characters =
|
||||
static const char ada_completer_word_break_characters[] =
|
||||
#ifdef VMS
|
||||
" \t\n!@#%^&*()+=|~`}{[]\";:?/,-";
|
||||
#else
|
||||
@ -558,7 +556,7 @@ add_angle_brackets (const char *str)
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
ada_get_gdb_completer_word_break_characters (void)
|
||||
{
|
||||
return ada_completer_word_break_characters;
|
||||
|
Reference in New Issue
Block a user