aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-27 15:26:19 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-27 15:26:19 +0000
commit2328b4b29a75b7a9438e9f6b562b32214dcd8d48 (patch)
tree22570de2bbfd10280657d61b9d1b46a1ea95414b /ext
parent0e2f5210571d991f9f1dc52af9969a2e2100ab1a (diff)
downloadruby-2328b4b29a75b7a9438e9f6b562b32214dcd8d48.tar.gz
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/curses/curses.c20
-rw-r--r--ext/curses/extconf.rb8
2 files changed, 23 insertions, 5 deletions
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
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 3e53ef65f7..a95b49ffea 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -129,5 +129,13 @@ if header_library
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