mirror of
https://github.com/uutils/coreutils
synced 2024-11-15 01:17:09 +00:00
Fix deprecation warnings
This commit is contained in:
parent
b3aeebb344
commit
ac77c6da17
11 changed files with 39 additions and 37 deletions
|
@ -194,7 +194,7 @@ fn set_user(user: &str) {
|
|||
fn strerror(errno: i32) -> String {
|
||||
unsafe {
|
||||
let err = libc::funcs::c95::string::strerror(errno);
|
||||
std::str::raw::from_c_str(err as *const i8)
|
||||
std::string::raw::from_buf(err as *const u8)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::vec::Vec;
|
|||
|
||||
use std::os;
|
||||
use std::ptr::{mut_null, read};
|
||||
use std::str::raw::from_c_str;
|
||||
use std::string::raw::from_buf;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub struct c_passwd {
|
||||
|
@ -207,7 +207,7 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
|
|||
let group = unsafe { getgrgid(g) };
|
||||
if group.is_not_null() {
|
||||
let name = unsafe {
|
||||
from_c_str(read(group).gr_name)
|
||||
from_buf(read(group).gr_name as *const u8)
|
||||
};
|
||||
print!("{:s} ", name);
|
||||
}
|
||||
|
|
38
src/id/id.rs
38
src/id/id.rs
|
@ -25,7 +25,7 @@ use libc::{
|
|||
getuid
|
||||
};
|
||||
use libc::funcs::posix88::unistd::{getegid, geteuid, getlogin};
|
||||
use std::str::raw::from_c_str;
|
||||
use std::string::raw::from_buf;
|
||||
use getopts::{getopts, optflag, usage};
|
||||
use c_types::{
|
||||
c_passwd,
|
||||
|
@ -136,7 +136,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
let gr = unsafe { getgrgid(id) };
|
||||
|
||||
if nflag && gr.is_not_null() {
|
||||
let gr_name = unsafe { from_c_str(read(gr).gr_name) };
|
||||
let gr_name = unsafe { from_buf(read(gr).gr_name as *const u8) };
|
||||
println!("{:s}", gr_name);
|
||||
} else {
|
||||
println!("{:u}", id);
|
||||
|
@ -156,7 +156,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
let pw = unsafe { getpwuid(id) };
|
||||
if nflag && pw.is_not_null() {
|
||||
let pw_name = unsafe {
|
||||
from_c_str(read(pw).pw_name)
|
||||
from_buf(read(pw).pw_name as *const u8)
|
||||
};
|
||||
println!("{:s}", pw_name);
|
||||
} else {
|
||||
|
@ -194,16 +194,16 @@ fn pretty(possible_pw: Option<c_passwd>) {
|
|||
if possible_pw.is_some() {
|
||||
let pw = possible_pw.unwrap();
|
||||
|
||||
let pw_name = unsafe { from_c_str(pw.pw_name) };
|
||||
let pw_name = unsafe { from_buf(pw.pw_name as *const u8) };
|
||||
print!("uid\t{:s}\ngroups\t", pw_name);
|
||||
group(possible_pw, true);
|
||||
} else {
|
||||
let login = unsafe { from_c_str(getlogin() as *const i8) };
|
||||
let login = unsafe { from_buf(getlogin() as *const u8) };
|
||||
let rid = unsafe { getuid() };
|
||||
let pw = unsafe { getpwuid(rid) };
|
||||
|
||||
let is_same_user = unsafe {
|
||||
from_c_str(read(pw).pw_name) == login
|
||||
from_buf(read(pw).pw_name as *const u8) == login
|
||||
};
|
||||
|
||||
if pw.is_null() || is_same_user {
|
||||
|
@ -213,7 +213,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
|
|||
if pw.is_not_null() {
|
||||
println!(
|
||||
"uid\t{:s}",
|
||||
unsafe { from_c_str(read(pw).pw_name) })
|
||||
unsafe { from_buf(read(pw).pw_name as *const u8) })
|
||||
} else {
|
||||
println!("uid\t{:u}\n", rid);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
|
|||
if pw.is_not_null() {
|
||||
println!(
|
||||
"euid\t{:s}",
|
||||
unsafe { from_c_str(read(pw).pw_name) });
|
||||
unsafe { from_buf(read(pw).pw_name as *const u8) });
|
||||
} else {
|
||||
println!("euid\t{:u}", eid);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
|
|||
if gr.is_not_null() {
|
||||
println!(
|
||||
"rgid\t{:s}",
|
||||
unsafe { from_c_str(read(gr).gr_name) });
|
||||
unsafe { from_buf(read(gr).gr_name as *const u8) });
|
||||
} else {
|
||||
println!("rgid\t{:u}", rid);
|
||||
}
|
||||
|
@ -285,11 +285,11 @@ fn pline(possible_pw: Option<c_passwd>) {
|
|||
possible_pw.unwrap()
|
||||
};
|
||||
|
||||
let pw_name = unsafe { from_c_str(pw.pw_name) };
|
||||
let pw_passwd = unsafe { from_c_str(pw.pw_passwd)};
|
||||
let pw_gecos = unsafe { from_c_str(pw.pw_gecos) };
|
||||
let pw_dir = unsafe { from_c_str(pw.pw_dir) };
|
||||
let pw_shell = unsafe { from_c_str(pw.pw_shell) };
|
||||
let pw_name = unsafe { from_buf(pw.pw_name as *const u8)};
|
||||
let pw_passwd = unsafe { from_buf(pw.pw_passwd as *const u8)};
|
||||
let pw_gecos = unsafe { from_buf(pw.pw_gecos as *const u8)};
|
||||
let pw_dir = unsafe { from_buf(pw.pw_dir as *const u8)};
|
||||
let pw_shell = unsafe { from_buf(pw.pw_shell as *const u8)};
|
||||
|
||||
println!(
|
||||
"{:s}:{:s}:{:u}:{:u}:{:s}:{:s}:{:s}",
|
||||
|
@ -349,7 +349,7 @@ fn id_print(possible_pw: Option<c_passwd>,
|
|||
print!(
|
||||
"uid={:u}({:s})",
|
||||
uid,
|
||||
unsafe { from_c_str(possible_pw.unwrap().pw_name) });
|
||||
unsafe { from_buf(possible_pw.unwrap().pw_name as *const u8) });
|
||||
} else {
|
||||
print!("uid={:u}", unsafe { getuid() });
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ fn id_print(possible_pw: Option<c_passwd>,
|
|||
if gr.is_not_null() {
|
||||
print!(
|
||||
"({:s})",
|
||||
unsafe { from_c_str(read(gr).gr_name) });
|
||||
unsafe { from_buf(read(gr).gr_name as *const u8) });
|
||||
}
|
||||
|
||||
let euid = unsafe { geteuid() };
|
||||
|
@ -369,7 +369,7 @@ fn id_print(possible_pw: Option<c_passwd>,
|
|||
if pw.is_not_null() {
|
||||
print!(
|
||||
"({:s})",
|
||||
unsafe { from_c_str(read(pw).pw_name) });
|
||||
unsafe { from_buf(read(pw).pw_name as *const u8) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ fn id_print(possible_pw: Option<c_passwd>,
|
|||
unsafe {
|
||||
let grp = getgrgid(egid);
|
||||
if grp.is_not_null() {
|
||||
print!("({:s})", from_c_str(read(grp).gr_name));
|
||||
print!("({:s})", from_buf(read(grp).gr_name as *const u8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ fn id_print(possible_pw: Option<c_passwd>,
|
|||
let group = unsafe { getgrgid(gr) };
|
||||
if group.is_not_null() {
|
||||
let name = unsafe {
|
||||
from_c_str(read(group).gr_name)
|
||||
from_buf(read(group).gr_name as *const u8)
|
||||
};
|
||||
print!("({:s})", name);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ extern crate getopts;
|
|||
extern crate libc;
|
||||
|
||||
use std::io::print;
|
||||
use std::str;
|
||||
use std::string;
|
||||
use libc::c_char;
|
||||
|
||||
#[path = "../common/util.rs"] mod util;
|
||||
|
@ -32,7 +32,7 @@ extern {
|
|||
unsafe fn get_userlogin() -> String {
|
||||
let login: *const libc::c_char = getlogin();
|
||||
|
||||
str::raw::from_c_str(login)
|
||||
string::raw::from_buf(login as *const u8)
|
||||
}
|
||||
|
||||
static NAME: &'static str = "logname";
|
||||
|
|
|
@ -158,7 +158,7 @@ fn tail<T: Reader> (reader: &mut BufferedReader<T>, line_count:uint, follow:bool
|
|||
if line_count<=ringbuf.len(){
|
||||
ringbuf.pop_front();
|
||||
}
|
||||
ringbuf.push_back(line);
|
||||
ringbuf.push(line);
|
||||
}
|
||||
Err(err) => fail!(err)
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ impl Graph {
|
|||
}
|
||||
|
||||
while !start_nodes.is_empty() {
|
||||
let n = start_nodes.shift().unwrap();
|
||||
let n = start_nodes.remove(0).unwrap();
|
||||
|
||||
self.result.push(n.clone());
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use std::str;
|
||||
use std::string;
|
||||
use std::io::println;
|
||||
use std::io::stdio::stderr;
|
||||
use getopts::{optflag,getopts};
|
||||
|
@ -50,7 +50,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
};
|
||||
|
||||
let tty = unsafe { str::raw::from_c_str(ttyname(libc::STDIN_FILENO)) };
|
||||
let tty = unsafe { string::raw::from_buf(ttyname(libc::STDIN_FILENO) as *const u8) };
|
||||
|
||||
if !silent {
|
||||
if !tty.as_slice().is_whitespace() {
|
||||
|
|
|
@ -19,7 +19,7 @@ extern crate libc;
|
|||
|
||||
use std::mem::uninitialized;
|
||||
use std::io::print;
|
||||
use std::str::raw::from_c_str;
|
||||
use std::string::raw::from_buf;
|
||||
use c_types::utsname;
|
||||
|
||||
#[path = "../common/util.rs"] mod util;
|
||||
|
@ -41,9 +41,11 @@ unsafe fn getuname() -> utsrust {
|
|||
let mut uts: utsname = uninitialized();
|
||||
uname(&mut uts);
|
||||
utsrust {
|
||||
sysname: from_c_str(uts.sysname.as_ptr()), nodename: from_c_str(uts.nodename.as_ptr()),
|
||||
release: from_c_str(uts.release.as_ptr()), version: from_c_str(uts.version.as_ptr()),
|
||||
machine: from_c_str(uts.machine.as_ptr())
|
||||
sysname: from_buf(uts.sysname.as_ptr() as *const u8),
|
||||
nodename: from_buf(uts.nodename.as_ptr() as *const u8),
|
||||
release: from_buf(uts.release.as_ptr() as *const u8),
|
||||
version: from_buf(uts.version.as_ptr() as *const u8),
|
||||
machine: from_buf(uts.machine.as_ptr() as *const u8)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ extern crate libc;
|
|||
use std::io::print;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
use std::string;
|
||||
use utmpx::*;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
|
@ -103,7 +103,7 @@ fn exec(filename: &str) {
|
|||
}
|
||||
|
||||
if (*line).ut_type == USER_PROCESS {
|
||||
let user = str::raw::from_c_str(mem::transmute(&(*line).ut_user));
|
||||
let user = string::raw::from_buf(mem::transmute(&(*line).ut_user));
|
||||
users.push(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ fn main() {
|
|||
|
||||
// try first arg as util name.
|
||||
if args.len() >= 2 {
|
||||
args.shift();
|
||||
args.remove(0);
|
||||
let util = args[0].as_slice();
|
||||
|
||||
match umap.find_equiv(&util) {
|
||||
|
|
|
@ -25,7 +25,7 @@ use std::io::print;
|
|||
#[cfg(unix)]
|
||||
mod platform {
|
||||
use super::libc;
|
||||
use std::str;
|
||||
use std::string;
|
||||
use self::c_types::{c_passwd, getpwuid};
|
||||
|
||||
#[path = "../../common/c_types.rs"] mod c_types;
|
||||
|
@ -38,7 +38,7 @@ mod platform {
|
|||
let passwd: *const c_passwd = getpwuid(geteuid());
|
||||
|
||||
let pw_name: *const libc::c_char = (*passwd).pw_name;
|
||||
let name = str::raw::from_c_str(pw_name);
|
||||
let name = string::raw::from_buf(pw_name as *const u8);
|
||||
|
||||
name
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue