From ea061bbb501ef0d0d5be06cf37513479d6af4b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olle=20Hyn=C3=A9n=20Ulfsj=C3=B6=C3=B6?= Date: Fri, 23 Oct 2020 16:23:22 +0200 Subject: [PATCH] Improve the regexps for parsing parameters to cmock.rb Also, conform to the standard 80 character limit Change-Id: I7830ddd5d65ccc06c96884c1c3d4575241f99e6d --- lib/cmock.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/cmock.rb b/lib/cmock.rb index b4dbab5..165f2d9 100644 --- a/lib/cmock.rb +++ b/lib/cmock.rb @@ -18,10 +18,12 @@ class CMock cm_config = CMockConfig.new(options) cm_unityhelper = CMockUnityHelperParser.new(cm_config) cm_writer = CMockFileWriter.new(cm_config) - cm_gen_utils = CMockGeneratorUtils.new(cm_config, :unity_helper => cm_unityhelper) + cm_gen_utils = CMockGeneratorUtils.new(cm_config, + :unity_helper => cm_unityhelper) cm_gen_plugins = CMockPluginManager.new(cm_config, cm_gen_utils) @cm_parser = CMockHeaderParser.new(cm_config) - @cm_generator = CMockGenerator.new(cm_config, cm_writer, cm_gen_utils, cm_gen_plugins) + @cm_generator = CMockGenerator.new(cm_config, cm_writer, cm_gen_utils, + cm_gen_plugins) @silent = (cm_config.verbosity < 2) end @@ -85,12 +87,18 @@ if $0 == __FILE__ options = {} filelist = [] ARGV.each do |arg| - if arg =~ /^-o\"?([a-zA-Z0-9._\\\/:\s]+)\"?/ + if (arg =~ /^-o\"?([a-zA-Z0-9@._\\\/:\s]+)\"?/) options.merge! CMockConfig.load_config_file_from_yaml(arg.gsub(/^-o/, '')) - elsif arg == '--skeleton' + elsif (arg == '--skeleton') options[:skeleton] = true - elsif arg =~ /^--([a-zA-Z0-9._\\\/:\s]+)=\"?([a-zA-Z0-9._\-\\\/:\s\;]+)\"?/ - options = option_maker(options, Regexp.last_match(1), Regexp.last_match(2)) + elsif (arg =~ /^--strippables=\"?(.*)\"?/) + # --strippables are dealt with separately since the user is allowed to + # enter any valid regular expression as argument + options = option_maker(options, 'strippables', Regexp.last_match(1)) + elsif (arg =~ /^--([a-zA-Z0-9._\\\/:\s]+)= + \"?([a-zA-Z0-9._\-\\\/:\s\;]+)\"?/x) + options = option_maker(options, Regexp.last_match(1), + Regexp.last_match(2)) else filelist << arg end