Fix change_make_var! for empty variables.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
Martin Kühl
2010-03-16 11:54:09 -07:00
committed by Adam Vandenberg
parent 1e9c7df871
commit d03411775f
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -6,6 +6,14 @@ class InreplaceTest < Test::Unit::TestCase
s1.change_make_var! "FLAG", "def"
assert_equal "FLAG=def", s1
end
def test_change_make_var_empty
# Replace empty flag
s1="FLAG = \nFLAG2=abc"
s1.extend(HomebrewInreplaceExtension)
s1.change_make_var! "FLAG", "def"
assert_equal "FLAG=def\nFLAG2=abc", s1
end
def test_change_make_var_append
# Append to flag
+1 -1
View File
@@ -157,7 +157,7 @@ module HomebrewInreplaceExtension
# value with "new_value", or removes the definition entirely.
def change_make_var! flag, new_value
new_value = "#{flag}=#{new_value}"
gsub! Regexp.new("^#{flag}\\s*=\\s*(.*)$"), new_value
gsub! Regexp.new("^#{flag}\\s*=[ \\t]*(.*)$"), new_value
end
# Removes variable assignments completely.
def remove_make_var! flags