Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] ruby 1.9: use String#ord in ask_getch and ask_yes_or_no
@ 2010-01-01 20:47 Rich Lane
  2010-01-03 14:59 ` William Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Lane @ 2010-01-01 20:47 UTC (permalink / raw)
  To: sup-devel

In Ruby 1.9, character literals and the return value from string index
accesses are now themselves strings and need to be converted to integers with
String#ord. This was breaking ask_getch. Integer#ord is defined on Ruby 1.8 so
this won't cause problems there.
---
 lib/sup/buffer.rb |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 4498b08..c826ab9 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -611,7 +611,7 @@ EOS
   def ask_getch question, accept=nil
     raise "impossible!" if @asking
 
-    accept = accept.split(//).map { |x| x[0] } if accept
+    accept = accept.split(//).map { |x| x.ord } if accept
 
     status, title = get_status_and_title @focus_buf
     Ncurses.sync do
@@ -647,7 +647,7 @@ EOS
   ## returns true (y), false (n), or nil (ctrl-g / cancel)
   def ask_yes_or_no question
     case(r = ask_getch question, "ynYN")
-    when ?y, ?Y
+    when ?y.ord, ?Y.ord
       true
     when nil
       nil
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-03 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-01 20:47 [sup-devel] [PATCH] ruby 1.9: use String#ord in ask_getch and ask_yes_or_no Rich Lane
2010-01-03 14:59 ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox