require 'curses'
require 'fileutils'
require 'trollop'
-require 'fastthread'
require "sup"
BIN_VERSION = "git"
## BSD users: if libc.so.6 is not found, try installing compat6x.
require 'dl/import'
module LibC
- extend DL::Importable
+ extend DL.const_defined?(:Importer) ? DL::Importer : DL::Importable
setlocale_lib = case Config::CONFIG['arch']
when /darwin/; "libc.dylib"
when /cygwin/; "cygwin1.dll"
end
end unless $opts[:no_initial_poll]
- imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread("poll after loading inbox") { sleep 1; PollManager.poll } unless $opts[:no_threads] || $opts[:no_initial_poll] }
+ imode.load_threads :num => ibuf.content_height, :when_done => lambda { |num| reporting_thread("poll after loading inbox") { sleep 1; PollManager.poll } unless $opts[:no_threads] || $opts[:no_initial_poll] }
if $opts[:compose]
ComposeMode.spawn_nicely :to_default => $opts[:compose]
require 'fileutils'
require 'gettext'
require 'curses'
+begin
+ require 'fastthread'
+rescue LoadError
+end
class Object
## this is for debugging purposes because i keep calling #id on the
require 'fileutils'
require 'ferret'
-require 'fastthread'
begin
require 'chronic'
def self.keysym_to_keycode k
case k
- when :down: Curses::KEY_DOWN
- when :up: Curses::KEY_UP
- when :left: Curses::KEY_LEFT
- when :right: Curses::KEY_RIGHT
- when :page_down: Curses::KEY_NPAGE
- when :page_up: Curses::KEY_PPAGE
- when :backspace: Curses::KEY_BACKSPACE
- when :home: Curses::KEY_HOME
- when :end: Curses::KEY_END
- when :ctrl_l: "\f"[0]
- when :ctrl_g: "\a"[0]
- when :tab: "\t"[0]
- when :enter, :return: 10 #Curses::KEY_ENTER
+ when :down then Curses::KEY_DOWN
+ when :up then Curses::KEY_UP
+ when :left then Curses::KEY_LEFT
+ when :right then Curses::KEY_RIGHT
+ when :page_down then Curses::KEY_NPAGE
+ when :page_up then Curses::KEY_PPAGE
+ when :backspace then Curses::KEY_BACKSPACE
+ when :home then Curses::KEY_HOME
+ when :end then Curses::KEY_END
+ when :ctrl_l then "\f".ord
+ when :ctrl_g then "\a".ord
+ when :tab then "\t".ord
+ when :enter, :return then 10 #Curses::KEY_ENTER
else
if k.is_a?(String) && k.length == 1
- k[0]
+ k.ord
else
raise ArgumentError, "unknown key name '#{k}'"
end
def self.keysym_to_string k
case k
- when :down: "<down arrow>"
- when :up: "<up arrow>"
- when :left: "<left arrow>"
- when :right: "<right arrow>"
- when :page_down: "<page down>"
- when :page_up: "<page up>"
- when :backspace: "<backspace>"
- when :home: "<home>"
- when :end: "<end>"
- when :enter, :return: "<enter>"
- when :tab: "tab"
- when " ": "<space>"
+ when :down then "<down arrow>"
+ when :up then "<up arrow>"
+ when :left then "<left arrow>"
+ when :right then "<right arrow>"
+ when :page_down then "<page down>"
+ when :page_up then "<page up>"
+ when :backspace then "<backspace>"
+ when :home then "<home>"
+ when :end then "<end>"
+ when :enter, :return then "<enter>"
+ when :tab then "tab"
+ when " " then "<space>"
else
Curses::keyname(keysym_to_keycode(k))
end
def patina_color
case status
- when :valid: :cryptosig_valid_color
- when :invalid: :cryptosig_invalid_color
+ when :valid then :cryptosig_valid_color
+ when :invalid then :cryptosig_invalid_color
else :cryptosig_unknown_color
end
end
elsif m.header["Content-Type"] && m.header["Content-Type"] !~ /^text\/plain/
extension =
case m.header["Content-Type"]
- when /text\/html/: "html"
- when /image\/(.*)/: $1
+ when /text\/html/ then "html"
+ when /image\/(.*)/ then $1
end
["sup-attachment-#{Time.now.to_i}-#{rand 10000}", extension].join(".")
require 'socket' # just for gethostname!
require 'pathname'
require 'rmail'
-require 'jcode' # for RE_UTF8
+
+# from jcode.rb, not included in ruby 1.9
+PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]'
+RE_UTF8 = Regexp.new(PATTERN_UTF8, 0, 'n')
module Redwood
## clone of java-style whole-method synchronization
## assumes a @mutex variable
## TODO: clean up, try harder to avoid namespace collisions
- def synchronized *meth
- meth.each do
+ def synchronized *methods
+ methods.each do |meth|
class_eval <<-EOF
alias unsynchronized_#{meth} #{meth}
def #{meth}(*a, &b)
end
end
- def ignore_concurrent_calls *meth
- meth.each do
+ def ignore_concurrent_calls *methods
+ methods.each do |meth|
mutex = "@__concurrent_protector_#{meth}"
flag = "@__concurrent_flag_#{meth}"
oldmeth = "__unprotected_#{meth}"
region_start = 0
while pos <= length
newpos = case state
- when :escaped_instring, :escaped_outstring: pos
+ when :escaped_instring, :escaped_outstring then pos
else index(/[,"\\]/, pos)
end
case char
when ?"
state = case state
- when :outstring: :instring
- when :instring: :outstring
- when :escaped_instring: :instring
- when :escaped_outstring: :outstring
+ when :outstring then :instring
+ when :instring then :outstring
+ when :escaped_instring then :instring
+ when :escaped_outstring then :outstring
end
when ?,, nil
state = case state
- when :outstring, :escaped_outstring:
+ when :outstring, :escaped_outstring then
ret << self[region_start ... newpos].gsub(/^\s+|\s+$/, "")
region_start = newpos + 1
:outstring
- when :instring: :instring
- when :escaped_instring: :instring
+ when :instring then :instring
+ when :escaped_instring then :instring
end
when ?\\
state = case state
- when :instring: :escaped_instring
- when :outstring: :escaped_outstring
- when :escaped_instring: :instring
- when :escaped_outstring: :outstring
+ when :instring then :escaped_instring
+ when :outstring then :escaped_outstring
+ when :escaped_instring then :instring
+ when :escaped_outstring then :outstring
end
end
pos = newpos + 1
gsub(/\t/, " ").gsub(/\r/, "")
end
+ if not defined? ord
+ def ord
+ self[0]
+ end
+ end
+
## takes a space-separated list of words, and returns an array of symbols.
## typically used in Sup for translating Ferret's representation of a list
## of labels (a string) to an array of label symbols.
def self.easy_decode target, charset, text
return text if charset =~ /^(x-unknown|unknown[-_ ]?8bit|ascii[-_ ]?7[-_ ]?bit)$/i
charset = case charset
- when /UTF[-_ ]?8/i: "utf-8"
- when /(iso[-_ ])?latin[-_ ]?1$/i: "ISO-8859-1"
- when /iso[-_ ]?8859[-_ ]?15/i: 'ISO-8859-15'
- when /unicode[-_ ]1[-_ ]1[-_ ]utf[-_]7/i: "utf-7"
+ when /UTF[-_ ]?8/i then "utf-8"
+ when /(iso[-_ ])?latin[-_ ]?1$/i then "ISO-8859-1"
+ when /iso[-_ ]?8859[-_ ]?15/i then 'ISO-8859-15'
+ when /unicode[-_ ]1[-_ ]1[-_ ]utf[-_]7/i then "utf-7"
else charset
end