Tools: Fix single-character string literals.

Use character literals where applicable.

Change-Id: I55679dcc13c4c79567712c0dfaaabc2b84fee010
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-10-13 12:26:45 +02:00
parent c2472e9105
commit 16154fba86
9 changed files with 31 additions and 26 deletions

View File

@ -103,7 +103,7 @@ void SegmentProperties::invalidate()
{ {
m_blockSignals = true; m_blockSignals = true;
m_ui_pane_p.label->setText(QLatin1String("p") + QString::number(m_segment)); m_ui_pane_p.label->setText(QLatin1Char('p') + QString::number(m_segment));
m_ui_pane_p.smooth->setChecked(m_smooth); m_ui_pane_p.smooth->setChecked(m_smooth);
m_ui_pane_p.smooth->parentWidget()->setEnabled(!m_last); m_ui_pane_p.smooth->parentWidget()->setEnabled(!m_last);

View File

@ -291,10 +291,11 @@ QString SplineEditor::generateCode()
{ {
QString s = QLatin1String("["); QString s = QLatin1String("[");
foreach (const QPointF &point, m_controlPoints) { foreach (const QPointF &point, m_controlPoints) {
s += QString::number(point.x(), 'g', 2) + "," + QString::number(point.y(), 'g', 3) + ","; s += QString::number(point.x(), 'g', 2) + QLatin1Char(',')
+ QString::number(point.y(), 'g', 3) + QLatin1Char(',');
} }
s.chop(1); //removing last "," s.chop(1); //removing last ","
s += "]"; s += QLatin1Char(']');
return s; return s;
} }
@ -673,7 +674,7 @@ void SplineEditor::setEasingCurve(const QString &code)
{ {
if (m_block) if (m_block)
return; return;
if (code.left(1) == QLatin1String("[") && code.right(1) == QLatin1String("]")) { if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
QString cleanCode = code; QString cleanCode = code;
cleanCode.remove(0, 1); cleanCode.remove(0, 1);
cleanCode.chop(1); cleanCode.chop(1);

View File

@ -129,10 +129,10 @@ QVariantMap pluginsForModulePath(const QString &modulePath) {
line = qmldirFile.readLine(); line = qmldirFile.readLine();
if (line.startsWith("plugin")) { if (line.startsWith("plugin")) {
plugins += QString::fromUtf8(line.split(' ').at(1)); plugins += QString::fromUtf8(line.split(' ').at(1));
plugins += QStringLiteral(" "); plugins += QLatin1Char(' ');
} else if (line.startsWith("classname")) { } else if (line.startsWith("classname")) {
classnames += QString::fromUtf8(line.split(' ').at(1)); classnames += QString::fromUtf8(line.split(' ').at(1));
classnames += QStringLiteral(" "); classnames += QLatin1Char(' ');
} else if (line.startsWith("depends")) { } else if (line.startsWith("depends")) {
QList<QByteArray> dep = line.split(' '); QList<QByteArray> dep = line.split(' ');
if (dep.length() != 3) if (dep.length() != 3)
@ -199,7 +199,7 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
if (plugininfo.contains(QStringLiteral("dependencies"))) { if (plugininfo.contains(QStringLiteral("dependencies"))) {
QStringList dependencies = plugininfo.value(QStringLiteral("dependencies")).toStringList(); QStringList dependencies = plugininfo.value(QStringLiteral("dependencies")).toStringList();
foreach (const QString &line, dependencies) { foreach (const QString &line, dependencies) {
QList<QString> dep = line.split(QStringLiteral(" ")); QList<QString> dep = line.split(QLatin1Char(' '));
QVariantMap depImport; QVariantMap depImport;
depImport[QStringLiteral("type")] = QStringLiteral("module"); depImport[QStringLiteral("type")] = QStringLiteral("module");
depImport[QStringLiteral("name")] = dep[0]; depImport[QStringLiteral("name")] = dep[0];

View File

@ -126,8 +126,8 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio
foreach (const QV4::StackFrame &frame, trace) { foreach (const QV4::StackFrame &frame, trace) {
std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source); std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source);
if (frame.line >= 0) if (frame.line >= 0)
std::cerr << ":" << frame.line; std::cerr << ':' << frame.line;
std::cerr << ")" << std::endl; std::cerr << ')' << std::endl;
} }
} }

View File

@ -245,7 +245,7 @@ void Minify::escape(const QChar &ch, QString *out)
switch (hx.length()) { switch (hx.length()) {
case 1: out->append(QLatin1String("000")); break; case 1: out->append(QLatin1String("000")); break;
case 2: out->append(QLatin1String("00")); break; case 2: out->append(QLatin1String("00")); break;
case 3: out->append(QLatin1String("0")); break; case 3: out->append(QLatin1Char('0')); break;
case 4: break; case 4: break;
default: Q_ASSERT(!"unreachable"); default: Q_ASSERT(!"unreachable");
} }
@ -274,7 +274,8 @@ bool Minify::parse(int startToken)
_tokens.append(tokenKind()); _tokens.append(tokenKind());
_tokenStrings.append(tokenText()); _tokenStrings.append(tokenText());
} else { } else {
std::cerr << qPrintable(fileName()) << ":" << tokenStartLine() << ":" << tokenStartColumn() << ": syntax error" << std::endl; std::cerr << qPrintable(fileName()) << ':' << tokenStartLine() << ':'
<< tokenStartColumn() << ": syntax error" << std::endl;
return false; return false;
} }
} }
@ -394,7 +395,8 @@ bool Minify::parse(int startToken)
goto again; goto again;
} }
std::cerr << qPrintable(fileName()) << ":" << tokenStartLine() << ":" << tokenStartColumn() << ": syntax error" << std::endl; std::cerr << qPrintable(fileName()) << ':' << tokenStartLine() << ':' << tokenStartColumn()
<< ": syntax error" << std::endl;
return false; return false;
} }
@ -447,7 +449,8 @@ bool Tokenize::parse(int startToken)
_tokens.append(tokenKind()); _tokens.append(tokenKind());
_tokenStrings.append(tokenText()); _tokenStrings.append(tokenText());
} else { } else {
std::cerr << qPrintable(fileName()) << ":" << tokenStartLine() << ":" << tokenStartColumn() << ": syntax error" << std::endl; std::cerr << qPrintable(fileName()) << ':' << tokenStartLine() << ':'
<< tokenStartColumn() << ": syntax error" << std::endl;
return false; return false;
} }
} }
@ -511,7 +514,8 @@ bool Tokenize::parse(int startToken)
goto again; goto again;
} }
std::cerr << qPrintable(fileName()) << ":" << tokenStartLine() << ":" << tokenStartColumn() << ": syntax error" << std::endl; std::cerr << qPrintable(fileName()) << ':' << tokenStartLine() << ':'
<< tokenStartColumn() << ": syntax error" << std::endl;
return false; return false;
} }
@ -599,7 +603,7 @@ int runQmlmin(int argc, char *argv[])
else { else {
usage(/*show help*/ isInvalidOpt); usage(/*show help*/ isInvalidOpt);
if (isInvalidOpt) if (isInvalidOpt)
std::cerr << "qmlmin: invalid option '" << qPrintable(arg) << "'" << std::endl; std::cerr << "qmlmin: invalid option '" << qPrintable(arg) << '\'' << std::endl;
else else
std::cerr << "qmlmin: too many input files specified" << std::endl; std::cerr << "qmlmin: too many input files specified" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
@ -632,7 +636,7 @@ int runQmlmin(int argc, char *argv[])
// //
QQmlJS::Minify secondMinify(width); QQmlJS::Minify secondMinify(width);
if (! secondMinify(fileName, minify.minifiedCode()) || secondMinify.minifiedCode() != minify.minifiedCode()) { if (! secondMinify(fileName, minify.minifiedCode()) || secondMinify.minifiedCode() != minify.minifiedCode()) {
std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "'" << std::endl; std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << '\'' << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -641,7 +645,7 @@ int runQmlmin(int argc, char *argv[])
minimizedTokens(fileName, minify.minifiedCode()); minimizedTokens(fileName, minify.minifiedCode());
if (originalTokens.tokenStream().size() != minimizedTokens.tokenStream().size()) { if (originalTokens.tokenStream().size() != minimizedTokens.tokenStream().size()) {
std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "'" << std::endl; std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << '\'' << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -375,7 +375,7 @@ public:
if (qmlTyName.startsWith("./")) { if (qmlTyName.startsWith("./")) {
qmlTyName.remove(0, 2); qmlTyName.remove(0, 2);
} }
if (qmlTyName.startsWith("/")) { if (qmlTyName.startsWith(QLatin1Char('/'))) {
qmlTyName.remove(0, 1); qmlTyName.remove(0, 1);
} }
const QString exportString = enquote( const QString exportString = enquote(
@ -736,7 +736,7 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
std::cerr << "parsing " std::cerr << "parsing "
<< qPrintable( dependenciesFile ) << " skipping"; << qPrintable( dependenciesFile ) << " skipping";
foreach (const QString &uriToSkip, urisToSkip) foreach (const QString &uriToSkip, urisToSkip)
std::cerr << " " << qPrintable(uriToSkip); std::cerr << ' ' << qPrintable(uriToSkip);
std::cerr << std::endl; std::cerr << std::endl;
} }
QJsonParseError parseError; QJsonParseError parseError;
@ -829,7 +829,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
if (!importScanner.waitForFinished()) { if (!importScanner.waitForFinished()) {
std::cerr << "failure to start " << qPrintable(command); std::cerr << "failure to start " << qPrintable(command);
foreach (const QString &arg, commandArgs) foreach (const QString &arg, commandArgs)
std::cerr << " " << qPrintable(arg); std::cerr << ' ' << qPrintable(arg);
std::cerr << std::endl; std::cerr << std::endl;
return false; return false;
} }

View File

@ -485,7 +485,7 @@ void QmlProfilerApplication::run()
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this,
SLOT(processFinished())); SLOT(processFinished()));
logStatus(QString("Starting '%1 %2' ...").arg(m_programPath, logStatus(QString("Starting '%1 %2' ...").arg(m_programPath,
arguments.join(" "))); arguments.join(QLatin1Char(' '))));
m_process->start(m_programPath, arguments); m_process->start(m_programPath, arguments);
if (!m_process->waitForStarted()) { if (!m_process->waitForStarted()) {
logError(QString("Could not run '%1': %2").arg(m_programPath, logError(QString("Could not run '%1': %2").arg(m_programPath,

View File

@ -262,8 +262,8 @@ void QmlProfilerData::addQmlEvent(QQmlProfilerDefinitions::RangeType type,
if (data.isEmpty()) if (data.isEmpty())
details = tr("Source code not available"); details = tr("Source code not available");
else { else {
details = data.join(QStringLiteral(" ")).replace( details = data.join(QLatin1Char(' ')).replace(
QLatin1Char('\n'),QStringLiteral(" ")).simplified(); QLatin1Char('\n'), QLatin1Char(' ')).simplified();
QRegExp rewrite(QStringLiteral("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)")); QRegExp rewrite(QStringLiteral("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
bool match = rewrite.exactMatch(details); bool match = rewrite.exactMatch(details);
if (match) { if (match) {

View File

@ -204,7 +204,7 @@ static int displayOptionsDialog(Options *options)
QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources"); QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources");
foreach (QFileInfo fileInfo, fileInfos) foreach (QFileInfo fileInfo, fileInfos)
qmlFileComboBox->addItem(fileInfo.dir().dirName() + "/" + fileInfo.fileName(), QVariant::fromValue(fileInfo)); qmlFileComboBox->addItem(fileInfo.dir().dirName() + QLatin1Char('/') + fileInfo.fileName(), QVariant::fromValue(fileInfo));
QCheckBox *originalCheckBox = new QCheckBox(&dialog); QCheckBox *originalCheckBox = new QCheckBox(&dialog);
originalCheckBox->setText("Use original QML viewer"); originalCheckBox->setText("Use original QML viewer");
@ -235,7 +235,7 @@ static int displayOptionsDialog(Options *options)
QVariant variant = qmlFileComboBox->itemData(qmlFileComboBox->currentIndex()); QVariant variant = qmlFileComboBox->itemData(qmlFileComboBox->currentIndex());
QFileInfo fileInfo = variant.value<QFileInfo>(); QFileInfo fileInfo = variant.value<QFileInfo>();
if (fileInfo.canonicalFilePath().startsWith(":")) if (fileInfo.canonicalFilePath().startsWith(QLatin1Char(':')))
options->file = QUrl("qrc" + fileInfo.canonicalFilePath()); options->file = QUrl("qrc" + fileInfo.canonicalFilePath());
else else
options->file = QUrl::fromLocalFile(fileInfo.canonicalFilePath()); options->file = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
@ -270,7 +270,7 @@ static bool checkVersion(const QUrl &url)
bool codeFound= false; bool codeFound= false;
while (!codeFound) { while (!codeFound) {
QString line = stream.readLine(); QString line = stream.readLine();
if (line.contains("{")) { if (line.contains(QLatin1Char('{'))) {
codeFound = true; codeFound = true;
} else { } else {
QString import; QString import;