public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Highlight deprecated commands using title style
@ 2020-12-14 16:02 Tom Tromey
  2020-12-15  9:57 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2020-12-14 16:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

After Andrew's latest patch, I noticed that the deprecation warnings
could use the (so-called) title style when printing command names.
This patch implements this idea.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* cli/cli-decode.c (deprecated_cmd_warning): Use title style for
	command names.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* gdb.base/style.exp: Add deprecation tests.
---
 gdb/ChangeLog                    |  5 +++++
 gdb/cli/cli-decode.c             | 23 ++++++++++++++++-------
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.base/style.exp |  7 +++++++
 4 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 13260ac44e6..fb2856d4333 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1939,16 +1939,23 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
       tmp_alias_str += std::string (alias->name);
 
       if (cmd->cmd_deprecated)
-	printf_filtered (_("Warning: command '%s' (%s) is deprecated.\n"),
-			 tmp_cmd_str.c_str (), tmp_alias_str.c_str ());
+	printf_filtered (_("Warning: command '%ps' (%ps) is deprecated.\n"),
+			 styled_string (title_style.style (),
+					tmp_cmd_str.c_str ()),
+			 styled_string (title_style.style (),
+					tmp_alias_str.c_str ()));
       else
-	printf_filtered (_("Warning: '%s', an alias for the command '%s', "
+	printf_filtered (_("Warning: '%ps', an alias for the command '%ps', "
 			   "is deprecated.\n"),
-			 tmp_alias_str.c_str (), tmp_cmd_str.c_str ());
+			 styled_string (title_style.style (),
+					tmp_alias_str.c_str ()),
+			 styled_string (title_style.style (),
+					tmp_cmd_str.c_str ()));
     }
   else
-    printf_filtered (_("Warning: command '%s' is deprecated.\n"),
-		     tmp_cmd_str.c_str ());
+    printf_filtered (_("Warning: command '%ps' is deprecated.\n"),
+		     styled_string (title_style.style (),
+				    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
@@ -1959,7 +1966,9 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
   else
     replacement = cmd->replacement;
   if (replacement != nullptr)
-    printf_filtered (_("Use '%s'.\n\n"), replacement);
+    printf_filtered (_("Use '%ps'.\n\n"),
+		     styled_string (title_style.style (),
+				    replacement));
   else
     printf_filtered (_("No alternative known.\n\n"));
 
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 28c270591ba..8d7eaa80b63 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -172,4 +172,11 @@ save_vars { env(TERM) } {
 	"warning: [style .*? file] is not a directory\\..*"
     gdb_test "show data-directory" \
 	"GDB's data directory is \"[style .*? file]\"\\..*"
+
+    # Check that deprecation styles command names.
+    gdb_test_no_output "maintenance deprecate p \"new_p\"" \
+	"maintenance deprecate p \"new_p\" /1/"
+    gdb_test "p 5" \
+	"Warning: '[style p title]', an alias for the command '[style print title]', is deprecated.*Use '[style new_p title]'.*" \
+	"p deprecated warning, with replacement"
 }
-- 
2.26.2


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

* Re: [PATCH] Highlight deprecated commands using title style
  2020-12-14 16:02 [PATCH] Highlight deprecated commands using title style Tom Tromey
@ 2020-12-15  9:57 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2020-12-15  9:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey <tromey@adacore.com> [2020-12-14 09:02:52 -0700]:

> After Andrew's latest patch, I noticed that the deprecation warnings
> could use the (so-called) title style when printing command names.
> This patch implements this idea.
> 
> gdb/ChangeLog
> 2020-12-14  Tom Tromey  <tromey@adacore.com>
> 
> 	* cli/cli-decode.c (deprecated_cmd_warning): Use title style for
> 	command names.
> 
> gdb/testsuite/ChangeLog
> 2020-12-14  Tom Tromey  <tromey@adacore.com>
> 
> 	* gdb.base/style.exp: Add deprecation tests.

LGTM.

Thanks,
Andrew


> ---
>  gdb/ChangeLog                    |  5 +++++
>  gdb/cli/cli-decode.c             | 23 ++++++++++++++++-------
>  gdb/testsuite/ChangeLog          |  4 ++++
>  gdb/testsuite/gdb.base/style.exp |  7 +++++++
>  4 files changed, 32 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
> index 13260ac44e6..fb2856d4333 100644
> --- a/gdb/cli/cli-decode.c
> +++ b/gdb/cli/cli-decode.c
> @@ -1939,16 +1939,23 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
>        tmp_alias_str += std::string (alias->name);
>  
>        if (cmd->cmd_deprecated)
> -	printf_filtered (_("Warning: command '%s' (%s) is deprecated.\n"),
> -			 tmp_cmd_str.c_str (), tmp_alias_str.c_str ());
> +	printf_filtered (_("Warning: command '%ps' (%ps) is deprecated.\n"),
> +			 styled_string (title_style.style (),
> +					tmp_cmd_str.c_str ()),
> +			 styled_string (title_style.style (),
> +					tmp_alias_str.c_str ()));
>        else
> -	printf_filtered (_("Warning: '%s', an alias for the command '%s', "
> +	printf_filtered (_("Warning: '%ps', an alias for the command '%ps', "
>  			   "is deprecated.\n"),
> -			 tmp_alias_str.c_str (), tmp_cmd_str.c_str ());
> +			 styled_string (title_style.style (),
> +					tmp_alias_str.c_str ()),
> +			 styled_string (title_style.style (),
> +					tmp_cmd_str.c_str ()));
>      }
>    else
> -    printf_filtered (_("Warning: command '%s' is deprecated.\n"),
> -		     tmp_cmd_str.c_str ());
> +    printf_filtered (_("Warning: command '%ps' is deprecated.\n"),
> +		     styled_string (title_style.style (),
> +				    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
> @@ -1959,7 +1966,9 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
>    else
>      replacement = cmd->replacement;
>    if (replacement != nullptr)
> -    printf_filtered (_("Use '%s'.\n\n"), replacement);
> +    printf_filtered (_("Use '%ps'.\n\n"),
> +		     styled_string (title_style.style (),
> +				    replacement));
>    else
>      printf_filtered (_("No alternative known.\n\n"));
>  
> diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
> index 28c270591ba..8d7eaa80b63 100644
> --- a/gdb/testsuite/gdb.base/style.exp
> +++ b/gdb/testsuite/gdb.base/style.exp
> @@ -172,4 +172,11 @@ save_vars { env(TERM) } {
>  	"warning: [style .*? file] is not a directory\\..*"
>      gdb_test "show data-directory" \
>  	"GDB's data directory is \"[style .*? file]\"\\..*"
> +
> +    # Check that deprecation styles command names.
> +    gdb_test_no_output "maintenance deprecate p \"new_p\"" \
> +	"maintenance deprecate p \"new_p\" /1/"
> +    gdb_test "p 5" \
> +	"Warning: '[style p title]', an alias for the command '[style print title]', is deprecated.*Use '[style new_p title]'.*" \
> +	"p deprecated warning, with replacement"
>  }
> -- 
> 2.26.2
> 

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

end of thread, other threads:[~2020-12-15  9:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 16:02 [PATCH] Highlight deprecated commands using title style Tom Tromey
2020-12-15  9:57 ` Andrew Burgess

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