From 431c5c678a1a22793dc12f867ff337ae9946b9e0 Mon Sep 17 00:00:00 2001 From: laurens Date: Sun, 10 Nov 2019 19:35:27 +0100 Subject: [PATCH] Refactor cleanup actions when normalizing source --- lib/cmock_header_parser.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 8739130..567ddc8 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -80,11 +80,16 @@ class CMockHeaderParser # Disguise them as normal functions with the ";" m.gsub!(/\s*\{\s\}/, ";") - # TODO: fix these cleanup actions... - m.gsub!(/^\s+/, '') # remove extra white space from beginning of line - m.gsub!(/\s+/, ' ') # remove remaining extra white space - m.gsub!(";",";\n") - m.gsub!(/^\s+/, '') # remove extra white space from beginning of line + # Cleanup the function declarations + # Not strictly necessary compile-wise, but it can help debugging + m_lines = m.split(/\s*;\s*/).uniq + m_lines.each { + |m_line| + m_line.gsub!(/^\s+/, '') # remove extra white space from beginning of line + m_line.gsub!(/\s+/, ' ') # remove remaining extra white space + } + + m_lines.join(";\n") + ";" # Join the lines and add the last semicolon manually end source.gsub!(/\s+$/, '') # remove extra white space from end of line