- fix: can't correctly handle '&&' and '||' in the #if directive (and correctly parse windows.h header file)

This commit is contained in:
royqh1979 2021-10-24 23:31:26 +08:00
parent 7bb59955e6
commit 3529e8dfea
2 changed files with 13 additions and 8 deletions

View File

@ -8,6 +8,7 @@ Version 0.7.3
- enhancement: "use utf8 by default" in editor's misc setting
- fix: syntax issues not correctly cleared when the file was saved as another name.
- enhancement: when running a program, redirect a data file to its stdin
- fix: can't correctly handle '&&' and '||' in the #if directive (and correctly parse windows.h header file)
Version 0.7.2
- fix: rainbow parenthesis stop functioning when change editor's general options

View File

@ -1320,21 +1320,21 @@ bool CppPreprocessor::evalNumber(const QString &expr, int &result, int &pos)
if (s.endsWith("LL",Qt::CaseInsensitive)) {
s.remove(s.length()-2,2);
result = s.toLongLong(&ok,0);
result = s.toLongLong(&ok);
} else if (s.endsWith("L",Qt::CaseInsensitive)) {
s.remove(s.length()-1,1);
result = s.toLong(&ok,0);
result = s.toLong(&ok);
} else if (s.endsWith("ULL",Qt::CaseInsensitive)) {
s.remove(s.length()-3,3);
result = s.toULongLong(&ok,0);
result = s.toULongLong(&ok);
} else if (s.endsWith("UL",Qt::CaseInsensitive)) {
s.remove(s.length()-2,2);
result = s.toULong(&ok,0);
result = s.toULong(&ok);
} else if (s.endsWith("U",Qt::CaseInsensitive)) {
s.remove(s.length()-1,1);
result = s.toUInt(&ok,0);
result = s.toUInt(&ok);
} else {
result = s.toInt(&ok,0);
result = s.toInt(&ok);
}
return ok;
}
@ -1578,7 +1578,9 @@ bool CppPreprocessor::evalBitAndExpr(const QString &expr, int &result, int &pos)
while (true) {
if (!skipSpaces(expr,pos))
break;
if (expr[pos]=='&') {
if (expr[pos]=='&'
&& (pos == expr.length()
|| expr[pos+1]!='&')) {
pos++;
int rightResult;
if (!evalEqualExpr(expr,rightResult,pos))
@ -1626,7 +1628,9 @@ bool CppPreprocessor::evalBitOrExpr(const QString &expr, int &result, int &pos)
while (true) {
if (!skipSpaces(expr,pos))
break;
if (expr[pos] == '|') {
if (expr[pos] == '|'
&& (pos == expr.length()
|| expr[pos+1]!='|')) {
pos++;
int rightResult;
if (!evalBitXorExpr(expr,rightResult,pos))