Use curlies consistently

This commit is contained in:
Ben S 2014-11-25 20:50:23 +00:00
parent e1d3512a69
commit 6ade060eb6
4 changed files with 29 additions and 29 deletions

View File

@ -185,6 +185,7 @@ impl<'a> File<'a> {
let v = target_path.filename().unwrap(); let v = target_path.filename().unwrap();
let filename = String::from_utf8_lossy(v).to_string(); let filename = String::from_utf8_lossy(v).to_string();
// Use stat instead of lstat - we *want* to follow links.
let link_target = fs::stat(&target_path).map(|stat| File { let link_target = fs::stat(&target_path).map(|stat| File {
path: target_path.clone(), path: target_path.clone(),
dir: self.dir, dir: self.dir,
@ -212,10 +213,12 @@ impl<'a> File<'a> {
// at one of those numbers and gained any information from it. // at one of those numbers and gained any information from it.
if self.stat.kind == io::TypeDirectory { if self.stat.kind == io::TypeDirectory {
GREY.paint("-") GREY.paint("-")
} else { }
else {
let (size, suffix) = if use_iec_prefixes { let (size, suffix) = if use_iec_prefixes {
format_IEC_bytes(self.stat.size) format_IEC_bytes(self.stat.size)
} else { }
else {
format_metric_bytes(self.stat.size) format_metric_bytes(self.stat.size)
}; };
@ -264,7 +267,8 @@ impl<'a> File<'a> {
fn permission_bit(bits: io::FilePermission, bit: io::FilePermission, character: &'static str, style: Style) -> String { fn permission_bit(bits: io::FilePermission, bit: io::FilePermission, character: &'static str, style: Style) -> String {
if bits.contains(bit) { if bits.contains(bit) {
style.paint(character.as_slice()) style.paint(character.as_slice())
} else { }
else {
GREY.paint("-".as_slice()) GREY.paint("-".as_slice())
} }
} }

View File

@ -40,7 +40,6 @@ pub struct Options {
pub view: View, pub view: View,
} }
impl Options { impl Options {
pub fn getopts(args: Vec<String>) -> Result<Options, int> { pub fn getopts(args: Vec<String>) -> Result<Options, int> {
let opts = [ let opts = [

View File

@ -24,7 +24,8 @@ impl SortPart {
Some(num) => Numeric(num), Some(num) => Numeric(num),
None => Stringular(slice.to_string()), None => Stringular(slice.to_string()),
} }
} else { }
else {
SortPart::Stringular(slice.to_ascii_lower()) SortPart::Stringular(slice.to_ascii_lower())
} }
} }

View File

@ -104,25 +104,21 @@ impl Unix {
let mut i = 0; let mut i = 0;
// The list of members is a pointer to a pointer of // The list of members is a pointer to a pointer of
// characters, terminated by a null pointer. So the first call // characters, terminated by a null pointer.
// to `as_ref` will always succeed, as that memory is
// guaranteed to be there (unless we go past the end of RAM).
// The second call will return None if it's a null pointer.
loop { loop {
match unsafe { group.offset(i).as_ref() } { match unsafe { group.offset(i).as_ref() } {
Some(&username) => { Some(&username) => {
if username == ptr::null() { if username == ptr::null() {
return false; return false; // username was null, weird
} }
else if unsafe { String::from_raw_buf(username as *const u8) } == *uname { else if unsafe { String::from_raw_buf(username as *const u8) } == *uname {
return true; return true; // group found!
} }
else { else {
i += 1; i += 1; // try again with the next group
} }
}, },
None => return false, None => return false, // no more groups to check, and none found
} }
} }
} }