Skip to content

Commit

Permalink
Fix QCollator::compare documentation
Browse files Browse the repository at this point in the history
We don't guarantee -1, 0 and 1, but simply negative 0 or
positive numbers. This is in line with e.g. QString::compare()

Task-number: QTBUG-42860
Change-Id: I6009b2eb732ae3b4726cec06ec0eacc2c46a3c93
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
laknoll authored and Lars Knoll committed Mar 18, 2015
1 parent 75cb6f5 commit ba8c34a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/corelib/tools/qcollator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ bool QCollator::ignorePunctuation() const
/*!
\fn int QCollator::compare(const QString &s1, const QString &s2) const
Compares \a s1 with \a s2. Returns -1, 0 or 1 depending on whether \a s1 is
smaller, equal or larger than \a s2.
Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero
depending on whether \a s1 is smaller, equal or larger than \a s2.
*/

/*!
Expand All @@ -288,8 +288,8 @@ bool QCollator::ignorePunctuation() const
\fn int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const
\overload
Compares \a s1 with \a s2. Returns -1, 0 or 1 depending on whether \a s1 is
smaller, equal or larger than \a s2.
Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero
depending on whether \a s1 is smaller, equal or larger than \a s2.
*/

/*!
Expand All @@ -299,8 +299,9 @@ bool QCollator::ignorePunctuation() const
Compares \a s1 with \a s2. \a len1 and \a len2 specify the length of the
QChar arrays pointer to by \a s1 and \a s2.
Returns -1, 0 or 1 depending on whether \a s1 is smaller, equal or larger than \a s2.
*/
Returns an integer less than, equal to, or greater than zero
depending on whether \a s1 is smaller, equal or larger than \a s2.
*/

/*!
\fn QCollatorSortKey QCollator::sortKey(const QString &string) const
Expand Down
3 changes: 1 addition & 2 deletions src/corelib/tools/qcollator_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ int QCollator::compare(const QString &s1, const QString &s2) const
QVarLengthArray<wchar_t> array1, array2;
stringToWCharArray(array1, s1);
stringToWCharArray(array2, s2);
int result = std::wcscoll(array1.constData(), array2.constData());
return result > 0 ? 1 : (result == 0 ? 0 : -1);
return std::wcscoll(array1.constData(), array2.constData());
}

int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const
Expand Down

0 comments on commit ba8c34a

Please sign in to comment.