From b38d555030ea8c09fd3fd0bba9c11f458908ec99 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 10 Feb 2013 15:26:07 -0600 Subject: Fix Regexp encoding under 1.9/2.0 --- Library/Homebrew/extend/pathname.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 7453f647b..dbed1cf22 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -179,18 +179,15 @@ class Pathname # Get enough of the file to detect common file types # POSIX tar magic has a 257 byte offset - magic_bytes = nil - File.open(self) { |f| magic_bytes = f.read(262) } - # magic numbers stolen from /usr/share/file/magic/ - case magic_bytes - when /^PK\003\004/ then :zip - when /^\037\213/ then :gzip - when /^BZh/ then :bzip2 - when /^\037\235/ then :compress - when /^.{257}ustar/ then :tar - when /^\xFD7zXZ\x00/ then :xz - when /^Rar!/ then :rar + case open { |f| f.read(262) } + when /^PK\003\004/n then :zip + when /^\037\213/n then :gzip + when /^BZh/n then :bzip2 + when /^\037\235/n then :compress + when /^.{257}ustar/n then :tar + when /^\xFD7zXZ\x00/n then :xz + when /^Rar!/n then :rar else # This code so that bad-tarballs and zips produce good error messages # when they don't unarchive properly. -- cgit v1.2.3