From 01c2a0b9ff55d58c9d595d9c86bcc0d4a3f4d674 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Tue, 16 Sep 2014 20:08:40 -0700 Subject: [PATCH] Remove all warnings (at least on Linux) --- src/cut/ranges.rs | 6 +++--- src/fmt/fmt.rs | 6 +++--- src/fmt/linebreak.rs | 30 +++++++++++++++--------------- src/fmt/parasplit.rs | 20 ++++++++++---------- src/nohup/nohup.rs | 2 +- src/sync/sync.rs | 2 +- test/cat.rs | 4 ++-- test/nl.rs | 4 ++-- test/tr.rs | 2 +- test/unexpand.rs | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 743fba693..aae12cc4e 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -23,15 +23,15 @@ impl std::from_str::FromStr for Range { match (parts.next(), parts.next()) { (Some(nm), None) => { - from_str::(nm).filtered(|nm| *nm > 0) + from_str::(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) } (Some(n), Some(m)) if m.len() == 0 => { - from_str::(n).filtered(|low| *low > 0) + from_str::(n).and_then(|low| if low > 0 { Some(low) } else { None }) .map(|low| Range { low: low, high: MAX }) } (Some(n), Some(m)) if n.len() == 0 => { - from_str::(m).filtered(|high| *high >= 1) + from_str::(m).and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) } (Some(n), Some(m)) => { diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 29a088ab4..f3dd1915c 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -200,9 +200,9 @@ pub fn uumain(args: Vec) -> int { } Ok(f) => f }; - let mut pStream = ParagraphStream::new(&fmt_opts, &mut fp); - for paraResult in pStream { - match paraResult { + let mut p_stream = ParagraphStream::new(&fmt_opts, &mut fp); + for para_result in p_stream { + match para_result { Err(s) => silent_unwrap!(ostream.write(s.as_bytes())), Ok(para) => break_lines(¶, &fmt_opts, &mut ostream) } diff --git a/src/fmt/linebreak.rs b/src/fmt/linebreak.rs index f0880fc69..8152210b7 100644 --- a/src/fmt/linebreak.rs +++ b/src/fmt/linebreak.rs @@ -40,16 +40,16 @@ impl<'a> BreakArgs<'a> { pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box) { // indent - let pIndent = para.indent_str.as_slice(); - let pIndentLen = para.indent_len; + let p_indent = para.indent_str.as_slice(); + let p_indent_len = para.indent_len; // words - let pWords = ParaWords::new(opts, para); - let mut pWords_words = pWords.words(); + let p_words = ParaWords::new(opts, para); + let mut p_words_words = p_words.words(); // the first word will *always* appear on the first line // make sure of this here - let (w, w_len) = match pWords_words.next() { + let (w, w_len) = match p_words_words.next() { Some(winfo) => (winfo.word, winfo.word_nchars), None => { silent_unwrap!(ostream.write_char('\n')); @@ -57,15 +57,15 @@ pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box ( }; // we penalize lines that have very different ratios from previous lines - let bad_deltaR = (DR_MULT * num::abs(num::pow((ratio - prev_rat) / 2.0, 3))) as i64; + let bad_delta_r = (DR_MULT * num::abs(num::pow((ratio - prev_rat) / 2.0, 3))) as i64; - let demerits = num::pow(1 + bad_linelen + bad_wordlen + bad_deltaR, 2); + let demerits = num::pow(1 + bad_linelen + bad_wordlen + bad_delta_r, 2); (demerits, ratio) } diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index fb3348e17..a0a8e5b4f 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -230,20 +230,20 @@ impl<'a> ParagraphStream<'a> { if line.indent_end > 0 { false } else { - let lSlice = line.line.as_slice(); - if lSlice.starts_with("From ") { + let l_slice = line.line.as_slice(); + if l_slice.starts_with("From ") { true } else { - let colonPosn = - match lSlice.find(':') { + let colon_posn = + match l_slice.find(':') { Some(n) => n, None => return false }; // header field must be nonzero length - if colonPosn == 0 { return false; } + if colon_posn == 0 { return false; } - return lSlice.slice_to(colonPosn).chars().all(|x| match x as uint { + return l_slice.slice_to(colon_posn).chars().all(|x| match x as uint { y if y < 33 || y > 126 => false, _ => true }); @@ -280,7 +280,7 @@ impl<'a> Iterator> for ParagraphStream<'a> { let mut indent_len = 0; let mut prefix_len = 0; let mut pfxind_end = 0; - let mut pLines = Vec::new(); + let mut p_lines = Vec::new(); let mut in_mail = false; let mut second_done = false; // for when we use crown or tagged mode @@ -298,7 +298,7 @@ impl<'a> Iterator> for ParagraphStream<'a> { } }; - if pLines.len() == 0 { + if p_lines.len() == 0 { // first time through the loop, get things set up // detect mail header if self.opts.mail && self.next_mail && ParagraphStream::is_mail_header(fl) { @@ -366,7 +366,7 @@ impl<'a> Iterator> for ParagraphStream<'a> { } } - pLines.push(self.lines.next().unwrap().get_formatline().line); + p_lines.push(self.lines.next().unwrap().get_formatline().line); // when we're in split-only mode, we never join lines, so stop here if self.opts.split_only { @@ -380,7 +380,7 @@ impl<'a> Iterator> for ParagraphStream<'a> { self.next_mail = in_mail; Some(Ok(Paragraph { - lines : pLines, + lines : p_lines, init_str : init_str, init_len : init_len, init_end : init_end, diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 06c067f0a..2d25ed451 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -43,7 +43,7 @@ fn rewind_stdout(s: &mut T) { #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] -fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } +unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] diff --git a/src/sync/sync.rs b/src/sync/sync.rs index e1e84bbdc..6a10f187f 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -170,7 +170,7 @@ pub fn uumain(args: Vec) -> int { } fn version() { - println!("sync (uutils) 1.0.0"); + println!("{} (uutils) {}", NAME, VERSION); println!("The MIT License"); println!(""); println!("Author -- Alexander Fomin."); diff --git a/test/cat.rs b/test/cat.rs index ba7248858..96f31681e 100644 --- a/test/cat.rs +++ b/test/cat.rs @@ -24,7 +24,7 @@ fn test_output_multi_files_print_all_chars() { fn test_stdin_squeeze() { let mut process= Command::new(PROGNAME).arg("-A").spawn().unwrap(); - process.stdin.take_unwrap().write(b"\x00\x01\x02").unwrap(); + process.stdin.take().unwrap().write(b"\x00\x01\x02").unwrap(); let po = process.wait_with_output().unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap(); @@ -35,7 +35,7 @@ fn test_stdin_squeeze() { fn test_stdin_number_non_blank() { let mut process = Command::new(PROGNAME).arg("-b").arg("-").spawn().unwrap(); - process.stdin.take_unwrap().write(b"\na\nb\n\n\nc").unwrap(); + process.stdin.take().unwrap().write(b"\na\nb\n\n\nc").unwrap(); let po = process.wait_with_output().unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap(); diff --git a/test/nl.rs b/test/nl.rs index 21ad94b77..9498c7320 100644 --- a/test/nl.rs +++ b/test/nl.rs @@ -6,7 +6,7 @@ static PROGNAME: &'static str = "./nl"; #[test] fn test_stdin_nonewline() { let mut process = Command::new(PROGNAME).spawn().unwrap(); - process.stdin.take_unwrap().write(b"No Newline").unwrap(); + process.stdin.take().unwrap().write(b"No Newline").unwrap(); let po = process.wait_with_output().unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap(); @@ -17,7 +17,7 @@ fn test_stdin_newline() { let mut process = Command::new(PROGNAME).arg("-s").arg("-") .arg("-w").arg("1").spawn().unwrap(); - process.stdin.take_unwrap().write(b"Line One\nLine Two\n").unwrap(); + process.stdin.take().unwrap().write(b"Line One\nLine Two\n").unwrap(); let po = process.wait_with_output().unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap(); diff --git a/test/tr.rs b/test/tr.rs index 562fee81a..4c7e7d706 100644 --- a/test/tr.rs +++ b/test/tr.rs @@ -5,7 +5,7 @@ static PROGNAME: &'static str = "./tr"; fn run(input: &str, args: &[&'static str]) -> Vec { let mut process = Command::new(PROGNAME).args(args).spawn().unwrap(); - process.stdin.take_unwrap().write_str(input).unwrap(); + process.stdin.take().unwrap().write_str(input).unwrap(); let po = match process.wait_with_output() { Ok(p) => p, diff --git a/test/unexpand.rs b/test/unexpand.rs index 98c30669c..caf70ffad 100644 --- a/test/unexpand.rs +++ b/test/unexpand.rs @@ -5,7 +5,7 @@ static PROGNAME: &'static str = "./unexpand"; fn run(input: &str, args: &[&'static str]) -> Vec { let mut process = Command::new(PROGNAME).args(args).spawn().unwrap(); - process.stdin.take_unwrap().write_str(input).unwrap(); + process.stdin.take().unwrap().write_str(input).unwrap(); let po = match process.wait_with_output() { Ok(p) => p,