Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/common/lib/libc/stdlib



On Tue, Apr 16, 2013 at 11:36:20PM +0100, David Laight wrote:
> On Tue, Apr 16, 2013 at 07:34:58PM +0000, Joerg Sonnenberger wrote:
> > Module Name:        src
> > Committed By:       joerg
> > Date:               Tue Apr 16 19:34:58 UTC 2013
> > 
> > Modified Files:
> >     src/common/lib/libc/stdlib: _strtol.h _strtoul.h
> > 
> > Log Message:
> > Do not use isalpha here, since we explicitly only support the Portable
> > Character Set as base and in theory a locale could define a ASCII
> > control character as letter, resulting in negations. Also avoid isdigit
> > here to give the compiler a better chance of deciding whether an
> > unsigned compare or a jump table is a better option, both are very
> > likely better choices than the memory indirection.
> 
> There really ought to be a way of requesting the straight ASCII
> versions of the isxxxx functions even after a local has been set.
> A lot of code will use isalpha() to check for valid variable names (etc)
> and really doesn't want locale-specific alpha characters be valid.
> (Otherwise scripts become non-portable.)

See the discussion about using loc==0.

> OTOH (unsigned)(ch - '0') <= 9 is probably the fastest isdigit()
> on any modern cpu.

I expect the compiler to do that transformation.

Joerg


Home | Main Index | Thread Index | Old Index