delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/25/15:01:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
NNTP-Posting-Date: Sat, 25 Dec 2004 13:54:47 -0600
Date: Sat, 25 Dec 2004 14:54:54 -0500
From: Joe Wright <joewwright AT comcast DOT net>
User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: CTYPE stuff for Eli or DJ
References: <KpSdnePxHo9G_VHcRVn-oQ AT comcast DOT com> <200412241848 DOT iBOImiRM013524 AT envy DOT delorie DOT com> <Ub6dnQHCSdfA-lHcRVn-1w AT comcast DOT com> <200412241919 DOT iBOJJnq5014101 AT envy DOT delorie DOT com> <ZrGdnQaTgL1eIlHcRVn-vg AT comcast DOT com> <01c4ea6a$Blat.v2.2.2$88d35240 AT zahav DOT net DOT il> <fe-dnemo0_kzyFDcRVn-2A AT comcast DOT com> <200412251642 DOT iBPGge9n026679 AT envy DOT delorie DOT com>
In-Reply-To: <200412251642.iBPGge9n026679@envy.delorie.com>
Message-ID: <CZOdnQS-wOQaWFDcRVn-gQ@comcast.com>
Lines: 49
NNTP-Posting-Host: 69.143.13.12
X-Trace: sv3-fYn2nkE3hAHIu1dRrLdZDiqyMW6eQpxhE+oVbPoV1cF53WYr2cVMWw0b6QVC5VGeni4QHOdf1Lu3FmM!OEWAjtWDfg9Awff1YfCZACH3Qpl4IkGy+riLXxS07HZT0eLYqB5cp/p+HyKH
X-Complaints-To: abuse AT comcast DOT net
X-DMCA-Complaints-To: dmca AT comcast DOT net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.22
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019