From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Star wildcard ranges (e.g., "info thread 2.*")
Date: Thu, 14 Jan 2016 11:29:00 -0000 [thread overview]
Message-ID: <56978693.7060206@redhat.com> (raw)
In-Reply-To: <1452702886-17749-3-git-send-email-palves@redhat.com>
On 01/13/2016 04:34 PM, Pedro Alves wrote:
>
> +void
> +number_range_setup_range (struct get_number_or_range_state *state,
> + int start_value, int end_value, const char *end_ptr)
> +{
> + gdb_assert (start_value > 0);
> +
> + state->in_range = 1;
> + state->string = "-";
I'm revisiting this "-" assignment. This was actually a hack to make
get_number_or_range believe it is handling a range. But, we already
have the state->in_range field for that. It was needed because get_number_of_range
checks *state->string != '-' _before_ checking state->in_range. But it doesn't
have to be that way -- if we swap that around, like in the hunk below, we no longer
need to hack state->string.
> + state->end_ptr = end_ptr;
> + state->last_retval = start_value - 1;
> + state->end_value = end_value;
> +}
I'm squashing in this hunk with the patch, removing the hack, and reposting
a v2 series.
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index bf6ecae..0946db0 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -134,7 +134,21 @@ init_number_or_range (struct get_number_or_range_state *state,
int
get_number_or_range (struct get_number_or_range_state *state)
{
- if (*state->string != '-')
+ if (state->in_range)
+ {
+ /* All number-parsing has already been done. Return the next
+ integer value (one greater than the saved previous value).
+ Do not advance the token pointer until the end of range is
+ reached. */
+
+ if (++state->last_retval == state->end_value)
+ {
+ /* End of range reached; advance token pointer. */
+ state->string = state->end_ptr;
+ state->in_range = 0;
+ }
+ }
+ else if (*state->string != '-')
{
/* Default case: state->string is pointing either to a solo
number, or to the first number of a range. */
@@ -165,27 +179,26 @@ get_number_or_range (struct get_number_or_range_state *state)
state->in_range = 1;
}
}
- else if (! state->in_range)
- error (_("negative value"));
else
- {
- /* state->string points to the '-' that betokens a range. All
- number-parsing has already been done. Return the next
- integer value (one greater than the saved previous value).
- Do not advance the token pointer until the end of range
- is reached. */
-
- if (++state->last_retval == state->end_value)
- {
- /* End of range reached; advance token pointer. */
- state->string = state->end_ptr;
- state->in_range = 0;
- }
- }
+ error (_("negative value"));
state->finished = *state->string == '\0';
return state->last_retval;
}
next prev parent reply other threads:[~2016-01-14 11:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 16:34 [PATCH 0/2] " Pedro Alves
2016-01-13 16:34 ` [PATCH 2/2] " Pedro Alves
2016-01-13 17:00 ` Eli Zaretskii
2016-01-14 11:13 ` Pedro Alves
2016-01-14 16:16 ` Eli Zaretskii
2016-01-14 16:42 ` Pedro Alves
2016-01-14 11:29 ` Pedro Alves [this message]
2016-01-13 16:34 ` [PATCH 1/2] Fix "thread apply $conv_var" and misc other related problems Pedro Alves
2016-01-13 16:34 ` [PATCH 0/2] Star wildcard ranges (e.g., "info thread 2.*") Pedro Alves
2016-01-13 16:42 ` Pedro Alves
2016-01-14 16:52 ` Simon Marchi
2016-01-15 21:50 ` Pedro Alves
2016-01-14 11:39 Pedro Alves
2016-01-14 11:39 ` [PATCH 2/2] " Pedro Alves
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=56978693.7060206@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/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