public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 3/4] Constify skip_quoted
@ 2013-09-30 18:57 Keith Seitz
  2013-10-01  4:14 ` Sergio Durigan Junior
  2013-10-01 20:14 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Keith Seitz @ 2013-09-30 18:57 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

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}.

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.



[-- Attachment #2: constify-skip_quoted.patch --]
[-- Type: text/x-patch, Size: 2835 bytes --]

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)
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA 3/4] Constify skip_quoted
  2013-09-30 18:57 [RFA 3/4] Constify skip_quoted Keith Seitz
@ 2013-10-01  4:14 ` Sergio Durigan Junior
  2013-10-01 20:14 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Sergio Durigan Junior @ 2013-10-01  4:14 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches@sourceware.org ml

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA 3/4] Constify skip_quoted
  2013-09-30 18:57 [RFA 3/4] Constify skip_quoted Keith Seitz
  2013-10-01  4:14 ` Sergio Durigan Junior
@ 2013-10-01 20:14 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2013-10-01 20:14 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches@sourceware.org ml

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

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

I agree.

Keith> One interesting little tidbit that fell out of this: defs.h and
Keith> completer.h both declare this function. I've removed the duplicate
Keith> declaration from defs.h.

This is ok.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-01 20:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-30 18:57 [RFA 3/4] Constify skip_quoted Keith Seitz
2013-10-01  4:14 ` Sergio Durigan Junior
2013-10-01 20:14 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).