Fixed int conversion in GetPrivateProfileInt so that all the tests
succeed.
This commit is contained in:
parent
7d6096480a
commit
6bf8542dd5
@ -1300,7 +1300,9 @@ UINT WINAPI GetPrivateProfileIntA( LPCSTR section, LPCSTR entry,
|
|||||||
INT def_val, LPCSTR filename )
|
INT def_val, LPCSTR filename )
|
||||||
{
|
{
|
||||||
char buffer[20];
|
char buffer[20];
|
||||||
long result;
|
UINT result = 0;
|
||||||
|
char *p = buffer;
|
||||||
|
int negative = 0;
|
||||||
|
|
||||||
if (!GetPrivateProfileStringA( section, entry, "",
|
if (!GetPrivateProfileStringA( section, entry, "",
|
||||||
buffer, sizeof(buffer), filename ))
|
buffer, sizeof(buffer), filename ))
|
||||||
@ -1312,11 +1314,22 @@ UINT WINAPI GetPrivateProfileIntA( LPCSTR section, LPCSTR entry,
|
|||||||
* else gets broken that way. */
|
* else gets broken that way. */
|
||||||
if (!buffer[0]) return (UINT)def_val;
|
if (!buffer[0]) return (UINT)def_val;
|
||||||
|
|
||||||
/* Don't use strtol() here !
|
/* do the conversion by hand to make sure
|
||||||
* (returns LONG_MAX/MIN on overflow instead of "proper" overflow)
|
* overflow is *not* handled properly ;-) */
|
||||||
YES, scan for unsigned format ! (otherwise compatibility error) */
|
while (*p && isspace(*p)) p++;
|
||||||
if (!sscanf(buffer, "%lu", &result)) return 0;
|
if (*p == '-')
|
||||||
return (UINT)result;
|
{
|
||||||
|
negative = 1;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
else if (*p == '+') p++;
|
||||||
|
|
||||||
|
while (*p && isdigit(*p))
|
||||||
|
{
|
||||||
|
result = result * 10 + *p - '0';
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
return negative ? (UINT)-result : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user