Mail Archives: djgpp/2004/12/25/15:01:10
DJ Delorie wrote:
>>It's the right thing because the array itself has 257 elements of
>>unsigned short, element 0 being 0. Elements 1..256 have bits set (or
>>not) depending on the characteristics of characters 0..255, hence
>>the +1 in the macro. Out-of-range should return 0. What you return?
>
>
> The correct thing to return, when the program passes you an erroneous
> input, is an error signal and set errno to ERANGE. Since the ctype
> functions have no way of returning an error signal directly, the error
> must be signalled indirectly. We do this by segfaulting. If you want
> to handle the error, install a segfault handler.
>
DJ, are you just having a bad day? It's Christmas. Lighten up.
'We do this by segfaulting'? Who is 'We'? Do you mean the
implementor? There is no reference in the Standard about the
implementation segfaulting and what the user should do about it.
What is a segfault handler? Do you offer one with DJGPP?
> But this should never happen, as you should not be passing such values
> to the ctype functions.
>
> We certainly should NOT be returning a successful value when passed
> invalid inputs.
>
> We do not want to help the programmer write bad code. We want bad
> code to suffer as much as possible, to help them find the bad code and
> fix it. That is the best way to help the programmer write good code.
There's that 'We' again. It is not up to you to punish me for
writing code you consider bad. Think about it. Your job as
implementor is to provide the most robust environment possible for
me to play in. It is not your job to catch me out. It is on the
other hand, my (the user's) job to catch you out. This so that you
can produce an even more robust environment to your audience.
How about this..
[((unsigned)(c)+1)&(UCHAR_MAX*2+1)]
..as our index? It doesn't punish us for invalid input simply
because there is no such thing. What do 'We' say about that?
PS. I'm older than you and I might have more time on my hands.
Merry Christmas.
--
Joe Wright mailto:joewwright AT comcast DOT net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
- Raw text -