mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Merge pull request #496 from ebfe/fix-build-alpha
test, tr, tsort: fix build
This commit is contained in:
commit
9125d52bcf
3 changed files with 16 additions and 13 deletions
|
@ -12,6 +12,7 @@
|
|||
extern crate libc;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::CString;
|
||||
use std::os::{args_as_bytes};
|
||||
use std::str::{from_utf8};
|
||||
|
||||
|
@ -334,7 +335,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
|
|||
Write = 0o2,
|
||||
Execute = 0o1,
|
||||
}
|
||||
let perm = |stat: stat, p: Permission| {
|
||||
let perm = |&: stat: stat, p: Permission| {
|
||||
use libc::{getgid, getuid};
|
||||
let (uid, gid) = unsafe { (getuid(), getgid()) };
|
||||
if uid == stat.st_uid {
|
||||
|
@ -346,7 +347,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
|
|||
}
|
||||
};
|
||||
|
||||
let path = unsafe { path.to_c_str_unchecked() };
|
||||
let path = CString::from_slice(path);
|
||||
let mut stat = unsafe { std::mem::zeroed() };
|
||||
if cond == PathCondition::SymLink {
|
||||
if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 {
|
||||
|
|
20
src/tr/tr.rs
20
src/tr/tr.rs
|
@ -92,13 +92,15 @@ fn delete(set: Vec<char>, complement: bool) {
|
|||
let mut out = stdout();
|
||||
|
||||
for &c in set.iter() {
|
||||
bset.insert(c as uint);
|
||||
bset.insert(c as usize);
|
||||
}
|
||||
|
||||
let is_allowed = if complement {
|
||||
|c: char| bset.contains(&(c as uint))
|
||||
} else {
|
||||
|c: char| !bset.contains(&(c as uint))
|
||||
let is_allowed = |&: c : char| {
|
||||
if complement {
|
||||
bset.contains(&(c as usize))
|
||||
} else {
|
||||
!bset.contains(&(c as usize))
|
||||
}
|
||||
};
|
||||
|
||||
for c in BufferedReader::new(stdin_raw()).chars() {
|
||||
|
@ -111,7 +113,7 @@ fn delete(set: Vec<char>, complement: bool) {
|
|||
}
|
||||
|
||||
fn tr(set1: &[char], set2: &[char]) {
|
||||
const BUFFER_LEN: uint = 1024;
|
||||
const BUFFER_LEN: usize = 1024;
|
||||
|
||||
let mut map = VecMap::new();
|
||||
let mut stdout = stdout();
|
||||
|
@ -120,16 +122,16 @@ fn tr(set1: &[char], set2: &[char]) {
|
|||
let set2_len = set2.len();
|
||||
for i in range(0, set1.len()) {
|
||||
if i >= set2_len {
|
||||
map.insert(set1[i] as uint, set2[set2_len - 1]);
|
||||
map.insert(set1[i] as usize, set2[set2_len - 1]);
|
||||
} else {
|
||||
map.insert(set1[i] as uint, set2[i]);
|
||||
map.insert(set1[i] as usize, set2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for c in BufferedReader::new(stdin_raw()).chars() {
|
||||
match c {
|
||||
Ok(inc) => {
|
||||
let trc = match map.get(&(inc as uint)) {
|
||||
let trc = match map.get(&(inc as usize)) {
|
||||
Some(t) => *t,
|
||||
None => inc,
|
||||
};
|
||||
|
|
|
@ -80,7 +80,7 @@ pub fn uumain(args: Vec<String>) -> isize {
|
|||
loop {
|
||||
match reader.read_line() {
|
||||
Ok(line) => {
|
||||
let ab: Vec<&str> = line.as_slice().trim_right_chars('\n').split(' ').collect();
|
||||
let ab: Vec<&str> = line.as_slice().trim_right_matches('\n').split(' ').collect();
|
||||
if ab.len() > 2 {
|
||||
crash!(1, "{}: input contains an odd number of tokens", input);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ impl Graph {
|
|||
}
|
||||
|
||||
while !start_nodes.is_empty() {
|
||||
let n = start_nodes.remove(0).unwrap();
|
||||
let n = start_nodes.remove(0);
|
||||
|
||||
self.result.push(n.clone());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue