Author: gschneider Date: Sun Nov 29 19:07:14 2009 New Revision: 44322
URL: http://svn.reactos.org/svn/reactos?rev=44322&view=rev Log: [setupapi] Sync SetupGetIntField to Wine, fixes six setupapi:parser tests
Modified: trunk/reactos/dll/win32/setupapi/parser.c
Modified: trunk/reactos/dll/win32/setupapi/parser.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/parser.c... ============================================================================== --- trunk/reactos/dll/win32/setupapi/parser.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/parser.c [iso-8859-1] Sun Nov 29 19:07:14 2009 @@ -1894,21 +1894,26 @@ char *end, *buffer = localbuff; DWORD required; INT res; - BOOL ret = FALSE; - - if (!SetupGetStringFieldA( context, index, localbuff, sizeof(localbuff), &required )) + BOOL ret; + + if (!(ret = SetupGetStringFieldA( context, index, localbuff, sizeof(localbuff), &required ))) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE; if (!(buffer = HeapAlloc( GetProcessHeap(), 0, required ))) return FALSE; - if (!SetupGetStringFieldA( context, index, buffer, required, NULL )) goto done; - } - res = strtol( buffer, &end, 0 ); - if (end != buffer && !*end) - { - *result = res; - ret = TRUE; - } - else SetLastError( ERROR_INVALID_DATA ); + if (!(ret = SetupGetStringFieldA( context, index, buffer, required, NULL ))) goto done; + } + /* The call to SetupGetStringFieldA succeeded. If buffer is empty we have an optional field */ + if (!*buffer) *result = 0; + else + { + res = strtol( buffer, &end, 0 ); + if (end != buffer && !*end) *result = res; + else + { + SetLastError( ERROR_INVALID_DATA ); + ret = FALSE; + } + }
done: if (buffer != localbuff) HeapFree( GetProcessHeap(), 0, buffer );