From 2328b4b29a75b7a9438e9f6b562b32214dcd8d48 Mon Sep 17 00:00:00 2001 From: shugo Date: Fri, 27 Sep 2013 15:26:19 +0000 Subject: * ext/curses/extconf.rb: check the size of chtype. * ext/curses/curses.c (NUM2CH, CH2NUM): use proper macros for the size of chtype. [ruby-core:56090] [Bug #8659] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/curses/curses.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'ext/curses/curses.c') diff --git a/ext/curses/curses.c b/ext/curses/curses.c index b8c82387ea..9708c2f2bc 100644 --- a/ext/curses/curses.c +++ b/ext/curses/curses.c @@ -58,8 +58,18 @@ # define USE_MOUSE 1 #endif -#define NUM2CH NUM2CHR -#define CH2FIX CHR2FIX +#if CHTYPE_IS_ULONG +# define NUM2CH NUM2ULONG +# define CH2NUM ULONG2NUM +#else +# if CHTYPE_IS_UINT +# define NUM2CH NUM2UINT +# define CH2NUM UINT2NUM +# else +# define NUM2CH NUM2CHR +# define CH2NUM CHR2FIX +# endif +#endif static VALUE mCurses; static VALUE mKey; @@ -581,7 +591,7 @@ static VALUE curses_inch(VALUE obj) { curses_stdscr(); - return CH2FIX(inch()); + return CH2NUM(inch()); } /* @@ -1865,7 +1875,7 @@ window_inch(VALUE obj) struct windata *winp; GetWINDOW(obj, winp); - return CH2FIX(winch(winp->window)); + return CH2NUM(winch(winp->window)); } /* @@ -2360,7 +2370,7 @@ window_getbkgd(VALUE obj) struct windata *winp; GetWINDOW(obj,winp); - return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil; + return (c = getbkgd(winp->window) != ERR) ? CH2NUM(c) : Qnil; #else return Qnil; #endif -- cgit v1.2.3