1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Merge pull request #486 from ebfe/fix-build-master

Partially fix build with rust master
This commit is contained in:
Heather 2015-01-08 17:42:28 +03:00
commit 6dec3b138d
76 changed files with 175 additions and 238 deletions

View file

@ -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:

2
deps/rust-crypto vendored

@ -1 +1 @@
Subproject commit 3db4f22536d9391b1eebadbe868593d44a6295ae
Subproject commit ebf18b21551cccba2aa75ea2372b2e85ab4cf89a

2
deps/time vendored

@ -1 +1 @@
Subproject commit 914a48401168169ccd1a822c2d32d87965306141
Subproject commit a0a0dedc41fac4d2504db533b70af1686ec19d15

View file

@ -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";

View file

@ -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";

View file

@ -81,7 +81,7 @@ pub fn uumain(args: Vec<String>) -> int {
0
}
#[deriving(Eq, PartialEq)]
#[derive(Eq, PartialEq)]
enum NumberingMode {
NumberNone,
NumberNonEmpty,
@ -99,8 +99,8 @@ fn write_lines(files: Vec<String>, 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<String>, 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<String>, number: NumberingMode, squeeze_blank: bool,
fn write_fast(files: Vec<String>) {
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()) {

View file

@ -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";

View file

@ -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 {

View file

@ -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) => {

View file

@ -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];

View file

@ -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 {

View file

@ -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 {}

View file

@ -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 },

View file

@ -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);

View file

@ -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],
}
}

View file

@ -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,

View file

@ -3,7 +3,7 @@ use std::io::{IoResult, IoError};
pub struct BufReader<R> {
reader: R,
buffer: [u8, ..4096],
buffer: [u8; 4096],
start: uint,
end: uint, // exclusive
}
@ -25,7 +25,7 @@ pub mod Bytes {
impl<R: Reader> BufReader<R> {
pub fn new(reader: R) -> BufReader<R> {
let empty_buffer = unsafe {
std::mem::uninitialized::<[u8, ..4096]>()
std::mem::uninitialized::<[u8; 4096]>()
};
BufReader {

View file

@ -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<R: Reader>(reader: R,
0
}
#[deriving(Clone)]
#[derive(Clone)]
struct Searcher<'a> {
haystack: &'a [u8],
needle: &'a [u8],

View file

@ -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::<uint>(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None })
std::str::FromStr::from_str::<uint>(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::<uint>(n).and_then(|low| if low > 0 { Some(low) } else { None })
std::str::FromStr::from_str::<uint>(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::<uint>(m).and_then(|high| if high >= 1 { Some(high) } else { None })
std::str::FromStr::from_str::<uint>(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::<uint>(n), from_str::<uint>(m)) {
match (std::str::FromStr::from_str::<uint>(n), std::str::FromStr::from_str::<uint>(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::<Range>(item) {
match std::str::FromStr::from_str(item) {
Some(range_item) => ranges.push(range_item),
None => return Err(format!("range '{}' was invalid", item))
}

View file

@ -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";

View file

@ -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

4
src/env/env.rs vendored
View file

@ -82,7 +82,7 @@ pub fn uumain(args: Vec<String>) -> 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<String>) -> 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

View file

@ -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<uint> {
let words = s.as_slice().split(',').collect::<Vec<&str>>();
let nums = words.into_iter()
.map(|sn| from_str::<uint>(sn)
.map(|sn| sn.parse::<uint>()
.unwrap_or_else(
|| crash!(1, "{}\n", "tab size contains invalid character(s)"))
)

View file

@ -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::<u64>() {
Some(x) => x,
None => { crash!(1, "{} not a number", num_str); }
};

View file

@ -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<String>) -> int {
match matches.opt_str("w") {
Some(s) => {
fmt_opts.width =
match from_str(s.as_slice()) {
match s.parse::<uint>() {
Some(t) => t,
None => { crash!(1, "Invalid WIDTH specification: `{}'", s); }
};
@ -153,7 +152,7 @@ pub fn uumain(args: Vec<String>) -> int {
match matches.opt_str("g") {
Some(s) => {
fmt_opts.goal =
match from_str(s.as_slice()) {
match s.parse::<uint>() {
Some(t) => t,
None => { crash!(1, "Invalid GOAL specification: `{}'", s); }
};
@ -169,7 +168,7 @@ pub fn uumain(args: Vec<String>) -> int {
match matches.opt_str("T") {
Some(s) => {
fmt_opts.tabwidth =
match from_str(s.as_slice()) {
match s.parse::<uint>() {
Some(t) => t,
None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); }
};

View file

@ -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<Line> 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<String>, // the lines of the file
pub init_str : String, // string representing the init, that is, the first line's indent

View file

@ -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<String>) -> int {
}
};
let width = match poss_width {
Some(inp_width) => match from_str(inp_width.as_slice()) {
Some(inp_width) => match inp_width.parse::<uint>() {
Some(width) => width,
None => crash!(1, "illegal width value (\"{}\")", inp_width)
},
@ -173,7 +172,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
(slice, "", 0)
};
println!("{}", out);
(val.into_string(), ncount)
(val.to_string(), ncount)
};
output = val;
count = ncount;

View file

@ -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";

View file

@ -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<Digest>, 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 {

View file

@ -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<String>) -> int {
show_error!("cannot specify both --bytes and --lines.");
return 1;
}
match from_str(n.as_slice()) {
match n.parse::<uint>() {
Some(m) => { line_count = m }
None => {
show_error!("invalid line count '{}'", n);
@ -78,7 +77,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
None => match given_options.opt_str("c") {
Some(count) => match from_str(count.as_slice()) {
Some(count) => match count.parse::<uint>() {
Some(m) => byte_count = m,
None => {
show_error!("invalid byte count '{}'", count);
@ -145,12 +144,12 @@ fn obsolete(options: &[String]) -> (Vec<String>, Option<uint>) {
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<uint> = from_str(from_utf8(current.slice(1,len)).unwrap());
let number: Option<uint> = from_utf8(current.slice(1,len)).unwrap().parse::<uint>();
return (options, Some(number.unwrap()));
}
}

View file

@ -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";

View file

@ -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";

View file

@ -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"))]

View file

@ -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"]

View file

@ -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";

View file

@ -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)

View file

@ -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";

View file

@ -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";

View file

@ -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,

View file

@ -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 {

View file

@ -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,

View file

@ -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";

View file

@ -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<String>) -> int {
@ -53,7 +52,7 @@ pub fn uumain(args: Vec<String>) -> 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<String>) -> 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
},

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -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,

View file

@ -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";

View file

@ -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<String>,

View file

@ -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::<uint>(cnt.as_slice()) {
Some(cnt) => match cnt.parse::<uint>() {
Some(val) => val,
None => {
show_error!("'{}' is not a valid count", cnt);
@ -192,11 +190,11 @@ fn parse_range(input_range: String) -> Result<RangeInclusive<uint>, (String, int
if split.len() != 2 {
Err(("invalid range format".to_string(), 1))
} else {
let begin = match from_str::<uint>(split[0]) {
let begin = match split[0].parse::<uint>() {
Some(m) => m,
None => return Err((format!("{} is not a valid number", split[0]), 1))
};
let end = match from_str::<uint>(split[1]) {
let end = match split[1].parse::<uint>() {
Some(m) => m,
None => return Err((format!("{} is not a valid number", split[1]), 1))
};

View file

@ -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"]

View file

@ -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";

View file

@ -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";

View file

@ -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<Reader>) -> (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<Reader>) -> (uint, u16) {
}
fn sysv_sum(mut reader: Box<Reader>) -> (uint, u16) {
let mut buf = [0, .. 512];
let mut buf = [0; 512];
let mut blocks_read = 0;
let mut ret = 0;

View file

@ -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) {

View file

@ -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<String>, 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| {

View file

@ -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<String>) -> int {
if follow {
match given_options.opt_str("s") {
Some(n) => {
let parsed: Option<u64> = from_str(n.as_slice());
let parsed: Option<u64> = n.parse();
match parsed {
Some(m) => { sleep_msec = m * 1000 }
None => {}
@ -193,7 +192,7 @@ fn parse_size(mut size_slice: &str) -> Option<uint> {
// 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<String>, Option<uint>) {
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<uint> = from_str(from_utf8(current.slice(1,len)).unwrap());
let number: Option<uint> = from_utf8(current.slice(1,len)).unwrap().parse();
return (options, Some(number.unwrap()));
}
}

View file

@ -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
}
};

View file

@ -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"]

View file

@ -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";

View file

@ -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";

View file

@ -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,

View file

@ -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";

View file

@ -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 {

View file

@ -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 {

View file

@ -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";

View file

@ -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<T: FromStr>(opt_name: &str, matches: &getopts::Matches) -> Option<T> {
matches.opt_str(opt_name).map(|arg_str| {
let opt_val: Option<T> = from_str(arg_str.as_slice());
let opt_val: Option<T> = 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<String>) -> 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]);

View file

@ -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";

View file

@ -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<String>) -> 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 {

View file

@ -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"]

View file

@ -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 {

View file

@ -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");
}

View file

@ -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";

View file

@ -1,5 +1,3 @@
#![feature(macro_rules)]
extern crate time;
use std::io::{process, fs, FilePermission};