This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][RFC] Avoid table lookup in isascii, isxdigit.
- From: Rich Felker <dalias at aerifal dot cx>
- To: Paul Eggert <eggert at cs dot ucla dot edu>
- Cc: OndÅej BÃlka <neleai at seznam dot cz>, libc-alpha at sourceware dot org
- Date: Sat, 13 Apr 2013 02:43:16 -0400
- Subject: Re: [PATCH][RFC] Avoid table lookup in isascii, isxdigit.
- References: <20130409115706 dot GA7587 at domone dot kolej dot mff dot cuni dot cz> <20130412204241 dot GK20323 at brightrain dot aerifal dot cx> <51687F17 dot 3070806 at cs dot ucla dot edu>
On Fri, Apr 12, 2013 at 02:39:35PM -0700, Paul Eggert wrote:
> On 04/12/13 13:42, Rich Felker wrote:
> > #define isdigit(c) ((unsigned)(c)-'0'<10)
>
> Unfortunately, this implementation mishandles some
> obscure usages, e.g.,:
>
> double eof = EOF;
> return isdigit (eof);
>
> on systems where the implementation raises a signal
> when converting an out-of-range floating-point value
> to unsigned.
Then make it ((unsigned)(int)(c)-'0'<10). Then the conversion behavior
is exactly the same as with a function call.
Rich