1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Remove all warnings (at least on Linux)

This commit is contained in:
Arcterus 2014-09-16 20:08:40 -07:00
parent 01c681ecb3
commit 01c2a0b9ff
10 changed files with 39 additions and 39 deletions

View file

@ -23,15 +23,15 @@ impl std::from_str::FromStr for Range {
match (parts.next(), parts.next()) { match (parts.next(), parts.next()) {
(Some(nm), None) => { (Some(nm), None) => {
from_str::<uint>(nm).filtered(|nm| *nm > 0) from_str::<uint>(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None })
.map(|nm| Range { low: nm, high: nm }) .map(|nm| Range { low: nm, high: nm })
} }
(Some(n), Some(m)) if m.len() == 0 => { (Some(n), Some(m)) if m.len() == 0 => {
from_str::<uint>(n).filtered(|low| *low > 0) from_str::<uint>(n).and_then(|low| if low > 0 { Some(low) } else { None })
.map(|low| Range { low: low, high: MAX }) .map(|low| Range { low: low, high: MAX })
} }
(Some(n), Some(m)) if n.len() == 0 => { (Some(n), Some(m)) if n.len() == 0 => {
from_str::<uint>(m).filtered(|high| *high >= 1) from_str::<uint>(m).and_then(|high| if high >= 1 { Some(high) } else { None })
.map(|high| Range { low: 1, high: high }) .map(|high| Range { low: 1, high: high })
} }
(Some(n), Some(m)) => { (Some(n), Some(m)) => {

View file

@ -200,9 +200,9 @@ pub fn uumain(args: Vec<String>) -> int {
} }
Ok(f) => f Ok(f) => f
}; };
let mut pStream = ParagraphStream::new(&fmt_opts, &mut fp); let mut p_stream = ParagraphStream::new(&fmt_opts, &mut fp);
for paraResult in pStream { for para_result in p_stream {
match paraResult { match para_result {
Err(s) => silent_unwrap!(ostream.write(s.as_bytes())), Err(s) => silent_unwrap!(ostream.write(s.as_bytes())),
Ok(para) => break_lines(&para, &fmt_opts, &mut ostream) Ok(para) => break_lines(&para, &fmt_opts, &mut ostream)
} }

View file

@ -40,16 +40,16 @@ impl<'a> BreakArgs<'a> {
pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box<Writer+'static>) { pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box<Writer+'static>) {
// indent // indent
let pIndent = para.indent_str.as_slice(); let p_indent = para.indent_str.as_slice();
let pIndentLen = para.indent_len; let p_indent_len = para.indent_len;
// words // words
let pWords = ParaWords::new(opts, para); let p_words = ParaWords::new(opts, para);
let mut pWords_words = pWords.words(); let mut p_words_words = p_words.words();
// the first word will *always* appear on the first line // the first word will *always* appear on the first line
// make sure of this here // 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), Some(winfo) => (winfo.word, winfo.word_nchars),
None => { None => {
silent_unwrap!(ostream.write_char('\n')); silent_unwrap!(ostream.write_char('\n'));
@ -57,15 +57,15 @@ pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box<Writer
} }
}; };
// print the init, if it exists, and get its length // print the init, if it exists, and get its length
let pInitLen = w_len + let p_init_len = w_len +
if opts.crown || opts.tagged { if opts.crown || opts.tagged {
// handle "init" portion // handle "init" portion
silent_unwrap!(ostream.write(para.init_str.as_bytes())); silent_unwrap!(ostream.write(para.init_str.as_bytes()));
para.init_len para.init_len
} else if !para.mail_header { } else if !para.mail_header {
// for non-(crown, tagged) that's the same as a normal indent // for non-(crown, tagged) that's the same as a normal indent
silent_unwrap!(ostream.write(pIndent.as_bytes())); silent_unwrap!(ostream.write(p_indent.as_bytes()));
pIndentLen p_indent_len
} else { } else {
// except that mail headers get no indent at all // except that mail headers get no indent at all
0 0
@ -78,17 +78,17 @@ pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box<Writer
let mut break_args = BreakArgs { let mut break_args = BreakArgs {
opts : opts, opts : opts,
init_len : pInitLen, init_len : p_init_len,
indent_str : pIndent, indent_str : p_indent,
indent_len : pIndentLen, indent_len : p_indent_len,
uniform : uniform, uniform : uniform,
ostream : ostream ostream : ostream
}; };
if opts.quick || para.mail_header { if opts.quick || para.mail_header {
break_simple(pWords_words, &mut break_args); break_simple(p_words_words, &mut break_args);
} else { } else {
break_knuth_plass(pWords_words, &mut break_args); break_knuth_plass(p_words_words, &mut break_args);
} }
} }
@ -370,9 +370,9 @@ fn compute_demerits(delta_len: int, stretch: int, wlen: int, prev_rat: f32) -> (
}; };
// we penalize lines that have very different ratios from previous lines // 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) (demerits, ratio)
} }

View file

@ -230,20 +230,20 @@ impl<'a> ParagraphStream<'a> {
if line.indent_end > 0 { if line.indent_end > 0 {
false false
} else { } else {
let lSlice = line.line.as_slice(); let l_slice = line.line.as_slice();
if lSlice.starts_with("From ") { if l_slice.starts_with("From ") {
true true
} else { } else {
let colonPosn = let colon_posn =
match lSlice.find(':') { match l_slice.find(':') {
Some(n) => n, Some(n) => n,
None => return false None => return false
}; };
// header field must be nonzero length // 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, y if y < 33 || y > 126 => false,
_ => true _ => true
}); });
@ -280,7 +280,7 @@ impl<'a> Iterator<Result<Paragraph, String>> for ParagraphStream<'a> {
let mut indent_len = 0; let mut indent_len = 0;
let mut prefix_len = 0; let mut prefix_len = 0;
let mut pfxind_end = 0; let mut pfxind_end = 0;
let mut pLines = Vec::new(); let mut p_lines = Vec::new();
let mut in_mail = false; let mut in_mail = false;
let mut second_done = false; // for when we use crown or tagged mode let mut second_done = false; // for when we use crown or tagged mode
@ -298,7 +298,7 @@ impl<'a> Iterator<Result<Paragraph, String>> for ParagraphStream<'a> {
} }
}; };
if pLines.len() == 0 { if p_lines.len() == 0 {
// first time through the loop, get things set up // first time through the loop, get things set up
// detect mail header // detect mail header
if self.opts.mail && self.next_mail && ParagraphStream::is_mail_header(fl) { if self.opts.mail && self.next_mail && ParagraphStream::is_mail_header(fl) {
@ -366,7 +366,7 @@ impl<'a> Iterator<Result<Paragraph, String>> 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 // when we're in split-only mode, we never join lines, so stop here
if self.opts.split_only { if self.opts.split_only {
@ -380,7 +380,7 @@ impl<'a> Iterator<Result<Paragraph, String>> for ParagraphStream<'a> {
self.next_mail = in_mail; self.next_mail = in_mail;
Some(Ok(Paragraph { Some(Ok(Paragraph {
lines : pLines, lines : p_lines,
init_str : init_str, init_str : init_str,
init_len : init_len, init_len : init_len,
init_end : init_end, init_end : init_end,

View file

@ -43,7 +43,7 @@ fn rewind_stdout<T: std::rt::rtio::RtioFileStream>(s: &mut T) {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")] #[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 = "linux")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]

View file

@ -170,7 +170,7 @@ pub fn uumain(args: Vec<String>) -> int {
} }
fn version() { fn version() {
println!("sync (uutils) 1.0.0"); println!("{} (uutils) {}", NAME, VERSION);
println!("The MIT License"); println!("The MIT License");
println!(""); println!("");
println!("Author -- Alexander Fomin."); println!("Author -- Alexander Fomin.");

View file

@ -24,7 +24,7 @@ fn test_output_multi_files_print_all_chars() {
fn test_stdin_squeeze() { fn test_stdin_squeeze() {
let mut process= Command::new(PROGNAME).arg("-A").spawn().unwrap(); 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 po = process.wait_with_output().unwrap();
let out = str::from_utf8(po.output.as_slice()).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() { fn test_stdin_number_non_blank() {
let mut process = Command::new(PROGNAME).arg("-b").arg("-").spawn().unwrap(); 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 po = process.wait_with_output().unwrap();
let out = str::from_utf8(po.output.as_slice()).unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap();

View file

@ -6,7 +6,7 @@ static PROGNAME: &'static str = "./nl";
#[test] #[test]
fn test_stdin_nonewline() { fn test_stdin_nonewline() {
let mut process = Command::new(PROGNAME).spawn().unwrap(); 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 po = process.wait_with_output().unwrap();
let out = str::from_utf8(po.output.as_slice()).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("-") let mut process = Command::new(PROGNAME).arg("-s").arg("-")
.arg("-w").arg("1").spawn().unwrap(); .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 po = process.wait_with_output().unwrap();
let out = str::from_utf8(po.output.as_slice()).unwrap(); let out = str::from_utf8(po.output.as_slice()).unwrap();

View file

@ -5,7 +5,7 @@ static PROGNAME: &'static str = "./tr";
fn run(input: &str, args: &[&'static str]) -> Vec<u8> { fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
let mut process = Command::new(PROGNAME).args(args).spawn().unwrap(); 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() { let po = match process.wait_with_output() {
Ok(p) => p, Ok(p) => p,

View file

@ -5,7 +5,7 @@ static PROGNAME: &'static str = "./unexpand";
fn run(input: &str, args: &[&'static str]) -> Vec<u8> { fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
let mut process = Command::new(PROGNAME).args(args).spawn().unwrap(); 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() { let po = match process.wait_with_output() {
Ok(p) => p, Ok(p) => p,