Commit ccff4586 authored by Alexandre Julliard's avatar Alexandre Julliard

Revert change for handling user overrides as numbers and reimplement

it differently.
parent 5e69f118
...@@ -739,7 +739,7 @@ static const WCHAR *get_locale_value_name( DWORD lctype ) ...@@ -739,7 +739,7 @@ static const WCHAR *get_locale_value_name( DWORD lctype )
* Retrieve user-modified locale info from the registry. * Retrieve user-modified locale info from the registry.
* Return length, 0 on error, -1 if not found. * Return length, 0 on error, -1 if not found.
*/ */
static INT get_registry_locale_info( UINT flags, LPCWSTR value, LPWSTR buffer, INT len ) static INT get_registry_locale_info( LPCWSTR value, LPWSTR buffer, INT len )
{ {
DWORD size; DWORD size;
INT ret; INT ret;
...@@ -752,9 +752,9 @@ static INT get_registry_locale_info( UINT flags, LPCWSTR value, LPWSTR buffer, I ...@@ -752,9 +752,9 @@ static INT get_registry_locale_info( UINT flags, LPCWSTR value, LPWSTR buffer, I
if (!(hkey = create_registry_key())) return -1; if (!(hkey = create_registry_key())) return -1;
RtlInitUnicodeString( &nameW, value ); RtlInitUnicodeString( &nameW, value );
size = info_size + (flags & LOCALE_RETURN_NUMBER ? 16 : len) * sizeof(WCHAR); size = info_size + len * sizeof(WCHAR);
if (!(info = HeapAlloc( GetProcessHeap(), 0, size + sizeof(WCHAR)))) if (!(info = HeapAlloc( GetProcessHeap(), 0, size )))
{ {
NtClose( hkey ); NtClose( hkey );
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
...@@ -767,42 +767,20 @@ static INT get_registry_locale_info( UINT flags, LPCWSTR value, LPWSTR buffer, I ...@@ -767,42 +767,20 @@ static INT get_registry_locale_info( UINT flags, LPCWSTR value, LPWSTR buffer, I
if (!status) if (!status)
{ {
ret = (size - info_size) / sizeof(WCHAR); ret = (size - info_size) / sizeof(WCHAR);
/* append terminating nul if needed */ /* append terminating null if needed */
if (!ret || ((WCHAR *)info->Data)[ret-1]) if (!ret || ((WCHAR *)info->Data)[ret-1])
{ {
if (ret < len || !buffer) if (ret < len || !buffer) ret++;
{
((WCHAR *)info->Data)[ret] = '\0';
ret++;
}
else else
{ {
SetLastError( ERROR_INSUFFICIENT_BUFFER ); SetLastError( ERROR_INSUFFICIENT_BUFFER );
ret = 0; ret = 0;
} }
} }
if (ret && buffer)
if (ret)
{ {
if (flags & LOCALE_RETURN_NUMBER) memcpy( buffer, info->Data, (ret-1) * sizeof(WCHAR) );
{ buffer[ret-1] = 0;
UINT number;
WCHAR *end;
number = strtolW( (WCHAR *)info->Data, &end, 10 );
if (*end)
{
SetLastError( ERROR_INVALID_FLAGS );
ret = 0;
}
else
{
if (buffer)
memcpy( buffer, &number, sizeof(number) );
ret = sizeof(UINT)/sizeof(WCHAR);
}
}
else if (buffer)
memcpy( buffer, info->Data, ret * sizeof(WCHAR) );
} }
} }
else else
...@@ -905,8 +883,6 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len ) ...@@ -905,8 +883,6 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
const WCHAR *p; const WCHAR *p;
unsigned int i; unsigned int i;
TRACE("(0x%08lx,0x%08lx,%p,%d)\n", lcid, lctype, buffer, len);
if (len < 0 || (len && !buffer)) if (len < 0 || (len && !buffer))
{ {
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
...@@ -927,9 +903,32 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len ) ...@@ -927,9 +903,32 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
if (value) if (value)
{ {
ret = get_registry_locale_info( lcflags & LOCALE_RETURN_NUMBER, value, buffer, len ); if (lcflags & LOCALE_RETURN_NUMBER)
if (ret != -1) {
return ret; WCHAR tmp[16];
ret = get_registry_locale_info( value, tmp, sizeof(tmp)/sizeof(WCHAR) );
if (ret > 0)
{
WCHAR *end;
UINT number = strtolW( tmp, &end, 10 );
if (*end) /* invalid number */
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = sizeof(UINT)/sizeof(WCHAR);
if (!buffer) return ret;
if (ret > len)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
memcpy( buffer, &number, sizeof(number) );
}
}
else ret = get_registry_locale_info( value, buffer, len );
if (ret != -1) return ret;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment