VirtualBox

Changeset 7420 in vbox


Ignore:
Timestamp:
Mar 10, 2008 4:13:56 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28854
Message:

Added RTStrCmp. Added missing NULL handling in RTStrICmp.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/string.h

    r7418 r7420  
    10831083
    10841084/**
     1085 * Performs a case sensitive string compare between two UTF-8 strings.
     1086 *
     1087 * Encoding errors are ignored by the current implementation. So, the only
     1088 * difference between this and the CRT strcmp function is the handling of
     1089 * NULL arguments.
     1090 *
     1091 * @returns < 0 if the first string less than the second string.
     1092 * @returns 0 if the first string identical to the second string.
     1093 * @returns > 0 if the first string greater than the second string.
     1094 * @param   psz1        First UTF-8 string. Null is allowed.
     1095 * @param   psz2        Second UTF-8 string. Null is allowed.
     1096 */
     1097RTDECL(int) RTStrCmp(const char *psz1, const char *psz2);
     1098
     1099/**
    10851100 * Performs a case insensitive string compare between two UTF-8 strings.
    10861101 *
     
    10921107 * @returns 0 if the first string identical to the second string.
    10931108 * @returns > 0 if the first string greater than the second string.
    1094  * @param   psz1        First UTF-8 string.
    1095  * @param   psz2        Second UTF-8 string.
     1109 * @param   psz1        First UTF-8 string. Null is allowed.
     1110 * @param   psz2        Second UTF-8 string. Null is allowed.
    10961111 */
    10971112RTDECL(int) RTStrICmp(const char *psz1, const char *psz2);
  • trunk/src/VBox/Runtime/common/string/utf-8.cpp

    r5999 r7420  
    964964
    965965/**
     966 * Performs a case sensitive string compare between two UTF-8 strings.
     967 *
     968 * Encoding errors are ignored by the current implementation. So, the only
     969 * difference between this and the CRT strcmp function is the handling of
     970 * NULL arguments.
     971 *
     972 * @returns < 0 if the first string less than the second string.
     973 * @returns 0 if the first string identical to the second string.
     974 * @returns > 0 if the first string greater than the second string.
     975 * @param   psz1        First UTF-8 string. Null is allowed.
     976 * @param   psz2        Second UTF-8 string. Null is allowed.
     977 */
     978RTDECL(int) RTStrCmp(const char *psz1, const char *psz2)
     979{
     980    if (psz1 == psz2)
     981        return 0;
     982    if (!psz1)
     983        return -1;
     984    if (!psz2)
     985        return 1;
     986
     987    return strcmp(psz1, psz2);
     988}
     989
     990
     991/**
    966992 * Performs a case insensitive string compare between two UTF-8 strings.
    967993 *
     
    973999 * @returns 0 if the first string identical to the second string.
    9741000 * @returns > 0 if the first string greater than the second string.
    975  * @param   psz1        First UTF-8 string.
    976  * @param   psz2        Second UTF-8 string.
     1001 * @param   psz1        First UTF-8 string. Null is allowed.
     1002 * @param   psz2        Second UTF-8 string. Null is allowed.
    9771003 */
    9781004RTDECL(int) RTStrICmp(const char *psz1, const char *psz2)
    9791005{
     1006    if (psz1 == psz2)
     1007        return 0;
     1008    if (!psz1)
     1009        return -1;
     1010    if (!psz2)
     1011        return 1;
     1012
    9801013    /** @todo implement proper UTF-8 case-insensitive string comparison. */
    9811014#ifdef RT_OS_WINDOWS
Note: See TracChangeset for help on using the changeset viewer.

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