aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vandenberg2010-03-16 11:57:55 -0700
committerAdam Vandenberg2010-03-16 12:00:00 -0700
commit098b97801bbc237dc9a4105c5a016478dfdcdb9c (patch)
treecc5119bf31c43d1a920abce5dfce95e1985948cf
parentd03411775f46165dfd1d829fa2fe4d55e2c143cc (diff)
downloadbrew-098b97801bbc237dc9a4105c5a016478dfdcdb9c.tar.bz2
Use tab/space when finding vars (and not newlines).
-rw-r--r--Library/Homebrew/test/test_inreplace.rb8
-rw-r--r--Library/Homebrew/utils.rb4
2 files changed, 10 insertions, 2 deletions
diff --git a/Library/Homebrew/test/test_inreplace.rb b/Library/Homebrew/test/test_inreplace.rb
index 74a5eed65..d2d2d4cfc 100644
--- a/Library/Homebrew/test/test_inreplace.rb
+++ b/Library/Homebrew/test/test_inreplace.rb
@@ -15,6 +15,14 @@ class InreplaceTest < Test::Unit::TestCase
assert_equal "FLAG=def\nFLAG2=abc", s1
end
+ def test_change_make_var_empty_2
+ # Replace empty flag
+ s1="FLAG = \nmv file_a file_b"
+ s1.extend(HomebrewInreplaceExtension)
+ s1.change_make_var! "FLAG", "def"
+ assert_equal "FLAG=def\nmv file_a file_b", s1
+ end
+
def test_change_make_var_append
# Append to flag
s1="FLAG = abc"
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 021a93f01..8ff6e8620 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -157,13 +157,13 @@ 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*=[ \\t]*(.*)$"), new_value
+ gsub! Regexp.new("^#{flag}[ \\t]*=[ \\t]*(.*)$"), new_value
end
# Removes variable assignments completely.
def remove_make_var! flags
flags.each do |flag|
# Also remove trailing \n, if present.
- gsub! Regexp.new("^#{flag}\\s*=(.*)$\n?"), ""
+ gsub! Regexp.new("^#{flag}[ \\t]*=(.*)$\n?"), ""
end
end
end