gdb_rl_find_completion_word: Remove 'found_quote' local

Compiling GDB with current git Clang (future 13) runs into this:

 src/gdb/completer.c:287:18: error: variable 'found_quote' set but not used [-Werror,-Wunused-but-set-variable]
   int scan, end, found_quote, delimiter, pass_next, isbrk;
		  ^

gdb_rl_find_completion_word came to life as a modified (stripped down)
version of readline's internal _rl_find_completion_word function.
When I added it, I don't remember whether I realized that
'found_quote' wasn't really necessary.  Maybe I kept it thinking of
keeping the source code in sync with readline?  I don't recall
anymore.  Since the function is already stripped down compared to the
original, stripping it down some more doesn't hurt.

So fix the issue by removing the unnecessary code.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

	* completer.c (RL_QF_SINGLE_QUOTE, RL_QF_DOUBLE_QUOTE)
	(RL_QF_BACKSLASH, RL_QF_OTHER_QUOTE): Delete.
	(gdb_rl_find_completion_word): Remove write-only 'found_quote'
	local.
This commit is contained in:
Pedro Alves
2021-06-07 23:36:05 +01:00
parent c57eb1a269
commit fa6ec8efa4
2 changed files with 9 additions and 20 deletions

View File

@ -1,3 +1,10 @@
2021-06-07 Pedro Alves <pedro@palves.net>
* completer.c (RL_QF_SINGLE_QUOTE, RL_QF_DOUBLE_QUOTE)
(RL_QF_BACKSLASH, RL_QF_OTHER_QUOTE): Delete.
(gdb_rl_find_completion_word): Remove write-only 'found_quote'
local.
2021-06-07 Pedro Alves <pedro@palves.net> 2021-06-07 Pedro Alves <pedro@palves.net>
* nat/amd64-linux-siginfo.c (union nat_sigval): Rename to ... * nat/amd64-linux-siginfo.c (union nat_sigval): Rename to ...

View File

@ -250,14 +250,6 @@ filename_completer_handle_brkchars (struct cmd_list_element *ignore,
(gdb_completer_file_name_break_characters); (gdb_completer_file_name_break_characters);
} }
/* Possible values for the found_quote flags word used by the completion
functions. It says what kind of (shell-like) quoting we found anywhere
in the line. */
#define RL_QF_SINGLE_QUOTE 0x01
#define RL_QF_DOUBLE_QUOTE 0x02
#define RL_QF_BACKSLASH 0x04
#define RL_QF_OTHER_QUOTE 0x08
/* Find the bounds of the current word for completion purposes, and /* Find the bounds of the current word for completion purposes, and
return a pointer to the end of the word. This mimics (and is a return a pointer to the end of the word. This mimics (and is a
modified version of) readline's _rl_find_completion_word internal modified version of) readline's _rl_find_completion_word internal
@ -284,7 +276,7 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info,
int *qc, int *dp, int *qc, int *dp,
const char *line_buffer) const char *line_buffer)
{ {
int scan, end, found_quote, delimiter, pass_next, isbrk; int scan, end, delimiter, pass_next, isbrk;
char quote_char; char quote_char;
const char *brkchars; const char *brkchars;
int point = strlen (line_buffer); int point = strlen (line_buffer);
@ -301,7 +293,7 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info,
} }
end = point; end = point;
found_quote = delimiter = 0; delimiter = 0;
quote_char = '\0'; quote_char = '\0';
brkchars = info->word_break_characters; brkchars = info->word_break_characters;
@ -311,8 +303,6 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info,
/* We have a list of characters which can be used in pairs to /* We have a list of characters which can be used in pairs to
quote substrings for the completer. Try to find the start of quote substrings for the completer. Try to find the start of
an unclosed quoted substring. */ an unclosed quoted substring. */
/* FOUND_QUOTE is set so we know what kind of quotes we
found. */
for (scan = pass_next = 0; for (scan = pass_next = 0;
scan < end; scan < end;
scan++) scan++)
@ -330,7 +320,6 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info,
if (quote_char != '\'' && line_buffer[scan] == '\\') if (quote_char != '\'' && line_buffer[scan] == '\\')
{ {
pass_next = 1; pass_next = 1;
found_quote |= RL_QF_BACKSLASH;
continue; continue;
} }
@ -351,13 +340,6 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info,
/* Found start of a quoted substring. */ /* Found start of a quoted substring. */
quote_char = line_buffer[scan]; quote_char = line_buffer[scan];
point = scan + 1; point = scan + 1;
/* Shell-like quoting conventions. */
if (quote_char == '\'')
found_quote |= RL_QF_SINGLE_QUOTE;
else if (quote_char == '"')
found_quote |= RL_QF_DOUBLE_QUOTE;
else
found_quote |= RL_QF_OTHER_QUOTE;
} }
} }
} }