From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20312 invoked by alias); 5 Apr 2017 08:46:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20289 invoked by uid 89); 5 Apr 2017 08:46:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Apr 2017 08:46:42 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v358hdK2144857 for ; Wed, 5 Apr 2017 04:46:42 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 29mvr41m4c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 05 Apr 2017 04:46:41 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Apr 2017 09:46:38 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 5 Apr 2017 09:46:36 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v358kZUU13369624; Wed, 5 Apr 2017 08:46:35 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3915FAE045; Wed, 5 Apr 2017 09:45:44 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D7A6AE058; Wed, 5 Apr 2017 09:45:44 +0100 (BST) Received: from ThinkPad (unknown [9.152.212.148]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Apr 2017 09:45:44 +0100 (BST) Date: Wed, 05 Apr 2017 08:46:00 -0000 From: Philipp Rudo To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 07/18] -Wwrite-strings: Constify work break character arrays In-Reply-To: <1491326751-16180-8-git-send-email-palves@redhat.com> References: <1491326751-16180-1-git-send-email-palves@redhat.com> <1491326751-16180-8-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 17040508-0016-0000-0000-00000471C5BB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040508-0017-0000-0000-0000271C8558 Message-Id: <20170405104634.20a5a437@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-05_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704050078 X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00081.txt.bz2 Hi Pedro great series. Just one minor thing I noticed here. On Tue, 4 Apr 2017 18:25:40 +0100 Pedro Alves wrote: [...] > diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c > index 9b91e0c..d31e058 100644 > --- a/gdb/ada-lang.c > +++ b/gdb/ada-lang.c > @@ -317,7 +317,7 @@ static unsigned int varsize_limit; >=20 > /* 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 =3D > +static const char ada_completer_word_break_characters[] =3D > #ifdef VMS > " \t\n!@#%^&*()+=3D|~`}{[]\";:?/,-"; > #else The comment above doesn't make sense, especially after your change. I think it should be removed.=20 Philipp > @@ -558,7 +558,7 @@ add_angle_brackets (const char *str) > return result; > } >=20 > -static char * > +static const char * > ada_get_gdb_completer_word_break_characters (void) > { > return ada_completer_word_break_characters; > diff --git a/gdb/completer.c b/gdb/completer.c > index 45adc62..9183e2a 100644 > --- a/gdb/completer.c > +++ b/gdb/completer.c > @@ -84,29 +84,30 @@ char *line_completion_function (const char *text, > int matches, readline library sees one in any of the current > completion strings, it thinks that the string needs to be quoted and > automatically supplies a leading quote. */ > -static char *gdb_completer_command_word_break_characters =3D > +static const char gdb_completer_command_word_break_characters[] =3D > " \t\n!@#$%^&*()+=3D|~`}{[]\"';:?/>.<,"; >=20 > /* When completing on file names, we remove from the list of word > break characters any characters that are commonly used in file > names, such as '-', '+', '~', etc. Otherwise, readline displays > incorrect completion candidates. */ > -#ifdef HAVE_DOS_BASED_FILE_SYSTEM > /* MS-DOS and MS-Windows use colon as part of the drive spec, and > most programs support @foo style response files. */ > -static char *gdb_completer_file_name_break_characters =3D " > \t\n*|\"';?><@"; +static const char > gdb_completer_file_name_break_characters[] =3D +#ifdef > HAVE_DOS_BASED_FILE_SYSTEM > + " \t\n*|\"';?><@"; > #else > -static char *gdb_completer_file_name_break_characters =3D " > \t\n*|\"';:?><"; > + " \t\n*|\"';:?><"; > #endif >=20 > /* Characters that can be used to quote completion strings. Note > that we can't include '"' because the gdb C parser treats such quoted > sequences as strings. */ > -static char *gdb_completer_quote_characters =3D "'"; > +static const char gdb_completer_quote_characters[] =3D "'"; > =0C > /* Accessor for some completer data that may interest other files. > */ >=20 > -char * > +const char * > get_gdb_completer_quote_characters (void) > { > return gdb_completer_quote_characters; > @@ -652,16 +653,26 @@ expression_completer (struct cmd_list_element > *ignore, /* See definition in completer.h. */ >=20 > void > +set_rl_completer_word_break_characters (const char *break_chars) > +{ > + rl_completer_word_break_characters =3D (char *) break_chars; > +} > + > +/* See definition in completer.h. */ > + > +void > set_gdb_completion_word_break_characters (completer_ftype *fn) > { > + const char *break_chars; > + > /* So far we are only interested in differentiating filename > completers from everything else. */ > if (fn =3D=3D filename_completer) > - rl_completer_word_break_characters > - =3D gdb_completer_file_name_break_characters; > + break_chars =3D gdb_completer_file_name_break_characters; > else > - rl_completer_word_break_characters > - =3D gdb_completer_command_word_break_characters; > + break_chars =3D gdb_completer_command_word_break_characters; > + > + set_rl_completer_word_break_characters (break_chars); > } >=20 > /* Here are some useful test cases for completion. FIXME: These > @@ -743,8 +754,8 @@ complete_line_internal (const char *text, > then we will switch to the special word break set for command > strings, which leaves out the '-' character used in some > commands. */ > - rl_completer_word_break_characters =3D > - current_language->la_word_break_characters(); > + set_rl_completer_word_break_characters > + (current_language->la_word_break_characters()); >=20 > /* Decide whether to complete on a list of gdb commands or on > symbols. */ > @@ -821,8 +832,8 @@ complete_line_internal (const char *text, > } > /* Ensure that readline does the right thing with respect > to inserting quotes. */ > - rl_completer_word_break_characters =3D > - gdb_completer_command_word_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_command_word_break_characters); > } > } > else > @@ -848,8 +859,8 @@ complete_line_internal (const char *text, >=20 > /* Ensure that readline does the right thing > with respect to inserting quotes. */ > - rl_completer_word_break_characters =3D > - gdb_completer_command_word_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_command_word_break_characters); > } > else if (reason =3D=3D handle_help) > list =3D NULL; > @@ -857,8 +868,8 @@ complete_line_internal (const char *text, > { > if (reason !=3D handle_brkchars) > list =3D complete_on_enum (c->enums, p, word); > - rl_completer_word_break_characters =3D > - gdb_completer_command_word_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_command_word_break_characters); > } > else > { > @@ -879,8 +890,8 @@ complete_line_internal (const char *text, > && strchr > (gdb_completer_file_name_break_characters, p[-1]) =3D=3D NULL; p--) > ; > - rl_completer_word_break_characters =3D > - gdb_completer_file_name_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_file_name_break_characters); > } > if (reason =3D=3D handle_brkchars > && c->completer_handle_brkchars !=3D NULL) > @@ -913,8 +924,8 @@ complete_line_internal (const char *text, >=20 > /* Ensure that readline does the right thing > with respect to inserting quotes. */ > - rl_completer_word_break_characters =3D > - gdb_completer_command_word_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_command_word_break_characters); > } > } > else if (reason =3D=3D handle_help) > @@ -947,8 +958,8 @@ complete_line_internal (const char *text, > p[-1]) =3D=3D NULL; > p--) > ; > - rl_completer_word_break_characters =3D > - gdb_completer_file_name_break_characters; > + set_rl_completer_word_break_characters > + (gdb_completer_file_name_break_characters); > } > if (reason =3D=3D handle_brkchars > && c->completer_handle_brkchars !=3D NULL) > 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 *); >=20 > -extern char *get_gdb_completer_quote_characters (void); > +extern const char *get_gdb_completer_quote_characters (void); >=20 > extern char *gdb_completion_word_break_characters (void); >=20 > +/* 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 > diff --git a/gdb/f-lang.c b/gdb/f-lang.c > index 8aba5ef..3c30d75 100644 > --- a/gdb/f-lang.c > +++ b/gdb/f-lang.c > @@ -203,7 +203,7 @@ f_language_arch_info (struct gdbarch *gdbarch, >=20 > /* Remove the modules separator :: from the default break list. */ >=20 > -static char * > +static const char * > f_word_break_characters (void) > { > static char *retval; > diff --git a/gdb/language.c b/gdb/language.c > index 119c07e..f1fc220 100644 > --- a/gdb/language.c > +++ b/gdb/language.c > @@ -698,7 +698,7 @@ default_pass_by_reference (struct type *type) > delimiting words. This is a reasonable default value that > most languages should be able to use. */ >=20 > -char * > +const char * > default_word_break_characters (void) > { > return " \t\n!@#$%^&*()+=3D|~`}{[]\"';:?/>.<,-"; > 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; >=20 > /* The list of characters forming word boundaries. */ > - char *(*la_word_break_characters) (void); > + const char *(*la_word_break_characters) (void); >=20 > /* 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); >=20 > /* Splitting strings into words. */ > -extern char *default_word_break_characters (void); > +extern const char *default_word_break_characters (void); >=20 > /* Print the index of an array element using the C99 syntax. */ > extern void default_print_array_index (struct value *index_value, > diff --git a/gdb/top.c b/gdb/top.c > index 295b680..4a22be1 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -2022,7 +2022,7 @@ init_main (void) > /* Setup important stuff for command line editing. */ > rl_completion_word_break_hook =3D > gdb_completion_word_break_characters; rl_completion_entry_function =3D > readline_line_completion_function; > - rl_completer_word_break_characters =3D default_word_break_characters > (); > + set_rl_completer_word_break_characters > (default_word_break_characters ()); rl_completer_quote_characters =3D > get_gdb_completer_quote_characters (); > rl_completion_display_matches_hook =3D cli_display_match_list; > rl_readline_name =3D "gdb";