From 3254aef5e52f1949006e20accfb6a2a10aa73e4e Mon Sep 17 00:00:00 2001 From: laurens Date: Wed, 8 Jan 2020 19:25:37 +0100 Subject: [PATCH] Handle headers which only have inline-function-declarations This means there is NO opening bracket, since there are no struct declarations or inline function definitions. --- lib/cmock_header_parser.rb | 2 +- test/unit/cmock_header_parser_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 3aaf9a1..260b73c 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -160,7 +160,7 @@ class CMockHeaderParser first_open_bracket = inline_function_match.post_match.index("{") first_semicolon = inline_function_match.post_match.index(";") - if first_semicolon < first_open_bracket + if first_open_bracket.nil? or first_semicolon < first_open_bracket puts "DECLARATION, IGNORE" source = inline_function_match.pre_match + inline_function_match.post_match next diff --git a/test/unit/cmock_header_parser_test.rb b/test/unit/cmock_header_parser_test.rb index 70142a5..de12202 100644 --- a/test/unit/cmock_header_parser_test.rb +++ b/test/unit/cmock_header_parser_test.rb @@ -2119,6 +2119,19 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do assert_equal(expected, @parser.transform_inline_functions(source)) end + it "Transform inline functions can handle header with only inline function declarations" do + source = + "static inline int dummy_func_decl(int a, char b, float c);\n" + + "\n" + + expected = + "int dummy_func_decl(int a, char b, float c);\n" + + "\n" + + @parser.treat_inlines = :include + assert_equal(expected, @parser.transform_inline_functions(source)) + end + it "Transform inline functions takes user provided patterns into account" do source = "static __inline__ __attribute__ ((always_inline)) uint16_t _somefunc (uint32_t a)\n" +