I was looking through the code and came across these edits, and I want to know if everything was done correctly with regards to the macro?
| modified: 2022-05-21 | ollydbg |
m_RE_Unix.Compile(_T("([^$]|^)(\\$[({]?(#?[A-Za-z_0-9.]+)[\\)} /\\\\]?)"), wxRE_EXTENDED | wxRE_NEWLINE); wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager");
https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/macrosmanager.cpp (https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/macrosmanager.cpp)
macrosmanager.cpp: row 93
My test example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define wxCHECK2_MSG(cond, op, msg) \
if ( cond ) \
{ \
printf("cond:%d",(int)cond); \
} \
else \
{ \
printf("op:%s \"%s\" %s:%d",#op,msg,__FILE__,__LINE__); \
op; \
}
//struct wxMAKE_UNIQUE_NAME(wxDummyCheckStruct) /* to force a semicolon */
// check which returns with the specified return code if the condition fails
#define wxCHECK_MSG(cond, rc, msg) wxCHECK2_MSG(cond, return rc, msg)
int test() {
return -55550; // test 1
// return 0; // test 2
}
int main(int argc, char** argv) {
// MACROS, not need ";" in end line
wxCHECK_MSG(test(), 1212121, "Error msg string.")
printf("\n%s:%d",__FILE__,__LINE__);
return 0;
}
Quote from: omlk on November 12, 2023, 10:17:45 PM
modified: 2022-05-21 ollydbg
Is that code changed by me?
Code::Blocks / SVN Repo / Commit [r12880] (https://sourceforge.net/p/codeblocks/code/12880/)
r12880 does not contains your mentioned changes.
Any way, I don't know what's issue you see.
Quote from: ollydbg on November 13, 2023, 02:55:11 AM
Quote from: omlk on November 12, 2023, 10:17:45 PM
modified: 2022-05-21 ollydbg
I saw this information here
https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/ (https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/)
and did not mean that you added the use of a macro. I wanted to show that in this revision [r12880] there is a use of maros.
If specifically, then it seems here [r12513] (https://sourceforge.net/p/codeblocks/code/12513/) (31.9 kB) by fuscated 2021-08-15 11:51:16
The point is, does the author of the changes really know how this macro works and the behavior will be correct in the event of a compilation error of the expression?
QuoteDoes the author of the changes really know how this macro works and the behavior will be correct in the event of a compilation error of the expression
You can bet he knows. MacrosManager::CompileRegexes() will return false if any of the IsValid() calls return false.
Quote from: Miguel Gimenez on November 13, 2023, 09:06:22 AM
You can bet he knows. MacrosManager::CompileRegexes() will return false if any of the IsValid() calls return false.
I'm not talking about the MacrosManager::CompileRegexes(), but about the
wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager");
wxCHECK_MSG(m_RE_DOS.IsValid(), false, "Invalid regex (m_RE_DOS) in macros manager");
wxCHECK_MSG(m_RE_IfSp.IsValid(), false, "Invalid regex (m_RE_IfSp) in macros manager"); processing and output of information where there is an incorrect regular expression. If there is an error in the 1st reg.expression, will the following reg.expressions, which are in the code below, be checked?
What does the second argument as "FALSE" mean?
wxCHECK_MSG(.., false,..);
The first error makes the method return false, read the documentation (https://docs.wxwidgets.org/trunk/group__group__funcmacro__debug.html#ga4822a2ea9fdd0bc98caa3ff42587743e) of wxCHECK_MSG.
Quote from: Miguel Gimenez on November 13, 2023, 01:37:33 PM
The first error makes the method return false, read the documentation (https://docs.wxwidgets.org/trunk/group__group__funcmacro__debug.html#ga4822a2ea9fdd0bc98caa3ff42587743e) of wxCHECK_MSG.
bool MacrosManager::CompileRegexes() {
m_RE_Unix.Compile(_T("([^$]|^)(\\$[({]?(#?[A-Za-z_0-9.]+)[\\)} /\\\\]?)"),wxRE_EXTENDED | wxRE_NEWLINE); wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager");
m_RE_DOS.Compile(_T("([^%]|^)(%(#?[A-Za-z_0-9.]+)%)"), wxRE_EXTENDED | wxRE_NEWLINE); wxCHECK_MSG(m_RE_DOS.IsValid(), false, "Invalid regex (m_RE_DOS) in macros manager");
m_RE_IfSp.Compile(_T("(([^=!<>]+)[ ]*(=|==|!=|>|<|>=|<=)[ ]*([^=!<>]+))"),wxRE_EXTENDED | wxRE_NEWLINE);
wxCHECK_MSG(m_RE_IfSp.IsValid(), false, "Invalid regex (m_RE_IfSp) in macros manager");
m_RE_Script.Compile(_T("(\\[\\[(.*)\\]\\])"), wxRE_EXTENDED | wxRE_NEWLINE); wxCHECK_MSG(m_RE_Script.IsValid(), false, "Invalid regex (m_RE_Script) in macros manager");
#ifndef __WXMAC__ const int flagsForMac = wxRE_ADVANCED; #else const int flagsForMac = wxRE_EXTENDED;#endif
m_RE_ToAbsolutePath.Compile(_T("\\$TO_ABSOLUTE_PATH{([^}]*)}"), flagsForMac); wxCHECK_MSG(m_RE_ToAbsolutePath.IsValid(), false,"Invalid regex (m_RE_ToAbsolutePath) in macros manager");
m_RE_To83Path.Compile(_T("\\$TO_83_PATH{([^}]*)}"), flagsForMac);
wxCHECK_MSG(m_RE_To83Path.IsValid(), false, "Invalid regex (m_RE_To83Path) in macros manager");
m_RE_RemoveQuotes.Compile(_T("\\$REMOVE_QUOTES{([^}]*)}"), flagsForMac); wxCHECK_MSG(m_RE_RemoveQuotes.IsValid(), false,"Invalid regex (m_RE_RemoveQuotes) in macros manager");
return true;
} this execute?
wxCHECK_MSG(m_RE_RemoveQuotes.IsValid(), false,"Invalid regex (m_RE_RemoveQuotes) in macros manager"); if in first
wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager"); retur false
You can specify which method will return false?
QuoteYou can specify which method will return false?
MacrosManager::CompileRegexes()
Quote from: Miguel Gimenez on November 13, 2023, 01:57:44 PM
QuoteYou can specify which method will return false?
MacrosManager::CompileRegexes()
Do other regular expressions not need to be checked?
what is the goal of your question ?
the macro is documented on what the second parameter does.
They will be checked after the failing one has been fixed.
Quote from: Miguel Gimenez on November 13, 2023, 02:22:53 PM
They will be checked after the failing one has been fixed.
OK, is that what you wanted? replacing assert? :)
assert generates an exception only in debug mode, wx debugging macros are a lot more informative in release and debug mode.
End trans.
Quote from: Miguel Gimenez on November 13, 2023, 02:32:59 PM
assert generates an exception only in debug mode, wx debugging macros are a lot more informative in release and debug mode.
End trans.
That is, there is no option in the widgets to see all the problems at once? just correct one at a time and watch the next one after fix?
Yes. That is exactly what they are intended for. Fail fast on an eventually corrupted state.
according to https://en.cppreference.com/w/cpp/error/assert (https://en.cppreference.com/w/cpp/error/assert):
Quote...outputs implementation-specific diagnostic information on the standard error output and calls std::abort.
At least as important: An assert serves as executable note to the next reader.
If on the other hand an assert actually threw an exception it would indeed be possible to proceed and see subsequent behaviour. If you really want to, you could redefine the macro. Good luck with that. Instead of that I would rather use unittests.