From 27ed81322c5ca5d76ac6bef00a0c76d9b94f48d2 Mon Sep 17 00:00:00 2001 From: petejodo Date: Mon, 7 Apr 2014 18:43:34 -0400 Subject: [PATCH 1/2] Fixed most issues caused by libc being moved from std to it's own crate. I just did a quick pass and fixed a majority of the simple issues but there are still some problems with the following utils: id md5sum tee uptime users whoami --- base64/base64.rs | 1 + basename/basename.rs | 1 + common/c_types.rs | 2 +- common/util.rs | 4 ++-- common/utmpx.rs | 4 ++-- du/du.rs | 1 + echo/echo.rs | 3 ++- fold/fold.rs | 1 + groups/groups.rs | 1 + hostid/hostid.rs | 3 ++- hostname/hostname.rs | 3 ++- kill/kill.rs | 1 + logname/logname.rs | 3 ++- mkdir/mkdir.rs | 1 + paste/paste.rs | 1 + printenv/printenv.rs | 1 + pwd/pwd.rs | 1 + rm/rm.rs | 1 + rmdir/rmdir.rs | 1 + seq/seq.rs | 1 + sleep/sleep.rs | 1 + tac/tac.rs | 1 + truncate/truncate.rs | 1 + tty/tty.rs | 3 ++- uname/uname.rs | 1 + wc/wc.rs | 1 + yes/yes.rs | 1 + 27 files changed, 34 insertions(+), 10 deletions(-) diff --git a/base64/base64.rs b/base64/base64.rs index d18d4ef4a..91048d3f1 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -14,6 +14,7 @@ extern crate serialize; extern crate getopts; +extern crate libc; #[phase(syntax, link)] extern crate log; use std::char; diff --git a/basename/basename.rs b/basename/basename.rs index e7af6ada6..5a20e0dfa 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -11,6 +11,7 @@ */ extern crate getopts; +extern crate libc; use std::io::{print, println}; use std::os; diff --git a/common/c_types.rs b/common/c_types.rs index 8fa74c931..70bb38cfa 100644 --- a/common/c_types.rs +++ b/common/c_types.rs @@ -2,7 +2,7 @@ extern crate getopts; -use std::libc::{ +use libc::{ c_char, c_int, uid_t, diff --git a/common/util.rs b/common/util.rs index 05542598e..16893aff0 100644 --- a/common/util.rs +++ b/common/util.rs @@ -30,7 +30,7 @@ macro_rules! show_warning( macro_rules! crash( ($exitcode:expr, $($args:expr),+) => ({ show_error!($exitcode, $($args),+); - unsafe { ::std::libc::exit($exitcode as ::std::libc::c_int); } + unsafe { ::libc::exit($exitcode as ::libc::c_int); } }) ) @@ -38,7 +38,7 @@ macro_rules! crash( #[macro_export] macro_rules! exit( ($exitcode:expr) => ({ - unsafe { ::std::libc::exit($exitcode); } + unsafe { ::libc::exit($exitcode); } }) ) diff --git a/common/utmpx.rs b/common/utmpx.rs index 9d3392e75..68aabac76 100644 --- a/common/utmpx.rs +++ b/common/utmpx.rs @@ -4,7 +4,7 @@ pub use self::utmpx::{DEFAULT_FILE,USER_PROCESS,BOOT_TIME,c_utmp}; #[cfg(target_os = "linux")] mod utmpx { - use std::libc; + use libc; pub static DEFAULT_FILE: &'static str = "/var/run/utmp"; @@ -48,7 +48,7 @@ mod utmpx { #[cfg(target_os = "macos")] mod utmpx { - use std::libc; + use libc; pub static DEFAULT_FILE: &'static str = "/var/run/utmpx"; diff --git a/du/du.rs b/du/du.rs index 44af7b497..182b36b42 100644 --- a/du/du.rs +++ b/du/du.rs @@ -13,6 +13,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; extern crate sync; extern crate time; diff --git a/echo/echo.rs b/echo/echo.rs index 84f3cf76f..ff179b47d 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -1,5 +1,5 @@ #![feature(macro_rules)] -#![crate_id(name="echo", vers="1.0.0", author="Derek Chiang")] +#[crate_id(name="echo", vers="1.0.0", author="Derek Chiang")] /* * This file is part of the uutils coreutils package. @@ -11,6 +11,7 @@ */ extern crate getopts; +extern crate libc; use std::os; use std::io::{print, println}; diff --git a/fold/fold.rs b/fold/fold.rs index adef2288e..201c890d0 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::io; use std::io::fs::File; diff --git a/groups/groups.rs b/groups/groups.rs index d46ac19d1..a232c63e9 100644 --- a/groups/groups.rs +++ b/groups/groups.rs @@ -11,6 +11,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use getopts::{ diff --git a/hostid/hostid.rs b/hostid/hostid.rs index a9f6e5127..19f891b7d 100644 --- a/hostid/hostid.rs +++ b/hostid/hostid.rs @@ -15,6 +15,7 @@ extern crate getopts; extern crate collections; extern crate serialize; +extern crate libc; #[phase(syntax, link)] extern crate log; @@ -27,7 +28,7 @@ use getopts::{ usage, }; -use std::libc::{c_long}; +use libc::{c_long}; #[path = "../common/util.rs"] mod util; diff --git a/hostname/hostname.rs b/hostname/hostname.rs index 3fe1785d4..27d3ef240 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -13,8 +13,9 @@ */ extern crate getopts; +extern crate libc; -use std::{os,libc,str}; +use std::{os,str}; use getopts::{optflag, getopts, usage}; extern { diff --git a/kill/kill.rs b/kill/kill.rs index 52ada4413..fe5c54d0e 100644 --- a/kill/kill.rs +++ b/kill/kill.rs @@ -13,6 +13,7 @@ extern crate getopts; +extern crate libc; extern crate collections; extern crate serialize; diff --git a/logname/logname.rs b/logname/logname.rs index 8aed0c719..de489f483 100644 --- a/logname/logname.rs +++ b/logname/logname.rs @@ -16,11 +16,12 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::io::{print, println}; use std::os; use std::str; -use std::libc; +use libc::c_char; #[path = "../common/util.rs"] mod util; diff --git a/mkdir/mkdir.rs b/mkdir/mkdir.rs index 41bce3ca6..122a943db 100644 --- a/mkdir/mkdir.rs +++ b/mkdir/mkdir.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::fs; diff --git a/paste/paste.rs b/paste/paste.rs index bc6338e82..e11b58156 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::io; use std::os; diff --git a/printenv/printenv.rs b/printenv/printenv.rs index e062ac4c6..0c87df0f3 100644 --- a/printenv/printenv.rs +++ b/printenv/printenv.rs @@ -14,6 +14,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::print; diff --git a/pwd/pwd.rs b/pwd/pwd.rs index 0fea9bad0..4661ebf30 100644 --- a/pwd/pwd.rs +++ b/pwd/pwd.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::print; diff --git a/rm/rm.rs b/rm/rm.rs index 0820936df..e8e193786 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::{print, stdin, stdio, fs, BufferedReader}; diff --git a/rmdir/rmdir.rs b/rmdir/rmdir.rs index d2bb7d3c1..be9efebe1 100644 --- a/rmdir/rmdir.rs +++ b/rmdir/rmdir.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::{print, fs}; diff --git a/seq/seq.rs b/seq/seq.rs index 14e37b9af..210d55451 100644 --- a/seq/seq.rs +++ b/seq/seq.rs @@ -6,6 +6,7 @@ // TODO: Support -f flag extern crate getopts; +extern crate libc; use std::os; diff --git a/sleep/sleep.rs b/sleep/sleep.rs index 54d23ac13..e9983e07a 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::num; use std::cast; diff --git a/tac/tac.rs b/tac/tac.rs index 054960ed7..69f2afabe 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::io; use std::os; diff --git a/truncate/truncate.rs b/truncate/truncate.rs index 0a2947db2..04ad57c44 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::io::{File, Open, ReadWrite, fs}; use std::os; diff --git a/tty/tty.rs b/tty/tty.rs index b415c543e..f781b4fba 100644 --- a/tty/tty.rs +++ b/tty/tty.rs @@ -17,8 +17,9 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; -use std::{libc,str,os}; +use std::{str,os}; use std::io::println; use std::io::stdio::stderr; use getopts::{optflag,getopts}; diff --git a/uname/uname.rs b/uname/uname.rs index c780ed53b..e7f8cb21f 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -15,6 +15,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::mem::uninit; diff --git a/wc/wc.rs b/wc/wc.rs index 7799da7a2..2aeffceef 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::str::from_utf8; diff --git a/yes/yes.rs b/yes/yes.rs index 1ea3517c8..45b0cd253 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -14,6 +14,7 @@ #![feature(macro_rules)] extern crate getopts; +extern crate libc; use std::os; use std::io::{print, println}; From e17adf9aa9d2d0059c5149d328c03d3627b068da Mon Sep 17 00:00:00 2001 From: petejodo Date: Tue, 8 Apr 2014 09:37:17 -0400 Subject: [PATCH 2/2] Accidentally removed an exclamation for crate_id in echo. Put it back. --- echo/echo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo/echo.rs b/echo/echo.rs index ff179b47d..c4e68921c 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -1,5 +1,5 @@ #![feature(macro_rules)] -#[crate_id(name="echo", vers="1.0.0", author="Derek Chiang")] +#![crate_id(name="echo", vers="1.0.0", author="Derek Chiang")] /* * This file is part of the uutils coreutils package.