diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 5037744..ca10559 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -27,7 +27,7 @@ class CMockHeaderParser # look for any edge cases of typedef'd void; # void must be void for cmock AndReturn calls to process properly. # to a certain extent, these replacements assume we're chewing on pre-processed header files - void_types = source.scan(/typedef\s+void\s+([^\s]+)\s*;/) + void_types = source.scan(/typedef\s+void\s+([\w\d]+)\s*;/) void_types.each {|type| source.gsub!(/#{type}/, 'void')} if void_types.size > 0 source.gsub!(/\s*\\\s*/m, ' ') # smush multiline into single line diff --git a/test/unit/cmock_header_parser_test.rb b/test/unit/cmock_header_parser_test.rb index 153a92f..976ed3e 100644 --- a/test/unit/cmock_header_parser_test.rb +++ b/test/unit/cmock_header_parser_test.rb @@ -115,10 +115,11 @@ class CMockHeaderParserTest < Test::Unit::TestCase source = "typedef void SILLY_VOID_TYPE1;\n" + - "typedef void SILLY_VOID_TYPE2 ;\n\n" + + "typedef void SILLY_VOID_TYPE2 ;\n" + + "typedef void (*FUNCPTR)(void);\n\n" + # do no substitution on type "SILLY_VOID_TYPE2 Foo(int a, unsigned int b);\n" + "void\n shiz(SILLY_VOID_TYPE1 *);\n" + - "void tat(void);\n" + "void tat(FUNCPTR);\n" @parser = CMockHeaderParser.new(source, @config) parsed_stuff = @parser.parse @@ -145,10 +146,10 @@ class CMockHeaderParserTest < Test::Unit::TestCase { :modifier => "", - :args_string => "void", + :args_string => "FUNCPTR cmock_arg1", :rettype => "void", :var_arg => nil, - :args => [], + :args => [{:type => "FUNCPTR", :name => "cmock_arg1"}], :name => "tat" } ]