From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113244 invoked by alias); 14 Jan 2016 11:29:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113231 invoked by uid 89); 14 Jan 2016 11:29:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS,T_FILL_THIS_FORM_SHORT autolearn=no version=3.3.2 spammy=Hx-languages-length:2519, revisiting, solo X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Jan 2016 11:29:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C7CB1C0BF2B9 for ; Thu, 14 Jan 2016 11:29:24 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0EBTN38023319 for ; Thu, 14 Jan 2016 06:29:24 -0500 Message-ID: <56978693.7060206@redhat.com> Date: Thu, 14 Jan 2016 11:29:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] Star wildcard ranges (e.g., "info thread 2.*") References: <1452702886-17749-1-git-send-email-palves@redhat.com> <1452702886-17749-3-git-send-email-palves@redhat.com> In-Reply-To: <1452702886-17749-3-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-01/txt/msg00290.txt.bz2 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; }