Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
what's the best and quick way to remove all the wx_str and c_str preprocessor
ollydbg:
We have many many code snippet like below:
--- Code: --- #if wxCHECK_VERSION(2, 9, 0)
Codef( _T("%AAppend(%t)"), ArrayChoices[i].wx_str());
#else
Codef( _T("%AAppend(%t)"), ArrayChoices[i].c_str());
#endif
--- End code ---
I believe someone can create a simple find/replace script which can quickly replace those code snippet to:
--- Code: --- Codef( _T("%AAppend(%t)"), ArrayChoices[i].wx_str());
--- End code ---
Which tool can be used to do this? I found that manually delete those lines are some dirty work. ;)
EDIT:
The match condition should be:
--- Code: --- #if wxCHECK_VERSION(2, 9, 0)
blablabla1
#else
blablabla2
#endif
--- End code ---
The content of "blablabla1" and "blablabla2" should be the same only except the "wx_str" and "c_str".
Jenna:
Should be doable with regexes.
dmoore:
Yes, replace in files with regex will do this
Make sure you have "use advanced regexes" checked in editor settings.
Link to syntax is in my sig. Use \n where n is an integer corresponding to your unnamed groups in the replace string. I never got around to adding support for substituting named groups in C::B (but maybe someone else did)
Something like this (untested)
--- Code: ---#if WXCHECK_VERSION\(2\s*,9,\s*0\).*?\n(.*?)#else.*?#endif.*?\n
--- End code ---
replace with
--- Code: ---\1
--- End code ---
Edit: placement of spacing.
ollydbg:
Thanks!!
There are some answers, but I'm going to test under C::B's own editor right now.
how to use regex to strip the preprocessor directive
Edit:
It looks like the same regex replacement rule works under notepad++ does not work under c::b. :(
dmoore:
For some reason the ".*" doesn't operate through line endings (this may have been intentional), so I had to use this:
--- Code: --- *#if wxCHECK_VERSION\(2\,\s*9\,\s*0\).*?\n(.*?)\n.*?#else\r?\n.*?\n.*?#endif(.*?)\n
--- End code ---
replacing with
--- Code: ---\1
--- End code ---
This allows at most one line of code between the #if, #else, and #endif lines.
Navigation
[0] Message Index
[#] Next page
Go to full version