summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-11-20 14:26:12 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-11-24 14:23:41 +0000
commit690ac170a61976e3d4e3b4f35de51c28c29aa07e (patch)
treef3515f9090049c3bc8c39fcb5366b3ef9b9b9f0d /src
parentcd37dc02bd8bbe9c54460e323a104bae5fee7f33 (diff)
qdoc: Fix incorrect usage of QChar(EOF)
Since qtbase commit 915be660, QChar(EOF), where EOF is defined as (-1) in stdlib.h, is deemed incorrect and causes an assert. Instead of assigning EOF to QChar, replace the readChar() macro with a lambda and track the EOF state with a boolean. Fixes: QTBUG-88687 Change-Id: I480054cd36dc049909f709e23269d42deffecec1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit e197fcdce4cd966f57e474cd7acac2cda71511ed) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/qdoc/cppcodemarker.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index f37d9fe9c..9846a0dd8 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -447,7 +447,6 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
for (int j = sizeof(keywordTable) / sizeof(QString) - 1; j; --j)
keywords.insert(keywordTable[j]);
}
-#define readChar() ch = QChar((i < code.length()) ? code[i++].cell() : EOF)
QString code = in;
QString out;
@@ -461,10 +460,17 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
QRegularExpression classRegExp(QRegularExpression::anchoredPattern("Qt?(?:[A-Z3]+[a-z][A-Za-z]*|t)"));
QRegularExpression functionRegExp(QRegularExpression::anchoredPattern("q([A-Z][a-z]+)+"));
QRegularExpression findFunctionRegExp(QStringLiteral("^\\s*\\("));
+ bool atEOF = false;
- readChar();
+ auto readChar = [&]() {
+ if (i < code.length())
+ ch = code[i++];
+ else
+ atEOF = true;
+ };
- while (ch != QChar(EOF)) {
+ readChar();
+ while (!atEOF) {
QString tag;
bool target = false;
@@ -474,7 +480,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
ident += ch;
finish = i;
readChar();
- } while (ch.isLetterOrNumber() || ch == '_');
+ } while (!atEOF && (ch.isLetterOrNumber() || ch == '_'));
if (classRegExp.match(ident).hasMatch()) {
tag = QStringLiteral("type");
@@ -494,7 +500,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
do {
finish = i;
readChar();
- } while (ch.isLetterOrNumber() || ch == '.');
+ } while (!atEOF && (ch.isLetterOrNumber() || ch == '.'));
tag = QStringLiteral("number");
} else {
switch (ch.unicode()) {
@@ -523,7 +529,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
finish = i;
readChar();
- while (ch != QChar(EOF) && ch != '"') {
+ while (!atEOF && ch != '"') {
if (ch == '\\')
readChar();
readChar();
@@ -535,7 +541,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
case '#':
finish = i;
readChar();
- while (ch != QChar(EOF) && ch != '\n') {
+ while (!atEOF && ch != '\n') {
if (ch == '\\')
readChar();
finish = i;
@@ -547,7 +553,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
finish = i;
readChar();
- while (ch != QChar(EOF) && ch != '\'') {
+ while (!atEOF && ch != '\'') {
if (ch == '\\')
readChar();
readChar();
@@ -569,7 +575,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
case ':':
finish = i;
readChar();
- if (ch == ':') {
+ if (!atEOF && ch == ':') {
finish = i;
readChar();
tag = QStringLiteral("op");
@@ -578,11 +584,11 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
case '/':
finish = i;
readChar();
- if (ch == '/') {
+ if (!atEOF && ch == '/') {
do {
finish = i;
readChar();
- } while (ch != QChar(EOF) && ch != '\n');
+ } while (!atEOF && ch != '\n');
tag = QStringLiteral("comment");
} else if (ch == '*') {
bool metAster = false;
@@ -592,9 +598,8 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
readChar();
while (!metAsterSlash) {
- if (ch == QChar(EOF))
+ if (atEOF)
break;
-
if (ch == '*')
metAster = true;
else if (metAster && ch == '/')