summaryrefslogtreecommitdiffstats
path: root/src/linguist
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-11 14:31:50 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-12 11:36:07 +0200
commit9cfa5da0238016c9732f84a3bf3642375382f77c (patch)
treee8c327fde7bc97247501b4a714c762dd640bfaae /src/linguist
parentb5d7809089a3556c3911cea63c76a6ebbcf0adfa (diff)
Be less laissez-faire with implicit conversions to QChar
QChar currently is convertible from nearly every integral type. This is bad code hygiene and should be fixed come Qt 6. The present patch is the result of compile fixes from marking these constructors explicit. As is clear from the distribution of fixes, only low-level string handling code used these implicit conversions, an indication that they're not in widespread use elsewhere. Change-Id: I02483d08d6a3ce85f574a6e0407b19d017c5032f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/linguist')
-rw-r--r--src/linguist/lupdate/java.cpp16
-rw-r--r--src/linguist/lupdate/qdeclarative.cpp2
-rw-r--r--src/linguist/shared/ts.cpp2
3 files changed, 10 insertions, 10 deletions
diff --git a/src/linguist/lupdate/java.cpp b/src/linguist/lupdate/java.cpp
index 40f5b9af1..670ca8ec9 100644
--- a/src/linguist/lupdate/java.cpp
+++ b/src/linguist/lupdate/java.cpp
@@ -108,11 +108,11 @@ std::ostream &yyMsg(int line = 0)
static QChar getChar()
{
if (yyInPos >= yyInStr.size())
- return EOF;
+ return QChar(EOF);
QChar c = yyInStr[yyInPos++];
- if (c.unicode() == '\n')
+ if (c == QLatin1Char('\n'))
++yyCurLineNo;
- return c.unicode();
+ return c;
}
static int getToken()
@@ -124,7 +124,7 @@ static int getToken()
yyComment.clear();
yyString.clear();
- while ( yyCh != EOF ) {
+ while (yyCh != QChar(EOF)) {
yyLineNo = yyCurLineNo;
if ( yyCh.isLetter() || yyCh.toLatin1() == '_' ) {
@@ -169,7 +169,7 @@ static int getToken()
if ( yyCh == QLatin1Char('/') ) {
do {
yyCh = getChar();
- if (yyCh == EOF)
+ if (yyCh == QChar(EOF))
break;
yyComment.append(yyCh);
} while (yyCh != QLatin1Char('\n'));
@@ -181,7 +181,7 @@ static int getToken()
while ( !metAsterSlash ) {
yyCh = getChar();
- if ( yyCh == EOF ) {
+ if (yyCh == QChar(EOF)) {
yyMsg() << qPrintable(LU::tr("Unterminated Java comment.\n"));
return Tok_Comment;
}
@@ -204,7 +204,7 @@ static int getToken()
case '"':
yyCh = getChar();
- while ( yyCh != EOF && yyCh != QLatin1Char('\n') && yyCh != QLatin1Char('"') ) {
+ while (yyCh != QChar(EOF) && yyCh != QLatin1Char('\n') && yyCh != QLatin1Char('"')) {
if ( yyCh == QLatin1Char('\\') ) {
yyCh = getChar();
if ( yyCh == QLatin1Char('u') ) {
@@ -257,7 +257,7 @@ static int getToken()
yyCh = getChar();
do {
yyCh = getChar();
- } while ( yyCh != EOF && yyCh != QLatin1Char('\'') );
+ } while (yyCh != QChar(EOF) && yyCh != QLatin1Char('\''));
yyCh = getChar();
break;
case '{':
diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp
index ddf7d2f35..23e8dc451 100644
--- a/src/linguist/lupdate/qdeclarative.cpp
+++ b/src/linguist/lupdate/qdeclarative.cpp
@@ -290,7 +290,7 @@ QString createErrorString(const QString &filename, const QString &code, Parser &
for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.length()); i < end; ++i) {
const QChar ch = textLine.at(i);
if (ch.isSpace())
- error += ch.unicode();
+ error += ch;
else
error += QLatin1Char(' ');
}
diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp
index 153f9708b..8d394766a 100644
--- a/src/linguist/shared/ts.cpp
+++ b/src/linguist/shared/ts.cpp
@@ -464,7 +464,7 @@ static QString protect(const QString &str)
result += QLatin1String("&apos;");
break;
default:
- if ((c < 0x20 || (ch > 0x7f && ch.isSpace())) && c != '\n' && c != '\t')
+ if ((c < 0x20 || (ch > QChar(0x7f) && ch.isSpace())) && c != '\n' && c != '\t')
result += numericEntity(c);
else // this also covers surrogates
result += QChar(c);