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

dje
2012-08-27T22:14:20Z

Yao Qi writes:
> On 08/25/2012 01:05 AM, dje@google.com wrote:
> >> @@ -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".
>
> Good catch! :) I changed this part as below,
>
> /* The type of parameter in stifle_history is int, so value from INT_MAX up
> means 'unlimited'. */

so values from INT_MAX up
mean 'unlimited'.

> if (history_size > INT_MAX)

>= INT_MAX

> {
> /* Ensure that 'show history size' print 'unlimited'. */

prints 'unlimited'.

> history_size = UINT_MAX;
> unstifle_history ();
> }
> else
> stifle_history (history_size);

Ok with those three changes.