ruby-changes:30995
From: shugo <ko1@a...>
Date: Sat, 28 Sep 2013 00:26:25 +0900 (JST)
Subject: [ruby-changes:30995] shugo:r43074 (trunk): * ext/curses/extconf.rb: check the size of chtype.
shugo 2013-09-28 00:26:19 +0900 (Sat, 28 Sep 2013) New Revision: 43074 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43074 Log: * 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] Modified files: trunk/ChangeLog trunk/ext/curses/curses.c trunk/ext/curses/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43073) +++ ChangeLog (revision 43074) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Sep 28 00:19:41 2013 Shugo Maeda <shugo@r...> + + * 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] + Fri Sep 27 18:33:23 2013 Koichi Sasada <ko1@a...> * gc.c: add two GC tuning environment variables. Index: ext/curses/curses.c =================================================================== --- ext/curses/curses.c (revision 43073) +++ ext/curses/curses.c (revision 43074) @@ -58,8 +58,18 @@ https://github.com/ruby/ruby/blob/trunk/ext/curses/curses.c#L58 # 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 https://github.com/ruby/ruby/blob/trunk/ext/curses/curses.c#L591 curses_inch(VALUE obj) { curses_stdscr(); - return CH2FIX(inch()); + return CH2NUM(inch()); } /* @@ -1865,7 +1875,7 @@ window_inch(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/curses/curses.c#L1875 struct windata *winp; GetWINDOW(obj, winp); - return CH2FIX(winch(winp->window)); + return CH2NUM(winch(winp->window)); } /* @@ -2360,7 +2370,7 @@ window_getbkgd(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/curses/curses.c#L2370 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 Index: ext/curses/extconf.rb =================================================================== --- ext/curses/extconf.rb (revision 43073) +++ ext/curses/extconf.rb (revision 43074) @@ -129,5 +129,13 @@ if header_library https://github.com/ruby/ruby/blob/trunk/ext/curses/extconf.rb#L129 warn "unexpeted value for --with-curses-version: #{with_curses_version}" end + for type in ["long", "int"] + if try_static_assert("sizeof(chtype) == sizeof(unsigned #{type})", + %w[stdio.h stdlib.h]+curses) + $defs << "-DCHTYPE_IS_U#{type.upcase}" + break + end + end + create_makefile("curses") end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/