From 782fad46679effa98d0926057e28487c51a35b87 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:07:08 +0100 Subject: [PATCH] int/uint -> isize/usize --- mkuutils.rs | 4 ++-- src/cat/cat.rs | 12 +++++----- src/cksum/cksum.rs | 2 +- src/cksum/crc_table.rs | 2 +- src/cksum/gen_table.rs | 6 ++--- src/common/signals.rs | 8 +++---- src/common/time.rs | 8 +++---- src/common/utmpx.rs | 24 ++++++++++---------- src/cut/buffer.rs | 14 ++++++------ src/cut/cut.rs | 16 +++++++------- src/cut/ranges.rs | 20 ++++++++--------- src/du/du.rs | 8 +++---- src/echo/echo.rs | 24 ++++++++++---------- src/expand/expand.rs | 12 +++++----- src/fmt/fmt.rs | 12 +++++----- src/fmt/linebreak.rs | 24 ++++++++++---------- src/fmt/parasplit.rs | 42 +++++++++++++++++------------------ src/fold/fold.rs | 10 ++++----- src/head/head.rs | 14 ++++++------ src/hostid/hostid.rs | 2 +- src/hostname/hostname.rs | 2 +- src/kill/kill.rs | 8 +++---- src/mkdir/mkdir.rs | 2 +- src/mv/mv.rs | 4 ++-- src/nl/helper.rs | 2 +- src/nl/nl.rs | 4 ++-- src/realpath/realpath.rs | 2 +- src/rm/rm.rs | 6 ++--- src/rmdir/rmdir.rs | 4 ++-- src/seq/seq.rs | 6 ++--- src/shuf/shuf.rs | 20 ++++++++--------- src/sort/sort.rs | 2 +- src/sync/sync.rs | 4 ++-- src/tail/tail.rs | 48 ++++++++++++++++++++-------------------- src/test/test.rs | 12 +++++----- src/timeout/timeout.rs | 8 +++---- src/truncate/truncate.rs | 2 +- src/tty/tty.rs | 2 +- src/uniq/uniq.rs | 6 ++--- src/uptime/uptime.rs | 8 +++---- src/uutils/uutils.rs | 4 ++-- src/wc/wc.rs | 42 +++++++++++++++++------------------ 42 files changed, 231 insertions(+), 231 deletions(-) diff --git a/mkuutils.rs b/mkuutils.rs index 0cd4ed112..7572dad2c 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -32,8 +32,8 @@ fn main() { crates.push_str("extern crate uutest;\n"); util_map.push_str("map.insert(\"test\", uutest::uumain);\n"); } - "true" => util_map.push_str("fn uutrue(_: Vec) -> int { 0 }\nmap.insert(\"true\", uutrue);\n"), - "false" => util_map.push_str("fn uufalse(_: Vec) -> int { 1 }\nmap.insert(\"false\", uufalse);\n"), + "true" => util_map.push_str("fn uutrue(_: Vec) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"), + "false" => util_map.push_str("fn uufalse(_: Vec) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"), "sync" => { crates.push_str("extern crate uusync;\n"); util_map.push_str("map.insert(\"sync\", uusync::uumain);\n"); diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 33b410cd5..dc6eff13a 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -91,7 +91,7 @@ enum NumberingMode { fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, show_ends: bool) { - let mut line_counter: uint = 1; + let mut line_counter: usize = 1; for path in files.iter() { let (mut reader, interactive) = match open(path.as_slice()) { @@ -164,7 +164,7 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, show_ends: bool, show_nonprint: bool, show_tabs: bool) { - let mut line_counter: uint = 1; + let mut line_counter: usize = 1; for path in files.iter() { let (mut reader, interactive) = match open(path.as_slice()) { @@ -173,7 +173,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, }; // Flush all 1024 iterations. - let mut flush_counter = range(0u, 1024); + let mut flush_counter = range(0us, 1024); let mut in_buf = [0; 1024 * 32]; let mut out_buf = [0; 1024 * 64]; @@ -187,7 +187,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, for &byte in in_buf.slice_to(n).iter() { if flush_counter.next().is_none() { writer.possibly_flush(); - flush_counter = range(0u, 1024); + flush_counter = range(0us, 1024); } if byte == '\n' as u8 { if !at_line_start || !squeeze_blank { @@ -293,8 +293,8 @@ fn open(path: &str) -> Option<(Box, bool)> { struct UnsafeWriter<'a, W> { inner: W, buf: &'a mut [u8], - pos: uint, - threshold: uint, + pos: usize, + threshold: usize, } impl<'a, W: Writer> UnsafeWriter<'a, W> { diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index c1a5a3e89..7200b133e 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -44,7 +44,7 @@ fn crc_final(mut crc: u32, mut length: usize) -> u32 { #[inline] fn cksum(fname: &str) -> IoResult<(u32, usize)> { let mut crc = 0u32; - let mut size = 0u; + let mut size = 0us; let mut stdin_buf; let mut file_buf; diff --git a/src/cksum/crc_table.rs b/src/cksum/crc_table.rs index feecc82ec..72de84ef3 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] = [0u32, 79764919u32, 159529838u32, 222504665u32, 319059676u32, 398814059u32, 445009330u32, 507990021u32, 638119352u32, 583659535u32, 797628118u32, 726387553u32, 890018660u32, 835552979u32, 1015980042u32, 944750013u32, 1276238704u32, 1221641927u32, 1167319070u32, 1095957929u32, 1595256236u32, 1540665371u32, 1452775106u32, 1381403509u32, 1780037320u32, 1859660671u32, 1671105958u32, 1733955601u32, 2031960084u32, 2111593891u32, 1889500026u32, 1952343757u32, 2552477408u32, 2632100695u32, 2443283854u32, 2506133561u32, 2334638140u32, 2414271883u32, 2191915858u32, 2254759653u32, 3190512472u32, 3135915759u32, 3081330742u32, 3009969537u32, 2905550212u32, 2850959411u32, 2762807018u32, 2691435357u32, 3560074640u32, 3505614887u32, 3719321342u32, 3648080713u32, 3342211916u32, 3287746299u32, 3467911202u32, 3396681109u32, 4063920168u32, 4143685023u32, 4223187782u32, 4286162673u32, 3779000052u32, 3858754371u32, 3904687514u32, 3967668269u32, 881225847u32, 809987520u32, 1023691545u32, 969234094u32, 662832811u32, 591600412u32, 771767749u32, 717299826u32, 311336399u32, 374308984u32, 453813921u32, 533576470u32, 25881363u32, 88864420u32, 134795389u32, 214552010u32, 2023205639u32, 2086057648u32, 1897238633u32, 1976864222u32, 1804852699u32, 1867694188u32, 1645340341u32, 1724971778u32, 1587496639u32, 1516133128u32, 1461550545u32, 1406951526u32, 1302016099u32, 1230646740u32, 1142491917u32, 1087903418u32, 2896545431u32, 2825181984u32, 2770861561u32, 2716262478u32, 3215044683u32, 3143675388u32, 3055782693u32, 3001194130u32, 2326604591u32, 2389456536u32, 2200899649u32, 2280525302u32, 2578013683u32, 2640855108u32, 2418763421u32, 2498394922u32, 3769900519u32, 3832873040u32, 3912640137u32, 3992402750u32, 4088425275u32, 4151408268u32, 4197601365u32, 4277358050u32, 3334271071u32, 3263032808u32, 3476998961u32, 3422541446u32, 3585640067u32, 3514407732u32, 3694837229u32, 3640369242u32, 1762451694u32, 1842216281u32, 1619975040u32, 1682949687u32, 2047383090u32, 2127137669u32, 1938468188u32, 2001449195u32, 1325665622u32, 1271206113u32, 1183200824u32, 1111960463u32, 1543535498u32, 1489069629u32, 1434599652u32, 1363369299u32, 622672798u32, 568075817u32, 748617968u32, 677256519u32, 907627842u32, 853037301u32, 1067152940u32, 995781531u32, 51762726u32, 131386257u32, 177728840u32, 240578815u32, 269590778u32, 349224269u32, 429104020u32, 491947555u32, 4046411278u32, 4126034873u32, 4172115296u32, 4234965207u32, 3794477266u32, 3874110821u32, 3953728444u32, 4016571915u32, 3609705398u32, 3555108353u32, 3735388376u32, 3664026991u32, 3290680682u32, 3236090077u32, 3449943556u32, 3378572211u32, 3174993278u32, 3120533705u32, 3032266256u32, 2961025959u32, 2923101090u32, 2868635157u32, 2813903052u32, 2742672763u32, 2604032198u32, 2683796849u32, 2461293480u32, 2524268063u32, 2284983834u32, 2364738477u32, 2175806836u32, 2238787779u32, 1569362073u32, 1498123566u32, 1409854455u32, 1355396672u32, 1317987909u32, 1246755826u32, 1192025387u32, 1137557660u32, 2072149281u32, 2135122070u32, 1912620623u32, 1992383480u32, 1753615357u32, 1816598090u32, 1627664531u32, 1707420964u32, 295390185u32, 358241886u32, 404320391u32, 483945776u32, 43990325u32, 106832002u32, 186451547u32, 266083308u32, 932423249u32, 861060070u32, 1041341759u32, 986742920u32, 613929101u32, 542559546u32, 756411363u32, 701822548u32, 3316196985u32, 3244833742u32, 3425377559u32, 3370778784u32, 3601682597u32, 3530312978u32, 3744426955u32, 3689838204u32, 3819031489u32, 3881883254u32, 3928223919u32, 4007849240u32, 4037393693u32, 4100235434u32, 4180117107u32, 4259748804u32, 2310601993u32, 2373574846u32, 2151335527u32, 2231098320u32, 2596047829u32, 2659030626u32, 2470359227u32, 2550115596u32, 2947551409u32, 2876312838u32, 2788305887u32, 2733848168u32, 3165939309u32, 3094707162u32, 3040238851u32, 2985771188u32]; diff --git a/src/cksum/gen_table.rs b/src/cksum/gen_table.rs index 622af56ec..f1ef74ed4 100644 --- a/src/cksum/gen_table.rs +++ b/src/cksum/gen_table.rs @@ -10,7 +10,7 @@ use std::io; -static CRC_TABLE_LEN: uint = 256; +static CRC_TABLE_LEN: usize = 256; fn main() { let mut table = Vec::with_capacity(CRC_TABLE_LEN); @@ -20,7 +20,7 @@ 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(); } @@ -28,7 +28,7 @@ pub static CRC_TABLE: [u32; {}] = {};", CRC_TABLE_LEN, table); fn crc_entry(input: u8) -> u32 { let mut crc = (input as u32) << 24; - for _ in range(0u, 8) { + for _ in range(0, 8) { if crc & 0x80000000 != 0 { crc <<= 1; crc ^= 0x04c11db7; diff --git a/src/common/signals.rs b/src/common/signals.rs index 4442a4af9..37b567d5f 100644 --- a/src/common/signals.rs +++ b/src/common/signals.rs @@ -9,10 +9,10 @@ #![allow(dead_code)] -pub static DEFAULT_SIGNAL:uint = 15; +pub static DEFAULT_SIGNAL:usize= 15; -pub struct Signal<'a> { pub name:&'a str, pub value: uint} +pub struct Signal<'a> { pub name:&'a str, pub value: usize} /* @@ -139,7 +139,7 @@ pub static ALL_SIGNALS:[Signal<'static>; 31] = [ Signal{ name: "USR2", value:31 }, ]; -pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { +pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { if signal_name_or_value == "0" { return Some(0); } @@ -153,6 +153,6 @@ pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { } #[inline(always)] -pub fn is_signal(num: uint) -> bool { +pub fn is_signal(num: usize) -> bool { num < ALL_SIGNALS.len() } diff --git a/src/common/time.rs b/src/common/time.rs index a85f43900..3b140528d 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -14,10 +14,10 @@ pub fn from_str(string: &str) -> Result { } let slice = string.slice_to(len - 1); let (numstr, times) = match string.char_at(len - 1) { - 's' | 'S' => (slice, 1u), - 'm' | 'M' => (slice, 60u), - 'h' | 'H' => (slice, 60u * 60), - 'd' | 'D' => (slice, 60u * 60 * 24), + 's' | 'S' => (slice, 1us), + 'm' | 'M' => (slice, 60us), + 'h' | 'H' => (slice, 60us * 60), + 'd' | 'D' => (slice, 60us * 60 * 24), val => { if !val.is_alphabetic() { (string, 1) diff --git a/src/common/utmpx.rs b/src/common/utmpx.rs index e68e0c40c..a210dfff4 100644 --- a/src/common/utmpx.rs +++ b/src/common/utmpx.rs @@ -10,10 +10,10 @@ mod utmpx { pub static DEFAULT_FILE: &'static str = "/var/run/utmp"; - pub const UT_LINESIZE: uint = 32; - pub const UT_NAMESIZE: uint = 32; - pub const UT_IDSIZE: uint = 4; - pub const UT_HOSTSIZE: uint = 256; + pub const UT_LINESIZE: usize = 32; + pub const UT_NAMESIZE: usize = 32; + pub const UT_IDSIZE: usize = 4; + pub const UT_HOSTSIZE: usize = 256; pub const EMPTY: libc::c_short = 0; pub const RUN_LVL: libc::c_short = 1; @@ -56,10 +56,10 @@ mod utmpx { pub static DEFAULT_FILE: &'static str = "/var/run/utmpx"; - pub const UT_LINESIZE: uint = 32; - pub const UT_NAMESIZE: uint = 256; - pub const UT_IDSIZE: uint = 4; - pub const UT_HOSTSIZE: uint = 256; + pub const UT_LINESIZE: usize = 32; + pub const UT_NAMESIZE: usize = 256; + pub const UT_IDSIZE: usize = 4; + pub const UT_HOSTSIZE: usize = 256; pub const EMPTY: libc::c_short = 0; pub const RUN_LVL: libc::c_short = 1; @@ -97,10 +97,10 @@ mod utmpx { pub static DEFAULT_FILE : &'static str = ""; - pub const UT_LINESIZE : uint = 16; - pub const UT_NAMESIZE : uint = 32; - pub const UT_IDSIZE : uint = 8; - pub const UT_HOSTSIZE : uint = 128; + pub const UT_LINESIZE : usize = 16; + pub const UT_NAMESIZE : usize = 32; + pub const UT_IDSIZE : usize = 8; + pub const UT_HOSTSIZE : usize = 128; pub const EMPTY : libc::c_short = 0; pub const BOOT_TIME : libc::c_short = 1; diff --git a/src/cut/buffer.rs b/src/cut/buffer.rs index ef6ce58a5..d1de6169c 100644 --- a/src/cut/buffer.rs +++ b/src/cut/buffer.rs @@ -4,14 +4,14 @@ use std::io::{IoResult, IoError}; pub struct BufReader { reader: R, buffer: [u8; 4096], - start: uint, - end: uint, // exclusive + start: usize, + end: usize, // exclusive } #[allow(non_snake_case)] pub mod Bytes { pub trait Select { - fn select<'a>(&'a mut self, bytes: uint) -> Selected<'a>; + fn select<'a>(&'a mut self, bytes: usize) -> Selected<'a>; } pub enum Selected<'a> { @@ -37,7 +37,7 @@ impl BufReader { } #[inline] - fn read(&mut self) -> IoResult { + fn read(&mut self) -> IoResult { let buffer_fill = self.buffer.slice_from_mut(self.end); match self.reader.read(buffer_fill) { @@ -50,7 +50,7 @@ impl BufReader { } #[inline] - fn maybe_fill_buf(&mut self) -> IoResult { + fn maybe_fill_buf(&mut self) -> IoResult { if self.end == self.start { self.start = 0; self.end = 0; @@ -61,7 +61,7 @@ impl BufReader { } } - pub fn consume_line(&mut self) -> uint { + pub fn consume_line(&mut self) -> usize { let mut bytes_consumed = 0; loop { @@ -91,7 +91,7 @@ impl BufReader { } impl Bytes::Select for BufReader { - fn select<'a>(&'a mut self, bytes: uint) -> Bytes::Selected<'a> { + fn select<'a>(&'a mut self, bytes: usize) -> Bytes::Selected<'a> { match self.maybe_fill_buf() { Err(IoError { kind: std::io::EndOfFile, .. }) => (), Err(err) => panic!("read error: {}", err.desc), diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 3a934b37a..3fc634a54 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -53,7 +53,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result, String> { fn cut_bytes(reader: R, ranges: &Vec, - opts: &Options) -> int { + opts: &Options) -> isize { use buffer::Bytes::Select; use buffer::Bytes::Selected::{NewlineFound, Complete, Partial, EndOfFile}; @@ -134,7 +134,7 @@ fn cut_bytes(reader: R, fn cut_characters(reader: R, ranges: &Vec, - opts: &Options) -> int { + opts: &Options) -> isize { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -195,7 +195,7 @@ fn cut_characters(reader: R, struct Searcher<'a> { haystack: &'a [u8], needle: &'a [u8], - position: uint + position: usize } impl<'a> Searcher<'a> { @@ -209,9 +209,9 @@ impl<'a> Searcher<'a> { } impl<'a> Iterator for Searcher<'a> { - type Item = (uint, uint); + type Item = (usize, usize); - fn next(&mut self) -> Option<(uint, uint)> { + fn next(&mut self) -> Option<(usize, usize)> { if self.needle.len() == 1 { for offset in range(self.position, self.haystack.len()) { if self.haystack[offset] == self.needle[0] { @@ -242,7 +242,7 @@ fn cut_fields_delimiter(reader: R, ranges: &Vec, delim: &String, only_delimited: bool, - out_delim: &String) -> int { + out_delim: &String) -> isize { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -316,7 +316,7 @@ fn cut_fields_delimiter(reader: R, fn cut_fields(reader: R, ranges: &Vec, - opts: &FieldOptions) -> int { + opts: &FieldOptions) -> isize { match opts.out_delimeter { Some(ref delim) => { return cut_fields_delimiter(reader, ranges, &opts.delimiter, @@ -395,7 +395,7 @@ fn cut_fields(reader: R, 0 } -fn cut_files(mut filenames: Vec, mode: Mode) -> int { +fn cut_files(mut filenames: Vec, mode: Mode) -> isize { let mut stdin_read = false; let mut exit_code = 0; diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 8a0401ef0..1c834f89e 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -11,31 +11,31 @@ use std; #[derive(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { - pub low: uint, - pub high: uint, + pub low: usize, + pub high: usize, } impl std::str::FromStr for Range { fn from_str(s: &str) -> Option { - use std::uint::MAX; + use std::usize::MAX; let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { - nm.parse::().and_then(|nm| if nm > 0 { Some(nm) } else { None }) + nm.parse::().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 => { - n.parse::().and_then(|low| if low > 0 { Some(low) } else { None }) + n.parse::().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 => { - m.parse::().and_then(|high| if high >= 1 { Some(high) } else { None }) + m.parse::().and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) } (Some(n), Some(m)) => { - match (n.parse::(), m.parse::()) { + match (n.parse::(), m.parse::()) { (Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } @@ -77,7 +77,7 @@ impl Range { } pub fn complement(ranges: &Vec) -> Vec { - use std::uint; + use std::usize; let mut complements = Vec::with_capacity(ranges.len() + 1); @@ -97,10 +97,10 @@ pub fn complement(ranges: &Vec) -> Vec { } } (Some(last), None) => { - if last.high < uint::MAX { + if last.high < usize::MAX { complements.push(Range { low: last.high + 1, - high: uint::MAX + high: usize::MAX }); } } diff --git a/src/du/du.rs b/src/du/du.rs index d7619f2cf..ec8e32856 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -32,7 +32,7 @@ static VERSION: &'static str = "1.0.0"; struct Options { all: bool, program_name: String, - max_depth: Option, + max_depth: Option, total: bool, separate_dirs: bool, } @@ -43,7 +43,7 @@ struct Stat { } // this takes `my_stat` to avoid having to stat files multiple times. fn du(path: &Path, mut my_stat: Stat, - options: Arc, depth: uint) -> Vec> { + options: Arc, depth: usize) -> Vec> { let mut stats = vec!(); let mut futures = vec!(); @@ -193,7 +193,7 @@ ers of 1000).", let summarize = matches.opt_present("summarize"); let max_depth_str = matches.opt_str("max-depth"); - let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::()); + let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::()); match (max_depth_str, max_depth) { (Some(ref s), _) if summarize => { show_error!("summarizing conflicts with --max-depth={}", *s); @@ -245,7 +245,7 @@ ers of 1000).", letters.push(c); } } - let number = numbers.parse::().unwrap(); + let number = numbers.parse::().unwrap(); let multiple = match letters.as_slice() { "K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024, "T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024, diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 017a83b2b..2ba4f39da 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -30,8 +30,8 @@ struct EchoOptions { } #[inline(always)] -fn to_char(bytes: &Vec, base: uint) -> char { - from_str_radix::(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char +fn to_char(bytes: &Vec, base: usize) -> char { + from_str_radix::(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char } #[inline(always)] @@ -51,19 +51,19 @@ fn isodigit(c: u8) -> bool { } } -fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) { - let (max_digits, is_legal_digit) : (uint, fn(u8) -> bool) = match base { - 8u => (3, isodigit), - 16u => (2, isxdigit), +fn convert_str(string: &[u8], index: usize, base: usize) -> (char, usize) { + let (max_digits, is_legal_digit) : (usize, fn(u8) -> bool) = match base { + 8us => (3, isodigit), + 16us => (2, isxdigit), _ => panic!(), }; let mut bytes = vec!(); - for offset in range(0u, max_digits) { - if string.len() <= index + offset as uint { + for offset in range(0us, max_digits) { + if string.len() <= index + offset as usize { break; } - let c = string[index + offset as uint]; + let c = string[index + offset as usize]; if is_legal_digit(c) { bytes.push(c as u8); } else { @@ -201,7 +201,7 @@ pub fn uumain(args: Vec) -> isize { 't' => print!("\t"), 'v' => print!("\x0B"), 'x' => { - let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16u); + let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16us); if num_char_used == 0 { print!("\\x"); } else { @@ -212,7 +212,7 @@ pub fn uumain(args: Vec) -> isize { } }, '0' => { - let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8u); + let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8us); if num_char_used == 0 { print!("\0"); } else { @@ -223,7 +223,7 @@ pub fn uumain(args: Vec) -> isize { } } _ => { - let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8u); + let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8us); if num_char_used == 0 { print!("\\{}", c); } else { diff --git a/src/expand/expand.rs b/src/expand/expand.rs index b65105d54..94ae03e92 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -22,17 +22,17 @@ mod util; static NAME: &'static str = "expand"; static VERSION: &'static str = "0.0.1"; -static DEFAULT_TABSTOP: uint = 8; +static DEFAULT_TABSTOP: usize = 8; -fn tabstops_parse(s: String) -> Vec { +fn tabstops_parse(s: String) -> Vec { let words = s.as_slice().split(',').collect::>(); let nums = words.into_iter() - .map(|sn| sn.parse::() + .map(|sn| sn.parse::() .unwrap_or_else( || crash!(1, "{}\n", "tab size contains invalid character(s)")) ) - .collect::>(); + .collect::>(); if nums.iter().any(|&n| n == 0) { crash!(1, "{}\n", "tab size cannot be 0"); @@ -48,7 +48,7 @@ fn tabstops_parse(s: String) -> Vec { struct Options { files: Vec, - tabstops: Vec, + tabstops: Vec, iflag: bool } @@ -117,7 +117,7 @@ fn open(path: String) -> io::BufferedReader> { } } -fn to_next_stop(tabstops: &[uint], col: uint) -> uint { +fn to_next_stop(tabstops: &[usize], col: usize) -> usize { match tabstops.as_slice() { [tabstop] => tabstop - col % tabstop, tabstops => match tabstops.iter().skip_while(|&t| *t <= col).next() { diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 2021ef7a0..51673ee0c 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -49,9 +49,9 @@ struct FmtOptions { xanti_prefix : bool, uniform : bool, quick : bool, - width : uint, - goal : uint, - tabwidth : uint, + width : usize, + goal : usize, + tabwidth : usize, } pub fn uumain(args: Vec) -> isize { @@ -140,7 +140,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("w") { Some(s) => { fmt_opts.width = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid WIDTH specification: `{}'", s); } }; @@ -152,7 +152,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("g") { Some(s) => { fmt_opts.goal = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid GOAL specification: `{}'", s); } }; @@ -168,7 +168,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("T") { Some(s) => { fmt_opts.tabwidth = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); } }; diff --git a/src/fmt/linebreak.rs b/src/fmt/linebreak.rs index f7f6b6c27..9e1451085 100644 --- a/src/fmt/linebreak.rs +++ b/src/fmt/linebreak.rs @@ -16,16 +16,16 @@ use std::mem; struct BreakArgs<'a> { opts : &'a FmtOptions, - init_len : uint, + init_len : usize, indent_str : &'a str, - indent_len : uint, + indent_len : usize, uniform : bool, ostream : &'a mut Box } impl<'a> BreakArgs<'a> { #[inline(always)] - fn compute_width<'b>(&self, winfo: &WordInfo<'b>, posn: uint, fresh: bool) -> uint { + fn compute_width<'b>(&self, winfo: &WordInfo<'b>, posn: usize, fresh: bool) -> usize { if fresh { 0 } else { @@ -100,7 +100,7 @@ fn break_simple<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &mut BreakArgs } #[inline(always)] -fn accum_words_simple<'a>(args: &mut BreakArgs<'a>, (l, prev_punct): (uint, bool), winfo: &'a WordInfo<'a>) -> (uint, bool) { +fn accum_words_simple<'a>(args: &mut BreakArgs<'a>, (l, prev_punct): (usize, bool), winfo: &'a WordInfo<'a>) -> (usize, bool) { // compute the length of this word, considering how tabs will expand at this position on the line let wlen = winfo.word_nchars + args.compute_width(winfo, l, false); @@ -174,12 +174,12 @@ fn break_knuth_plass<'a, T: Clone + Iterator<&'a WordInfo<'a>>>(mut iter: T, arg } struct LineBreak<'a> { - prev : uint, + prev : usize, linebreak : Option<&'a WordInfo<'a>>, break_before : bool, demerits : i64, prev_rat : f32, - length : uint, + length : usize, fresh : bool } @@ -200,7 +200,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA let next_active_breaks = &mut vec!(); let stretch = (args.opts.width - args.opts.goal) as int; - let minlength = args.opts.goal - stretch as uint; + let minlength = args.opts.goal - stretch as usize; let mut new_linebreaks = vec!(); let mut is_sentence_start = false; let mut least_demerits = 0; @@ -311,7 +311,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA } #[inline(always)] -fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(&'a WordInfo<'a>, bool)> { +fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(&'a WordInfo<'a>, bool)> { let mut breakwords = vec!(); // of the active paths, we select the one with the fewest demerits let mut best_idx = match active.iter().min_by(|&&a| paths[a].demerits) { @@ -378,7 +378,7 @@ fn compute_demerits(delta_len: int, stretch: int, wlen: int, prev_rat: f32) -> ( } #[inline(always)] -fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_idx: uint, w: &'a WordInfo<'a>, slen: uint, min: uint) -> LineBreak<'a> { +fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_idx: usize, w: &'a WordInfo<'a>, slen: usize, min: usize) -> LineBreak<'a> { let (break_before, line_length) = if active.fresh { // never break before a word if that word would be the first on a line @@ -410,7 +410,7 @@ fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_i // Number of spaces to add before a word, based on mode, newline, sentence start. #[inline(always)] -fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> uint { +fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> usize { if uniform || newline { if start || (newline && punct) { 2 @@ -425,7 +425,7 @@ fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> uint // If we're on a fresh line, slen=0 and we slice off leading whitespace. // Otherwise, compute slen and leave whitespace alone. #[inline(always)] -fn slice_if_fresh<'a>(fresh: bool, word: &'a str, start: uint, uniform: bool, newline: bool, sstart: bool, punct: bool) -> (uint, &'a str) { +fn slice_if_fresh<'a>(fresh: bool, word: &'a str, start: usize, uniform: bool, newline: bool, sstart: bool, punct: bool) -> (usize, &'a str) { if fresh { (0, word.slice_from(start)) } else { @@ -442,7 +442,7 @@ fn write_newline(indent: &str, ostream: &mut Box) { // Write the word, along with slen spaces. #[inline(always)] -fn write_with_spaces(word: &str, slen: uint, ostream: &mut Box) { +fn write_with_spaces(word: &str, slen: usize, ostream: &mut Box) { if slen == 2 { silent_unwrap!(ostream.write(" ".as_bytes())); } else if slen == 1 { diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index 776ae9198..b36a58ac2 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -15,8 +15,8 @@ use FileOrStdReader; use FmtOptions; #[inline(always)] -fn char_width(c: char) -> uint { - if (c as uint) < 0xA0 { +fn char_width(c: char) -> usize { + if (c as usize) < 0xA0 { // if it is ASCII, call it exactly 1 wide (including control chars) // calling control chars' widths 1 is consistent with OpenBSD fmt 1 @@ -59,10 +59,10 @@ impl Line { #[derive(Show)] struct FileLine { line : String, - indent_end : uint, // the end of the indent, always the start of the text - pfxind_end : uint, // the end of the PREFIX's indent, that is, the spaces before the prefix - indent_len : uint, // display length of indent taking into account tabs - prefix_len : uint, // PREFIX indent length taking into account tabs + indent_end : usize, // the end of the indent, always the start of the text + pfxind_end : usize, // the end of the PREFIX's indent, that is, the spaces before the prefix + indent_len : usize, // display length of indent taking into account tabs + prefix_len : usize, // PREFIX indent length taking into account tabs } // iterator that produces a stream of Lines from a file @@ -77,7 +77,7 @@ impl<'a> FileLines<'a> { } // returns true if this line should be formatted - fn match_prefix(&self, line: &str) -> (bool, uint) { + fn match_prefix(&self, line: &str) -> (bool, usize) { if !self.opts.use_prefix { return (true, 0u); } FileLines::match_prefix_generic(self.opts.prefix.as_slice(), line, self.opts.xprefix) @@ -93,7 +93,7 @@ impl<'a> FileLines<'a> { } } - fn match_prefix_generic(pfx: &str, line: &str, exact: bool) -> (bool, uint) { + fn match_prefix_generic(pfx: &str, line: &str, exact: bool) -> (bool, usize) { if line.starts_with(pfx) { return (true, 0); } @@ -112,7 +112,7 @@ impl<'a> FileLines<'a> { (false, 0) } - fn compute_indent(&self, string: &str, prefix_end: uint) -> (uint, uint, uint) { + fn compute_indent(&self, string: &str, prefix_end: usize) -> (usize, usize, usize) { let mut prefix_len = 0; let mut indent_len = 0; let mut indent_end = 0; @@ -199,11 +199,11 @@ impl<'a> Iterator for FileLines<'a> { 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 - pub init_len : uint, // printable length of the init string considering TABWIDTH - init_end : uint, // byte location of end of init in first line String + pub init_len : usize, // printable length of the init string considering TABWIDTH + init_end : usize, // byte location of end of init in first line String pub indent_str : String, // string representing indent - pub indent_len : uint, // length of above - indent_end : uint, // byte location of end of indent (in crown and tagged mode, only applies to 2nd line and onward) + pub indent_len : usize, // length of above + indent_end : usize, // byte location of end of indent (in crown and tagged mode, only applies to 2nd line and onward) pub mail_header : bool // we need to know if this is a mail header because we do word splitting differently in that case } @@ -243,7 +243,7 @@ impl<'a> ParagraphStream<'a> { // header field must be nonzero length if colon_posn == 0 { return false; } - return l_slice.slice_to(colon_posn).chars().all(|x| match x as uint { + return l_slice.slice_to(colon_posn).chars().all(|x| match x as usize { y if y < 33 || y > 126 => false, _ => true }); @@ -446,13 +446,13 @@ impl<'a> ParaWords<'a> { struct WordSplit<'a> { opts : &'a FmtOptions, string : &'a str, - length : uint, - position : uint, + length : usize, + position : usize, prev_punct : bool } impl<'a> WordSplit<'a> { - fn analyze_tabs(&self, string: &str) -> (Option, uint, Option) { + fn analyze_tabs(&self, string: &str) -> (Option, usize, Option) { // given a string, determine (length before tab) and (printed length after first tab) // if there are no tabs, beforetab = -1 and aftertab is the printed length let mut beforetab = None; @@ -494,10 +494,10 @@ impl<'a> WordSplit<'a> { pub struct WordInfo<'a> { pub word : &'a str, - pub word_start : uint, - pub word_nchars : uint, - pub before_tab : Option, - pub after_tab : uint, + pub word_start : usize, + pub word_nchars : usize, + pub before_tab : Option, + pub after_tab : usize, pub sentence_start : bool, pub ends_punct : bool, pub new_line : bool diff --git a/src/fold/fold.rs b/src/fold/fold.rs index c7c6deaeb..ffda8c552 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -62,7 +62,7 @@ pub fn uumain(args: Vec) -> isize { } }; let width = match poss_width { - Some(inp_width) => match inp_width.parse::() { + Some(inp_width) => match inp_width.parse::() { Some(width) => width, None => crash!(1, "illegal width value (\"{}\")", inp_width) }, @@ -91,7 +91,7 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { } #[inline] -fn fold(filenames: Vec, bytes: bool, spaces: bool, width: uint) { +fn fold(filenames: Vec, bytes: bool, spaces: bool, width: usize) { for filename in filenames.iter() { let filename: &str = filename.as_slice(); let mut stdin_buf; @@ -110,7 +110,7 @@ fn fold(filenames: Vec, bytes: bool, spaces: bool, width: uint) { } #[inline] -fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, width: uint) { +fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, width: usize) { let mut file = file; for line in file.lines() { let line_string = safe_unwrap!(line); @@ -156,7 +156,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, match rfind_whitespace(slice) { Some(m) => { let routput = slice.slice_chars(m + 1, slice.chars().count()); - let ncount = routput.chars().fold(0u, |out, ch: char| { + let ncount = routput.chars().fold(0us, |out, ch: char| { out + match ch { '\t' => 8, '\x08' => if out > 0 { -1 } else { 0 }, @@ -215,7 +215,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, } #[inline] -fn rfind_whitespace(slice: &str) -> Option { +fn rfind_whitespace(slice: &str) -> Option { for (i, ch) in slice.chars().rev().enumerate() { if ch.is_whitespace() { return Some(slice.chars().count() - (i + 1)); diff --git a/src/head/head.rs b/src/head/head.rs index 965bd2364..c5f0347ad 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -27,8 +27,8 @@ mod util; static NAME: &'static str = "head"; pub fn uumain(args: Vec) -> isize { - let mut line_count = 10u; - let mut byte_count = 0u; + let mut line_count = 10us; + let mut byte_count = 0us; // handle obsolete -number syntax let options = match obsolete(args.tail()) { @@ -68,7 +68,7 @@ pub fn uumain(args: Vec) -> isize { show_error!("cannot specify both --bytes and --lines."); return 1; } - match n.parse::() { + match n.parse::() { Some(m) => { line_count = m } None => { show_error!("invalid line count '{}'", n); @@ -77,7 +77,7 @@ pub fn uumain(args: Vec) -> isize { } } None => match given_options.opt_str("c") { - Some(count) => match count.parse::() { + Some(count) => match count.parse::() { Some(m) => byte_count = m, None => { show_error!("invalid byte count '{}'", count); @@ -131,7 +131,7 @@ pub fn uumain(args: Vec) -> isize { // // In case is found, the options vector will get rid of that object so that // getopts works correctly. -fn obsolete(options: &[String]) -> (Vec, Option) { +fn obsolete(options: &[String]) -> (Vec, Option) { let mut options: Vec = options.to_vec(); let mut a = 0; let b = options.len(); @@ -149,7 +149,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); return (options, Some(number.unwrap())); } } @@ -162,7 +162,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { } // TODO: handle errors on read -fn head(reader: &mut BufferedReader, count: uint, use_bytes: bool) -> bool { +fn head(reader: &mut BufferedReader, count: usize, use_bytes: bool) -> bool { if use_bytes { for byte in reader.bytes().take(count) { if !pipe_print!("{}", byte.unwrap() as char) { diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 63ac56798..f84ff8987 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -33,7 +33,7 @@ mod util; static NAME: &'static str = "hostid"; static VERSION: &'static str = "0.0.1"; -static EXIT_ERR: int = 1; +static EXIT_ERR: isize = 1; pub enum Mode { HostId, diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 65674873a..572882355 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -130,7 +130,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) { } fn xgethostname() -> String { - let namelen = 256u; + let namelen = 256us; let mut name : Vec = repeat(0).take(namelen).collect(); let err = unsafe { gethostname (name.as_mut_ptr() as *mut libc::c_char, diff --git a/src/kill/kill.rs b/src/kill/kill.rs index f42176237..68d73c2bc 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -39,8 +39,8 @@ mod signals; static NAME: &'static str = "kill"; static VERSION: &'static str = "0.0.1"; -static EXIT_OK: int = 0; -static EXIT_ERR: int = 1; +static EXIT_OK: isize = 0; +static EXIT_ERR: isize = 1; pub enum Mode { Kill, @@ -184,7 +184,7 @@ fn help(progname: &str, usage: &str) { println!("{}", get_help_text(progname, usage)); } -fn kill(signalname: &str, pids: std::vec::Vec) -> int { +fn kill(signalname: &str, pids: std::vec::Vec) -> isize { let mut status = 0; let optional_signal_value = signals::signal_by_name_or_value(signalname); let signal_value = match optional_signal_value { @@ -194,7 +194,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> int { for pid in pids.iter() { match pid.as_slice().parse() { Some(x) => { - let result = Process::kill(x, signal_value as int); + let result = Process::kill(x, signal_value as isize); match result { Ok(_) => (), Err(f) => { diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 120c5bd2d..174759974 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -93,7 +93,7 @@ fn print_help(opts: &[getopts::OptGroup]) { /** * Create the list of new directories */ -fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), int> { +fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), isize> { let mut result = Ok(()); let mut parent_dirs = Vec::new(); diff --git a/src/mv/mv.rs b/src/mv/mv.rs index e2d68ae0b..73024b138 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -186,7 +186,7 @@ fn help(progname: &str, usage: &str) { println!("{}", msg); } -fn exec(files: &[Path], b: Behaviour) -> int { +fn exec(files: &[Path], b: Behaviour) -> isize { match b.target_dir { Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b), None => {} @@ -244,7 +244,7 @@ fn exec(files: &[Path], b: Behaviour) -> int { 0 } -fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> int { +fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> isize { if !target_dir.is_dir() { show_error!("target ‘{}’ is not a directory", target_dir.display()); return 1; diff --git a/src/nl/helper.rs b/src/nl/helper.rs index c68a5d4f6..0b6c4cdf4 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -83,7 +83,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("w") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -w")); diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 747ae0bbe..415e43571 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -42,7 +42,7 @@ struct Settings { starting_line_number: u64, line_increment: u64, join_blank_lines: u64, - number_width: uint, // Used with String::from_char, hence uint. + number_width: usize, // Used with String::from_char, hence usize. // The format of the number and the (default value for) // renumbering each page. number_format: NumberFormat, @@ -278,7 +278,7 @@ fn nl (reader: &mut BufferedReader, settings: &Settings) { // way, start counting empties from zero once more. empty_line_count = 0; // A line number is to be printed. - let mut w: uint = 0; + let mut w: usize = 0; if settings.number_width > line_no_width { w = settings.number_width - line_no_width; } diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 80a7c08cf..3871b1156 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -77,7 +77,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool { Some(x) => x, }; - let mut links_left = 256i; + let mut links_left = 256is; for part in abs.components() { result.push(part); diff --git a/src/rm/rm.rs b/src/rm/rm.rs index ec45e221e..ccc28d046 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -125,7 +125,7 @@ pub fn uumain(args: Vec) -> isize { } // TODO: implement one-file-system -fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), int> { +fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), isize> { let mut r = Ok(()); for filename in files.iter() { @@ -167,7 +167,7 @@ fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: r } -fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> { +fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) @@ -187,7 +187,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo Ok(()) } -fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> { +fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index e16501042..1eba92797 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -65,7 +65,7 @@ pub fn uumain(args: Vec) -> isize { 0 } -fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), int>{ +fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize>{ let mut r = Ok(()); for dir in dirs.iter() { @@ -86,7 +86,7 @@ fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Resu r } -fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), int> { +fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize> { let mut walk_dir = match fs::walk_dir(path) { Ok(m) => m, Err(f) => { diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 9e4cf2c25..ada3cbc53 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -36,7 +36,7 @@ fn escape_sequences(s: &str) -> String { replace("\\t", "\t") } -fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, int> { +fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, isize> { let mut seq_args = vec!(); let program = args[0].clone(); let mut iter = args.into_iter().skip(1); @@ -215,8 +215,8 @@ fn done_printing(next: f64, step: f64, last: f64) -> bool { } } -fn print_seq(first: f64, step: f64, last: f64, largest_dec: uint, separator: String, terminator: String, pad: bool, padding: uint) { - let mut i = 0i; +fn print_seq(first: f64, step: f64, last: f64, largest_dec: usize, separator: String, terminator: String, pad: bool, padding: usize) { + let mut i = 0is; let mut value = first + i as f64 * step; while !done_printing(value, step, last) { let istr = value.to_string(); diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 3d2cd1d4c..29163453c 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -17,7 +17,7 @@ use std::io; use std::io::IoResult; use std::iter::{range_inclusive, RangeInclusive}; use std::rand::{self, Rng}; -use std::uint; +use std::usize; #[path = "../common/util.rs"] #[macro_use] @@ -26,7 +26,7 @@ mod util; enum Mode { Default, Echo, - InputRange(RangeInclusive) + InputRange(RangeInclusive) } static NAME: &'static str = "shuf"; @@ -95,14 +95,14 @@ 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 cnt.parse::() { + Some(cnt) => match cnt.parse::() { Some(val) => val, None => { show_error!("'{}' is not a valid count", cnt); return 1; } }, - None => uint::MAX + None => usize::MAX }; let output = matches.opt_str("output"); let random = matches.opt_str("random-source"); @@ -118,7 +118,7 @@ With no FILE, or when FILE is -, read standard input.", 0 } -fn shuf(input: Vec, mode: Mode, repeat: bool, zero: bool, count: uint, output: Option, random: Option) -> IoResult<()> { +fn shuf(input: Vec, mode: Mode, repeat: bool, zero: bool, count: usize, output: Option, random: Option) -> IoResult<()> { match mode { Mode::Echo => shuf_lines(input, repeat, zero, count, output, random), Mode::InputRange(range) => shuf_lines(range.map(|num| num.to_string()).collect(), repeat, zero, count, output, random), @@ -163,7 +163,7 @@ impl WrappedRng { } } -fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, outname: Option, random: Option) -> IoResult<()> { +fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: usize, outname: Option, random: Option) -> IoResult<()> { let mut output = match outname { Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box, None => Box::new(io::stdout()) as Box @@ -175,7 +175,7 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, out let mut len = lines.len(); let max = if repeat { count } else { cmp::min(count, len) }; for _ in range(0, max) { - let idx = rng.next_u32() as uint % len; + let idx = rng.next_u32() as usize % len; try!(write!(output, "{}{}", lines[idx], if zero { '\0' } else { '\n' })); if !repeat { lines.remove(idx); @@ -185,16 +185,16 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, out Ok(()) } -fn parse_range(input_range: String) -> Result, (String, int)> { +fn parse_range(input_range: String) -> Result, (String, isize)> { let split: Vec<&str> = input_range.as_slice().split('-').collect(); if split.len() != 2 { Err(("invalid range format".to_string(), 1)) } else { - let begin = match split[0].parse::() { + let begin = match split[0].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[0]), 1)) }; - let end = match split[1].parse::() { + 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/sort/sort.rs b/src/sort/sort.rs index 68be324c8..27fe680f9 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -132,7 +132,7 @@ fn frac_compare(a: &String, b: &String) -> Ordering { } } if char_a.is_digit(10) && char_b.is_digit(10) { - (char_a as int).cmp(&(char_b as int)) + (char_a as isize).cmp(&(char_b as isize)) } else if char_a.is_digit(10) { skip_zeros(char_a, a_chars, Ordering::Greater) } else if char_b.is_digit(10) { diff --git a/src/sync/sync.rs b/src/sync/sync.rs index daad1ba4c..8d3c51307 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -28,7 +28,7 @@ mod platform { fn sync() -> libc::c_void; } - pub unsafe fn do_sync() -> int { + pub unsafe fn do_sync() -> isize { sync(); 0 } @@ -177,7 +177,7 @@ fn help(program: &str, options: &[getopts::OptGroup]) { print!("{}", usage("Force changed blocks to disk, update the super block.", options)); } -fn uusync() -> int { +fn uusync() -> isize { unsafe { platform::do_sync() } diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 532f263cc..c9b240063 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -32,8 +32,8 @@ static VERSION: &'static str = "0.0.1"; pub fn uumain(args: Vec) -> isize { let mut beginning = false; let mut lines = true; - let mut byte_count = 0u; - let mut line_count = 10u; + let mut byte_count = 0us; + let mut line_count = 10us; let mut sleep_msec = 1000u64; // handle obsolete -number syntax @@ -147,33 +147,33 @@ pub fn uumain(args: Vec) -> isize { 0 } -fn parse_size(mut size_slice: &str) -> Option { +fn parse_size(mut size_slice: &str) -> Option { let mut base = if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' { size_slice = size_slice.slice_to(size_slice.len() - 1); - 1000u + 1000us } else { - 1024u + 1024us }; let exponent = if size_slice.len() > 0 { let mut has_suffix = true; let exp = match size_slice.char_at(size_slice.len() - 1) { - 'K' => 1u, - 'M' => 2u, - 'G' => 3u, - 'T' => 4u, - 'P' => 5u, - 'E' => 6u, - 'Z' => 7u, - 'Y' => 8u, + 'K' => 1us, + 'M' => 2us, + 'G' => 3us, + 'T' => 4us, + 'P' => 5us, + 'E' => 6us, + 'Z' => 7us, + 'Y' => 8us, 'b' => { - base = 512u; - 1u + base = 512us; + 1us } _ => { has_suffix = false; - 0u + 0us } }; if has_suffix { @@ -181,14 +181,14 @@ fn parse_size(mut size_slice: &str) -> Option { } exp } else { - 0u + 0us }; - let mut multiplier = 1u; - for _ in range(0u, exponent) { + let mut multiplier = 1us; + for _ in range(0us, exponent) { multiplier *= base; } - if base == 1000u && exponent == 0u { + if base == 1000us && exponent == 0us { // sole B is not a valid suffix None } else { @@ -204,7 +204,7 @@ fn parse_size(mut size_slice: &str) -> Option { // // In case is found, the options vector will get rid of that object so that // getopts works correctly. -fn obsolete(options: &[String]) -> (Vec, Option) { +fn obsolete(options: &[String]) -> (Vec, Option) { let mut options: Vec = options.to_vec(); let mut a = 0; let b = options.len(); @@ -222,7 +222,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); return (options, Some(number.unwrap())); } } @@ -243,7 +243,7 @@ macro_rules! tail_impl ( let mut data = $reader.$kindfn().skip( if $beginning { let temp = $count; - $count = ::std::uint::MAX; + $count = ::std::usize::MAX; temp - 1 } else { 0 @@ -267,7 +267,7 @@ macro_rules! tail_impl ( }) ); -fn tail(reader: &mut BufferedReader, mut line_count: uint, mut byte_count: uint, beginning: bool, lines: bool, follow: bool, sleep_msec: u64) { +fn tail(reader: &mut BufferedReader, mut line_count: usize, mut byte_count: usize, beginning: bool, lines: bool, follow: bool, sleep_msec: u64) { if lines { tail_impl!(String, lines, print_string, reader, line_count, beginning); } else { diff --git a/src/test/test.rs b/src/test/test.rs index be9721b0d..8d5742785 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -39,7 +39,7 @@ pub fn uumain(_: Vec) -> isize { _ => args.slice(1, args.len()), }; let mut error = false; - let retval = 1 - parse_expr(args, &mut error) as int; + let retval = 1 - parse_expr(args, &mut error) as isize; if error { 2 } else { @@ -160,7 +160,7 @@ fn dispatch(args: &mut &[&[u8]], error: &mut bool) -> bool { val } -fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = two(*args, error); if *error { *error = false; @@ -170,7 +170,7 @@ fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { } } -fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = three(*args, error); if *error { *error = false; @@ -180,7 +180,7 @@ fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { } } -fn dispatch_four(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_four(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = four(*args, error); if *error { *error = false; @@ -226,7 +226,7 @@ fn parse_expr_helper<'a>(hashmap: &HashMap<&'a [u8], Precedence>, *error = true; &min_prec }); - while !*error && args.len() > 0 && prec as uint >= min_prec as uint { + while !*error && args.len() > 0 && prec as usize >= min_prec as usize { let op = args[0]; *args = (*args).slice_from(1); let mut rhs = dispatch(args, error); @@ -235,7 +235,7 @@ fn parse_expr_helper<'a>(hashmap: &HashMap<&'a [u8], Precedence>, *error = true; &min_prec }); - if subprec as uint <= prec as uint || *error { + if subprec as usize <= prec as usize || *error { break; } rhs = parse_expr_helper(hashmap, args, rhs, subprec, error); diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 3462b8cb3..eb89dd435 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -32,7 +32,7 @@ extern { static NAME: &'static str = "timeout"; static VERSION: &'static str = "1.0.0"; -static ERR_EXIT_STATUS: int = 125; +static ERR_EXIT_STATUS: isize = 125; pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); @@ -100,7 +100,7 @@ Usage: 0 } -fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_after: f64, foreground: bool, preserve_status: bool) -> int { +fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> isize { if !foreground { unsafe { setpgid(0, 0) }; } @@ -128,7 +128,7 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_aft ExitSignal(stat) => stat }, Err(_) => { - return_if_err!(ERR_EXIT_STATUS, process.signal(signal as int)); + return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize)); process.set_timeout(Some((kill_after * 1000f64) as u64)); match process.wait() { Ok(status) => { @@ -146,7 +146,7 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_aft // XXX: this may not be right return 124; } - return_if_err!(ERR_EXIT_STATUS, process.signal(signals::signal_by_name_or_value("KILL").unwrap() as int)); + return_if_err!(ERR_EXIT_STATUS, process.signal(signals::signal_by_name_or_value("KILL").unwrap() as isize)); process.set_timeout(None); return_if_err!(ERR_EXIT_STATUS, process.wait()); 137 diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 76cac158a..533b9de6a 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -99,7 +99,7 @@ file based on its current size: 0 } -fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), int> { +fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), isize> { let (refsize, mode) = match reference { Some(rfilename) => { let rfile = match File::open(&Path::new(rfilename.clone())) { diff --git a/src/tty/tty.rs b/src/tty/tty.rs index fd366c861..2d1e3dcc4 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -74,7 +74,7 @@ pub fn uumain(args: Vec) -> isize { } }; - exit_code as int + exit_code as isize } fn usage () { diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 1246234f0..98a43d6aa 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -29,8 +29,8 @@ struct Uniq { all_repeated: bool, delimiters: String, show_counts: bool, - slice_start: Option, - slice_stop: Option, + slice_start: Option, + slice_stop: Option, ignore_case: bool, } @@ -96,7 +96,7 @@ impl Uniq { first_line_printed } - fn print_line(&self, writer: &mut io::BufferedWriter, line: &String, count: uint, print_delimiter: bool) { + fn print_line(&self, writer: &mut io::BufferedWriter, line: &String, count: usize, print_delimiter: bool) { let output_line = if self.show_counts { format!("{:7} {}", count, line) } else { diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 5e127c853..ff5f7630a 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -98,14 +98,14 @@ fn print_loadavg() { else { print!("load average: "); for n in range(0, loads) { - print!("{:.2}{}", avg[n as uint], if n == loads - 1 { "\n" } + print!("{:.2}{}", avg[n as usize], if n == loads - 1 { "\n" } else { ", " } ); } } } #[cfg(unix)] -fn process_utmpx() -> (Option, uint) { +fn process_utmpx() -> (Option, usize) { unsafe { utmpxname(CString::from_slice(DEFAULT_FILE.as_bytes()).as_ptr()); } @@ -142,11 +142,11 @@ fn process_utmpx() -> (Option, uint) { } #[cfg(windows)] -fn process_utmpx() -> (Option, uint) { +fn process_utmpx() -> (Option, usize) { (None, 0) // TODO: change 0 to number of users } -fn print_nusers(nusers: uint) { +fn print_nusers(nusers: usize) { if nusers == 1 { print!("1 user, "); } else if nusers > 1 { diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 056a31d64..c42f43bb5 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -19,13 +19,13 @@ use std::collections::hash_map::HashMap; static NAME: &'static str = "uutils"; static VERSION: &'static str = "1.0.0"; -fn util_map() -> HashMap<&'static str, fn(Vec) -> int> { +fn util_map() -> HashMap<&'static str, fn(Vec) -> isize> { let mut map = HashMap::new(); @UTIL_MAP@ map } -fn usage(cmap: &HashMap<&'static str, fn(Vec) -> int>) { +fn usage(cmap: &HashMap<&'static str, fn(Vec) -> isize>) { println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 84498e02a..81de3567a 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -26,11 +26,11 @@ mod util; struct Result { filename: String, - bytes: uint, - chars: uint, - lines: uint, - words: uint, - max_line_length: uint, + bytes: usize, + chars: usize, + lines: usize, + words: usize, + max_line_length: usize, } static NAME: &'static str = "wc"; @@ -94,25 +94,25 @@ fn is_word_seperator(byte: u8) -> bool { byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF } -pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), int> { - let mut total_line_count: uint = 0; - let mut total_word_count: uint = 0; - let mut total_char_count: uint = 0; - let mut total_byte_count: uint = 0; - let mut total_longest_line_length: uint = 0; +pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), isize> { + let mut total_line_count: usize = 0; + let mut total_word_count: usize = 0; + let mut total_char_count: usize = 0; + let mut total_byte_count: usize = 0; + let mut total_longest_line_length: usize = 0; let mut results = vec!(); - let mut max_str_len: uint = 0; + let mut max_str_len: usize = 0; for path in files.iter() { let mut reader = try!(open(path.as_slice())); - let mut line_count: uint = 0; - let mut word_count: uint = 0; - let mut byte_count: uint = 0; - let mut char_count: uint = 0; - let mut current_char_count: uint = 0; - let mut longest_line_length: uint = 0; + let mut line_count: usize = 0; + let mut word_count: usize = 0; + let mut byte_count: usize = 0; + let mut char_count: usize = 0; + let mut current_char_count: usize = 0; + let mut longest_line_length: usize = 0; loop { // reading from a TTY seems to raise a condition on, rather than return Some(0) like a file. @@ -191,8 +191,8 @@ pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), int> { Ok(()) } -fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: uint, - byte_count: uint, longest_line_length: uint, matches: &Matches, max_str_len: uint) { +fn print_stats(filename: &str, line_count: usize, word_count: usize, char_count: usize, + byte_count: usize, longest_line_length: usize, matches: &Matches, max_str_len: usize) { if matches.opt_present("lines") { print!("{:1$}", line_count, max_str_len); } @@ -228,7 +228,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u } } -fn open(path: &str) -> StdResult>, int> { +fn open(path: &str) -> StdResult>, isize> { if "-" == path { let reader = Box::new(stdin_raw()) as Box; return Ok(BufferedReader::new(reader));