summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringbuilder.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-07-21 16:39:55 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-22 13:10:42 +0200
commit7fc3203062f27f582de84420fa0b519c58b5d1ff (patch)
tree32acac6be4593b508847dd8aff6ad6716693c2cb /src/corelib/tools/qstringbuilder.cpp
parent769f5223425e24d4305c94482580970dea1e63c8 (diff)
QAbstractConcatenable::convertFromAscii: make len the actual length
Before, it was the length + 1, to include the ending \0 (for historical reasons) Having it the actual length is more intuitive and less error prone Also added QT_ASCII_CAST_WARN to QConcatenable<QByteArray>::appendTo to show the warnig that convertion from ascii to qstring occurs. Change-Id: Ie7c8552b6b4e7ccb393cb09f5f0ca9b00336c714 Reviewed-by: thiago Reviewed-on: http://codereview.qt.nokia.com/1988 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src/corelib/tools/qstringbuilder.cpp')
-rw-r--r--src/corelib/tools/qstringbuilder.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 4c6848498b..7c1bde4ac7 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -108,13 +108,12 @@ QT_BEGIN_NAMESPACE
*/
/*! \internal
- Note: The len contains the ending \0
*/
void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
{
#ifndef QT_NO_TEXTCODEC
if (QString::codecForCStrings && len) {
- QString tmp = QString::fromAscii(a, len > 0 ? len - 1 : -1);
+ QString tmp = QString::fromAscii(a, len > 0 ? len : -1);
memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
out += tmp.length();
return;
@@ -126,7 +125,7 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out
while (*a)
*out++ = QLatin1Char(*a++);
} else {
- for (int i = 0; i < len - 1; ++i)
+ for (int i = 0; i < len; ++i)
*out++ = QLatin1Char(a[i]);
}
}