Hi, all! Using CodeWarrior special edition 7.2 for ColdFire. I find that the toupper() and tolower() macros are totally broken!
This sample code:
static void Temp(void) { printf("\n toupper a A 2 \\r = %c %c %c 0x%02x\n", toupper('a'), toupper('A'), toupper('2'), toupper('\r')); printf(" tolower a A 2 \\r = %c %c %c 0x%02x\n", tolower('a'), tolower('A'), tolower('2'), tolower('\r')); printf(" isupper a A 2 \\r = %d %d %d %d\n", isupper('a'), isupper('A'), isupper('2'), isupper('\r')); printf(" islower a A 2 \\r = %d %d %d %d\n", islower('a'), islower('A'), islower('2'), islower('\r'));}gives this output:
toupper a A 2 \r = a a 2 0x0d tolower a A 2 \r = A A 2 0x0d isupper a A 2 \r = 0 1 0 0 islower a A 2 \r = 2 0 0 0
As you see, toupper() and tolower() functions are swapped. isupper() and islower() work correctly.
The fix looks to be in file ColdFire_Support\ewl\EWL_C\include\cctype
Swap the macro definitions in lines 70 and 71 as per this diff:
70,71c70,71< _EWL_INLINE int _EWL_CDECL tolower(int c) _EWL_CANT_THROW { return islower(c) ? c - ('a' - 'A') : c; }< _EWL_INLINE int _EWL_CDECL toupper(int c) _EWL_CANT_THROW { return isupper(c) ? c + ('a' - 'A') : c; }---> _EWL_INLINE int _EWL_CDECL tolower(int c) _EWL_CANT_THROW { return isupper(c) ? c + ('a' - 'A') : c; }> _EWL_INLINE int _EWL_CDECL toupper(int c) _EWL_CANT_THROW { return islower(c) ? c - ('a' - 'A') : c; }