sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 57efd0b64eb6c00d9ca6aac2f54748370d0cd4a2
parent 8623da417336632468dae24cf947b9808159c0f4
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sun, 17 Jan 2010 18:11:11 -0500

Merge branch 'ruby-1.9-encoding' into next

Diffstat:
M lib/sup/maildir.rb | 4 ++--
M lib/sup/mbox/loader.rb | 4 ++--
M lib/sup/util.rb | 9 ---------
3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -59,7 +59,7 @@ class Maildir < Source
         File.stat(tmp_path)
       rescue Errno::ENOENT #this is what we want.
         begin
-          File.open_binary(tmp_path, 'w') do |f|
+          File.open(tmp_path, 'wb') do |f|
             yield f #provide a writable interface for the caller
             f.fsync
           end
@@ -207,7 +207,7 @@ private
   def with_file_for id
     fn = @ids_to_fns[id] or raise OutOfSyncSourceError, "No such id: #{id.inspect}."
     begin
-      File.open_binary(fn, 'r') { |f| yield f }
+      File.open(fn, 'rb') { |f| yield f }
     rescue SystemCallError, IOError => e
       raise FatalSourceError, "Problem reading file for id #{id.inspect}: #{fn.inspect}: #{e.message}."
     end
diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb
@@ -22,7 +22,7 @@ class Loader < Source
       raise ArgumentError, "not an mbox uri" unless uri.scheme == "mbox"
       raise ArgumentError, "mbox URI ('#{uri}') cannot have a host: #{uri.host}" if uri.host
       raise ArgumentError, "mbox URI must have a path component" unless uri.path
-      @f = File.open_binary uri.path, 'r'
+      @f = File.open uri.path, 'rb'
       @path = uri.path
     else
       @f = uri_or_fp
@@ -115,7 +115,7 @@ class Loader < Source
 
   def store_message date, from_email, &block
     need_blank = File.exists?(@filename) && !File.zero?(@filename)
-    File.open_binary(@filename, "a") do |f|
+    File.open(@filename, "ab") do |f|
       f.puts if need_blank
       f.puts "From #{from_email} #{date.rfc2822}"
       yield f
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -697,12 +697,3 @@ class Iconv
     end
   end
 end
-
-class File
-  ## ruby 1.8.5 can't handle the :BINARY flag that ruby 1.9 *requires*.
-  ## SO LAMEEEEEEEEEEEEEEEeeeeeeeeeeeeeeeeeee.
-  def self.open_binary filename, mode, &b
-    mode += 'b:BINARY' if String.method_defined? :encoding
-    open filename, mode, &b
-  end
-end