Re: [PATCH 1/3] var_integer -> var_uinteger

dje
2012-08-24T17:06:14Z

Yao Qi writes:
> On 08/24/2012 02:19 AM, dje@google.com wrote:
> > > - if (history_size == INT_MAX)
> > > + if (history_size == UINT_MAX)
> > > unstifle_history ();
> > > - else if (history_size >= 0)
> > > - stifle_history (history_size);
> > > + else if (history_size >= INT_MAX)
> > > + /* The type of parameter in stifle_history is int, so check the range. */
> > > + error (_("History size must be less than %d"), INT_MAX);
> >
> > I think we don't want to remove resetting "history_size = INT_MAX;"
> > in the error case here (but see below).
>
> Checking the value is negative should be done in do_set_command, and
> patch was posted here,
>
> [PATCH 1/3] var_zuinteger_unlimited and 'set listsize'.
> http://sourceware.org/ml/gdb-patches/2012-08/msg00021.html
>
> Posting a new one has been on my TODO list, and I'll do it once this
> patch goes in.

Ah.
My point was that if the user sets the value to INT_MAX+1, for example, and you flag that as an error, then the value should be reset back to something legal.
But no matter, if we go with all values being legal. :-)

> @@ -1445,15 +1445,12 @@ show_commands (char *args, int from_tty)
> static void
> set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
> {
> - if (history_size == INT_MAX)
> + /* The type of parameter in stifle_history is int, so value from INT_MAX and
> + up means "unlimited". */
> + if (history_size >= INT_MAX)
> unstifle_history ();
> - else if (history_size >= 0)
> - stifle_history (history_size);
> else
> - {
> - history_size = INT_MAX;
> - error (_("History size must be non-negative"));
> - }
> + stifle_history (history_size);
> }

One issue that arises is if the user sets the value to, say, INT_MAX+1 we call unstifle_history, but show "show hist size" will print INT_MAX+1 instead of "unlimited".
If we go this route, perhaps any value >= INT_MAX should cause the underlying value to be set to UINT_MAX so that "show" will print "unlimited".