Hi all, these functions were pretty much broken (overflow and signed/unsigned behaviour), so I fixed almost every problem. Some German tax calculation program barfed because of this. Now it works "much" better: it crashes due to a rather familiar BadMatch error at X_GetImage ;-) (I'm almost sure I know where this happens in Wine code, and of course we should really fix that problem finally) I wrote my private testing framework for these functions, so I'll convert that to the "official" framework soon. -- Andreas Mohr Stauferstr. 6, D-71272 Renningen, Germany
Determining best CVS host... Using CVSROOT :pserver:cvs@rhlx01.fht-esslingen.de:/home/wine Index: files/profile.c =================================================================== RCS file: /home/wine/wine/files/profile.c,v retrieving revision 1.62 diff -u -r1.62 profile.c --- files/profile.c 4 Jan 2002 18:24:37 -0000 1.62 +++ files/profile.c 19 Jan 2002 21:21:02 -0000 @@ -20,6 +20,7 @@ #include "winbase.h" #include "winnls.h" #include "winerror.h" +#include "wine/exception.h" #include "wine/winbase16.h" #include "winreg.h" #include "file.h" @@ -83,6 +84,12 @@ static const char hex[16] = "0123456789ABCDEF"; +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + return EXCEPTION_EXECUTE_HANDLER; +} + /*********************************************************************** * PROFILE_CopyEntry * @@ -962,6 +969,7 @@ PROFILE_GetWineIniString( section, key_name, "", buffer, sizeof(buffer) ); if (!buffer[0]) return def; + /* FIXME: strtol wrong ?? see GetPrivateProfileIntA */ result = strtol( buffer, &p, 0 ); return (p == buffer) ? 0 /* No digits at all */ : (int)result; } @@ -1342,12 +1350,10 @@ UINT16 WINAPI GetPrivateProfileInt16( LPCSTR section, LPCSTR entry, INT16 def_val, LPCSTR filename ) { - long result=(long)GetPrivateProfileIntA(section,entry,def_val,filename); - - if (result > 65535) return 65535; - if (result >= 0) return (UINT16)result; - if (result < -32768) return -32768; - return (UINT16)(INT16)result; + /* we used to have some elaborate return value limitation (<= -32768 etc.) + * here, but Win98SE doesn't care about this at all, so I deleted it. + * AFAIR versions prior to Win9x had these limits, though. */ + return (INT16)GetPrivateProfileIntA(section,entry,def_val,filename); } /*********************************************************************** @@ -1357,14 +1363,29 @@ INT def_val, LPCSTR filename ) { char buffer[20]; - char *p; long result; - PROFILE_GetPrivateProfileString( section, entry, "", - buffer, sizeof(buffer), filename, FALSE ); - if (!buffer[0]) return (UINT)def_val; - result = strtol( buffer, &p, 0 ); - if (p == buffer) return 0; /* No digits at all */ + __TRY { + if (!PROFILE_GetPrivateProfileString( section, entry, "", + buffer, sizeof(buffer), filename, FALSE )) + return def_val; + /* FIXME: if entry can be found but it's empty, then Win16 is + * supposed to return 0 instead of def_val ! Difficult/problematic + * to implement (every other failure also returns zero buffer), + * thus wait until testing framework avail for making sure nothing + * else gets broken that way. */ + if (!buffer[0]) return (UINT)def_val; + + /* Don't use strtol() here ! + * (returns LONG_MAX/MIN on overflow instead of "proper" overflow) + YES, scan for unsigned format ! (otherwise compatibility error) */ + if (!sscanf(buffer, "%lu", &result)) + result = 0; + } + __EXCEPT(page_fault) { + result = 0; + } + __ENDTRY return (UINT)result; }