Update to the new integer suffixes

This commit is contained in:
Michael Gehring 2015-02-22 13:01:40 +01:00
parent 8098d172d7
commit 26568d2021
11 changed files with 37 additions and 37 deletions

View file

@ -165,7 +165,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) {
// Flush all 1024 iterations.
let mut flush_counter = range(0us, 1024);
let mut flush_counter = range(0usize, 1024);
let mut in_buf = [0; 1024 * 32];
let mut out_buf = [0; 1024 * 64];
@ -177,7 +177,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
for &byte in in_buf[..n].iter() {
if flush_counter.next().is_none() {
writer.possibly_flush();
flush_counter = range(0us, 1024);
flush_counter = range(0usize, 1024);
}
if byte == '\n' as u8 {
if !at_line_start || !squeeze_blank {

View file

@ -45,7 +45,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 = 0us;
let mut size = 0usize;
let mut stdin_buf;
let mut file_buf;

View file

@ -14,10 +14,10 @@ pub fn from_str(string: &str) -> Result<f64, String> {
}
let slice = &string[..len - 1];
let (numstr, times) = match string.char_at(len - 1) {
's' | 'S' => (slice, 1us),
'm' | 'M' => (slice, 60us),
'h' | 'H' => (slice, 60us * 60),
'd' | 'D' => (slice, 60us * 60 * 24),
's' | 'S' => (slice, 1usize),
'm' | 'M' => (slice, 60usize),
'h' | 'H' => (slice, 60usize * 60),
'd' | 'D' => (slice, 60usize * 60 * 24),
val => {
if !val.is_alphabetic() {
(string, 1)

View file

@ -60,7 +60,7 @@ fn convert_str(string: &[u8], index: usize, base: u32) -> (char, usize) {
};
let mut bytes = vec!();
for offset in range(0us, max_digits) {
for offset in range(0usize, max_digits) {
if string.len() <= index + offset as usize {
break;
}

View file

@ -157,7 +157,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, 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(0us, |out, ch: char| {
let ncount = routput.chars().fold(0usize, |out, ch: char| {
out + match ch {
'\t' => 8,
'\x08' => if out > 0 { -1 } else { 0 },

View file

@ -29,8 +29,8 @@ mod util;
static NAME: &'static str = "head";
pub fn uumain(args: Vec<String>) -> i32 {
let mut line_count = 10us;
let mut byte_count = 0us;
let mut line_count = 10usize;
let mut byte_count = 0usize;
// handle obsolete -number syntax
let options = match obsolete(args.tail()) {

View file

@ -132,7 +132,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
}
fn xgethostname() -> String {
let namelen = 256us;
let namelen = 256usize;
let mut name : Vec<u8> = repeat(0).take(namelen).collect();
let err = unsafe {
gethostname (name.as_mut_ptr() as *mut libc::c_char,

View file

@ -78,7 +78,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool {
Some(x) => x,
};
let mut links_left = 256is;
let mut links_left = 256isize;
for part in abs.components() {
result.push(part);

View file

@ -217,7 +217,7 @@ fn done_printing(next: f64, step: f64, last: f64) -> bool {
}
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 i = 0isize;
let mut value = first + i as f64 * step;
while !done_printing(value, step, last) {
let istr = value.to_string();

View file

@ -170,10 +170,10 @@ impl ByteSplitter {
let mut strategy_param : Vec<char> = settings.strategy_param.chars().collect();
let suffix = strategy_param.pop().unwrap();
let multiplier = match suffix {
'0'...'9' => 1us,
'b' => 512us,
'k' => 1024us,
'm' => 1024us * 1024us,
'0'...'9' => 1usize,
'b' => 512usize,
'k' => 1024usize,
'm' => 1024usize * 1024usize,
_ => crash!(1, "invalid number of bytes")
};
let n = if suffix.is_alphabetic() {

View file

@ -34,8 +34,8 @@ static VERSION: &'static str = "0.0.1";
pub fn uumain(args: Vec<String>) -> i32 {
let mut beginning = false;
let mut lines = true;
let mut byte_count = 0us;
let mut line_count = 10us;
let mut byte_count = 0usize;
let mut line_count = 10usize;
let mut sleep_msec = 1000u64;
// handle obsolete -number syntax
@ -153,29 +153,29 @@ fn parse_size(mut size_slice: &str) -> Option<usize> {
let mut base =
if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' {
size_slice = &size_slice[..size_slice.len() - 1];
1000us
1000usize
} else {
1024us
1024usize
};
let exponent =
if size_slice.len() > 0 {
let mut has_suffix = true;
let exp = match size_slice.char_at(size_slice.len() - 1) {
'K' => 1us,
'M' => 2us,
'G' => 3us,
'T' => 4us,
'P' => 5us,
'E' => 6us,
'Z' => 7us,
'Y' => 8us,
'K' => 1usize,
'M' => 2usize,
'G' => 3usize,
'T' => 4usize,
'P' => 5usize,
'E' => 6usize,
'Z' => 7usize,
'Y' => 8usize,
'b' => {
base = 512us;
1us
base = 512usize;
1usize
}
_ => {
has_suffix = false;
0us
0usize
}
};
if has_suffix {
@ -183,14 +183,14 @@ fn parse_size(mut size_slice: &str) -> Option<usize> {
}
exp
} else {
0us
0usize
};
let mut multiplier = 1us;
for _ in range(0us, exponent) {
let mut multiplier = 1usize;
for _ in range(0usize, exponent) {
multiplier *= base;
}
if base == 1000us && exponent == 0us {
if base == 1000usize && exponent == 0usize {
// sole B is not a valid suffix
None
} else {