Re: [PATCH 2/4] Error on bad count number

Yao Qi
2014-03-10T02:01:56Z

On 03/07/2014 09:27 PM, Pedro Alves wrote:
> On 03/07/2014 09:38 AM, Yao Qi wrote:
>> On 03/06/2014 08:21 PM, Pedro Alves wrote:
>>>> AFAICS, get_number handles negative numbers. E.g.,
>>>>
>> Yes, get_number handles negative, but is it expected for get_number
>> to handle negative?
>
> Nothing in a name like "get number" suggests to me only positive
> numbers would be returned. I think it should be up to the

You didn't address the second half of my comments that
get_number_or_range errors on negative number.

> caller to handle whether the returned value is valid in
> that context.
>

This is sort of what I want to do. I'd like to restrict get_number
and get_number_or_range to only handle non-negative number, and return
negative number as error code. The callers of get_number or
get_number_or_range can decide to emit warning or error in their own
context. Checking how char pointer pointer advanced can only tell a
boolean state about error is encountered or not, but no details of
the type of the error.

I want to use get_number in mi_cmd_break_commands, and returns error
code about "not-a-number" or "junk at the end" respectively.

--
Yao (é½å°§)