From 2594690aff1f23e0dbb42576daed2788960bcbd7 Mon Sep 17 00:00:00 2001 From: Ben S Date: Sat, 16 May 2015 13:17:50 +0100 Subject: [PATCH] Start using the libc crate from crates.io --- Cargo.lock | 17 +++++++++-------- Cargo.toml | 1 + src/main.rs | 4 ++-- src/term.rs | 17 +++++------------ 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31db78f..6aa0eab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,8 @@ dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "datetime 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.9 (git+https://github.com/alexcrichton/git2-rs.git)", + "git2 0.2.10 (git+https://github.com/alexcrichton/git2-rs.git)", + "libc 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "locale 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "natord 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -53,13 +54,13 @@ dependencies = [ [[package]] name = "git2" -version = "0.2.9" -source = "git+https://github.com/alexcrichton/git2-rs.git#3a5f0b5698c5203fa48e33094158990a2c53c979" +version = "0.2.10" +source = "git+https://github.com/alexcrichton/git2-rs.git#f820ef645e2275c80c3009da770a5b6a9b5ce0f0" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.2.12 (git+https://github.com/alexcrichton/git2-rs.git)", - "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.2.13 (git+https://github.com/alexcrichton/git2-rs.git)", + "url 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -69,8 +70,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.2.12" -source = "git+https://github.com/alexcrichton/git2-rs.git#3a5f0b5698c5203fa48e33094158990a2c53c979" +version = "0.2.13" +source = "git+https://github.com/alexcrichton/git2-rs.git#f820ef645e2275c80c3009da770a5b6a9b5ce0f0" dependencies = [ "libc 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "url" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index c1c5416..c34e634 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ ansi_term = "0.5.0" bitflags = "0.1" datetime = "0.1.3" getopts = "0.2.1" +libc = "*" locale = "0.1.2" natord = "1.0.7" num_cpus = "*" diff --git a/src/main.rs b/src/main.rs index 49fa51c..03c05e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,10 @@ #![feature(collections, convert, core, exit_status, file_type, fs_ext, fs_mode)] -#![feature(libc, metadata_ext, raw_ext, scoped, symlink_metadata)] +#![feature(metadata_ext, raw_ext, scoped, symlink_metadata)] extern crate ansi_term; extern crate datetime; extern crate getopts; +extern crate libc; extern crate locale; extern crate natord; extern crate num_cpus; @@ -12,7 +13,6 @@ extern crate pad; extern crate users; extern crate unicode_width; - #[cfg(feature="git")] extern crate git2; diff --git a/src/term.rs b/src/term.rs index dc98cbe..a3ba130 100644 --- a/src/term.rs +++ b/src/term.rs @@ -1,19 +1,12 @@ mod c { - #![allow(non_camel_case_types)] - extern crate libc; - pub use self::libc::{ - c_int, - c_ushort, - c_ulong, - STDOUT_FILENO, - }; + pub use libc::{c_int, c_ushort, c_ulong, STDOUT_FILENO}; use std::mem::zeroed; // Getting the terminal size is done using an ioctl command that // takes the file handle to the terminal (which in our case is // stdout), and populates a structure with the values. - pub struct winsize { + pub struct Winsize { pub ws_row: c_ushort, pub ws_col: c_ushort, } @@ -30,9 +23,9 @@ mod c { pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; } - pub unsafe fn dimensions() -> winsize { - let mut window: winsize = zeroed(); - ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut window as *mut winsize); + pub unsafe fn dimensions() -> Winsize { + let mut window: Winsize = zeroed(); + ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut window as *mut Winsize); window } }