[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-core
Subject: Re: [ ruby-Bugs-2298 ] Curses bkgd functions loose their high bits when converting
From: "H.Yamamoto" <ocean () m2 ! ccsnet ! ne ! jp>
Date: 2005-08-25 8:27:09
Message-ID: 20050825172017.C58CD380.ocean () m2 ! ccsnet ! ne ! jp
[Download RAW message or body]
Hi.
Umm, chtype in curses seems not to be `char' rather `long'.
Probably, patch is needed for other functions using chtype.
CAUTION: I'm not using curses, so this patch is not checked yet. (even compile)
# And maybe it's enough to use NUM2LONG directory instead of defining NUM2CH.
Index: curses.c
===================================================================
RCS file: /src/ruby/ext/curses/curses.c,v
retrieving revision 1.29
diff -u -w -b -p -r1.29 curses.c
--- curses.c 7 Jun 2005 15:02:32 -0000 1.29
+++ curses.c 25 Aug 2005 06:16:21 -0000
@@ -54,6 +54,9 @@
# define USE_MOUSE 1
#endif
+#define NUM2CH NUM2LONG
+#define CH2FIX LONG2FIX
+
static VALUE mCurses;
static VALUE mKey;
static VALUE cWindow;
@@ -362,7 +365,7 @@ curses_inch(obj)
VALUE obj;
{
curses_stdscr();
- return CHR2FIX(inch());
+ return CH2FIX(inch());
}
/* def addch(ch) */
@@ -372,7 +375,7 @@ curses_addch(obj, ch)
VALUE ch;
{
curses_stdscr();
- addch(NUM2CHR(ch));
+ addch(NUM2CH(ch));
return Qnil;
}
@@ -383,7 +386,7 @@ curses_insch(obj, ch)
VALUE ch;
{
curses_stdscr();
- insch(NUM2CHR(ch));
+ insch(NUM2CH(ch));
return Qnil;
}
@@ -547,7 +550,7 @@ static VALUE
curses_bkgdset(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGDSET
- bkgdset(NUM2CHR(ch));
+ bkgdset(NUM2CH(ch));
#endif
return Qnil;
}
@@ -556,7 +559,7 @@ static VALUE
curses_bkgd(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGD
- return (bkgd(NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
+ return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
@@ -1002,13 +1005,13 @@ window_box(argc, argv, self)
rb_scan_args(argc, argv, "21", &vert, &hor, &corn);
GetWINDOW(self, winp);
- box(winp->window, NUM2CHR(vert), NUM2CHR(hor));
+ box(winp->window, NUM2CH(vert), NUM2CH(hor));
if (!NIL_P(corn)) {
int cur_x, cur_y, x, y;
- char c;
+ chtype c;
- c = NUM2CHR(corn);
+ c = NUM2CH(corn);
getyx(winp->window, cur_y, cur_x);
x = NUM2INT(window_maxx(self)) - 1;
y = NUM2INT(window_maxy(self)) - 1;
@@ -1058,7 +1061,7 @@ window_inch(obj)
struct windata *winp;
GetWINDOW(obj, winp);
- return CHR2FIX(winch(winp->window));
+ return CH2FIX(winch(winp->window));
}
/* def addch(ch) */
@@ -1070,7 +1073,7 @@ window_addch(obj, ch)
struct windata *winp;
GetWINDOW(obj, winp);
- waddch(winp->window, NUM2CHR(ch));
+ waddch(winp->window, NUM2CH(ch));
return Qnil;
}
@@ -1084,7 +1087,7 @@ window_insch(obj, ch)
struct windata *winp;
GetWINDOW(obj, winp);
- winsch(winp->window, NUM2CHR(ch));
+ winsch(winp->window, NUM2CH(ch));
return Qnil;
}
@@ -1313,7 +1316,7 @@ window_bkgdset(VALUE obj, VALUE ch)
struct windata *winp;
GetWINDOW(obj,winp);
- wbkgdset(winp->window, NUM2CHR(ch));
+ wbkgdset(winp->window, NUM2CH(ch));
#endif
return Qnil;
}
@@ -1325,7 +1328,7 @@ window_bkgd(VALUE obj, VALUE ch)
struct windata *winp;
GetWINDOW(obj,winp);
- return (wbkgd(winp->window, NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
+ return (wbkgd(winp->window, NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
@@ -1335,11 +1338,11 @@ static VALUE
window_getbkgd(VALUE obj)
{
#ifdef HAVE_WGETBKGD
- char c;
+ chtype c;
struct windata *winp;
GetWINDOW(obj,winp);
- return (c = getbkgd(winp->window) != ERR) ? CHR2FIX(c) : Qnil;
+ return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil;
#else
return Qnil;
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic