public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	gdb-patches@sourceware.org
Subject: Re: [RFVv4 1/5] New cli-utils.h/.c function extract_info_print_args
Date: Fri, 26 Oct 2018 18:04:00 -0000	[thread overview]
Message-ID: <428fbdae-026b-e57c-2f93-25a1ceae8e97@redhat.com> (raw)
In-Reply-To: <20181025201107.24828-2-philippe.waroquiers@skynet.be>

Hi Philippe,

This is OK with the below fixed.

On 10/25/2018 09:11 PM, Philippe Waroquiers wrote:

> gdb/ChangeLog
> 2018-10-25  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
> 
> 	* cli-utils.c (extract_arg_maybe_quoted): New function.
> 	(extract_info_print_args): New function.
> 	(info_print_args_help): New function.
>         (report_unrecognized_option_error): New function.
> 	* cli-utils.h (extract_arg_maybe_quoted): New function.
> 	(extract_info_print_args): New function.
> 	(info_print_args_help): New function.
>         (report_unrecognized_option_error): New function.

Noticed some leading whitespaces instead of tabs here.  Make
sure those are fixed when this copied to the ChangeLog file.

> +/* See documentation in cli-utils.h.  */
> +
> +const char *
> +info_print_args_help (const char *prefix,
> +		      const char *entity_kind)
> +{
> +  std::string help = string_printf (_("\
> +%sIf NAMEREGEXP is provided, only prints the %s whose name\n\
> +matches NAMEREGEXP.\n\
> +If -t TYPEREGEXP is provided, only prints the %s whose type\n\
> +matches TYPEREGEXP.  Note that the matching is done with the type\n\
> +printed by the 'whatis' command.\n\
> +By default, the command might produce headers and/or messages indicating\n\
> +why no %s can be printed.\n\
> +The flag -q disables the production of these headers and messages."),
> +				    prefix,
> +				    entity_kind, entity_kind, entity_kind);
> +
> +  /*  Note : this returns a string allocated with xstrdup, as this
> +      is typically used as argument to add_prefix_cmd, which needs a
> +      string that stays valid after destruction of the std::string.  */
> +  return xstrdup (help.c_str ());

Looks like you missed a previous comment here:

 "Keep the function's interface, but use xstrprintf instead
 of 'xstrdup + string_printf' then."

That meant you can skip the std::string and write this instead:

 const char *
 info_print_args_help (const char *prefix,
 		      const char *entity_kind)
 {
   return xstrprintf (_("\


> +/* Tell the user that ARGS starts with an option unrecognized by COMMAND,
> +   and throws an error.  */
> +

When I first read this comment I thought that the function printed to
gdb_stdout and then threw the error.  I'd suggest this tweak:

/* Throws an error telling the user that ARGS starts with an option
   unrecognized by COMMAND.  */

> +extern void report_unrecognized_option_error (const char *command,
> +					      const char *args);

Thanks,
Pedro Alves

  reply	other threads:[~2018-10-26 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 20:11 [RFAv4 0/5] info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP] Philippe Waroquiers
2018-10-25 20:11 ` [RFVv4 2/5] Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables] Philippe Waroquiers
2018-10-26 18:05   ` Pedro Alves
2018-10-25 20:11 ` [RFVv4 1/5] New cli-utils.h/.c function extract_info_print_args Philippe Waroquiers
2018-10-26 18:04   ` Pedro Alves [this message]
2018-10-25 20:11 ` [RFVv4 5/5] Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP] Philippe Waroquiers
2018-10-26 18:06   ` Pedro Alves
2018-10-27 12:52     ` Philippe Waroquiers
2018-10-25 20:11 ` [RFVv4 4/5] Announce changes in NEWS to info [args|functions|locals|variables] Philippe Waroquiers
2018-10-26  6:27   ` Eli Zaretskii
2018-10-25 20:11 ` [RFVv4 3/5] Document changes " Philippe Waroquiers
2018-10-26  6:26   ` Eli Zaretskii
2018-10-26 17:15     ` Philippe Waroquiers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=428fbdae-026b-e57c-2f93-25a1ceae8e97@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).