DragonFly BSD
DragonFly commits List (threaded) for 2005-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/lib/libc/string strcasecmp.c


From: Jeroen Ruigrok/asmodai <asmodai@xxxxxx>
Date: Fri, 29 Apr 2005 07:51:37 +0200

-On [20050428 21:32], Matthew Dillon (dillon@xxxxxxxxxxxxxxxxxxxx) wrote:
>    Joerg, char's are NOT unsigned.

>#include <stdio.h>
>
>int
>main(int ac, char **av)
>{
>    char x = -1;
>
>    printf("%d\n", x);
>}
>
>    See?  NOT unsigned.  And we aren't going to make them unsigned, either.

ANSI C99, section 6.5.2:

15 The three types char, signed char, and unsigned char are collectively
called the character types. The implementation shall define char to have the
same range, representation, and behavior as either signed char or unsigned
char.35)

35) CHAR_MIN, defined in <limits.h>, will have one of the values 0 or
SCHAR_MIN, and this can be used to distinguish the two options. Irrespective
of the choice made, char is a separate type from the other two and is not
compatible with either.

machine/limits.h:

#ifdef __CHAR_UNSIGNED__
#define CHAR_MAX        UCHAR_MAX       /* max value for a char */
#define CHAR_MIN        0               /* min value for a char */
#else
#define CHAR_MAX        SCHAR_MAX       /* max value for a char */
#define CHAR_MIN        SCHAR_MIN       /* min value for a char */
#endif

So in the default case, Matt is right.  But it is a choice we as an
implementation can make ourselves.

-- 
Jeroen Ruigrok van der Werven <asmodai(at)wxs.nl> / asmodai / kita no mono
Free Tibet! http://www.savetibet.org/ | http://ashemedai.deviantart.com/
http://www.tendra.org/   | http://www.in-nomine.org/
You are more than you think, less than you could be...



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