From 7628b3c1c0dbf5143547183fd0f00cbf32dfdeb6 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 13 Apr 2013 13:40:50 -0500 Subject: use tparm instead of tiparm osx comes with ncurses 5.4 (and homebrew only has 5.7?), but tiparm was a new function in 5.8 --- Makefile | 11 ++--------- src/curses_helper.c | 12 ------------ src/info.rs | 27 +++++++++++---------------- 3 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 src/curses_helper.c diff --git a/Makefile b/Makefile index 1315c93..bf455f4 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,11 @@ bin/%: test/%.rs tmp/built @mkdir -p bin $(RUSTC) --out-dir bin -L lib $< -tmp/built: $(MAIN_SOURCE) $(OTHER_SOURCES) tmp/libtermios_wrapper.a tmp/libcurses_helper.a tmp/libio_helper.a +tmp/built: $(MAIN_SOURCE) $(OTHER_SOURCES) tmp/libtermios_wrapper.a tmp/libio_helper.a @mkdir -p lib $(RUSTC) --out-dir lib -L tmp $(MAIN_SOURCE) && touch tmp/built -clibs: tmp/libtermios_wrapper.a tmp/libcurses_helper.a tmp/libio_helper.a +clibs: tmp/libtermios_wrapper.a tmp/libio_helper.a tmp/libtermios_wrapper.a: tmp/termios_wrapper.o ar cr $@ $< @@ -32,13 +32,6 @@ tmp/termios_wrapper.o: src/termios_wrapper.c @mkdir -p tmp cc -fPIC -c -o $@ $< -tmp/libcurses_helper.a: tmp/curses_helper.o - ar cr $@ $< - -tmp/curses_helper.o: src/curses_helper.c - @mkdir -p tmp - cc -fPIC -c -o $@ $< - tmp/libio_helper.a: tmp/io_helper.o ar cr $@ $< diff --git a/src/curses_helper.c b/src/curses_helper.c deleted file mode 100644 index 1daee18..0000000 --- a/src/curses_helper.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -char *tiparm1(const char *name, int p1) -{ - return tiparm(name, p1); -} - -char *tiparm2(const char *name, int p1, int p2) -{ - return tiparm(name, p1, p2); -} diff --git a/src/info.rs b/src/info.rs index 8056180..72c0f51 100644 --- a/src/info.rs +++ b/src/info.rs @@ -1,4 +1,4 @@ -use core::libc::{c_char,c_int}; +use core::libc::{c_char,c_int,c_long}; /// The default colors available on a terminal emulator. #[deriving(Eq)] @@ -185,7 +185,7 @@ pub fn escape1 (name: &str, p1: int) -> Option<~str> { None } else { - Some(str::raw::from_c_str(tiparm1(e, p1))) + Some(str::raw::from_c_str(tparm1(e, p1))) } } } @@ -205,7 +205,7 @@ pub fn escape2 (name: &str, p1: int, p2: int) -> Option<~str> { None } else { - Some(str::raw::from_c_str(tiparm2(e, p1, p2))) + Some(str::raw::from_c_str(tparm2(e, p1, p2))) } } } @@ -220,8 +220,8 @@ unsafe fn tigetstr (name: *c_char) -> *c_char { c_out } -unsafe fn tiparm1 (name: *c_char, p1: int) -> *c_char { - let ret = helper::tiparm1(name, p1 as c_int); +unsafe fn tparm1 (name: *c_char, p1: int) -> *c_char { + let ret = c::tparm(name, p1 as c_long, 0, 0, 0, 0, 0, 0, 0, 0); if ret == ptr::null() { fail!(fmt!("Couldn't assemble parameters with %s %d", unsafe { str::raw::from_c_str(name) }, p1)); @@ -229,8 +229,8 @@ unsafe fn tiparm1 (name: *c_char, p1: int) -> *c_char { ret } -unsafe fn tiparm2 (name: *c_char, p1: int, p2: int) -> *c_char { - let ret = helper::tiparm2(name, p1 as c_int, p2 as c_int); +unsafe fn tparm2 (name: *c_char, p1: int, p2: int) -> *c_char { + let ret = c::tparm(name, p1 as c_long, p2 as c_long, 0, 0, 0, 0, 0, 0, 0); if ret == ptr::null() { fail!(fmt!("Couldn't assemble parameters with %s %d %d", unsafe { str::raw::from_c_str(name) }, p1, p2)); @@ -242,13 +242,8 @@ unsafe fn tiparm2 (name: *c_char, p1: int, p2: int) -> *c_char { extern mod c { fn setupterm (term: *c_char, fd: c_int, errret: *c_int) -> c_int; fn tigetstr (s: *c_char) -> *c_char; -} - -// tiparm uses varargs, which you can't bind from rust yet -// actually, you sort of probably can? there's just an llvm assertion that -// prevents multiple bindings to the same function from working (rust/#5791) -#[link_name = "curses_helper"] -extern mod helper { - fn tiparm1(s: *c_char, p1: c_int) -> *c_char; - fn tiparm2(s: *c_char, p1: c_int, p2: c_int) -> *c_char; + fn tparm (s: *c_char, + a1: c_long, a2: c_long, a3: c_long, + a4: c_long, a5: c_long, a6: c_long, + a7: c_long, a8: c_long, a9: c_long) -> *c_char; } -- cgit v1.2.3