From 629a90d521f25dd0837c0b3428510adc4e5b4f90 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 26 Jan 2023 11:07:46 +0800 Subject: [PATCH] - enhancement: Simplified chinese translations for encoding names. - fix: Crash when there are preprocessing directives like '#if 0/0' or '#if 0%0' --- NEWS.md | 1 + RedPandaIDE/debugger.cpp | 8 ++++---- RedPandaIDE/parser/cpppreprocessor.cpp | 10 ++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 02c51855..3b624147 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,7 @@ Red Panda C++ Version 2.10 - change: Project's encoding shouldn't be set to "auto detect" - fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page. - enhancement: Simplified chinese translations for encoding names. + - fix: Crash when there are preprocessing directives like '#if 0/0' or '#if 0%0' Red Panda C++ Version 2.9 diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index e98436e0..d84c96fc 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -634,10 +634,10 @@ void Debugger::sendBreakpointCommand(PBreakpoint breakpoint) .arg(condition, filename) .arg(breakpoint->line)); } else { - // sendCommand("-break-insert", - // QString("%1 --source \"%2\" --line %3") - // .arg(condition,filename) - // .arg(breakpoint->line)); + sendCommand("-break-insert", + QString("%1 --source \"%2\" --line %3") + .arg(condition,filename) + .arg(breakpoint->line)); } } } diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 9aba6b25..9cf5e7e2 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -1441,12 +1441,18 @@ bool CppPreprocessor::evalMulExpr(const QString &expr, int &result, int &pos) pos++; if (!evalUnaryExpr(expr,rightResult,pos)) return false; - result /= rightResult; + if (rightResult != 0) + result /= rightResult; + else + result = 0; } else if (expr[pos]=='%') { pos++; if (!evalUnaryExpr(expr,rightResult,pos)) return false; - result %= rightResult; + if (rightResult != 0) + result %= rightResult; + else + result = 0; } else { break; }