toupper() and tolower() swapped?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

toupper() and tolower() swapped?

3,563件の閲覧回数
jonathang
Contributor II

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; }
ラベル(1)
タグ(1)
0 件の賞賛
返信
5 返答(返信)

2,054件の閲覧回数
J2MEJediMaster
Specialist I

It is important that you file a service request on this so that the engineers are aware of the problem. Click here to file an on-line service request. On that page, for the Category choice you want to pick 'Technical Request', and for the Topic choice you want to select 'CodeWarrior'.

 

---Tom

0 件の賞賛
返信

2,054件の閲覧回数
jonathang
Contributor II
OK, minor rant here.  (I don't usually do this.)

J2MEJediMaster wrote:

It is important that you file a service request on this so that the engineers are aware of the problem.


I found this to be a somewhat surprising response.  WIth most companies, it would be more like "I have forwarded this issue to the engineers".

 

Regardless, I jumped through your hoops and reported the issue.  The immediate response was (paraphrased), "This is a known problem and you already found the workaround."  Hmm.  That was a waste of everyone's time, wasn't it?

 

My conclusion is that no one on this forum is advised of known issues and workarounds, and that the CodeWarrior developers do not read these forums.  That seems kinda underwhelming.

 

It would also be a time-saver if there were a public list of known CodeWarrior bugs, kind of like the errata lists for the CPU chips.  If there is any such thing, I have not found it.

 

0 件の賞賛
返信

2,054件の閲覧回数
CrasyCat
Specialist III

Hello

 

J2MEJediMaster did recommend you to submit a service request in order to make sure the defect is recorded properly.

In fact defect reported by external customers have higher priority than defect reported internally.

This is the reason we recommend customer to report defects themselves. In addition sometimes engineering requires additional information that we would not be able to provide ourselves.

 

And unfortunately right now we do not have a list of known issue available on external web site.

 

CrasyCat

0 件の賞賛
返信

2,054件の閲覧回数
blake_genes
Contributor II

How about now??? I just ran into this problem 16 months after this guy solved it, and spent most of a day finding out that toupper and tolower were swapped.  Is there any way to get a list of problems, other than just reading the entire forum history?

 

0 件の賞賛
返信

2,054件の閲覧回数
vier_kuifjes
Senior Contributor I

It's not easy to get Freescale into fixing bugs, I found that out myself.

 

I once reported a compiler optimisation bug that I found after months of searching and officially reported it to Freescale.

The bug was never fixed because Freescale couldn't get my code running on their test system, although the bug was clearly visible in the disassembly of the code!

 

Frustrating...

0 件の賞賛
返信