ruby-ncurses/0001-STR2CSTR-deprecated.patch

321 lines
14 KiB
Diff
Raw Normal View History

diff -Naur ncurses-ruby-1.3.1/form_wrap.c ncurses-ruby-1.3.1.p/form_wrap.c
--- ncurses-ruby-1.3.1/form_wrap.c 2011-05-31 01:41:46.000000000 +0200
+++ ncurses-ruby-1.3.1.p/form_wrap.c 2013-03-14 14:38:21.097682379 +0100
@@ -625,7 +625,8 @@
char** list = ALLOC_N(char*, n+1);
int i;
for (i = 0; i < n; i++) {
- list[i] = STR2CSTR(rb_ary_entry(arg3, (long)i));
+ VALUE tmp = rb_ary_entry(arg3, (long)i);
+ list[i] = StringValuePtr(tmp);
}
list[n] = NULL;
return INT2NUM(set_field_type(field, ftype,
@@ -654,7 +655,7 @@
if (argc != 2)
rb_raise(rb_eArgError, "TYPE_REGEXP requires one additional argument");
return INT2NUM(set_field_type(field, ftype,
- STR2CSTR(arg3)));
+ StringValuePtr(arg3)));
}
else if (ftype == TYPE_IPV4){
if (argc != 1)
@@ -742,7 +743,7 @@
*/
static VALUE rbncurs_c_set_field_buffer(VALUE rb_field, VALUE buf, VALUE value) {
FIELD* field = get_field(rb_field);
- return INT2NUM(set_field_buffer(field, NUM2INT(buf), STR2CSTR(value)));
+ return INT2NUM(set_field_buffer(field, NUM2INT(buf), StringValuePtr(value)));
}
static VALUE rbncurs_m_set_field_buffer(VALUE dummy, VALUE rb_field, VALUE buf, VALUE value)
{ return rbncurs_c_set_field_buffer(rb_field, buf, value); }
@@ -1052,7 +1053,7 @@
{ return rbncurs_c_form_request_name(request); }
static VALUE rbncurs_c_form_request_by_name(VALUE name) {
- return INT2NUM(form_request_by_name(STR2CSTR(name)));
+ return INT2NUM(form_request_by_name(StringValuePtr(name)));
}
static VALUE rbncurs_m_form_request_by_name(VALUE dummy, VALUE name)
{ return rbncurs_c_form_request_by_name(name); }
diff -Naur ncurses-ruby-1.3.1/menu_wrap.c ncurses-ruby-1.3.1.p/menu_wrap.c
--- ncurses-ruby-1.3.1/menu_wrap.c 2011-05-31 01:41:46.000000000 +0200
+++ ncurses-ruby-1.3.1.p/menu_wrap.c 2013-03-14 14:39:37.016571464 +0100
@@ -372,7 +372,7 @@
* Item creation/destruction functions - mitem_new(3X) man page
*/
static VALUE rbncurs_m_new_item(VALUE dummy, VALUE name, VALUE description)
-{ return wrap_item(new_item(STR2CSTR(name), STR2CSTR(description))); }
+{ return wrap_item(new_item(StringValuePtr(name), StringValuePtr(description))); }
static VALUE rbncurs_c_free_item(VALUE rb_item)
{
@@ -670,7 +670,7 @@
static VALUE rbncurs_c_menu_request_by_name(VALUE name)
{
- return INT2NUM(menu_request_by_name(STR2CSTR(name)));
+ return INT2NUM(menu_request_by_name(StringValuePtr(name)));
}
static VALUE rbncurs_m_menu_request_by_name(VALUE dummy, VALUE name)
{ return rbncurs_c_menu_request_by_name(name); }
@@ -909,7 +909,7 @@
static VALUE rbncurs_c_set_menu_mark(VALUE rb_menu, VALUE value)
{
MENU *menu = get_menu(rb_menu);
- return INT2NUM(set_menu_mark(menu, STR2CSTR(value)));
+ return INT2NUM(set_menu_mark(menu, StringValuePtr(value)));
}
static VALUE rbncurs_m_set_menu_mark(VALUE dummy, VALUE rb_field, VALUE value)
{ return rbncurs_c_set_menu_mark(rb_field, value); }
@@ -929,7 +929,7 @@
static VALUE rbncurs_c_set_menu_pattern(VALUE rb_menu, VALUE pattern)
{
MENU *menu = get_menu(rb_menu);
- return INT2NUM(set_menu_pattern(menu, STR2CSTR(pattern)));
+ return INT2NUM(set_menu_pattern(menu, StringValuePtr(pattern)));
}
static VALUE rbncurs_m_set_menu_pattern(VALUE dummy, VALUE rb_menu, VALUE pattern)
{ return rbncurs_c_set_menu_pattern(rb_menu, pattern); }
diff -Naur ncurses-ruby-1.3.1/ncurses_wrap.c ncurses-ruby-1.3.1.p/ncurses_wrap.c
--- ncurses-ruby-1.3.1/ncurses_wrap.c 2011-05-31 01:41:46.000000000 +0200
+++ ncurses-ruby-1.3.1.p/ncurses_wrap.c 2013-03-14 15:09:59.535783327 +0100
@@ -475,7 +475,7 @@
static VALUE rbncurs_define_key(VALUE dummy, VALUE definition, VALUE keycode)
{
return INT2NUM(define_key((definition != Qnil)
- ? STR2CSTR(definition)
+ ? StringValuePtr(definition)
: (char*)(NULL),
NUM2INT(keycode)));
}
@@ -580,10 +580,10 @@
return return_value;
}
static VALUE rbncurs_addnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
- return INT2NUM(addnstr(STR2CSTR(arg1), NUM2INT(arg2)));
+ return INT2NUM(addnstr(StringValuePtr(arg1), NUM2INT(arg2)));
}
static VALUE rbncurs_addstr(VALUE dummy, VALUE arg1) {
- return INT2NUM(addstr(STR2CSTR(arg1)));
+ return INT2NUM(addstr(StringValuePtr(arg1)));
}
static VALUE rbncurs_attroff(VALUE dummy, VALUE arg1) {
return INT2NUM(attroff(NUM2ULONG(arg1)));
@@ -1011,10 +1011,10 @@
return INT2NUM(insertln());
}
static VALUE rbncurs_insnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
- return INT2NUM(insnstr(STR2CSTR(arg1), NUM2INT(arg2)));
+ return INT2NUM(insnstr(StringValuePtr(arg1), NUM2INT(arg2)));
}
static VALUE rbncurs_insstr(VALUE dummy, VALUE arg1) {
- return INT2NUM(insstr(STR2CSTR(arg1)));
+ return INT2NUM(insstr(StringValuePtr(arg1)));
}
#ifdef HAVE_INTRFLUSH
static VALUE rbncurs_intrflush(VALUE dummy, VALUE arg1, VALUE arg2) {
@@ -1070,10 +1070,10 @@
return return_value;
}
static VALUE rbncurs_mvaddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
- return INT2NUM(mvaddnstr(NUM2INT(arg1), NUM2INT(arg2), STR2CSTR(arg3), NUM2INT(arg4)));
+ return INT2NUM(mvaddnstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3), NUM2INT(arg4)));
}
static VALUE rbncurs_mvaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- return INT2NUM(mvaddstr(NUM2INT(arg1), NUM2INT(arg2), STR2CSTR(arg3)));
+ return INT2NUM(mvaddstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3)));
}
#ifdef HAVE_MVCHGAT
static VALUE rbncurs_mvchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6) {
@@ -1106,10 +1106,10 @@
return INT2NUM(mvinsch(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3)));
}
static VALUE rbncurs_mvinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
- return INT2NUM(mvinsnstr(NUM2INT(arg1), NUM2INT(arg2), STR2CSTR(arg3), NUM2INT(arg4)));
+ return INT2NUM(mvinsnstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3), NUM2INT(arg4)));
}
static VALUE rbncurs_mvinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- return INT2NUM(mvinsstr(NUM2INT(arg1), NUM2INT(arg2), STR2CSTR(arg3)));
+ return INT2NUM(mvinsstr(NUM2INT(arg1), NUM2INT(arg2), StringValuePtr(arg3)));
}
#ifdef HAVE_MVVLINE
static VALUE rbncurs_mvvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
@@ -1137,10 +1137,10 @@
return return_value;
}
static VALUE rbncurs_mvwaddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
- return INT2NUM(mvwaddnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), STR2CSTR(arg4), NUM2INT(arg5)));
+ return INT2NUM(mvwaddnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4), NUM2INT(arg5)));
}
static VALUE rbncurs_mvwaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
- return INT2NUM(mvwaddstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), STR2CSTR(arg4)));
+ return INT2NUM(mvwaddstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4)));
}
#ifdef HAVE_MVWCHGAT
static VALUE rbncurs_mvwchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
@@ -1171,10 +1171,10 @@
return INT2NUM(mvwinsch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4)));
}
static VALUE rbncurs_mvwinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
- return INT2NUM(mvwinsnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), STR2CSTR(arg4), NUM2INT(arg5)));
+ return INT2NUM(mvwinsnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4), NUM2INT(arg5)));
}
static VALUE rbncurs_mvwinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
- return INT2NUM(mvwinsstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), STR2CSTR(arg4)));
+ return INT2NUM(mvwinsstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), StringValuePtr(arg4)));
}
#ifdef HAVE_MVWVLINE
static VALUE rbncurs_mvwvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
@@ -1238,7 +1238,7 @@
}
#ifdef HAVE_PUTP
static VALUE rbncurs_putp(VALUE dummy, VALUE arg1) {
- return INT2NUM(putp(STR2CSTR(arg1)));
+ return INT2NUM(putp(StringValuePtr(arg1)));
}
#endif
#ifdef HAVE_QIFLUSH
@@ -1271,12 +1271,12 @@
}
#ifdef HAVE_SCR_DUMP
static VALUE rbncurs_scr_dump(VALUE dummy, VALUE arg1) {
- return INT2NUM(scr_dump(STR2CSTR(arg1)));
+ return INT2NUM(scr_dump(StringValuePtr(arg1)));
}
#endif
#ifdef HAVE_SCR_INIT
static VALUE rbncurs_scr_init(VALUE dummy, VALUE arg1) {
- return INT2NUM(scr_init(STR2CSTR(arg1)));
+ return INT2NUM(scr_init(StringValuePtr(arg1)));
}
#endif
static VALUE rbncurs_scrl(VALUE dummy, VALUE arg1) {
@@ -1290,12 +1290,12 @@
}
#ifdef HAVE_SCR_RESTORE
static VALUE rbncurs_scr_restore(VALUE dummy, VALUE arg1) {
- return INT2NUM(scr_restore(STR2CSTR(arg1)));
+ return INT2NUM(scr_restore(StringValuePtr(arg1)));
}
#endif
#ifdef HAVE_SCR_SET
static VALUE rbncurs_scr_set(VALUE dummy, VALUE arg1) {
- return INT2NUM(scr_set(STR2CSTR(arg1)));
+ return INT2NUM(scr_set(StringValuePtr(arg1)));
}
#endif
static VALUE rbncurs_setscrreg(VALUE dummy, VALUE arg1, VALUE arg2) {
@@ -1352,7 +1352,7 @@
return INT2NUM(slk_restore());
}
static VALUE rbncurs_slk_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- return INT2NUM(slk_set(NUM2INT(arg1), STR2CSTR(arg2), NUM2INT(arg3)));
+ return INT2NUM(slk_set(NUM2INT(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
}
static VALUE rbncurs_slk_touch(VALUE dummy) {
return INT2NUM(slk_touch());
@@ -1383,17 +1383,17 @@
}
#ifdef HAVE_TIGETFLAG
static VALUE rbncurs_tigetflag(VALUE dummy, VALUE arg1) {
- return INT2NUM(tigetflag(STR2CSTR(arg1)));
+ return INT2NUM(tigetflag(StringValuePtr(arg1)));
}
#endif
#ifdef HAVE_TIGETNUM
static VALUE rbncurs_tigetnum(VALUE dummy, VALUE arg1) {
- return INT2NUM(tigetnum(STR2CSTR(arg1)));
+ return INT2NUM(tigetnum(StringValuePtr(arg1)));
}
#endif
#ifdef HAVE_TIGETSTR
static VALUE rbncurs_tigetstr(VALUE dummy, VALUE arg1) {
- return rb_str_new2(tigetstr(STR2CSTR(arg1)));
+ return rb_str_new2(tigetstr(StringValuePtr(arg1)));
}
#endif
static VALUE rbncurs_timeout(VALUE dummy, VALUE arg1) {
@@ -1438,10 +1438,10 @@
return return_value;
}
static VALUE rbncurs_waddnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- return INT2NUM(waddnstr(get_window(arg1), STR2CSTR(arg2), NUM2INT(arg3)));
+ return INT2NUM(waddnstr(get_window(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
}
static VALUE rbncurs_waddstr(VALUE dummy, VALUE arg1, VALUE arg2) {
- return INT2NUM(waddstr(get_window(arg1), STR2CSTR(arg2)));
+ return INT2NUM(waddstr(get_window(arg1), StringValuePtr(arg2)));
}
static VALUE rbncurs_wattron(VALUE dummy, VALUE arg1, VALUE arg2) {
return INT2NUM(wattron(get_window(arg1), NUM2INT(arg2)));
@@ -1514,10 +1514,10 @@
return INT2NUM(winsertln(get_window(arg1)));
}
static VALUE rbncurs_winsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- return INT2NUM(winsnstr(get_window(arg1), STR2CSTR(arg2), NUM2INT(arg3)));
+ return INT2NUM(winsnstr(get_window(arg1), StringValuePtr(arg2), NUM2INT(arg3)));
}
static VALUE rbncurs_winsstr(VALUE dummy, VALUE arg1, VALUE arg2) {
- return INT2NUM(winsstr(get_window(arg1), STR2CSTR(arg2)));
+ return INT2NUM(winsstr(get_window(arg1), StringValuePtr(arg2)));
}
static VALUE rbncurs_wmove(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
return INT2NUM(wmove(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
@@ -1619,7 +1619,7 @@
{ return rb_str_new2(unctrl(NUM2ULONG(ch))); }
static VALUE rbncurs_newterm(VALUE dummy, VALUE rb_type, VALUE rb_outfd, VALUE rb_infd)
{
- char * type = (rb_type == Qnil) ? (char*)0 : STR2CSTR(rb_type);
+ char * type = (rb_type == Qnil) ? (char*)0 : StringValuePtr(rb_type);
int outfd = NUM2INT(rb_funcall(rb_outfd, rb_intern("to_i"), 0));
int infd = NUM2INT(rb_funcall(rb_infd, rb_intern("to_i"), 0));
VALUE rb_screen =
@@ -2277,7 +2277,7 @@
#ifdef HAVE_MCPRINT
static VALUE rbncurs_mcprint(VALUE dummy, VALUE data, VALUE len)
{
- return INT2NUM(mcprint(STR2CSTR(data), NUM2INT(len)));
+ return INT2NUM(mcprint(StringValuePtr(data), NUM2INT(len)));
}
#endif
#ifdef HAVE_HAS_KEY
@@ -2378,9 +2378,9 @@
" and a String");
return Qnil;
}
+ VALUE tmp = rb_funcall3(rb_mKernel, rb_intern("sprintf"), argc-1, argv + 1);
wprintw(get_window(argv[0]), "%s",
- STR2CSTR(rb_funcall3(rb_mKernel, rb_intern("sprintf"), argc-1,
- argv + 1)));
+ StringValuePtr(tmp));
return Qnil;
}
@@ -2394,14 +2394,14 @@
return Qnil;
}
_tracef("%s",
- STR2CSTR(rb_funcall3(rb_mKernel, rb_intern("sprintf"), argc, argv)));
+ StringValuePtr(funcall3(rb_mKernel, rb_intern("sprintf"), argc, argv)));
return Qnil;
}
#endif /* HAVE__TRACEF */
#ifdef HAVE__TRACEDUMP
static VALUE rbncurs_tracedump(VALUE dummy, VALUE rb_label, VALUE rb_win)
{
- _tracedump(STR2CSTR(rb_label), get_window(rb_win));
+ _tracedump(StringValuePtr(rb_label), get_window(rb_win));
}
#endif /* HAVE__TRACEDUMP */
#ifdef HAVE__TRACEATTR
@@ -2706,7 +2706,7 @@
#ifdef HAVE_LOCALE_H
static VALUE rbncurs_setlocale(VALUE dummy, VALUE category, VALUE locale)
-{ return rb_str_new2(setlocale(NUM2INT(category), STR2CSTR(locale)));}
+{ return rb_str_new2(setlocale(NUM2INT(category), StringValuePtr(locale)));}
#endif
static void init_safe_functions(void)