mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
refactor/uucore ~ align return values for executable/util macros
This commit is contained in:
parent
eb13533e4e
commit
69ce4dc8e5
1 changed files with 13 additions and 5 deletions
|
@ -20,7 +20,7 @@ macro_rules! executable(
|
||||||
let exe = match $crate::executable_os!().to_str() {
|
let exe = match $crate::executable_os!().to_str() {
|
||||||
// * UTF-8
|
// * UTF-8
|
||||||
Some(s) => s.to_string(),
|
Some(s) => s.to_string(),
|
||||||
// * "lossless" debug format if `executable_os!()` is not well-formed UTF-8
|
// * "lossless" debug format (if/when `executable_os!()` is not well-formed UTF-8)
|
||||||
None => format!("{:?}", $crate::executable_os!())
|
None => format!("{:?}", $crate::executable_os!())
|
||||||
};
|
};
|
||||||
&exe.to_owned()
|
&exe.to_owned()
|
||||||
|
@ -31,7 +31,14 @@ macro_rules! executable(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! executable_name(
|
macro_rules! executable_name(
|
||||||
() => ({
|
() => ({
|
||||||
&std::path::Path::new($crate::executable_os!()).file_stem().unwrap().to_string_lossy()
|
let stem = &std::path::Path::new($crate::executable_os!()).file_stem().unwrap().to_owned();
|
||||||
|
let exe = match stem.to_str() {
|
||||||
|
// * UTF-8
|
||||||
|
Some(s) => s.to_string(),
|
||||||
|
// * "lossless" debug format (if/when `executable_os!()` is not well-formed UTF-8)
|
||||||
|
None => format!("{:?}", stem)
|
||||||
|
};
|
||||||
|
&exe.to_owned()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -40,11 +47,12 @@ macro_rules! executable_name(
|
||||||
macro_rules! util_name(
|
macro_rules! util_name(
|
||||||
() => ({
|
() => ({
|
||||||
let crate_name = env!("CARGO_PKG_NAME");
|
let crate_name = env!("CARGO_PKG_NAME");
|
||||||
if crate_name.starts_with("uu_") {
|
let name = if crate_name.starts_with("uu_") {
|
||||||
&crate_name[3..]
|
&crate_name[3..]
|
||||||
} else {
|
} else {
|
||||||
&crate_name
|
crate_name
|
||||||
}
|
};
|
||||||
|
&name.to_owned()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue