[RFA,1/3] Add usage to printf command

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

Commit Message

Tom Tromey Feb. 15, 2018, 8:49 p.m. UTC
  This patch adds the "Usage:" text to the printf command's help text,
and tries to improve the text a tiny bit.

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

	* printcmd.c (_initialize_printcmd): Add usage to printf.
---
 gdb/ChangeLog  | 4 ++++
 gdb/printcmd.c | 5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Alan Hayward Feb. 16, 2018, 11:35 a.m. UTC | #1
> On 15 Feb 2018, at 20:49, Tom Tromey <tom@tromey.com> wrote:

> 

> This patch adds the "Usage:" text to the printf command's help text,

> and tries to improve the text a tiny bit.

> 

> gdb/ChangeLog

> 2018-02-14  Tom Tromey  <tom@tromey.com>

> 

> 	* printcmd.c (_initialize_printcmd): Add usage to printf.

> ---

> gdb/ChangeLog  | 4 ++++

> gdb/printcmd.c | 5 +++--

> 2 files changed, 7 insertions(+), 2 deletions(-)

> 

> diff --git a/gdb/printcmd.c b/gdb/printcmd.c

> index fc9d7e4dd9..13b967f0a2 100644

> --- a/gdb/printcmd.c

> +++ b/gdb/printcmd.c

> @@ -2680,8 +2680,9 @@ No argument means cancel all automatic-display expressions.\n\

> Do \"info display\" to see current list of code numbers."), &deletelist);

> 

>   add_com ("printf", class_vars, printf_command, _("\

> -printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\

> -This is useful for formatted output in user-defined commands."));

> +Formatted printing, like the C \"printf\" function.\n\

> +Usage: printf \"format string\", arg1, arg2, arg3, ..., argn\n\

> +This supports most C printf format specifications, like %s, %d, etc."));

> 


I like the addition of a “usage”. But this will be the only command to have it.

Probably not in scope for this patch series, but it would be nice for consistency
for usage statements to be added to all the commands in this file.



>   add_com ("output", class_vars, output_command, _("\

> Like \"print\" but don't put in value history and don't print newline.\n\

> -- 

> 2.13.6

>
  
Tom Tromey Feb. 16, 2018, 9:58 p.m. UTC | #2
>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:

Alan> I like the addition of a “usage”. But this will be the only command to have it.

Plenty of commands have it.

Alan> Probably not in scope for this patch series, but it would be nice for consistency
Alan> for usage statements to be added to all the commands in this file.

I can drop this patch.

Tom
  
Simon Marchi Feb. 16, 2018, 11:09 p.m. UTC | #3
On 2018-02-16 16:58, Tom Tromey wrote:
>>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:
> 
> Alan> I like the addition of a “usage”. But this will be the only
> command to have it.
> 
> Plenty of commands have it.
> 
> Alan> Probably not in scope for this patch series, but it would be
> nice for consistency
> Alan> for usage statements to be added to all the commands in this 
> file.
> 
> I can drop this patch.

Please don't :).  I think this is a welcome change.

Simon
  
Alan Hayward Feb. 19, 2018, 9:16 a.m. UTC | #4
> On 16 Feb 2018, at 23:09, Simon Marchi <simon.marchi@polymtl.ca> wrote:

> 

> On 2018-02-16 16:58, Tom Tromey wrote:

>>>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:

>> Alan> I like the addition of a “usage”. But this will be the only

>> command to have it.

>> Plenty of commands have it.


I meant to say “the only command in printcmd.c to have it". :)

>> Alan> Probably not in scope for this patch series, but it would be

>> nice for consistency

>> Alan> for usage statements to be added to all the commands in this file.

>> I can drop this patch.

> 

> Please don't :).  I think this is a welcome change.

> 


Agree with Simon.


Alan.
  

Patch

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index fc9d7e4dd9..13b967f0a2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2680,8 +2680,9 @@  No argument means cancel all automatic-display expressions.\n\
 Do \"info display\" to see current list of code numbers."), &deletelist);
 
   add_com ("printf", class_vars, printf_command, _("\
-printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
-This is useful for formatted output in user-defined commands."));
+Formatted printing, like the C \"printf\" function.\n\
+Usage: printf \"format string\", arg1, arg2, arg3, ..., argn\n\
+This supports most C printf format specifications, like %s, %d, etc."));
 
   add_com ("output", class_vars, output_command, _("\
 Like \"print\" but don't put in value history and don't print newline.\n\