diff --git a/Makefile b/Makefile index e2b6ff48f..5eefff85b 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ TESTS := \ # Setup for building crates define BUILD_SETUP -X := $(shell $(RUSTC) --print-file-name --crate-type rlib $(SRCDIR)/$(1)/$(1).rs) +X := $(shell $(RUSTC) --print file-names --crate-type rlib $(SRCDIR)/$(1)/$(1).rs) $(1)_RLIB := $$(X) CRATE_RLIBS += $$(X) endef @@ -221,9 +221,9 @@ $(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS $(if $(ENABLE_STRIP),strip $@) # Dependencies --include $(BUILDDIR)/rust-crypto.d $(BUILDDIR)/.rust-crypto: $(BUILDDIR)/.rust-time | $(BUILDDIR) - $(RUSTC) $(RUSTCFLAGS) --extern time=$(BUILDDIR)/libtime.rlib --crate-type rlib --crate-name crypto --dep-info $(BUILDDIR)/rust-crypto.d $(BASEDIR)/deps/rust-crypto/src/rust-crypto/lib.rs --out-dir $(BUILDDIR)/ + cd $(BASEDIR)/deps/rust-crypto && cargo build --release + cp -r $(BASEDIR)/deps/rust-crypto/target/release/libcrypto*.rlib $(BUILDDIR)/libcrypto.rlib @touch $@ $(BUILDDIR)/.rust-time: diff --git a/deps/rust-crypto b/deps/rust-crypto index 3db4f2253..ebf18b215 160000 --- a/deps/rust-crypto +++ b/deps/rust-crypto @@ -1 +1 @@ -Subproject commit 3db4f22536d9391b1eebadbe868593d44a6295ae +Subproject commit ebf18b21551cccba2aa75ea2372b2e85ab4cf89a diff --git a/deps/time b/deps/time index 914a48401..a0a0dedc4 160000 --- a/deps/time +++ b/deps/time @@ -1 +1 @@ -Subproject commit 914a48401168169ccd1a822c2d32d87965306141 +Subproject commit a0a0dedc41fac4d2504db533b70af1686ec19d15 diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 06f62e5e5..d2881e0d3 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -9,13 +9,10 @@ * that was distributed with this source code. */ -#![feature(phase)] -#![feature(macro_rules)] - extern crate serialize; extern crate getopts; extern crate libc; -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; use std::ascii::AsciiExt; use std::io::{println, File, stdout}; @@ -31,6 +28,7 @@ use serialize::base64; use serialize::base64::{FromBase64, ToBase64}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "base64"; diff --git a/src/basename/basename.rs b/src/basename/basename.rs index d2b44ac0d..0f9f304cb 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -1,4 +1,3 @@ -#![feature(macro_rules)] #![crate_name = "basename"] /* @@ -17,6 +16,7 @@ use std::borrow::ToOwned; use std::io::{print, println}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "basename"; diff --git a/src/cat/cat.rs b/src/cat/cat.rs index a6b19faf6..d90591513 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -81,7 +81,7 @@ pub fn uumain(args: Vec) -> int { 0 } -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] enum NumberingMode { NumberNone, NumberNonEmpty, @@ -99,8 +99,8 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, None => continue, }; - let mut in_buf = [0, .. 1024 * 31]; - let mut out_buf = [0, .. 1024 * 64]; + let mut in_buf = [0; 1024 * 31]; + let mut out_buf = [0; 1024 * 64]; let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw()); let mut at_line_start = true; loop { @@ -175,8 +175,8 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, // Flush all 1024 iterations. let mut flush_counter = range(0u, 1024); - let mut in_buf = [0, .. 1024 * 32]; - let mut out_buf = [0, .. 1024 * 64]; + let mut in_buf = [0; 1024 * 32]; + let mut out_buf = [0; 1024 * 64]; let mut writer = UnsafeWriter::new(out_buf.as_mut_slice(), stdout_raw()); let mut at_line_start = true; loop { @@ -242,7 +242,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, fn write_fast(files: Vec) { let mut writer = stdout_raw(); - let mut in_buf = [0, .. 1024 * 64]; + let mut in_buf = [0; 1024 * 64]; for path in files.iter() { let (mut reader, _) = match open(path.as_slice()) { diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 6a9d0ce7b..5c5125c3c 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -9,14 +9,12 @@ * file that was distributed with this source code. */ -#![feature(macro_rules, phase)] - #![allow(unused_variables)] // only necessary while the TODOs still exist extern crate getopts; extern crate libc; extern crate regex; -#[phase(plugin)] extern crate regex_macros; +#[macro_use] extern crate regex_macros; use std::io::fs; use std::io::fs::PathExtensions; @@ -26,6 +24,7 @@ use std::num::from_str_radix; use regex::Regex; #[path = "../common/util.rs"] +#[macro_use] mod util; const NAME: &'static str = "chmod"; diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 5afbbfa99..c718460c6 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -8,7 +8,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] extern crate getopts; extern crate libc; @@ -17,7 +16,7 @@ use c_types::{get_pw_from_args, get_group}; use libc::funcs::posix88::unistd::{execvp, setuid, setgid}; use std::io::fs::PathExtensions; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; extern { diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index 0a3b793e7..8c29652c9 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -1,5 +1,4 @@ #![crate_name = "cksum"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -19,6 +18,7 @@ use std::mem; use crc_table::CRC_TABLE; #[path="../common/util.rs"] +#[macro_use] mod util; mod crc_table; @@ -59,7 +59,7 @@ fn cksum(fname: &str) -> IoResult<(u32, uint)> { } }; - let mut bytes: [u8, ..1024 * 1024] = unsafe { mem::uninitialized() }; + let mut bytes: [u8; 1024 * 1024] = unsafe { mem::uninitialized() }; loop { match rd.read(&mut bytes) { Ok(num_bytes) => { diff --git a/src/cksum/crc_table.rs b/src/cksum/crc_table.rs index a810d89cc..feecc82ec 100644 --- a/src/cksum/crc_table.rs +++ b/src/cksum/crc_table.rs @@ -1,3 +1,3 @@ /* auto-generated (DO NOT EDIT) */ -pub static CRC_TABLE: [u32, ..256] = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, 2552477408, 2632100695, 2443283854, 2506133561, 2334638140, 2414271883, 2191915858, 2254759653, 3190512472, 3135915759, 3081330742, 3009969537, 2905550212, 2850959411, 2762807018, 2691435357, 3560074640, 3505614887, 3719321342, 3648080713, 3342211916, 3287746299, 3467911202, 3396681109, 4063920168, 4143685023, 4223187782, 4286162673, 3779000052, 3858754371, 3904687514, 3967668269, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, 2896545431, 2825181984, 2770861561, 2716262478, 3215044683, 3143675388, 3055782693, 3001194130, 2326604591, 2389456536, 2200899649, 2280525302, 2578013683, 2640855108, 2418763421, 2498394922, 3769900519, 3832873040, 3912640137, 3992402750, 4088425275, 4151408268, 4197601365, 4277358050, 3334271071, 3263032808, 3476998961, 3422541446, 3585640067, 3514407732, 3694837229, 3640369242, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, 4046411278, 4126034873, 4172115296, 4234965207, 3794477266, 3874110821, 3953728444, 4016571915, 3609705398, 3555108353, 3735388376, 3664026991, 3290680682, 3236090077, 3449943556, 3378572211, 3174993278, 3120533705, 3032266256, 2961025959, 2923101090, 2868635157, 2813903052, 2742672763, 2604032198, 2683796849, 2461293480, 2524268063, 2284983834, 2364738477, 2175806836, 2238787779, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, 3316196985, 3244833742, 3425377559, 3370778784, 3601682597, 3530312978, 3744426955, 3689838204, 3819031489, 3881883254, 3928223919, 4007849240, 4037393693, 4100235434, 4180117107, 4259748804, 2310601993, 2373574846, 2151335527, 2231098320, 2596047829, 2659030626, 2470359227, 2550115596, 2947551409, 2876312838, 2788305887, 2733848168, 3165939309, 3094707162, 3040238851, 2985771188]; +pub static CRC_TABLE: [u32; 256] = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, 2552477408, 2632100695, 2443283854, 2506133561, 2334638140, 2414271883, 2191915858, 2254759653, 3190512472, 3135915759, 3081330742, 3009969537, 2905550212, 2850959411, 2762807018, 2691435357, 3560074640, 3505614887, 3719321342, 3648080713, 3342211916, 3287746299, 3467911202, 3396681109, 4063920168, 4143685023, 4223187782, 4286162673, 3779000052, 3858754371, 3904687514, 3967668269, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, 2896545431, 2825181984, 2770861561, 2716262478, 3215044683, 3143675388, 3055782693, 3001194130, 2326604591, 2389456536, 2200899649, 2280525302, 2578013683, 2640855108, 2418763421, 2498394922, 3769900519, 3832873040, 3912640137, 3992402750, 4088425275, 4151408268, 4197601365, 4277358050, 3334271071, 3263032808, 3476998961, 3422541446, 3585640067, 3514407732, 3694837229, 3640369242, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, 4046411278, 4126034873, 4172115296, 4234965207, 3794477266, 3874110821, 3953728444, 4016571915, 3609705398, 3555108353, 3735388376, 3664026991, 3290680682, 3236090077, 3449943556, 3378572211, 3174993278, 3120533705, 3032266256, 2961025959, 2923101090, 2868635157, 2813903052, 2742672763, 2604032198, 2683796849, 2461293480, 2524268063, 2284983834, 2364738477, 2175806836, 2238787779, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, 3316196985, 3244833742, 3425377559, 3370778784, 3601682597, 3530312978, 3744426955, 3689838204, 3819031489, 3881883254, 3928223919, 4007849240, 4037393693, 4100235434, 4180117107, 4259748804, 2310601993, 2373574846, 2151335527, 2231098320, 2596047829, 2659030626, 2470359227, 2550115596, 2947551409, 2876312838, 2788305887, 2733848168, 3165939309, 3094707162, 3040238851, 2985771188]; diff --git a/src/cksum/gen_table.rs b/src/cksum/gen_table.rs index f1ca4257a..622af56ec 100644 --- a/src/cksum/gen_table.rs +++ b/src/cksum/gen_table.rs @@ -20,13 +20,13 @@ fn main() { let mut file = io::File::open_mode(&Path::new("crc_table.rs"), io::Truncate, io::Write).unwrap(); let output = format!("/* auto-generated (DO NOT EDIT) */ -pub static CRC_TABLE: [u32, ..{}] = {};", CRC_TABLE_LEN, table); +pub static CRC_TABLE: [u32; {}] = {};", CRC_TABLE_LEN, table); file.write_line(output.as_slice()).unwrap(); } #[inline] fn crc_entry(input: u8) -> u32 { - let mut crc = input as u32 << 24; + let mut crc = (input as u32) << 24; for _ in range(0u, 8) { if crc & 0x80000000 != 0 { diff --git a/src/common/c_types.rs b/src/common/c_types.rs index 1f653dc63..e96cbd83f 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -52,22 +52,22 @@ impl Copy for c_passwd {} #[cfg(any(target_os = "macos", target_os = "freebsd"))] #[repr(C)] pub struct utsname { - pub sysname: [c_char, ..256], - pub nodename: [c_char, ..256], - pub release: [c_char, ..256], - pub version: [c_char, ..256], - pub machine: [c_char, ..256] + pub sysname: [c_char; 256], + pub nodename: [c_char; 256], + pub release: [c_char; 256], + pub version: [c_char; 256], + pub machine: [c_char; 256] } #[cfg(target_os = "linux")] #[repr(C)] pub struct utsname { - pub sysname: [c_char, ..65], - pub nodename: [c_char, ..65], - pub release: [c_char, ..65], - pub version: [c_char, ..65], - pub machine: [c_char, ..65], - pub domainame: [c_char, ..65] + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainame: [c_char; 65] } impl Copy for utsname {} diff --git a/src/common/signals.rs b/src/common/signals.rs index 3a5bd17bf..4442a4af9 100644 --- a/src/common/signals.rs +++ b/src/common/signals.rs @@ -28,7 +28,7 @@ Linux Programmer's Manual */ #[cfg(target_os = "linux")] -pub static ALL_SIGNALS:[Signal<'static>, ..31] = [ +pub static ALL_SIGNALS:[Signal<'static>; 31] = [ Signal{ name: "HUP", value:1 }, Signal{ name: "INT", value:2 }, Signal{ name: "QUIT", value:3 }, @@ -105,7 +105,7 @@ No Name Default Action Description */ #[cfg(any(target_os = "macos", target_os = "freebsd"))] -pub static ALL_SIGNALS:[Signal<'static>, ..31] = [ +pub static ALL_SIGNALS:[Signal<'static>; 31] = [ Signal{ name: "HUP", value:1 }, Signal{ name: "INT", value:2 }, Signal{ name: "QUIT", value:3 }, diff --git a/src/common/util.rs b/src/common/util.rs index 5986eca63..2aaf848ba 100644 --- a/src/common/util.rs +++ b/src/common/util.rs @@ -7,11 +7,8 @@ * file that was distributed with this source code. */ -#![macro_escape] - extern crate libc; -#[macro_export] macro_rules! show_error( ($($args:expr),+) => ({ pipe_write!(&mut ::std::io::stderr(), "{}: error: ", ::NAME); diff --git a/src/common/utmpx.rs b/src/common/utmpx.rs index b5e525729..e68e0c40c 100644 --- a/src/common/utmpx.rs +++ b/src/common/utmpx.rs @@ -36,17 +36,17 @@ mod utmpx { pub struct c_utmp { pub ut_type: libc::c_short, pub ut_pid: libc::pid_t, - pub ut_line: [libc::c_char, ..UT_LINESIZE], - pub ut_id: [libc::c_char, ..UT_IDSIZE], + pub ut_line: [libc::c_char; UT_LINESIZE], + pub ut_id: [libc::c_char; UT_IDSIZE], - pub ut_user: [libc::c_char, ..UT_NAMESIZE], - pub ut_host: [libc::c_char, ..UT_HOSTSIZE], + pub ut_user: [libc::c_char; UT_NAMESIZE], + pub ut_host: [libc::c_char; UT_HOSTSIZE], pub ut_exit: c_exit_status, pub ut_session: libc::c_long, pub ut_tv: libc::timeval, - pub ut_addr_v6: [libc::int32_t, ..4], - pub __unused: [libc::c_char, ..20], + pub ut_addr_v6: [libc::int32_t; 4], + pub __unused: [libc::c_char; 20], } } @@ -80,14 +80,14 @@ mod utmpx { #[repr(C)] pub struct c_utmp { - pub ut_user: [libc::c_char, ..UT_NAMESIZE], - pub ut_id: [libc::c_char, ..UT_IDSIZE], - pub ut_line: [libc::c_char, ..UT_LINESIZE], + pub ut_user: [libc::c_char; UT_NAMESIZE], + pub ut_id: [libc::c_char; UT_IDSIZE], + pub ut_line: [libc::c_char; UT_LINESIZE], pub ut_pid: libc::pid_t, pub ut_type: libc::c_short, pub ut_tv: libc::timeval, - pub ut_host: [libc::c_char, ..UT_HOSTSIZE], - pub __unused: [libc::c_char, ..16] + pub ut_host: [libc::c_char; UT_HOSTSIZE], + pub __unused: [libc::c_char; 16] } } @@ -116,11 +116,11 @@ mod utmpx { pub struct c_utmp { pub ut_type : libc::c_short, pub ut_tv : libc::timeval, - pub ut_id : [libc::c_char, ..UT_IDSIZE], + pub ut_id : [libc::c_char; UT_IDSIZE], pub ut_pid : libc::pid_t, - pub ut_user : [libc::c_char, ..UT_NAMESIZE], - pub ut_line : [libc::c_char, ..UT_LINESIZE], - pub ut_host : [libc::c_char, ..UT_HOSTSIZE], - pub ut_spare : [libc::c_char, ..64], + pub ut_user : [libc::c_char; UT_NAMESIZE], + pub ut_line : [libc::c_char; UT_LINESIZE], + pub ut_host : [libc::c_char; UT_HOSTSIZE], + pub ut_spare : [libc::c_char; 64], } } diff --git a/src/cp/cp.rs b/src/cp/cp.rs index 4e3826c59..765063d17 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -1,6 +1,4 @@ #![crate_name = "cp"] -#![feature(macro_rules)] -#![feature(phase)] /* * This file is part of the uutils coreutils package. @@ -12,7 +10,7 @@ */ extern crate getopts; -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; use std::os; use std::io; @@ -24,7 +22,7 @@ use getopts::{ usage, }; -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] pub enum Mode { Copy, Help, diff --git a/src/cut/buffer.rs b/src/cut/buffer.rs index 74994011a..ef6ce58a5 100644 --- a/src/cut/buffer.rs +++ b/src/cut/buffer.rs @@ -3,7 +3,7 @@ use std::io::{IoResult, IoError}; pub struct BufReader { reader: R, - buffer: [u8, ..4096], + buffer: [u8; 4096], start: uint, end: uint, // exclusive } @@ -25,7 +25,7 @@ pub mod Bytes { impl BufReader { pub fn new(reader: R) -> BufReader { let empty_buffer = unsafe { - std::mem::uninitialized::<[u8, ..4096]>() + std::mem::uninitialized::<[u8; 4096]>() }; BufReader { diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 4d0b9f0e1..5ef2871bb 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -21,6 +19,7 @@ use getopts::{optopt, optflag, getopts, usage}; use ranges::Range; #[path = "../common/util.rs"] +#[macro_use] mod util; mod ranges; mod buffer; @@ -192,7 +191,7 @@ fn cut_characters(reader: R, 0 } -#[deriving(Clone)] +#[derive(Clone)] struct Searcher<'a> { haystack: &'a [u8], needle: &'a [u8], diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 8a3ef2b2c..2a8092fe5 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -9,7 +9,7 @@ use std; -#[deriving(PartialEq,Eq,PartialOrd,Ord,Show)] +#[derive(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { pub low: uint, pub high: uint, @@ -23,19 +23,19 @@ impl std::str::FromStr for Range { match (parts.next(), parts.next()) { (Some(nm), None) => { - from_str::(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) + std::str::FromStr::from_str::(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) } (Some(n), Some(m)) if m.len() == 0 => { - from_str::(n).and_then(|low| if low > 0 { Some(low) } else { None }) + std::str::FromStr::from_str::(n).and_then(|low| if low > 0 { Some(low) } else { None }) .map(|low| Range { low: low, high: MAX }) } (Some(n), Some(m)) if n.len() == 0 => { - from_str::(m).and_then(|high| if high >= 1 { Some(high) } else { None }) + std::str::FromStr::from_str::(m).and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) } (Some(n), Some(m)) => { - match (from_str::(n), from_str::(m)) { + match (std::str::FromStr::from_str::(n), std::str::FromStr::from_str::(m)) { (Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } @@ -54,7 +54,7 @@ impl Range { let mut ranges = vec!(); for item in list.split(',') { - match from_str::(item) { + match std::str::FromStr::from_str(item) { Some(range_item) => ranges.push(range_item), None => return Err(format!("range '{}' was invalid", item)) } diff --git a/src/du/du.rs b/src/du/du.rs index c84c4e283..b545d174c 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -10,7 +10,6 @@ */ #![allow(non_snake_case)] -#![feature(macro_rules)] extern crate getopts; extern crate libc; @@ -25,6 +24,7 @@ use std::str::from_utf8; use time::Timespec; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "du"; diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 1cf203f08..176fbd5e3 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -1,4 +1,3 @@ -#![feature(macro_rules)] #![crate_name = "echo"] /* @@ -24,7 +23,7 @@ mod util; static NAME: &'static str = "echo"; static VERSION: &'static str = "1.0.0"; -#[deriving(Clone)] +#[derive(Clone)] struct EchoOptions { newline: bool, escape: bool diff --git a/src/env/env.rs b/src/env/env.rs index b8c739384..dec94d810 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -82,7 +82,7 @@ pub fn uumain(args: Vec) -> int { match (name, value) { (Some(n), Some(v)) => { - opts.sets.push((n.into_string(), v.into_string())); + opts.sets.push((n.to_string(), v.to_string())); } _ => { // read the program now @@ -154,7 +154,7 @@ pub fn uumain(args: Vec) -> int { match (name, value) { (Some(n), Some(v)) => { // yes - opts.sets.push((n.into_string(), v.into_string())); + opts.sets.push((n.to_string(), v.to_string())); wait_cmd = true; } // no, its a program-like opt diff --git a/src/expand/expand.rs b/src/expand/expand.rs index bcaa121fb..6ba026e92 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io; -use std::str::from_str; +use std::str::StrExt; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "expand"; @@ -29,7 +28,7 @@ fn tabstops_parse(s: String) -> Vec { let words = s.as_slice().split(',').collect::>(); let nums = words.into_iter() - .map(|sn| from_str::(sn) + .map(|sn| sn.parse::() .unwrap_or_else( || crash!(1, "{}\n", "tab size contains invalid character(s)")) ) diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 5cb9b85fb..935c1c645 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -1,5 +1,4 @@ #![crate_name = "factor"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -18,6 +17,7 @@ use std::io::BufferedReader; use std::io::stdio::stdin_raw; #[path="../common/util.rs"] +#[macro_use] mod util; static VERSION: &'static str = "1.0.0"; @@ -56,7 +56,7 @@ fn print_factors(num: u64) { } fn print_factors_str(num_str: &str) { - let num = match from_str(num_str) { + let num = match num_str.parse::() { Some(x) => x, None => { crash!(1, "{} not a number", num_str); } }; diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index eaee850c4..db5dd748b 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -8,8 +8,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate core; extern crate getopts; @@ -19,7 +17,6 @@ use std::io::stdio::{stdin_raw, stdout_raw}; use linebreak::break_lines; use parasplit::ParagraphStream; -#[macro_export] macro_rules! silent_unwrap( ($exp:expr) => ( match $exp { @@ -28,7 +25,9 @@ macro_rules! silent_unwrap( } ) ); + #[path = "../common/util.rs"] +#[macro_use] mod util; mod linebreak; mod parasplit; @@ -141,7 +140,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("w") { Some(s) => { fmt_opts.width = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid WIDTH specification: `{}'", s); } }; @@ -153,7 +152,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("g") { Some(s) => { fmt_opts.goal = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid GOAL specification: `{}'", s); } }; @@ -169,7 +168,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("T") { Some(s) => { fmt_opts.tabwidth = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); } }; diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index 583262f90..776ae9198 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -30,7 +30,7 @@ fn char_width(c: char) -> uint { // lines with PSKIP, lacking PREFIX, or which are entirely blank are // NoFormatLines; otherwise, they are FormatLines -#[deriving(Show)] +#[derive(Show)] pub enum Line { FormatLine(FileLine), NoFormatLine(String, bool) @@ -56,7 +56,7 @@ impl Line { // each line's prefix has to be considered to know whether to merge it with // the next line or not -#[deriving(Show)] +#[derive(Show)] struct FileLine { line : String, indent_end : uint, // the end of the indent, always the start of the text @@ -195,7 +195,7 @@ impl<'a> Iterator for FileLines<'a> { // plus info about the paragraph's indentation // (but we only retain the String from the FileLine; the other info // is only there to help us in deciding how to merge lines into Paragraphs -#[deriving(Show)] +#[derive(Show)] pub struct Paragraph { lines : Vec, // the lines of the file pub init_str : String, // string representing the init, that is, the first line's indent diff --git a/src/fold/fold.rs b/src/fold/fold.rs index 08a12cc6a..79bc76f96 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -19,6 +17,7 @@ use std::io::fs::File; use std::io::BufferedReader; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "fold"; @@ -63,7 +62,7 @@ pub fn uumain(args: Vec) -> int { } }; let width = match poss_width { - Some(inp_width) => match from_str(inp_width.as_slice()) { + Some(inp_width) => match inp_width.parse::() { Some(width) => width, None => crash!(1, "illegal width value (\"{}\")", inp_width) }, @@ -173,7 +172,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, (slice, "", 0) }; println!("{}", out); - (val.into_string(), ncount) + (val.to_string(), ncount) }; output = val; count = ncount; diff --git a/src/groups/groups.rs b/src/groups/groups.rs index b1989e14b..7db857155 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -8,8 +8,6 @@ * file that was distributed with this source code. * */ -#![feature(macro_rules)] - extern crate getopts; use getopts::{ @@ -19,7 +17,7 @@ use getopts::{ }; use c_types::{get_pw_from_args, group}; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; static NAME: &'static str = "groups"; diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index 2a00f3276..199ef94b3 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -11,8 +11,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate regex; extern crate crypto; @@ -31,6 +29,7 @@ use crypto::sha1::Sha1; use crypto::sha2::{Sha224, Sha256, Sha384, Sha512}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "hashsum"; @@ -275,7 +274,7 @@ fn digest_reader(digest: &mut Box, reader: &mut Reader, binary: bool) -> // Digest file, do not hold too much in memory at any given moment let windows = cfg!(windows); - let mut buffer = [0, ..524288]; + let mut buffer = [0; 524288]; let mut vec = Vec::with_capacity(524288); let mut looking_for_newline = false; loop { diff --git a/src/head/head.rs b/src/head/head.rs index 941bc7726..7e1bbd2ed 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -10,11 +10,9 @@ * Synced with: https://raw.github.com/avsm/src/master/usr.bin/head/head.c */ -#![feature(macro_rules)] - extern crate getopts; -use std::char::UnicodeChar; +use std::char::CharExt; use std::io::{stdin}; use std::io::{BufferedReader, BytesReader}; use std::io::fs::File; @@ -23,6 +21,7 @@ use std::str::from_utf8; use getopts::{optopt, optflag, getopts, usage}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "head"; @@ -69,7 +68,7 @@ pub fn uumain(args: Vec) -> int { show_error!("cannot specify both --bytes and --lines."); return 1; } - match from_str(n.as_slice()) { + match n.parse::() { Some(m) => { line_count = m } None => { show_error!("invalid line count '{}'", n); @@ -78,7 +77,7 @@ pub fn uumain(args: Vec) -> int { } } None => match given_options.opt_str("c") { - Some(count) => match from_str(count.as_slice()) { + Some(count) => match count.parse::() { Some(m) => byte_count = m, None => { show_error!("invalid byte count '{}'", count); @@ -145,12 +144,12 @@ fn obsolete(options: &[String]) -> (Vec, Option) { let len = current.len(); for pos in range(1, len) { // Ensure that the argument is only made out of digits - if !UnicodeChar::is_numeric(current[pos] as char) { break; } + if !(current[pos] as char).is_numeric() { break; } // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_str(from_utf8(current.slice(1,len)).unwrap()); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); return (options, Some(number.unwrap())); } } diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 05dc6dabf..f4902fa5a 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -1,6 +1,4 @@ #![crate_name = "hostid"] -#![feature(macro_rules)] -#![feature(phase)] /* * This file is part of the uutils coreutils package. @@ -18,7 +16,7 @@ extern crate serialize; extern crate libc; -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; use getopts::{ getopts, @@ -29,6 +27,7 @@ use getopts::{ use libc::{c_long}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "hostid"; diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index d6dcf0b97..d0f7d8994 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -12,8 +12,6 @@ * https://www.opensource.apple.com/source/shell_cmds/shell_cmds-170/hostname/hostname.c?txt */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -23,6 +21,7 @@ use std::str; use getopts::{optflag, getopts, usage}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "hostname"; diff --git a/src/id/id.rs b/src/id/id.rs index 1c160129e..442957779 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -14,7 +14,6 @@ */ #![allow(non_camel_case_types)] -#![feature(macro_rules)] extern crate getopts; extern crate libc; @@ -36,7 +35,7 @@ use c_types::{ group }; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; #[cfg(not(target_os = "linux"))] diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 379fa4e5e..abd556da7 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -1,6 +1,4 @@ #![crate_name = "kill"] -#![feature(macro_rules)] -#![feature(phase)] /* * This file is part of the uutils coreutils package. @@ -17,7 +15,7 @@ extern crate libc; extern crate collections; extern crate serialize; -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; use std::io::process::Process; @@ -32,6 +30,7 @@ use getopts::{ use signals::ALL_SIGNALS; #[path = "../common/util.rs"] +#[macro_use] mod util; #[path = "../common/signals.rs"] diff --git a/src/link/link.rs b/src/link/link.rs index a0ab5c582..121aad5b7 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -1,5 +1,4 @@ #![crate_name = "link"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -16,6 +15,7 @@ use std::io::fs::link; use std::path::Path; #[path="../common/util.rs"] +#[macro_use] mod util; static NAME : &'static str = "link"; diff --git a/src/logname/logname.rs b/src/logname/logname.rs index 6213822b3..0571640e1 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -13,15 +13,13 @@ #![allow(non_camel_case_types)] -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io::print; use libc::c_char; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; extern { // POSIX requires using getlogin (or equivalent code) diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index cd38180d1..e21490292 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -9,16 +9,15 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; -use std::io::fs::{mod, PathExtensions}; +use std::io::fs::{self, PathExtensions}; use std::io::FilePermission; use std::num::from_str_radix; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "mkdir"; diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index cd11902f4..7ef335874 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -1,5 +1,4 @@ #![crate_name = "mkfifo"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -18,6 +17,7 @@ use std::os; use libc::funcs::posix88::stat_::mkfifo; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME : &'static str = "mkfifo"; diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 526b2865a..396d15f8a 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -10,8 +10,6 @@ * that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; use std::io::{BufferedReader, IoResult, fs}; @@ -28,6 +26,7 @@ use getopts::{ use std::borrow::ToOwned; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "mv"; @@ -43,7 +42,7 @@ pub struct Behaviour { verbose: bool, } -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] pub enum OverwriteMode { NoClobber, Interactive, @@ -52,7 +51,7 @@ pub enum OverwriteMode { impl Copy for OverwriteMode {} -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] pub enum BackupMode { NoBackup, SimpleBackup, diff --git a/src/nice/nice.rs b/src/nice/nice.rs index a2069ed58..4573e8eb4 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -26,6 +24,7 @@ const VERSION: &'static str = "1.0.0"; const PRIO_PROCESS: c_int = 0; #[path = "../common/util.rs"] +#[macro_use] mod util; extern { diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 3d2e2e95e..9273e72f6 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -1,5 +1,4 @@ #![crate_name = "nl"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. * @@ -10,9 +9,7 @@ * */ -#![feature(phase)] -#[phase(plugin)] -extern crate regex_macros; +#[macro_use] extern crate regex_macros; extern crate regex; extern crate getopts; @@ -24,6 +21,7 @@ use std::path::Path; use getopts::{optopt, optflag, getopts, usage, OptGroup}; #[path="../common/util.rs"] +#[macro_use] mod util; mod helper; @@ -39,7 +37,7 @@ struct Settings { body_numbering: NumberingStyle, footer_numbering: NumberingStyle, // The variable corresponding to -d - section_delimiter: [char, ..2], + section_delimiter: [char; 2], // The variables corresponding to the options -v, -i, -l, -w. starting_line_number: u64, line_increment: u64, diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index f93fc44c6..8792f526f 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ -#![feature(globs, macro_rules)] extern crate getopts; extern crate libc; @@ -22,7 +21,7 @@ use libc::consts::os::posix88::SIGHUP; use libc::funcs::posix01::signal::signal; use libc::consts::os::posix01::SIG_IGN; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; static NAME: &'static str = "nohup"; diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index 8bc88156d..589165288 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; use std::os; @@ -19,6 +17,7 @@ static NAME : &'static str = "nproc"; static VERSION : &'static str = "0.0.0"; #[path = "../common/util.rs"] +#[macro_use] mod util; pub fn uumain(args: Vec) -> int { @@ -53,7 +52,7 @@ pub fn uumain(args: Vec) -> int { } let mut ignore = match matches.opt_str("ignore") { - Some(numstr) => match from_str(numstr.as_slice()) { + Some(numstr) => match numstr.parse() { Some(num) => num, None => { show_error!("\"{}\" is not a valid number", numstr); @@ -65,7 +64,7 @@ pub fn uumain(args: Vec) -> int { if !matches.opt_present("all") { ignore += match os::getenv("OMP_NUM_THREADS") { - Some(threadstr) => match from_str(threadstr.as_slice()) { + Some(threadstr) => match threadstr.parse() { Some(num) => num, None => 0 }, diff --git a/src/paste/paste.rs b/src/paste/paste.rs index 04b77ee4c..72af5d141 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "paste"; diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index ef442e71e..70b7c028f 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -11,8 +11,6 @@ /* last synced with: printenv (GNU coreutils) 8.13 */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -20,6 +18,7 @@ use std::os; use std::io::print; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "printenv"; diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index 5a3f94c53..52af689aa 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io::print; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "pwd"; diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 6a2eba810..05e901a03 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] extern crate getopts; extern crate libc; use getopts::{optflag, getopts, usage}; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; static NAME: &'static str = "realpath"; static VERSION: &'static str = "1.0.0"; diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 025a55a7b..2d2337a45 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] extern crate getopts; extern crate libc; use getopts::{optflag, optopt, getopts, usage}; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; static NAME: &'static str = "relpath"; static VERSION: &'static str = "1.0.0"; diff --git a/src/rm/rm.rs b/src/rm/rm.rs index f5d13030c..1e22b4a91 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -18,9 +16,10 @@ use std::io::{print, stdin, stdio, fs, BufferedReader}; use std::io::fs::PathExtensions; #[path = "../common/util.rs"] +#[macro_use] mod util; -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] enum InteractiveMode { InteractiveNone, InteractiveOnce, diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 5d33ff4ed..06fa2700a 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -18,6 +16,7 @@ use std::io::{print, fs}; use std::io::fs::PathExtensions; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "rmdir"; diff --git a/src/seq/seq.rs b/src/seq/seq.rs index a396b0ec2..1b72f0123 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -1,7 +1,5 @@ #![crate_name = "seq"] -#![feature(macro_rules)] - // TODO: Make -w flag work with decimals // TODO: Support -f flag @@ -11,11 +9,12 @@ extern crate libc; use std::cmp; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "seq"; -#[deriving(Clone)] +#[derive(Clone)] struct SeqOptions { separator: String, terminator: Option, diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 07d15529f..5ca8fbf6d 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -9,20 +9,18 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::cmp; -use std::str::from_str; use std::io; use std::io::IoResult; use std::iter::{range_inclusive, RangeInclusive}; -use std::rand::{mod, Rng}; +use std::rand::{self, Rng}; use std::uint; #[path = "../common/util.rs"] +#[macro_use] mod util; enum Mode { @@ -97,7 +95,7 @@ With no FILE, or when FILE is -, read standard input.", let repeat = matches.opt_present("repeat"); let zero = matches.opt_present("zero-terminated"); let count = match matches.opt_str("head-count") { - Some(cnt) => match from_str::(cnt.as_slice()) { + Some(cnt) => match cnt.parse::() { Some(val) => val, None => { show_error!("'{}' is not a valid count", cnt); @@ -192,11 +190,11 @@ fn parse_range(input_range: String) -> Result, (String, int if split.len() != 2 { Err(("invalid range format".to_string(), 1)) } else { - let begin = match from_str::(split[0]) { + let begin = match split[0].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[0]), 1)) }; - let end = match from_str::(split[1]) { + let end = match split[1].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[1]), 1)) }; diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index 4133f1a04..b6d83db67 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -9,16 +9,15 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::f64; use std::io::{print, timer}; -use std::time::duration::{mod, Duration}; +use std::time::duration::{self, Duration}; #[path = "../common/util.rs"] +#[macro_use] mod util; #[path = "../common/time.rs"] diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 28c6226c8..596a59fe0 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -1,5 +1,4 @@ #![crate_name = "sort"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -20,6 +19,7 @@ use std::io::stdio::stdin_raw; use std::str::Chars; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "sort"; diff --git a/src/split/split.rs b/src/split/split.rs index 81d85db67..6dd2e33f7 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -19,6 +17,7 @@ use std::num::Int; use std::char; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "split"; diff --git a/src/sum/sum.rs b/src/sum/sum.rs index 05649085d..4d46f421d 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -1,5 +1,4 @@ #![crate_name = "sum"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -17,13 +16,14 @@ use std::io::{File, IoResult, print}; use std::io::stdio::{stdin_raw}; #[path="../common/util.rs"] +#[macro_use] mod util; static VERSION: &'static str = "1.0.0"; static NAME: &'static str = "sum"; fn bsd_sum(mut reader: Box) -> (uint, u16) { - let mut buf = [0, .. 1024]; + let mut buf = [0; 1024]; let mut blocks_read = 0; let mut checksum: u16 = 0; loop { @@ -43,7 +43,7 @@ fn bsd_sum(mut reader: Box) -> (uint, u16) { } fn sysv_sum(mut reader: Box) -> (uint, u16) { - let mut buf = [0, .. 512]; + let mut buf = [0; 512]; let mut blocks_read = 0; let mut ret = 0; diff --git a/src/sync/sync.rs b/src/sync/sync.rs index 898242f48..2b9903544 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -10,14 +10,12 @@ /* Last synced with: sync (GNU coreutils) 8.13 */ - #![feature(macro_rules)] - extern crate getopts; extern crate libc; use getopts::{optflag, getopts, usage}; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; static NAME: &'static str = "sync"; static VERSION: &'static str = "1.0.0"; @@ -88,7 +86,7 @@ mod platform { #[allow(unused_unsafe)] unsafe fn find_first_volume() -> (String, *const libc::c_void) { - let mut name: [libc::c_char, ..260] = mem::uninitialized(); // MAX_PATH + let mut name: [libc::c_char; 260] = mem::uninitialized(); // MAX_PATH match FindFirstVolumeA(name.as_mut_ptr(), name.len() as libc::uint32_t) { _x if _x == -1 as *const libc::c_void => { // INVALID_HANDLE_VALUE @@ -106,7 +104,7 @@ mod platform { (first_volume, next_volume_handle) => { let mut volumes = Vec::from_elem(1, first_volume); loop { - let mut name: [libc::c_char, ..260] = mem::uninitialized(); // MAX_PATH + let mut name: [libc::c_char; 260] = mem::uninitialized(); // MAX_PATH match FindNextVolumeA(next_volume_handle, name.as_mut_ptr(), name.len() as libc::uint32_t) { diff --git a/src/tac/tac.rs b/src/tac/tac.rs index cadbd43e4..7211f3df5 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "tac"; @@ -82,10 +81,10 @@ fn tac(filenames: Vec, before: bool, _: bool, separator: &str) { let mut data = crash_if_err!(1, file.read_to_string()); if data.as_slice().ends_with("\n") { // removes blank line that is inserted otherwise - let mut buf = data.into_string(); + let mut buf = data.to_string(); let len = buf.len(); buf.truncate(len - 1); - data = buf.into_string(); + data = buf.to_string(); } let split_vec: Vec<&str> = data.as_slice().split_str(separator).collect(); let rev: String = split_vec.iter().rev().fold(String::new(), |mut a, &b| { diff --git a/src/tail/tail.rs b/src/tail/tail.rs index af95a4685..ae27794be 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -9,11 +9,9 @@ * */ -#![feature(macro_rules)] - extern crate getopts; -use std::char::UnicodeChar; +use std::char::CharExt; use std::io::{stdin, stdout}; use std::io::{BufferedReader, BytesReader}; use std::io::fs::File; @@ -25,6 +23,7 @@ use std::io::timer::sleep; use std::time::duration::Duration; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "tail"; @@ -72,7 +71,7 @@ pub fn uumain(args: Vec) -> int { if follow { match given_options.opt_str("s") { Some(n) => { - let parsed: Option = from_str(n.as_slice()); + let parsed: Option = n.parse(); match parsed { Some(m) => { sleep_msec = m * 1000 } None => {} @@ -193,7 +192,7 @@ fn parse_size(mut size_slice: &str) -> Option { // sole B is not a valid suffix None } else { - let value = from_str(size_slice); + let value = size_slice.parse(); match value { Some(v) => Some(multiplier * v), None => None @@ -218,12 +217,12 @@ fn obsolete(options: &[String]) -> (Vec, Option) { let len = current.len(); for pos in range(1, len) { // Ensure that the argument is only made out of digits - if !UnicodeChar::is_numeric(current[pos] as char) { break; } + if !(current[pos] as char).is_numeric() { break; } // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_str(from_utf8(current.slice(1,len)).unwrap()); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); return (options, Some(number.unwrap())); } } diff --git a/src/test/test.rs b/src/test/test.rs index 0b0c2ad8a..7bab557ac 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -303,7 +303,7 @@ fn setup_hashmap<'a>() -> HashMap<&'a [u8], Precedence> { hashmap } -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] enum PathCondition { BlockSpecial, CharacterSpecial, @@ -338,11 +338,11 @@ fn path(path: &[u8], cond: PathCondition) -> bool { use libc::{getgid, getuid}; let (uid, gid) = unsafe { (getuid(), getgid()) }; if uid == stat.st_uid { - stat.st_mode & (p as mode_t << 6) != 0 + stat.st_mode & ((p as mode_t) << 6) != 0 } else if gid == stat.st_gid { - stat.st_mode & (p as mode_t << 3) != 0 + stat.st_mode & ((p as mode_t) << 3) != 0 } else { - stat.st_mode & (p as mode_t << 0) != 0 + stat.st_mode & ((p as mode_t) << 0) != 0 } }; diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 1f59c6ac2..2ce570618 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -18,6 +16,7 @@ use std::io::{PathDoesntExist, FileNotFound}; use std::io::process::{Command, ExitStatus, ExitSignal, InheritFd}; #[path = "../common/util.rs"] +#[macro_use] mod util; #[path = "../common/time.rs"] diff --git a/src/touch/touch.rs b/src/touch/touch.rs index 6c99b9880..07a37aad9 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -1,5 +1,4 @@ #![crate_name = "touch"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -17,6 +16,7 @@ use std::io::File; use std::io::fs::PathExtensions; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "touch"; diff --git a/src/tr/tr.rs b/src/tr/tr.rs index 337711833..e8fb644a5 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -1,5 +1,4 @@ #![crate_name = "tr"] -#![feature(macro_rules)] /* * This file is part of the uutils coreutils package. @@ -22,6 +21,7 @@ use std::iter::FromIterator; use std::vec::Vec; #[path="../common/util.rs"] +#[macro_use] mod util; static NAME : &'static str = "tr"; diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index b8e87a04c..7b76fe4fb 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -19,9 +17,10 @@ use std::io::{File, Open, ReadWrite, fs}; use std::io::fs::PathExtensions; #[path = "../common/util.rs"] +#[macro_use] mod util; -#[deriving(Eq, PartialEq)] +#[derive(Eq, PartialEq)] enum TruncateMode { Reference, Extend, diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index c4dd9659c..198c19933 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -10,8 +10,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -19,6 +17,7 @@ use std::io; use std::collections::{HashSet, HashMap}; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "tsort"; diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 219456087..3c08489c5 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -14,8 +14,6 @@ #![allow(dead_code)] -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -24,6 +22,7 @@ use std::io::stdio::stderr; use getopts::{optflag,getopts}; #[path = "../common/util.rs"] +#[macro_use] mod util; extern { diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 9772f8034..c7e8a1ff1 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -12,7 +12,6 @@ /* last synced with: uname (GNU coreutils) 8.21 */ #![allow(non_camel_case_types)] -#![feature(macro_rules)] extern crate getopts; extern crate libc; @@ -21,7 +20,7 @@ use std::mem::uninitialized; use std::io::print; use c_types::utsname; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; struct utsrust { diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index 58deef87a..fb1393760 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "unexpand"; diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 61b19f1d7..dc6b96953 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -9,8 +9,6 @@ * */ -#![feature(macro_rules)] - extern crate getopts; use std::ascii::OwnedAsciiExt; @@ -19,6 +17,7 @@ use std::str::FromStr; use std::io; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "uniq"; @@ -67,7 +66,7 @@ impl Uniq { Some(i) => min(slice_start + i, len), None => len }; - let sliced = line.as_slice().slice(slice_start, slice_stop).into_string(); + let sliced = line.as_slice().slice(slice_start, slice_stop).to_string(); if self.ignore_case { sliced.into_ascii_uppercase() } else { @@ -112,7 +111,7 @@ impl Uniq { fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option { matches.opt_str(opt_name).map(|arg_str| { - let opt_val: Option = from_str(arg_str.as_slice()); + let opt_val: Option = arg_str.parse(); opt_val.unwrap_or_else(|| crash!(1, "Invalid argument for {}: {}", opt_name, arg_str)) }) @@ -158,8 +157,8 @@ pub fn uumain(args: Vec) -> int { println!("{} {}", NAME, VERSION); } else { let (in_file_name, out_file_name) = match matches.free.len() { - 0 => ("-".into_string(), "-".into_string()), - 1 => (matches.free[0].clone(), "-".into_string()), + 0 => ("-".to_string(), "-".to_string()), + 1 => (matches.free[0].clone(), "-".to_string()), 2 => (matches.free[0].clone(), matches.free[1].clone()), _ => { crash!(1, "Extra operand: {}", matches.free[2]); diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 36c38fa3d..1895c9902 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -11,16 +11,15 @@ /* last synced with: unlink (GNU coreutils) 8.21 */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io; -use std::io::fs::{mod, PathExtensions}; +use std::io::fs::{self, PathExtensions}; use std::io::print; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "unlink"; diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 2bc30317d..2fd2eb2ea 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -12,7 +12,6 @@ /* last synced with: cat (GNU coreutils) 8.13 */ #![allow(non_camel_case_types)] -#![feature(macro_rules, globs)] extern crate getopts; extern crate libc; @@ -24,7 +23,7 @@ use std::ptr::null; use libc::{time_t, c_double, c_int, c_char}; use utmpx::*; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[path = "../common/c_types.rs"] mod c_types; @@ -89,7 +88,7 @@ pub fn uumain(args: Vec) -> int { } fn print_loadavg() { - let mut avg: [c_double, ..3] = [0.0, ..3]; + let mut avg: [c_double; 3] = [0.0; 3]; let loads: i32 = unsafe { transmute(getloadavg(avg.as_mut_ptr(), 3)) }; if loads == -1 { diff --git a/src/users/users.rs b/src/users/users.rs index 74857fad8..122de7022 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -14,8 +14,6 @@ // Allow dead code here in order to keep all fields, constants here, for consistency. #![allow(dead_code, non_camel_case_types)] -#![feature(macro_rules, globs)] - extern crate getopts; extern crate libc; @@ -25,6 +23,7 @@ use std::ptr; use utmpx::*; #[path = "../common/util.rs"] +#[macro_use] mod util; #[path = "../common/utmpx.rs"] diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 0ac4e6605..75f20d347 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; @@ -23,6 +21,7 @@ use std::result::Result as StdResult; use getopts::Matches; #[path = "../common/util.rs"] +#[macro_use] mod util; struct Result { diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 97f4b9bb9..dbea93b70 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -13,14 +13,12 @@ #![allow(non_camel_case_types)] -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io::print; -#[path = "../common/util.rs"] mod util; +#[path = "../common/util.rs"] #[macro_use] mod util; #[cfg(unix)] mod platform { @@ -54,7 +52,7 @@ mod platform { #[allow(unused_unsafe)] pub unsafe fn getusername() -> String { - let mut buffer: [libc::c_char, ..2048] = mem::uninitialized(); // XXX: it may be possible that this isn't long enough. I don't know + let mut buffer: [libc::c_char; 2048] = mem::uninitialized(); // XXX: it may be possible that this isn't long enough. I don't know if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 { crash!(1, "username is too long"); } diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 6f0fbb065..e7143f42b 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -11,14 +11,13 @@ /* last synced with: yes (GNU coreutils) 8.13 */ -#![feature(macro_rules)] - extern crate getopts; extern crate libc; use std::io::print; #[path = "../common/util.rs"] +#[macro_use] mod util; static NAME: &'static str = "yes"; diff --git a/test/mv.rs b/test/mv.rs index b853d327c..b5d5916a8 100644 --- a/test/mv.rs +++ b/test/mv.rs @@ -1,5 +1,3 @@ -#![feature(macro_rules)] - extern crate time; use std::io::{process, fs, FilePermission};