VirtualBox

Changeset 32979 in vbox


Ignore:
Timestamp:
Oct 7, 2010 2:16:52 PM (14 years ago)
Author:
vboxsync
Message:

iprt: RTUuidFromStr() / RTUuidFromUtf16(): allow the format with braces as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/uuid-generic.cpp

    r28800 r32979  
    255255    AssertPtrReturn(pszString, VERR_INVALID_PARAMETER);
    256256
     257    bool fHaveBraces = (pszString[0] == '{' && pszString[37] == '}');
     258    if (fHaveBraces)
     259        pszString++;
     260
    257261#define MY_CHECK(expr) do { if (RT_UNLIKELY(!(expr))) return VERR_INVALID_UUID_FORMAT; } while (0)
    258262#define MY_ISXDIGIT(ch) (g_au8Digits[(ch) & 0xff] != 0xff)
     
    293297    MY_CHECK(MY_ISXDIGIT(pszString[34]));
    294298    MY_CHECK(MY_ISXDIGIT(pszString[35]));
    295     MY_CHECK(!pszString[36]);
     299    MY_CHECK(!pszString[36 + (fHaveBraces ? 1 : 0)]);
    296300#undef MY_ISXDIGIT
    297301#undef MY_CHECK
     
    421425    AssertPtrReturn(pwszString, VERR_INVALID_PARAMETER);
    422426
     427    bool fHaveBraces = (pwszString[0] == '{' && pwszString[37] == '}');
     428    if (fHaveBraces)
     429        pwszString++;
     430
    423431#define MY_CHECK(expr) do { if (RT_UNLIKELY(!(expr))) return VERR_INVALID_UUID_FORMAT; } while (0)
    424432#define MY_ISXDIGIT(ch) (!((ch) & 0xff00) && g_au8Digits[(ch) & 0xff] != 0xff)
     
    459467    MY_CHECK(MY_ISXDIGIT(pwszString[34]));
    460468    MY_CHECK(MY_ISXDIGIT(pwszString[35]));
    461     MY_CHECK(!pwszString[36]);
     469    MY_CHECK(!pwszString[36 + (fHaveBraces ? 1 : 0)]);
    462470#undef MY_ISXDIGIT
    463471#undef MY_CHECK
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette