X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f NNTP-Posting-Date: Fri, 24 Dec 2004 19:17:55 -0600 Date: Fri, 24 Dec 2004 20:18:03 -0500 From: Joe Wright 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: <200412241848 DOT iBOImiRM013524 AT envy DOT delorie DOT com> <200412241919 DOT iBOJJnq5014101 AT envy DOT delorie DOT com> In-Reply-To: <200412241919.iBOJJnq5014101@envy.delorie.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 28 NNTP-Posting-Host: 69.143.13.12 X-Trace: sv3-fIFXUyKKhAmORmJTH/mJnprDccR3Hv9nZXPvRbv3A1kX41b5ifFJCPy8W6kdGMyxVC9LGxILKccAR30!XpED++spaDX3w84649RPeGq57BKynMoaA4/kTiTEJwMW8cbzUdVdYM6zmL3q 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: >>Even faulty, if '(int)(c)+1' is not in range do we risk segfault or >>other awful outcome? Kaz' demons come to mind. > > > Most libc functions will segfault if you pass them faulty data. It is > up to the application to ensure robust usage of libc functions. > > Frankly, I'd rather see your application segfault than silently do the > wrong thing. That will encourage you to fix it ;-) No need for that, I think. Consider.. __dj_ctype_flags[(unsigned)(c) > 255 ? 0 : ((c)+1)] ..which will allow 'int is*(int c)' to take any int, including EOF and do the 'Wright' thing. Note that casting as in 'isspace((unsigned char)c)' will keep you in the 0..256 array bounds but gives wrong answers, unless you think that -224 (0xffffff20) is a space. Am I missing something? Merry Christmas -- Joe Wright mailto:joewwright AT comcast DOT net "Everything should be made as simple as possible, but not simpler." --- Albert Einstein ---