VirtualBox

Changeset 7345 in vbox


Ignore:
Timestamp:
Mar 6, 2008 9:16:50 PM (17 years ago)
Author:
vboxsync
Message:

Main/Glue/string: Don't strcmp NULL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/string.h

    r6935 r7345  
    130130    int compare (const BSTR str) const
    131131    {
    132         return ::RTStrUcs2Cmp ((PRTUCS2) bstr, (PRTUCS2) str);
     132        return ::RTUtf16Cmp ((PRTUTF16) bstr, (PRTUTF16) str);
    133133    }
    134134
     
    165165    bool isEmpty() const { return isNull() || *bstr == 0; }
    166166
    167     size_t length() const { return isNull() ? 0 : ::RTStrUcs2Len ((PRTUCS2) bstr); }
     167    size_t length() const { return isNull() ? 0 : ::RTUtf16Len ((PRTUTF16) bstr); }
    168168
    169169    /** Intended to to pass instances as |BSTR| input parameters to methods. */
     
    252252        if (rs)
    253253        {
    254             PRTUCS2 s = NULL;
    255             ::RTStrUtf8ToUcs2 (&s, rs);
     254            PRTUTF16 s = NULL;
     255            ::RTStrToUtf16 (rs, &s);
    256256            raw_copy (ls, (BSTR) s);
    257             ::RTStrUcs2Free (s);
     257            ::RTUtf16Free (s);
    258258        }
    259259    }
     
    272272/**
    273273 *  Helper class that represents UTF8 (|char *|) strings. Useful in
    274  *  conjunction with Bstr to simplify conversions beetween UCS2 (|BSTR|)
     274 *  conjunction with Bstr to simplify conversions beetween UTF16 (|BSTR|)
    275275 *  and UTF8.
    276276 *
     
    371371    int compare (const char *s) const
    372372    {
    373         return str == s ? 0 : ::strcmp (str, s);
     373        if (str == s)
     374            return 0;
     375        if (str == NULL)
     376            return -1;
     377        if (s == NULL)
     378            return 1;
     379
     380        return ::strcmp (str, s);
    374381    }
    375382
     
    486493        {
    487494#if !defined (VBOX_WITH_XPCOM)
    488             ::RTStrUcs2ToUtf8 (&ls, (PRTUCS2) rs);
     495            ::RTUtf16ToUtf8 ((PRTUTF16) rs, &ls);
    489496#else
    490497            char *s = NULL;
    491             ::RTStrUcs2ToUtf8 (&s, (PRTUCS2) rs);
     498            ::RTUtf16ToUtf8 ((PRTUTF16) rs, &s);
    492499            raw_copy (ls, s);
    493500            ::RTStrFree (s);
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