delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/25/11:43:25

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Sat, 25 Dec 2004 11:42:40 -0500
Message-Id: <200412251642.iBPGge9n026679@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <fe-dnemo0_kzyFDcRVn-2A@comcast.com> (message from Joe Wright on
Sat, 25 Dec 2004 06:57:44 -0500)
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>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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.

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.

- Raw text -


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