From: Tom Tromey <tom@tromey.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFAv2 1/6] New cli-utils.h/.c function extract_info_print_args
Date: Tue, 18 Sep 2018 15:31:00 -0000 [thread overview]
Message-ID: <878t3yu8vv.fsf@tromey.com> (raw)
In-Reply-To: <20180826165359.1600-2-philippe.waroquiers@skynet.be> (Philippe Waroquiers's message of "Sun, 26 Aug 2018 18:53:54 +0200")
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
Philippe> cli-utils.c has a new static function extract_arg_maybe_quoted
Philippe> that extracts an argument, possibly single quoted.
I think it would be better if this handled quotes the same way that
gdb_argv (aka libiberty's buildargv) does. That approach seems ok-ish
(maybe not perfect), and following it would mean that at least we're not
increasing the number of ways that command lines are quoted in gdb.
I guess the reason you did not simply use gdb_argv is that the trailing
regexp is the rest of the input string.
Philippe> +/* See documentation in cli-utils.h. */
Philippe> +
Philippe> +void
Philippe> +extract_info_print_args (const char* command,
Philippe> + const char **args,
Philippe> + bool *quiet,
Philippe> + std::string *regexp,
Philippe> + std::string *t_regexp)
I tend to think this should go somewhere else, since cli-utils is more
like "low level" parsing helpers. But I don't really know where I
guess.
Philippe> + if (*args != NULL && **args != '\000')
Philippe> + *regexp = extract_arg (args);
It seems to me that this should just be "*regexp = args" for backward
compatibility. This formulation will stop at whitespace, whereas the
previous code did not.
If changing the meaning of "info types regexp" where the regexp has
whitespace is ok, then switching fully to gdb_argv would be better. I
don't know if it is ok to do but I suspect not.
Philippe> +/* A helper function to extract an argument from *ARG. An argument is
Philippe> + delimited by whitespace, but it can also be optionally quoted using
Philippe> + single quote characters. The return value is empty if no argument
Philippe> + was found. */
Philippe> +
Philippe> +static std::string
Philippe> +extract_arg_maybe_quoted (const char **arg)
Philippe> +{
One question I have is whether we could just change extract_arg to do
the dequoting. Auditing the existing calls to see if this change would
negatively impact them might not be too hard. And, it would be nice to
make gdb's CLI a bit more regular.
Philippe> +#define INFO_PRINT_ARGS_HELP(entity_kind) \
Philippe> +"If NAMEREGEXP is provided, only prints the " entity_kind " whose name\n\
Philippe> +matches NAMEREGEXP.\n\
Philippe> +If -t TYPEREGEXP is provided, only prints the " entity_kind " whose type\n\
Philippe> +matches TYPEREGEXP. Note that the matching is done with the type\n\
Philippe> +printed by the 'whatis' command.\n\
Philippe> +By default, the command might produce headers and/or messages indicating\n\
Philippe> +why no " entity_kind " can be printed.\n\
Philippe> +The flag -q disables the production of these headers and messages."
Constructing help text like this is i18n-unfriendly. gdb tries to do
this correctly, though IIRC the build isn't all wired up properly and
there aren't any actual translations :-/
Maybe it can be reworded somehow. I'm not sure if xgettext can handle
this kind of string concatenation in combination with macro expansion,
either.
Tom
next prev parent reply other threads:[~2018-09-18 15:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-26 16:54 [RFAv2 0/6] info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP] Philippe Waroquiers
2018-08-26 16:54 ` [RFAv2 4/6] Document changes to info [args|functions|locals|variables] Philippe Waroquiers
2018-08-26 18:19 ` Eli Zaretskii
2018-08-26 16:54 ` [RFAv2 6/6] Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP] Philippe Waroquiers
2018-08-26 16:54 ` [RFAv2 2/6] Make struct type_print_options default_ptype_flags non static Philippe Waroquiers
2018-08-26 16:54 ` [RFAv2 1/6] New cli-utils.h/.c function extract_info_print_args Philippe Waroquiers
2018-09-18 15:31 ` Tom Tromey [this message]
2018-09-23 20:16 ` Philippe Waroquiers
2018-09-24 13:07 ` Tom Tromey
2018-09-25 4:37 ` Philippe Waroquiers
2018-08-26 16:54 ` [RFAv2 5/6] Announce changes in NEWS to info [args|functions|locals|variables] Philippe Waroquiers
2018-08-26 18:21 ` Eli Zaretskii
2018-08-27 4:39 ` Philippe Waroquiers
2018-08-27 14:59 ` Eli Zaretskii
2018-08-26 16:54 ` [RFAv2 3/6] Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args " Philippe Waroquiers
2018-09-18 15:52 ` Tom Tromey
2018-09-23 21:34 ` Philippe Waroquiers
2018-09-06 20:16 ` PING Re: [RFAv2 0/6] info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP] Philippe Waroquiers
2018-09-13 19:27 ` PING^2 " 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=878t3yu8vv.fsf@tromey.com \
--to=tom@tromey.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