Change remaining uses of {to,from}Ascii to {to,from}Latin1 [QtCore]

This operation should be a no-op anyway, since at this point in time,
the fromAscii and toAscii functions simply call their fromLatin1 and
toLatin1 counterparts.

Task-number: QTBUG-21872
Change-Id: I38f97ad379deafebef02c75d611343ca15640c8a
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
Thiago Macieira 2012-05-02 16:32:26 +02:00 committed by Qt by Nokia
parent 2376a5c4e0
commit 712ca9d95a
17 changed files with 39 additions and 39 deletions

View File

@ -73,10 +73,10 @@ static QString driveSpec(const QString &path)
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
if (path.size() < 2) if (path.size() < 2)
return QString(); return QString();
char c = path.at(0).toAscii(); char c = path.at(0).toLatin1();
if (c < 'a' && c > 'z' && c < 'A' && c > 'Z') if (c < 'a' && c > 'z' && c < 'A' && c > 'Z')
return QString(); return QString();
if (path.at(1).toAscii() != ':') if (path.at(1).toLatin1() != ':')
return QString(); return QString();
return path.mid(0, 2); return path.mid(0, 2);
#else #else

View File

@ -200,7 +200,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QRegExp varRegExp(QLatin1String("\\$\\{([^\\}]*)\\}")); QRegExp varRegExp(QLatin1String("\\$\\{([^\\}]*)\\}"));
while (value.contains(varRegExp)) { while (value.contains(varRegExp)) {
QString replacement = QString replacement =
QFile::decodeName(qgetenv(varRegExp.cap(1).toAscii().data())); QFile::decodeName(qgetenv(varRegExp.cap(1).toLatin1().data()));
value.replace(varRegExp.cap(0), replacement); value.replace(varRegExp.cap(0), replacement);
} }
} }

View File

@ -2341,7 +2341,7 @@ QTextStream &QTextStream::operator<<(char c)
{ {
Q_D(QTextStream); Q_D(QTextStream);
CHECK_VALID_STREAM(*this); CHECK_VALID_STREAM(*this);
d->putString(QString(QChar::fromAscii(c))); d->putString(QString(QChar::fromLatin1(c)));
return *this; return *this;
} }

View File

@ -3236,7 +3236,7 @@ void QMetaObject::connectSlotsByName(QObject *o)
bool foundIt = false; bool foundIt = false;
for(int j = 0; j < list.count(); ++j) { for(int j = 0; j < list.count(); ++j) {
const QObject *co = list.at(j); const QObject *co = list.at(j);
QByteArray objName = co->objectName().toAscii(); QByteArray objName = co->objectName().toLatin1();
int len = objName.length(); int len = objName.length();
if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_') if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
continue; continue;

View File

@ -290,7 +290,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break; break;
case QMetaType::Char: case QMetaType::Char:
case QMetaType::UChar: case QMetaType::UChar:
*str = QChar::fromAscii(d->data.c); *str = QChar::fromLatin1(d->data.c);
break; break;
case QMetaType::Short: case QMetaType::Short:
case QMetaType::Long: case QMetaType::Long:

View File

@ -285,7 +285,7 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
#endif #endif
if (!address) { if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromAscii(symbol)).arg(fileName).arg(qdlerror()); QString::fromLatin1(symbol)).arg(fileName).arg(qdlerror());
} else { } else {
errorString.clear(); errorString.clear();
} }

View File

@ -122,7 +122,7 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
#endif #endif
if (!address) { if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromAscii(symbol)).arg(fileName).arg(qt_error_string()); QString::fromLatin1(symbol)).arg(fileName).arg(qt_error_string());
} else { } else {
errorString.clear(); errorString.clear();
} }

View File

@ -1421,9 +1421,9 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item)
debug << "type:" << item.d_ptr->type debug << "type:" << item.d_ptr->type
<< "func:" << item.d_ptr->func; << "func:" << item.d_ptr->func;
if (item.d_ptr->config) { if (item.d_ptr->config) {
debug << QString::fromAscii("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20) debug << QString::fromLatin1("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20)
<< QString::fromAscii("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20) << QString::fromLatin1("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20)
<< QString::fromAscii("overshoot:%1").arg(item.d_ptr->config->_o, 0, 'f', 20); << QString::fromLatin1("overshoot:%1").arg(item.d_ptr->config->_o, 0, 'f', 20);
} }
return debug; return debug;
} }

View File

@ -578,9 +578,9 @@ void tst_QTextCodec::utf8Codec_data()
// QTest::newRow("null5") << QByteArray() << QString() << 5; // QTest::newRow("null5") << QByteArray() << QString() << 5;
QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1; QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1;
QTest::newRow("empty0") << QByteArray() << QString() << 0; QTest::newRow("empty0") << QByteArray() << QString() << 0;
QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromAscii("\0abcd", 5) << 5; QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromLatin1("\0abcd", 5) << 5;
QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab") << -1; QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab") << -1;
QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab\0cd", 5) << 5; QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab\0cd", 5) << 5;
str = "Old Italic: "; str = "Old Italic: ";
str += QChar(0xd800); str += QChar(0xd800);

View File

@ -481,7 +481,7 @@ void tst_QDir::exists_data()
char drive = 'Z'; char drive = 'Z';
QString driv; QString driv;
do { do {
driv = QString::fromAscii("%1:/").arg(drive); driv = QString::fromLatin1("%1:/").arg(drive);
if (!driveLetters.contains(driv)) break; if (!driveLetters.contains(driv)) break;
--drive; --drive;
} while (drive >= 'A'); } while (drive >= 'A');

View File

@ -1544,7 +1544,7 @@ void tst_QFile::bufferedRead()
file.close(); file.close();
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r"); FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toLatin1() , "r");
#else #else
FILE *stdFile = fopen("stdfile.txt", "r"); FILE *stdFile = fopen("stdfile.txt", "r");
#endif #endif
@ -2306,7 +2306,7 @@ void tst_QFile::virtualFile()
void tst_QFile::textFile() void tst_QFile::textFile()
{ {
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toAscii() , "wt"); FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toLatin1() , "wt");
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
FILE *fs = ::fopen("writeabletextfile", "wt"); FILE *fs = ::fopen("writeabletextfile", "wt");
#else #else

View File

@ -74,7 +74,7 @@ void Receiver::received ()
s->fire (); s->fire ();
fprintf (stderr, "Receiver<%s>::received() sender=%s\n", fprintf (stderr, "Receiver<%s>::received() sender=%s\n",
(const char *) objectName ().toAscii (), sender ()->metaObject()->className()); (const char *) objectName ().toLatin1 (), sender ()->metaObject()->className());
TRACE (stepCopy, "ends Receiver::received()"); TRACE (stepCopy, "ends Receiver::received()");
} }
@ -93,7 +93,7 @@ void Disconnector::received ()
qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step); qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n", fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
(const char *) objectName ().toAscii (), sender ()->metaObject()->className()); (const char *) objectName ().toLatin1 (), sender ()->metaObject()->className());
if (sender () == 0) if (sender () == 0)
fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n"); fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");

View File

@ -197,9 +197,9 @@ QByteArray verifyZeroTermination(const QByteArray &ba)
int baSize = ba.size(); int baSize = ba.size();
char baTerminator = ba.constData()[baSize]; char baTerminator = ba.constData()[baSize];
if ('\0' != baTerminator) if ('\0' != baTerminator)
return QString::fromAscii( return QString::fromLatin1(
"*** Result ('%1') not null-terminated: 0x%2 ***").arg(QString::fromAscii(ba)) "*** Result ('%1') not null-terminated: 0x%2 ***").arg(QString::fromLatin1(ba))
.arg(baTerminator, 2, 16, QChar('0')).toAscii(); .arg(baTerminator, 2, 16, QChar('0')).toLatin1();
// Skip mutating checks on shared strings // Skip mutating checks on shared strings
if (baDataPtr->ref.isShared()) if (baDataPtr->ref.isShared())
@ -210,12 +210,12 @@ QByteArray verifyZeroTermination(const QByteArray &ba)
const_cast<char *>(baData)[baSize] = 'x'; const_cast<char *>(baData)[baSize] = 'x';
if ('x' != ba.constData()[baSize]) { if ('x' != ba.constData()[baSize]) {
return QString::fromAscii("*** Failed to replace null-terminator in " return QString::fromLatin1("*** Failed to replace null-terminator in "
"result ('%1') ***").arg(QString::fromAscii(ba)).toAscii(); "result ('%1') ***").arg(QString::fromLatin1(ba)).toLatin1();
} }
if (ba != baCopy) { if (ba != baCopy) {
return QString::fromAscii( "*** Result ('%1') differs from its copy " return QString::fromLatin1( "*** Result ('%1') differs from its copy "
"after null-terminator was replaced ***").arg(QString::fromAscii(ba)).toAscii(); "after null-terminator was replaced ***").arg(QString::fromLatin1(ba)).toLatin1();
} }
const_cast<char *>(baData)[baSize] = '\0'; // Restore sanity const_cast<char *>(baData)[baSize] = '\0'; // Restore sanity

View File

@ -174,8 +174,8 @@ void tst_QCryptographicHash::files_data() {
QTest::addColumn<QString>("filename"); QTest::addColumn<QString>("filename");
QTest::addColumn<QCryptographicHash::Algorithm>("algorithm"); QTest::addColumn<QCryptographicHash::Algorithm>("algorithm");
QTest::addColumn<QByteArray>("md5sum"); QTest::addColumn<QByteArray>("md5sum");
QTest::newRow("data1") << QString::fromAscii("data/2c1517dad3678f03917f15849b052fd5.md5") << QCryptographicHash::Md5 << QByteArray("2c1517dad3678f03917f15849b052fd5"); QTest::newRow("data1") << QString::fromLatin1("data/2c1517dad3678f03917f15849b052fd5.md5") << QCryptographicHash::Md5 << QByteArray("2c1517dad3678f03917f15849b052fd5");
QTest::newRow("data2") << QString::fromAscii("data/d41d8cd98f00b204e9800998ecf8427e.md5") << QCryptographicHash::Md5 << QByteArray("d41d8cd98f00b204e9800998ecf8427e"); QTest::newRow("data2") << QString::fromLatin1("data/d41d8cd98f00b204e9800998ecf8427e.md5") << QCryptographicHash::Md5 << QByteArray("d41d8cd98f00b204e9800998ecf8427e");
} }

View File

@ -103,15 +103,15 @@ void tst_QEasingCurve::type()
QTest::ignoreMessage(QtWarningMsg, "QEasingCurve: Invalid curve type -9999"); QTest::ignoreMessage(QtWarningMsg, "QEasingCurve: Invalid curve type -9999");
curve.setType((QEasingCurve::Type)-9999); curve.setType((QEasingCurve::Type)-9999);
QCOMPARE(curve.type(), QEasingCurve::InCubic); QCOMPARE(curve.type(), QEasingCurve::InCubic);
QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1") QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QEasingCurve: Invalid curve type %1")
.arg(QEasingCurve::NCurveTypes).toLatin1().constData()); .arg(QEasingCurve::NCurveTypes).toLatin1().constData());
curve.setType(QEasingCurve::NCurveTypes); curve.setType(QEasingCurve::NCurveTypes);
QCOMPARE(curve.type(), QEasingCurve::InCubic); QCOMPARE(curve.type(), QEasingCurve::InCubic);
QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1") QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QEasingCurve: Invalid curve type %1")
.arg(QEasingCurve::Custom).toLatin1().constData()); .arg(QEasingCurve::Custom).toLatin1().constData());
curve.setType(QEasingCurve::Custom); curve.setType(QEasingCurve::Custom);
QCOMPARE(curve.type(), QEasingCurve::InCubic); QCOMPARE(curve.type(), QEasingCurve::InCubic);
QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1") QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QEasingCurve: Invalid curve type %1")
.arg(-1).toLatin1().constData()); .arg(-1).toLatin1().constData());
curve.setType((QEasingCurve::Type)-1); curve.setType((QEasingCurve::Type)-1);
QCOMPARE(curve.type(), QEasingCurve::InCubic); QCOMPARE(curve.type(), QEasingCurve::InCubic);
@ -389,10 +389,10 @@ void tst_QEasingCurve::valueForProgress()
for (int t = 0; t <= 100; t+= 10) { for (int t = 0; t <= 100; t+= 10) {
qreal ease = curve.valueForProgress(t/qreal(100)); qreal ease = curve.valueForProgress(t/qreal(100));
strInputs += QString::fromAscii(" << %1").arg(t); strInputs += QString::fromLatin1(" << %1").arg(t);
strOutputs += " << " + fixedToString(qRound(ease*10000)); strOutputs += " << " + fixedToString(qRound(ease*10000));
} }
QString str = QString::fromAscii(" QTest::newRow(\"%1\") << int(QEasingCurve::%2)\n" QString str = QString::fromLatin1(" QTest::newRow(\"%1\") << int(QEasingCurve::%2)\n"
" << (IntList() %3)\n" " << (IntList() %3)\n"
" << (RealList()%4);\n\n") " << (RealList()%4);\n\n")
.arg(strCurve) .arg(strCurve)

View File

@ -2124,14 +2124,14 @@ void tst_Collections::qstring()
QVERIFY(s.toLocal8Bit().isEmpty()); QVERIFY(s.toLocal8Bit().isEmpty());
s = "first-ascii"; s = "first-ascii";
QVERIFY(s.toAscii() == "first-ascii"); QVERIFY(s.toLatin1() == "first-ascii");
s = "second-ascii"; s = "second-ascii";
QVERIFY(s.toAscii() == "second-ascii"); QVERIFY(s.toLatin1() == "second-ascii");
s.clear(); s.clear();
QVERIFY(s.isNull()); QVERIFY(s.isNull());
QVERIFY(s.toAscii().size() == 0); QVERIFY(s.toLatin1().size() == 0);
QVERIFY(s.toAscii().isEmpty()); QVERIFY(s.toLatin1().isEmpty());
QVERIFY(s.toAscii().isNull()); QVERIFY(s.toLatin1().isNull());
s = "ascii"; s = "ascii";
s += QChar((uchar) 0xb0); s += QChar((uchar) 0xb0);

View File

@ -228,7 +228,7 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
wchar_t szSearchPath[MAX_PATH]; wchar_t szSearchPath[MAX_PATH];
QString::fromAscii(path).toWCharArray(szSearchPath); QString::fromLatin1(path).toWCharArray(szSearchPath);
wcscat(szSearchPath, L"\\*"); wcscat(szSearchPath, L"\\*");
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult); HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
m_bFirstSearchResult = true; m_bFirstSearchResult = true;