mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
refactor/whoami ~ polish spelling (comments, names, and exceptions)
This commit is contained in:
parent
dff33a0edb
commit
5c9b474cc8
4 changed files with 5 additions and 9 deletions
|
@ -10,10 +10,10 @@
|
||||||
// spell-checker:ignore (ToDO) getusername
|
// spell-checker:ignore (ToDO) getusername
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub use self::unix::getusername;
|
pub use self::unix::get_username;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub use self::windows::getusername;
|
pub use self::windows::get_username;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod unix;
|
mod unix;
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::io::Result;
|
||||||
use uucore::entries::uid2usr;
|
use uucore::entries::uid2usr;
|
||||||
use uucore::libc::geteuid;
|
use uucore::libc::geteuid;
|
||||||
|
|
||||||
pub unsafe fn getusername() -> Result<String> {
|
pub unsafe fn get_username() -> Result<String> {
|
||||||
// Get effective user id
|
// Get effective user id
|
||||||
let uid = geteuid();
|
let uid = geteuid();
|
||||||
uid2usr(uid)
|
uid2usr(uid)
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) advapi lmcons winnt getusername WCHAR UNLEN
|
|
||||||
|
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
|
||||||
use self::winapi::shared::lmcons;
|
use self::winapi::shared::lmcons;
|
||||||
|
@ -18,7 +16,7 @@ use std::io::{Error, Result};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use uucore::wide::FromWide;
|
use uucore::wide::FromWide;
|
||||||
|
|
||||||
pub unsafe fn getusername() -> Result<String> {
|
pub unsafe fn get_username() -> Result<String> {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
||||||
let mut len = buffer.len() as minwindef::DWORD;
|
let mut len = buffer.len() as minwindef::DWORD;
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
/* last synced with: whoami (GNU coreutils) 8.21 */
|
/* last synced with: whoami (GNU coreutils) 8.21 */
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) getusername
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -38,7 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
pub fn exec() {
|
pub fn exec() {
|
||||||
unsafe {
|
unsafe {
|
||||||
match platform::getusername() {
|
match platform::get_username() {
|
||||||
Ok(username) => println!("{}", username),
|
Ok(username) => println!("{}", username),
|
||||||
Err(err) => match err.raw_os_error() {
|
Err(err) => match err.raw_os_error() {
|
||||||
Some(0) | None => crash!(1, "failed to get username"),
|
Some(0) | None => crash!(1, "failed to get username"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue