mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Merge pull request #2400 from youknowone/line-ends
cleaning up str ends checks
This commit is contained in:
commit
7e47836e94
2 changed files with 3 additions and 11 deletions
|
@ -118,14 +118,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
fn basename(fullname: &str, suffix: &str) -> String {
|
fn basename(fullname: &str, suffix: &str) -> String {
|
||||||
// Remove all platform-specific path separators from the end
|
// Remove all platform-specific path separators from the end
|
||||||
let mut path: String = fullname
|
let path = fullname.trim_end_matches(is_separator);
|
||||||
.chars()
|
|
||||||
.rev()
|
|
||||||
.skip_while(|&ch| is_separator(ch))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Undo reverse
|
|
||||||
path = path.chars().rev().collect();
|
|
||||||
|
|
||||||
// Convert to path buffer and get last path component
|
// Convert to path buffer and get last path component
|
||||||
let pb = PathBuf::from(path);
|
let pb = PathBuf::from(path);
|
||||||
|
|
|
@ -50,9 +50,8 @@ fn mkdelim(col: usize, opts: &ArgMatches) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_nl(line: &mut String) {
|
fn ensure_nl(line: &mut String) {
|
||||||
match line.chars().last() {
|
if !line.ends_with('\n') {
|
||||||
Some('\n') => (),
|
line.push('\n');
|
||||||
_ => line.push('\n'),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue