tech-userlevel archive

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

Re: tolower()/islower() and char

On Thu, Jan 14, 2021 at 12:28:57PM +0100, Manuel Bouyer wrote:
> On Thu, Jan 14, 2021 at 12:19:39PM +0100, Martin Husemann wrote:
> > On Thu, Jan 14, 2021 at 12:14:28PM +0100, Manuel Bouyer wrote:
> > > Any comment about this ? I'm not familiar with these details ...
> > 
> > man ctype and search for CAVEATS
> thanks.
> So NetBSD and glibc took different approach to try to avoid undefined
> behavior. I am right saying that both are standard-compliant ?
> Does the standard explicitely state that the value should either be
> EOF or >= 0 ?

The standard is explicit that the argument must be EOF or an unsigned
char. There is no way to support both true 8bit locales and magically
fix this. '\xff' in Latin1 is a letter for example and EOF is not.

I'm still shocked by how many developers have been using C for 20 years
and still manage to not use ctype.h correctly...


Home | Main Index | Thread Index | Old Index