aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-12-10 14:47:18 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-12-11 22:10:50 +0000
commit44c77c32720c25f56a34ec4114c7addf5836ba97 (patch)
tree865794887de9bc0d9f95a885b35527d995ba1203 /gdb/cli
parent9ef6d4a1b48ea1f5693aa270b8b768146a31b9e9 (diff)
downloadgdb-44c77c32720c25f56a34ec4114c7addf5836ba97.zip
gdb-44c77c32720c25f56a34ec4114c7addf5836ba97.tar.gz
gdb-44c77c32720c25f56a34ec4114c7addf5836ba97.tar.bz2
gdb: make deprecated_cmd_warning i18n friendly
Rewrite deprecated_cmd_warning to be i18n friendly. While I'm going through the function I also cleaned up some whitespace issues, replaced uses of NULL with nullptr, and moved some comments to avoid having to add { ... }. Though the message being printed has a 'Warning: ' prefix I could have changed from using printf_filtered to use warning, however, I haven't done that in this commit as that would change what GDB outputs and I wanted this commit NOT to change the output. There should be no user visible changes after this commit. gdb/ChangeLog: * cli/cli-decode.c (deprecated_cmd_warning): Use nullptr instead of NULL. Don't print message piece by piece, but sentence at a time to allow internationalisation. Some whitespace cleanup.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index dc83f55..2ad7717 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1686,6 +1686,7 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
if (found->deprecated_warn_user && !lookup_for_completion_p)
deprecated_cmd_warning (line, clist);
+
/* Return the default_args of the alias, not the default_args
of the command it is pointing to. */
if (default_args != nullptr)
@@ -1899,59 +1900,57 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
void
deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
{
- struct cmd_list_element *alias = NULL;
- struct cmd_list_element *prefix_cmd = NULL;
- struct cmd_list_element *cmd = NULL;
+ struct cmd_list_element *alias = nullptr;
+ struct cmd_list_element *prefix_cmd = nullptr;
+ struct cmd_list_element *cmd = nullptr;
+ /* Return if text doesn't evaluate to a command. */
if (!lookup_cmd_composition_1 (text, &alias, &prefix_cmd, &cmd, list))
- /* Return if text doesn't evaluate to a command. */
return;
- if (!((alias ? alias->deprecated_warn_user : 0)
- || cmd->deprecated_warn_user) )
- /* Return if nothing is deprecated. */
+ /* Return if nothing is deprecated. */
+ if (!((alias != nullptr ? alias->deprecated_warn_user : 0)
+ || cmd->deprecated_warn_user))
return;
-
- printf_filtered ("Warning:");
-
- if (alias && !cmd->cmd_deprecated)
- printf_filtered (" '%s', an alias for the", alias->name);
-
- printf_filtered (" command '");
-
- if (prefix_cmd)
- printf_filtered ("%s", prefix_cmd->prefixname);
-
- printf_filtered ("%s", cmd->name);
-
- if (alias && cmd->cmd_deprecated)
- printf_filtered ("' (%s) is deprecated.\n", alias->name);
- else
- printf_filtered ("' is deprecated.\n");
-
- /* If it is only the alias that is deprecated, we want to indicate
- the new alias, otherwise we'll indicate the new command. */
+ /* Join command prefix (if any) and the command name. */
+ std::string tmp_cmd_str;
+ if (prefix_cmd != nullptr)
+ tmp_cmd_str += std::string (prefix_cmd->prefixname);
+ tmp_cmd_str += std::string (cmd->name);
- if (alias && !cmd->cmd_deprecated)
- {
- if (alias->replacement)
- printf_filtered ("Use '%s'.\n\n", alias->replacement);
- else
- printf_filtered ("No alternative known.\n\n");
- }
- else
+ /* Display the appropriate first line, this warns that the thing the user
+ entered is deprecated. */
+ if (alias != nullptr)
{
- if (cmd->replacement)
- printf_filtered ("Use '%s'.\n\n", cmd->replacement);
+ if (cmd->cmd_deprecated)
+ printf_filtered (_("Warning: command '%s' (%s) is deprecated.\n"),
+ tmp_cmd_str.c_str (), alias->name);
else
- printf_filtered ("No alternative known.\n\n");
+ printf_filtered (_("Warning: '%s', an alias for the command '%s' "
+ "is deprecated.\n"),
+ alias->name, tmp_cmd_str.c_str ());
}
+ else
+ printf_filtered (_("Warning: command '%s' is deprecated.\n"),
+ tmp_cmd_str.c_str ());
+
+ /* Now display a second line indicating what the user should use instead.
+ If it is only the alias that is deprecated, we want to indicate the
+ new alias, otherwise we'll indicate the new command. */
+ const char *replacement;
+ if (alias != nullptr && !cmd->cmd_deprecated)
+ replacement = alias->replacement;
+ else
+ replacement = cmd->replacement;
+ if (replacement != nullptr)
+ printf_filtered (_("Use '%s'.\n\n"), replacement);
+ else
+ printf_filtered (_("No alternative known.\n\n"));
/* We've warned you, now we'll keep quiet. */
- if (alias)
+ if (alias != nullptr)
alias->deprecated_warn_user = 0;
-
cmd->deprecated_warn_user = 0;
}