This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] Make get_number_or_range accept value history references


On Thursday 24 February 2011 19:11:02, Michael Snyder wrote:
> +      if (isdigit (h[1]) || h[1] == '\0' || h[1] == ' ' || h[1] == '\t')
> +       /* single-dollar history value */
> +       index = strtol (&h[1], endp, 10);

Is this correct for the ' '  and '\t' cases?  It looks
like it will accept "$ 3" as history value 3, but
it should parsed as "$" -- the last history value.

You're also not checking if the string is all
digits, so $123asdf is being accepted as $123, while
the language parsers treat that as an internal
variable.  Maybe you should take a look at write_dollar_variable,
and factor out or borrow code from there to avoid these
discrepancies?

> +      else if (h[1] == '$' 
> +              && (isdigit (h[2]) || h[2] == '\0'
> +                  || h[2] == ' ' || h[2] == '\t'))
> +       /* double-dollar history value */
> +       index = -strtol (&h[2], endp, 10);

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]