mirror of
https://github.com/ThrowTheSwitch/CMock
synced 2025-06-03 04:19:33 -04:00
- Just looking for static|inline in the gsub is a bit too aggressive. Instead, look for the "static inline" and parse it: - Everything before the match should just be copied, we don't want to touch anything but the inline functions. - Remove the implementation of the inline function (this is enclosed in square brackets) and replace it with ";" to complete the transformation to normal/non-inline function. - Copy everything after the inline function implementation Repeat the above step until we can't find "static inline" anymore - To remove the inline implementation, we count the number of square-bracket 'levels' in the inline function and remove every pair. This ensures that constructs like: inline void func(void) { if (...) { //NOP } else { //NOP } } will not end up leaving the 'else' keyword unremoved: inline void func(void); else If we count the number of levels, we don't end up in this scenario since we remove 3 'pairs', the if-one, the else-one and finally the main body.