[#8484] strptime fails to properly parse certain inputs — <noreply@...>

Bugs item #5263, was opened at 2006-08-01 23:14

13 messages 2006/08/02
[#8485] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — Yukihiro Matsumoto <matz@...> 2006/08/02

Hi,

[#8538] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — nobu@... 2006/08/06

Hi,

[#8561] sandbox timers & block scopes — why the lucky stiff <ruby-core@...>

Two puzzles I am trying to solve:

28 messages 2006/08/08
[#8624] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

raise ThisDecayingInquisition, "anyone? anyone at all?"

[#8627] Re: sandbox timers & block scopes — MenTaLguY <mental@...> 2006/08/15

On Wed, 2006-08-16 at 00:35 +0900, why the lucky stiff wrote:

[#8628] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

On Wed, Aug 16, 2006 at 02:46:30AM +0900, MenTaLguY wrote:

[#8629] Re: sandbox timers & block scopes — "Charles O Nutter" <headius@...> 2006/08/15

On 8/15/06, why the lucky stiff <ruby-core@whytheluckystiff.net> wrote:

[#8690] a ruby-core primer — why the lucky stiff <ruby-core@...>

Hello, all. I've been working on the ruby-core page for the new Ruby site.

21 messages 2006/08/22

Re: char-actization Curses.getch

From: nobu@...
Date: 2006-08-17 14:11:08 UTC
List: ruby-core #8657
Hi,

At Thu, 17 Aug 2006 21:21:39 +0900,
Ondrej Bilka wrote in [ruby-core:08656]:
> Another issue at head is that Curses.getch still returns int.
> Problem is that when keypad is set it returns pseudokeycodes, so we have
> to convert only when <256.

It's a problem.

Only way I thought of is they return

  * a String for ordinary key,
  * a Fixnum for keypad, and
  * nil for ERR.


Index: ext/curses/curses.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/curses/curses.c,v
retrieving revision 1.33
diff -p -u -2 -r1.33 curses.c
--- ext/curses/curses.c	28 Jul 2006 08:18:22 -0000	1.33
+++ ext/curses/curses.c	17 Aug 2006 13:46:18 -0000
@@ -383,4 +383,15 @@ curses_addstr(VALUE obj, VALUE str)
 }
 
+static VALUE
+getch_value(int c)
+{
+    if (c == ERR) return Qnil;
+    if (!(c & KEY_CODE_YES)) {
+	char cc = (char)c;
+	return rb_tainted_str_new(&cc, 1);
+    }
+    return UINT2NUM(c);
+}
+
 /* def getch */
 static VALUE
@@ -389,5 +400,5 @@ curses_getch(VALUE obj)
     rb_read_check(stdin);
     curses_stdscr();
-    return UINT2NUM(getch());
+    return getch_value(getch());
 }
 
@@ -1068,8 +1079,8 @@ window_getch(VALUE obj)
 {
     struct windata *winp;
-    
+
     rb_read_check(stdin);
     GetWINDOW(obj, winp);
-    return UINT2NUM(wgetch(winp->window));
+    return getch_value(wgetch(winp->window));
 }
 


-- 
Nobu Nakada

In This Thread