This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 3/4] Constify skip_quoted


On Monday, September 30 2013, Keith Seitz wrote:

> Hi,
>
> This third patch offers up a const version of skip_quoted. It's only
> ever really used as const, so it was easy to clean-up all the
> callers. IMO, we don't need to worry (yet?) about skip_quoted_const
> like we do with skip_spaces{,_const}.

Looks good too, but I can't approve it.

Thanks!

> One interesting little tidbit that fell out of this: defs.h and
> completer.h both declare this function. I've removed the duplicate
> declaration from defs.h.
>
> Tested, blah, blah. You know the spiel.
>
> Keith
>
> ChangeLog
> 2013-09-24  Keith Seitz  <keiths@redhat.com>
>
> 	* completer.c (skip_quoted_chars): Make all arguments const.
> 	Return const.
> 	(skip_quoted): Likewise.
> 	* completer.h (skip_quoted_chars): Likewise.
> 	(skip_quoted): Likewise.
> 	* defs.h (skip_quoted): Remove duplicate declaration.
> 	* jv-exp.y: Include completer.h.
> 	(yylex): Remove unneccessary cast to char * fro skip_quoted.
> 	* p-exp.y: Include completer.h.
> diff --git a/gdb/completer.c b/gdb/completer.c
> index e132651..91bf812 100644
> --- a/gdb/completer.c
> +++ b/gdb/completer.c
> @@ -911,11 +911,12 @@ line_completion_function (const char *text, int matches,
>     QUOTECHARS or BREAKCHARS is NULL, use the same values used by the
>     completer.  */
>  
> -char *
> -skip_quoted_chars (char *str, char *quotechars, char *breakchars)
> +const char *
> +skip_quoted_chars (const char *str, const char *quotechars,
> +		   const char *breakchars)
>  {
>    char quote_char = '\0';
> -  char *scan;
> +  const char *scan;
>  
>    if (quotechars == NULL)
>      quotechars = gdb_completer_quote_characters;
> @@ -953,8 +954,8 @@ skip_quoted_chars (char *str, char *quotechars, char *breakchars)
>     characters and word break characters used by the completer).
>     Returns pointer to the location after the "word".  */
>  
> -char *
> -skip_quoted (char *str)
> +const char *
> +skip_quoted (const char *str)
>  {
>    return skip_quoted_chars (str, NULL, NULL);
>  }
> diff --git a/gdb/completer.h b/gdb/completer.h
> index d6090f4..97eb9dd 100644
> --- a/gdb/completer.h
> +++ b/gdb/completer.h
> @@ -50,8 +50,9 @@ extern char *gdb_completion_word_break_characters (void);
>  
>  /* Exported to linespec.c */
>  
> -extern char *skip_quoted_chars (char *, char *, char *);
> +extern const char *skip_quoted_chars (const char *, const char *,
> +				      const char *);
>  
> -extern char *skip_quoted (char *);
> +extern const char *skip_quoted (const char *);
>  
>  #endif /* defined (COMPLETER_H) */
> diff --git a/gdb/defs.h b/gdb/defs.h
> index 50b9bfe..0b36b44 100644
> --- a/gdb/defs.h
> +++ b/gdb/defs.h
> @@ -311,8 +311,6 @@ extern void print_transfer_performance (struct ui_file *stream,
>  
>  typedef void initialize_file_ftype (void);
>  
> -extern char *skip_quoted (char *);
> -
>  extern char *gdb_readline (char *);
>  
>  extern char *gdb_readline_wrapper (char *);
> diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
> index a9ad4d9..2c5154e 100644
> --- a/gdb/jv-exp.y
> +++ b/gdb/jv-exp.y
> @@ -47,6 +47,7 @@
>  #include "symfile.h" /* Required by objfiles.h.  */
>  #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
>  #include "block.h"
> +#include "completer.h"
>  
>  #define parse_type builtin_type (parse_gdbarch)
>  #define parse_java_type builtin_java_type (parse_gdbarch)
> @@ -918,7 +919,7 @@ yylex (void)
>        c = *lexptr++;
>        if (c != '\'')
>  	{
> -	  namelen = skip_quoted ((char *) tokstart) - tokstart;
> +	  namelen = skip_quoted (tokstart) - tokstart;
>  	  if (namelen > 2)
>  	    {
>  	      lexptr = tokstart + namelen;
> diff --git a/gdb/p-exp.y b/gdb/p-exp.y
> index ca25393..de14cbb 100644
> --- a/gdb/p-exp.y
> +++ b/gdb/p-exp.y
> @@ -55,6 +55,7 @@
>  #include "symfile.h" /* Required by objfiles.h.  */
>  #include "objfiles.h" /* For have_full_symbols and have_partial_symbols.  */
>  #include "block.h"
> +#include "completer.h"
>  
>  #define parse_type builtin_type (parse_gdbarch)

-- 
Sergio


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]