tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Basic patch for passing W9X short DOS paths to TCC.


From: Dave Dodge
Subject: Re: [Tinycc-devel] Basic patch for passing W9X short DOS paths to TCC.
Date: Tue, 14 Apr 2009 16:18:12 -0400
User-agent: Mutt/1.5.17 (2008-05-15)

On Tue, Apr 14, 2009 at 06:37:49PM +0100, lostgallifreyan wrote:
> Dave Dodge <address@hidden> wrote:
> >If the filename string contains any high-valued characters, such as
> >accented letters, then accessing it with a char* might produce a
> >negative char value, and passing that to isupper/islower can be a
> >problem.
> 
> Ok. Point taken about undefined behaviour. Is the "unsigned char *p"
> declaration enough though?

Yes.  Dereferencing a valid (unsigned char *) will produce an
(unsigned char), which by definition is safe to pass to isupper.

> One mail suggested using "unsigned" at every subsequent use of the
> variable.

That's because p was a (char *), and therefore *p was producing a
possibly-signed value.  Casting the dereferenced value to (unsigned
char) is another way of ensuring isupper gets a usable value, but I
think simply changing p to an (unsigned char *) is cleaner.

BTW it's worth noting that casting from a signed integer to an
unsigned integer is a well-defined operation, but casting from
unsigned to signed is implementation-defined.

                                                  -Dave Dodge




reply via email to

[Prev in Thread] Current Thread [Next in Thread]