[ruby-imagesize/f17] Regex treatment with ruby 1.9 (ref: bug 819188)
Mamoru Tasaka
mtasaka at fedoraproject.org
Sat May 5 17:23:44 UTC 2012
commit afe314905b649ef052cd30763190cc4c3959d00f
Author: Mamoru Tasaka <tasaka1 at localhost.localdomain>
Date: Sun May 6 02:23:41 2012 +0900
Regex treatment with ruby 1.9 (ref: bug 819188)
ruby-imagesize-0.1.1-ruby19-regex-utf8.patch | 23 +++++++++++++++++++++++
ruby-imagesize.spec | 10 +++++++++-
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/ruby-imagesize-0.1.1-ruby19-regex-utf8.patch b/ruby-imagesize-0.1.1-ruby19-regex-utf8.patch
new file mode 100644
index 0000000..0b011e6
--- /dev/null
+++ b/ruby-imagesize-0.1.1-ruby19-regex-utf8.patch
@@ -0,0 +1,23 @@
+--- imagesize-0.1.1/lib/image_size.rb.ruby19 2012-05-06 02:01:28.000000000 +0900
++++ imagesize-0.1.1/lib/image_size.rb 2012-05-06 01:04:41.000000000 +0900
+@@ -120,15 +120,16 @@
+ end
+
+ def check_type(img_top)
+- if img_top =~ /^GIF8[7,9]a/ then Type::GIF
++ if img_top.force_encoding(Encoding::ASCII_8BIT) =~ /^GIF8[7,9]a/n
++ then Type::GIF
+ elsif img_top[0, 8] == "\x89PNG\x0d\x0a\x1a\x0a" then Type::PNG
+ elsif img_top[0, 2] == "\xFF\xD8" then Type::JPEG
+ elsif img_top[0, 2] == 'BM' then Type::BMP
+- elsif img_top =~ /^P[1-7]/ then Type::PPM
+- elsif img_top =~ /\#define\s+\S+\s+\d+/ then Type::XBM
++ elsif img_top =~ /^P[1-7]/n then Type::PPM
++ elsif img_top =~ /\#define\s+\S+\s+\d+/n then Type::XBM
+ elsif img_top[0, 4] == "MM\x00\x2a" then Type::TIFF
+ elsif img_top[0, 4] == "II\x2a\x00" then Type::TIFF
+- elsif img_top =~ /\/\* XPM \*\// then Type::XPM
++ elsif img_top =~ /\/\* XPM \*\//n then Type::XPM
+ elsif img_top[0, 4] == "8BPS" then Type::PSD
+ elsif img_top[1, 2] == "WS" then Type::SWF
+ elsif img_top[0] == 10 then Type::PCX
diff --git a/ruby-imagesize.spec b/ruby-imagesize.spec
index e1a7dd6..e12b114 100644
--- a/ruby-imagesize.spec
+++ b/ruby-imagesize.spec
@@ -5,13 +5,15 @@
Name: ruby-%{modname}
Version: 0.1.1
-Release: 6%{?dist}
+Release: 7%{?dist}
Summary: Measure image size code by Pure Ruby
Group: Development/Languages
License: Ruby
URL: http://imagesize.rubyforge.org/
Source0: http://rubyforge.org/frs/download.php/%{repoid}/%{modname}-%{version}.tgz
+# With ruby1.9 handling regex needs some encoding treatment...
+Patch0: ruby-imagesize-0.1.1-ruby19-regex-utf8.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -36,6 +38,9 @@ find . -name \*.rb -exec %{__chmod} 0644 {} ';'
# clean up
%{__sed} -i -e '1d' -e 's|\r||' lib/image_size.rb
+# Patch
+%patch0 -p1
+
%build
ruby setup.rb config \
--prefix=%{_prefix} \
@@ -69,6 +74,9 @@ testrb test/test_image_size.rb
%{ruby_vendorlibdir}/image_size/
%changelog
+* Sun May 6 2012 Mamoru Tasaka <mtasaka at fedoraproject.org> - 0.1.1-7
+- Regex treatment with ruby 1.9 (ref: bug 819188)
+
* Tue Feb 07 2012 Bohuslav Kabrda <bkabrda at redhat.com> - 0.1.1-6
- Rebuilt for Ruby 1.9.3.
More information about the scm-commits
mailing list