QtCore: assorted migrations to QString::asprintf
Change-Id: Ie99d3eeeced89dd8336717954fd5ca7117bb20b4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
abcb5471b7
commit
05c38a9111
@ -617,12 +617,11 @@ void QHashData::dump()
|
||||
numBuckets);
|
||||
qDebug(" %p (fakeNode = %p)", this, fakeNext);
|
||||
for (int i = 0; i < numBuckets; ++i) {
|
||||
QString line;
|
||||
Node *n = buckets[i];
|
||||
if (n != reinterpret_cast<Node *>(this)) {
|
||||
line.sprintf("%d:", i);
|
||||
QString line = QString::asprintf("%d:", i);
|
||||
while (n != reinterpret_cast<Node *>(this)) {
|
||||
line += QString().sprintf(" -> [%p]", n);
|
||||
line += QString::asprintf(" -> [%p]", n);
|
||||
if (!n) {
|
||||
line += " (CORRUPT)";
|
||||
break;
|
||||
|
@ -69,10 +69,7 @@ int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
|
||||
if (!str || !fmt)
|
||||
return -1;
|
||||
|
||||
QString buf;
|
||||
buf.vsprintf(fmt, ap);
|
||||
|
||||
QByteArray ba = buf.toLocal8Bit();
|
||||
const QByteArray ba = QString::vasprintf(fmt, ap).toLocal8Bit();
|
||||
|
||||
if (n > 0) {
|
||||
size_t blen = qMin(size_t(ba.length()), size_t(n - 1));
|
||||
|
@ -117,13 +117,13 @@ void tst_QGetPutEnv::intValue_data()
|
||||
ROW(0xffffffff, 0, false);
|
||||
const int bases[] = {10, 8, 16};
|
||||
for (size_t i = 0; i < sizeof bases / sizeof *bases; ++i) {
|
||||
QTest::newRow(qPrintable(QString().sprintf("INT_MAX, base %d", bases[i])))
|
||||
QTest::newRow(qPrintable(QString::asprintf("INT_MAX, base %d", bases[i])))
|
||||
<< QByteArray::number(INT_MAX) << INT_MAX << true;
|
||||
QTest::newRow(qPrintable(QString().sprintf("INT_MAX+1, base %d", bases[i])))
|
||||
QTest::newRow(qPrintable(QString::asprintf("INT_MAX+1, base %d", bases[i])))
|
||||
<< QByteArray::number(qlonglong(INT_MAX) + 1) << 0 << false;
|
||||
QTest::newRow(qPrintable(QString().sprintf("INT_MIN, base %d", bases[i])))
|
||||
QTest::newRow(qPrintable(QString::asprintf("INT_MIN, base %d", bases[i])))
|
||||
<< QByteArray::number(INT_MIN) << INT_MIN << true;
|
||||
QTest::newRow(qPrintable(QString().sprintf("INT_MIN-1, base %d", bases[i])))
|
||||
QTest::newRow(qPrintable(QString::asprintf("INT_MIN-1, base %d", bases[i])))
|
||||
<< QByteArray::number(qlonglong(INT_MIN) - 1) << 0 << false;
|
||||
};
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ void QtTestObject::testLongLong(qint64 ll1, quint64 ll2)
|
||||
|
||||
void QtTestObject::testSender()
|
||||
{
|
||||
slotResult.sprintf("%p", sender());
|
||||
slotResult = QString::asprintf("%p", sender());
|
||||
}
|
||||
|
||||
void QtTestObject::slotWithUnregisteredParameterType(MyUnregisteredType)
|
||||
|
@ -1198,9 +1198,9 @@ void tst_QStateMachine::addAndRemoveState()
|
||||
{
|
||||
QStateMachine machine2;
|
||||
{
|
||||
QString warning;
|
||||
warning.sprintf("QStateMachine::removeState: state %p's machine (%p) is different from this machine (%p)",
|
||||
&machine2, (void*)0, &machine);
|
||||
const QString warning
|
||||
= QString::asprintf("QStateMachine::removeState: state %p's machine (%p) is different from this machine (%p)",
|
||||
&machine2, (void*)0, &machine);
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
|
||||
machine.removeState(&machine2);
|
||||
}
|
||||
@ -1261,8 +1261,8 @@ void tst_QStateMachine::stateEntryAndExit()
|
||||
QCOMPARE(trans->sourceState(), (QState*)s2);
|
||||
QCOMPARE(trans->targetState(), (QAbstractState*)s3);
|
||||
{
|
||||
QString warning;
|
||||
warning.sprintf("QState::removeTransition: transition %p's source state (%p) is different from this state (%p)", trans, s2, s1);
|
||||
const QString warning
|
||||
= QString::asprintf("QState::removeTransition: transition %p's source state (%p) is different from this state (%p)", trans, s2, s1);
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
|
||||
s1->removeTransition(trans);
|
||||
}
|
||||
@ -1286,8 +1286,8 @@ void tst_QStateMachine::stateEntryAndExit()
|
||||
machine.setInitialState(s1);
|
||||
QCOMPARE(machine.initialState(), (QAbstractState*)s1);
|
||||
{
|
||||
QString warning;
|
||||
warning.sprintf("QState::setInitialState: state %p is not a child of this state (%p)", &machine, &machine);
|
||||
QString warning
|
||||
= QString::asprintf("QState::setInitialState: state %p is not a child of this state (%p)", &machine, &machine);
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
|
||||
machine.setInitialState(&machine);
|
||||
QCOMPARE(machine.initialState(), (QAbstractState*)s1);
|
||||
@ -2013,8 +2013,8 @@ void tst_QStateMachine::parallelStates()
|
||||
s1_2_1->addTransition(s1_2_f);
|
||||
s1_2->setInitialState(s1_2_1);
|
||||
{
|
||||
QString warning;
|
||||
warning.sprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", s1);
|
||||
const QString warning
|
||||
= QString::asprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", s1);
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
|
||||
s1->setInitialState(0);
|
||||
}
|
||||
@ -3055,8 +3055,8 @@ void tst_QStateMachine::historyStates()
|
||||
QCOMPARE(s0h->defaultState(), (QAbstractState*)0);
|
||||
s0h->setDefaultState(s00);
|
||||
QCOMPARE(s0h->defaultState(), (QAbstractState*)s00);
|
||||
QString warning;
|
||||
warning.sprintf("QHistoryState::setDefaultState: state %p does not belong to this history state's group (%p)", s0, s0);
|
||||
const QString warning
|
||||
= QString::asprintf("QHistoryState::setDefaultState: state %p does not belong to this history state's group (%p)", s0, s0);
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
|
||||
s0h->setDefaultState(s0);
|
||||
QState *s1 = new QState(root);
|
||||
|
@ -1054,22 +1054,22 @@ void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int)
|
||||
const uint bits = bitsSetInByte(byte);
|
||||
const quint64 value = static_cast<quint64>(byte);
|
||||
const quint64 input = value << ((i % sizeof_T_Int) * 8U);
|
||||
newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bits;
|
||||
newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bits;
|
||||
}
|
||||
|
||||
// and some random ones:
|
||||
if (sizeof_T_Int >= 8)
|
||||
for (size_t i = 0; i < 1000; ++i) {
|
||||
const quint64 input = quint64(qrand()) << 32 | quint32(qrand());
|
||||
newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bitsSetInInt64(input);
|
||||
newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bitsSetInInt64(input);
|
||||
}
|
||||
else if (sizeof_T_Int >= 2)
|
||||
for (size_t i = 0; i < 1000 ; ++i) {
|
||||
const quint32 input = qrand();
|
||||
if (sizeof_T_Int >= 4)
|
||||
newRow(qPrintable(QString().sprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input);
|
||||
newRow(qPrintable(QString::asprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input);
|
||||
else
|
||||
newRow(qPrintable(QString().sprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
|
||||
newRow(qPrintable(QString::asprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ void tst_QChar::operators_data()
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j)
|
||||
QTest::newRow(qPrintable(QString().sprintf("'\\%d' (op) '\\%d'", i, j)))
|
||||
QTest::newRow(qPrintable(QString::asprintf("'\\%d' (op) '\\%d'", i, j)))
|
||||
<< QChar(ushort(i)) << QChar(ushort(j));
|
||||
}
|
||||
}
|
||||
|
@ -316,8 +316,7 @@ void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri)
|
||||
|
||||
while ( squareRegExp[ii] != 0 ) {
|
||||
for ( int j = 0; j < 100; j++ ) {
|
||||
QString name;
|
||||
name.sprintf( "square%.1d%.2d", ii, j );
|
||||
const QString name = QString::asprintf( "square%.1d%.2d", ii, j );
|
||||
|
||||
QString target = "";
|
||||
target.fill( 'a', j );
|
||||
|
Loading…
Reference in New Issue
Block a user