- return a precomputed result for a NULL string

- pass strlen an LPSTR to eliminate a sign warning
This commit is contained in:
Mike McCormack 2005-08-22 09:19:38 +00:00 committed by Alexandre Julliard
parent 6bb46e31e7
commit 6c8527c31c
1 changed files with 17 additions and 15 deletions

View File

@ -813,27 +813,29 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid)
*/
HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id)
{
const BYTE *s = (const BYTE *) idstr;
const BYTE *s;
int i;
BYTE table[256];
if (!s)
s = "{00000000-0000-0000-0000-000000000000}";
else { /* validate the CLSID string */
if (!idstr) {
memset( id, 0, sizeof (CLSID) );
return S_OK;
}
if (strlen(s) != 38)
return CO_E_CLASSSTRING;
/* validate the CLSID string */
if (strlen(idstr) != 38)
return CO_E_CLASSSTRING;
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
return CO_E_CLASSSTRING;
s = (const BYTE *) idstr;
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
return CO_E_CLASSSTRING;
for (i=1; i<37; i++) {
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
((s[i] >= 'a') && (s[i] <= 'f')) ||
((s[i] >= 'A') && (s[i] <= 'F'))))
return CO_E_CLASSSTRING;
}
for (i=1; i<37; i++) {
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
((s[i] >= 'a') && (s[i] <= 'f')) ||
((s[i] >= 'A') && (s[i] <= 'F'))))
return CO_E_CLASSSTRING;
}
TRACE("%s -> %p\n", s, id);