diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-08-17 19:32:23 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-02 10:51:07 (GMT) |
commit | a1e1103e1c3f0e47c5d075660a77d00f47e1c125 (patch) | |
tree | 1e9f7c1f7cf9839a5e8f93986ca5e76391a5fc22 /src/corelib/tools/qstring.cpp | |
parent | 0896d1f24396a2721cf1671f4e658b8856a0f430 (diff) | |
download | Qt-a1e1103e1c3f0e47c5d075660a77d00f47e1c125.zip Qt-a1e1103e1c3f0e47c5d075660a77d00f47e1c125.tar.gz Qt-a1e1103e1c3f0e47c5d075660a77d00f47e1c125.tar.bz2 |
Rewrite ucstrcmp in terms of ucstrncmp
Reviewed-By: Bradley T. Hughes
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index d940bf8..2813b29 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -173,19 +173,6 @@ static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b) return 1; } -// Unicode case-sensitive comparison -static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) -{ - if (a == b && alen == blen) - return 0; - int l = qMin(alen, blen); - while (l-- && *a == *b) - a++,b++; - if (l == -1) - return (alen-blen); - return a->unicode() - b->unicode(); -} - // Unicode case-sensitive compare two same-sized strings static int ucstrncmp(const QChar *a, const QChar *b, int l) { @@ -196,6 +183,16 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l) return a->unicode() - b->unicode(); } +// Unicode case-sensitive comparison +static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) +{ + if (a == b && alen == blen) + return 0; + int l = qMin(alen, blen); + int cmp = ucstrncmp(a, b, l); + return cmp ? cmp : (alen-blen); +} + // Unicode case-insensitive compare two same-sized strings static int ucstrnicmp(const ushort *a, const ushort *b, int l) { |