X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Futil.rb;h=f99e1c17c79a3add8d5da43901c6b161d5c7170d;hb=90271a77cd8986ee230afb908e4a1cff01a5a2e3;hp=5d57361e990da24abe6c470ded4fa31a3800f51b;hpb=9dd4f50b9f62ab5642241359bf6f7c291ccfa738;p=sup diff --git a/lib/sup/util.rb b/lib/sup/util.rb index 5d57361..f99e1c1 100644 --- a/lib/sup/util.rb +++ b/lib/sup/util.rb @@ -25,6 +25,7 @@ class Lockfile def lockinfo_on_disk h = load_lock_id IO.read(path) h['mtime'] = File.mtime path + h['path'] = path h end @@ -91,7 +92,7 @@ end class Range ## only valid for integer ranges (unless I guess it's exclusive) - def size + def size last - first + (exclude_end? ? 0 : 1) end end @@ -176,7 +177,7 @@ class String ## nasty multibyte hack for ruby 1.8. if it's utf-8, split into chars using ## the utf8 regex and count those. otherwise, use the byte length. def display_length - if $encoding == "UTF-8" + if $encoding == "UTF-8" || $encoding == "utf8" scan(/./u).size else size @@ -653,7 +654,7 @@ class Iconv begin Iconv.iconv(target + "//IGNORE", charset, text + " ").join[0 .. -2] rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::InvalidCharacter, Iconv::IllegalSequence => e - Redwood::log "warning: error (#{e.class.name}) decoding text from #{charset} to #{target}: #{text[0 ... 20]}" + warn "couldn't transcode text from #{charset} to #{target} (\"#{text[0 ... 20]}\"...) (got #{e.message}); using original as is" text end end