|
From: Andre R. <and...@us...> - 2004-12-09 20:27:08
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26941/Common/source Modified Files: timedate.c Log Message: Worked around a crashing bug in getNewLocalePatternString, possibly a CW 8.x compiler bug. [but #static boolean getNewLocalePatternString (unsigned long lc, char ** foo, char * defValue) {] Index: timedate.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/timedate.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** timedate.c 31 Oct 2004 16:38:27 -0000 1.3 --- timedate.c 9 Dec 2004 20:26:51 -0000 1.4 *************** *** 190,202 **** static boolean getNewLocalePatternString (unsigned long lc, char ** foo, char * defValue) { char buf[256]; char buf2[256]; ! short i, j, cnt, len; char c; len = GetLocaleInfo (LOCALE_USER_DEFAULT, lc, buf, 256); ! --len; ! if (len != 0) { i = 0; j = 0; --- 190,224 ---- static boolean getNewLocalePatternString (unsigned long lc, char ** foo, char * defValue) { + + /* + 2004-12-09 aradke: site of a mysterious crashing bug, possibly a CodeWarrior 8.x compiler bug. + with full optimizations, the cw compiler produces the following code for Win32: + 221: buf2[j++] = '%'; + 00420257 movsx eax,word ptr [j] + 0042025E movsx edi,word ptr [j] + 222: buf2[j++] = '%'; + 00420265 movsx edx,word ptr [edi+1] + 00420269 mov byte ptr buf2[eax],25h + + the instruction at 00420265 ends up attempting to read from address 0x00000001. + details are available in bug #1081295 on sourceforge.net: + http://sourceforge.net/tracker/index.php?func=detail&aid=1081295&group_id=120666&atid=687798 + + the crashes disappear when the type of the integer variables is switched from short to int, + so that's what we'll do for now. + + also, check len for failed GetLocaleInfo call before decrementing it. + */ + char buf[256]; char buf2[256]; ! int i, j, cnt, len; /*2004-12-09 aradke*/ char c; len = GetLocaleInfo (LOCALE_USER_DEFAULT, lc, buf, 256); ! ! if (len > 0) { ! --len; /*2004-12-09 aradke: dont't attempt to parse trailing nil char*/ i = 0; j = 0; |