mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +00:00
various integer type changes
This commit is contained in:
parent
09b1162912
commit
80f9ef08d2
4 changed files with 11 additions and 11 deletions
|
@ -96,7 +96,7 @@ pub fn uumain(args: Vec<String>) -> isize {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr();
|
let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr();
|
||||||
let mut command_parts: Vec<*const i8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect();
|
let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect();
|
||||||
command_parts.push(std::ptr::null());
|
command_parts.push(std::ptr::null());
|
||||||
execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as isize
|
execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as isize
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
||||||
} else {
|
} else {
|
||||||
let pw_pointer = unsafe {
|
let pw_pointer = unsafe {
|
||||||
let cstr = CString::from_slice(username.as_bytes());
|
let cstr = CString::from_slice(username.as_bytes());
|
||||||
getpwnam(cstr.as_bytes_with_nul().as_ptr())
|
getpwnam(cstr.as_bytes_with_nul().as_ptr() as *const i8)
|
||||||
};
|
};
|
||||||
if !pw_pointer.is_null() {
|
if !pw_pointer.is_null() {
|
||||||
Some(unsafe { read(pw_pointer) })
|
Some(unsafe { read(pw_pointer) })
|
||||||
|
@ -199,7 +199,7 @@ unsafe fn get_group_list_internal(name: *const c_char, gid: gid_t, groups: *mut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_groups() -> Result<Vec<gid_t>, usize> {
|
pub fn get_groups() -> Result<Vec<gid_t>, i32> {
|
||||||
let ngroups = unsafe { getgroups(0, null_mut()) };
|
let ngroups = unsafe { getgroups(0, null_mut()) };
|
||||||
if ngroups == -1 {
|
if ngroups == -1 {
|
||||||
return Err(os::errno());
|
return Err(os::errno());
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct EchoOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_char(bytes: &Vec<u8>, base: usize) -> char {
|
fn to_char(bytes: &Vec<u8>, base: u32) -> char {
|
||||||
from_str_radix::<usize>(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char
|
from_str_radix::<usize>(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +52,10 @@ fn isodigit(c: u8) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_str(string: &[u8], index: usize, base: usize) -> (char, usize) {
|
fn convert_str(string: &[u8], index: usize, base: u32) -> (char, usize) {
|
||||||
let (max_digits, is_legal_digit) : (usize, fn(u8) -> bool) = match base {
|
let (max_digits, is_legal_digit) : (usize, fn(u8) -> bool) = match base {
|
||||||
8us => (3, isodigit),
|
8 => (3, isodigit),
|
||||||
16us => (2, isxdigit),
|
16 => (2, isxdigit),
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ pub fn uumain(args: Vec<String>) -> isize {
|
||||||
't' => print!("\t"),
|
't' => print!("\t"),
|
||||||
'v' => print!("\x0B"),
|
'v' => print!("\x0B"),
|
||||||
'x' => {
|
'x' => {
|
||||||
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16us);
|
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16);
|
||||||
if num_char_used == 0 {
|
if num_char_used == 0 {
|
||||||
print!("\\x");
|
print!("\\x");
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,7 +213,7 @@ pub fn uumain(args: Vec<String>) -> isize {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'0' => {
|
'0' => {
|
||||||
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8us);
|
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8);
|
||||||
if num_char_used == 0 {
|
if num_char_used == 0 {
|
||||||
print!("\0");
|
print!("\0");
|
||||||
} else {
|
} else {
|
||||||
|
@ -224,7 +224,7 @@ pub fn uumain(args: Vec<String>) -> isize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8us);
|
let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8);
|
||||||
if num_char_used == 0 {
|
if num_char_used == 0 {
|
||||||
print!("\\{}", c);
|
print!("\\{}", c);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -243,7 +243,7 @@ fn num_prefix(i: usize, width: usize) -> String {
|
||||||
let div = Int::pow(10 as usize, w);
|
let div = Int::pow(10 as usize, w);
|
||||||
let r = n / div;
|
let r = n / div;
|
||||||
n -= r * div;
|
n -= r * div;
|
||||||
c.push(char::from_digit(r, 10).unwrap());
|
c.push(char::from_digit(r as u32, 10).unwrap());
|
||||||
}
|
}
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue