[1/7] Change completion_tracker to use char type

Message ID 20180808232016.12777-2-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Aug. 8, 2018, 11:20 p.m. UTC
  This changes completion_tracker to use the char type for the quote
char.  This avoids some narrowing warnings at the places where
quote_char() is called.

gdb/ChangeLog
2018-08-08  Tom Tromey  <tom@tromey.com>

	* completer.h (completion_tracker::set_quote_char): Change
	parameter type to "char".
	(completion_tracker::quote_char): Return "char".  Now const.
	(completion_tracker::m_quote_char): Now "char".
---
 gdb/ChangeLog   | 7 +++++++
 gdb/completer.h | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)
  

Comments

Pedro Alves Aug. 9, 2018, 5:38 p.m. UTC | #1
On 08/09/2018 12:20 AM, Tom Tromey wrote:
> This changes completion_tracker to use the char type for the quote
> char.  This avoids some narrowing warnings at the places where
> quote_char() is called.

See comment about use of int vs char here:

 https://sourceware.org/ml/gdb-patches/2017-07/msg00228.html

Look for "Why int".

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/completer.h b/gdb/completer.h
index 2bdfa26f6c..9f10bf0ea8 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -329,13 +329,13 @@  public:
   /* Set the quote char to be appended after a unique completion is
      added to the input line.  Set to '\0' to clear.  See
      m_quote_char's description.  */
-  void set_quote_char (int quote_char)
+  void set_quote_char (char quote_char)
   { m_quote_char = quote_char; }
 
   /* The quote char to be appended after a unique completion is added
      to the input line.  Returns '\0' if no quote char has been set.
      See m_quote_char's description.  */
-  int quote_char () { return m_quote_char; }
+  char quote_char () const { return m_quote_char; }
 
   /* Tell the tracker that the current completer wants to provide a
      custom word point instead of a list of a break chars, in the
@@ -450,7 +450,7 @@  private:
       before tab: "b 'function("
       after tab:  "b 'function()' "
   */
-  int m_quote_char = '\0';
+  char m_quote_char = '\0';
 
   /* If true, the completer has its own idea of "word" point, and
      doesn't want to rely on readline computing it based on brkchars.