~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/generic/uuid-generic.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: uuid-generic.cpp $ */
 
1
/* $Id: uuid-generic.cpp 32995 2010-10-08 08:11:27Z vboxsync $ */
2
2
/** @file
3
3
 * IPRT - UUID, Generic.
4
4
 */
248
248
 
249
249
RTDECL(int)  RTUuidFromStr(PRTUUID pUuid, const char *pszString)
250
250
{
 
251
    bool fHaveBraces;
 
252
 
251
253
    /*
252
254
     * Validate parameters.
253
255
     */
254
256
    AssertPtrReturn(pUuid, VERR_INVALID_PARAMETER);
255
257
    AssertPtrReturn(pszString, VERR_INVALID_PARAMETER);
256
258
 
 
259
    fHaveBraces = pszString[0] == '{';
 
260
    pszString += fHaveBraces;
 
261
 
257
262
#define MY_CHECK(expr) do { if (RT_UNLIKELY(!(expr))) return VERR_INVALID_UUID_FORMAT; } while (0)
258
263
#define MY_ISXDIGIT(ch) (g_au8Digits[(ch) & 0xff] != 0xff)
259
264
    MY_CHECK(MY_ISXDIGIT(pszString[ 0]));
292
297
    MY_CHECK(MY_ISXDIGIT(pszString[33]));
293
298
    MY_CHECK(MY_ISXDIGIT(pszString[34]));
294
299
    MY_CHECK(MY_ISXDIGIT(pszString[35]));
295
 
    MY_CHECK(!pszString[36]);
 
300
    if (fHaveBraces)
 
301
        MY_CHECK(pszString[36] == '}');
 
302
    MY_CHECK(!pszString[36 + fHaveBraces]);
296
303
#undef MY_ISXDIGIT
297
304
#undef MY_CHECK
298
305
 
413
420
 
414
421
RTDECL(int)  RTUuidFromUtf16(PRTUUID pUuid, PCRTUTF16 pwszString)
415
422
{
 
423
    bool fHaveBraces;
416
424
 
417
425
    /*
418
426
     * Validate parameters.
420
428
    AssertPtrReturn(pUuid, VERR_INVALID_PARAMETER);
421
429
    AssertPtrReturn(pwszString, VERR_INVALID_PARAMETER);
422
430
 
 
431
    fHaveBraces = pwszString[0] == '{';
 
432
    pwszString += fHaveBraces;
 
433
 
423
434
#define MY_CHECK(expr) do { if (RT_UNLIKELY(!(expr))) return VERR_INVALID_UUID_FORMAT; } while (0)
424
435
#define MY_ISXDIGIT(ch) (!((ch) & 0xff00) && g_au8Digits[(ch) & 0xff] != 0xff)
425
436
    MY_CHECK(MY_ISXDIGIT(pwszString[ 0]));
458
469
    MY_CHECK(MY_ISXDIGIT(pwszString[33]));
459
470
    MY_CHECK(MY_ISXDIGIT(pwszString[34]));
460
471
    MY_CHECK(MY_ISXDIGIT(pwszString[35]));
461
 
    MY_CHECK(!pwszString[36]);
 
472
    if (fHaveBraces)
 
473
        MY_CHECK(pwszString[36] == '}');
 
474
    MY_CHECK(!pwszString[36 + fHaveBraces]);
462
475
#undef MY_ISXDIGIT
463
476
#undef MY_CHECK
464
477