mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
Simplify invalid encoding handling into two small methods of Args
The previous encoding handling was unnecessarily complex. This commit removes the enum that specifies the handling and instead has two separate methods to collect the strings either with lossy conversion or by ignoring invalidly encoded strings.
This commit is contained in:
parent
5621502a95
commit
ba713b6365
48 changed files with 107 additions and 153 deletions
|
@ -12,7 +12,7 @@ use std::io::{stdout, Read, Write};
|
|||
use uucore::display::Quotable;
|
||||
use uucore::encoding::{wrap_print, Data, Format};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Stdin};
|
||||
|
@ -87,7 +87,7 @@ impl Config {
|
|||
|
||||
pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> {
|
||||
let command = base_app(about, usage);
|
||||
let arg_list = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let arg_list = args.collect_lossy();
|
||||
Config::from(&command.try_get_matches_from(arg_list)?)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use clap::{crate_version, Arg, Command};
|
|||
use std::path::{is_separator, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = r#"Print NAME with any leading directory components removed
|
||||
If specified, also remove a trailing SUFFIX"#;
|
||||
|
@ -28,7 +28,7 @@ pub mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
// Since options have to go before names,
|
||||
// if the first argument is not an option, then there is no option,
|
||||
|
|
|
@ -14,7 +14,6 @@ use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR};
|
|||
use uucore::{
|
||||
encoding::Format,
|
||||
error::{UResult, UUsageError},
|
||||
InvalidEncodingHandling,
|
||||
};
|
||||
|
||||
use std::io::{stdin, Read};
|
||||
|
@ -52,7 +51,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
|
||||
fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
|
||||
let matches = uu_app()
|
||||
.try_get_matches_from(args.collect_str(InvalidEncodingHandling::ConvertLossy))
|
||||
.try_get_matches_from(args.collect_lossy())
|
||||
.with_exit_code(1)?;
|
||||
let format = ENCODINGS
|
||||
.iter()
|
||||
|
|
|
@ -36,7 +36,7 @@ use std::net::Shutdown;
|
|||
use std::os::unix::fs::FileTypeExt;
|
||||
#[cfg(unix)]
|
||||
use unix_socket::UnixStream;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static NAME: &str = "cat";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
@ -184,7 +184,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use uucore::fs::is_symlink;
|
|||
use uucore::libc::mode_t;
|
||||
#[cfg(not(windows))]
|
||||
use uucore::mode;
|
||||
use uucore::{format_usage, show_error, InvalidEncodingHandling};
|
||||
use uucore::{format_usage, show_error};
|
||||
|
||||
static ABOUT: &str = "Change the mode of each FILE to MODE.
|
||||
With --reference, change the mode of each FILE to that of RFILE.";
|
||||
|
@ -46,7 +46,7 @@ fn get_long_usage() -> String {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let mut args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let mut args = args.collect_lossy();
|
||||
|
||||
// Before we can parse 'args' with clap (and previously getopts),
|
||||
// a possible MODE prefix '-' needs to be removed (e.g. "chmod -x FILE").
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::path::Path;
|
|||
use std::process;
|
||||
use uucore::error::{set_exit_code, UResult};
|
||||
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
||||
use uucore::{entries, format_usage, InvalidEncodingHandling};
|
||||
use uucore::{entries, format_usage};
|
||||
|
||||
static ABOUT: &str = "Run COMMAND with root directory set to NEWROOT.";
|
||||
static USAGE: &str = "{} [OPTION]... NEWROOT [COMMAND [ARG]...]";
|
||||
|
@ -33,7 +33,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use std::io::{self, stdin, BufReader, Read};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::InvalidEncodingHandling;
|
||||
use uucore::{format_usage, show};
|
||||
|
||||
// NOTE: CRC_TABLE_LEN *must* be <= 256 as we cast 0..CRC_TABLE_LEN to u8
|
||||
|
@ -114,7 +113,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::io::{self, stdin, BufRead, BufReader, Stdin};
|
|||
use std::path::Path;
|
||||
use uucore::error::FromIo;
|
||||
use uucore::error::UResult;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
||||
|
||||
|
@ -132,7 +132,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
let filename1 = matches.value_of(options::FILE_1).unwrap();
|
||||
|
|
|
@ -16,7 +16,7 @@ use clap::{crate_version, Arg, ArgMatches, Command};
|
|||
use regex::Regex;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
mod csplit_error;
|
||||
mod patterns;
|
||||
|
@ -713,7 +713,7 @@ mod tests {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ use uucore::display::Quotable;
|
|||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
|
||||
use self::searcher::Searcher;
|
||||
use uucore::format_usage;
|
||||
use uucore::ranges::Range;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
mod searcher;
|
||||
|
||||
|
@ -398,7 +398,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let delimiter_is_equal = args.contains(&"-d=".to_string()); // special case
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
|
|
@ -37,7 +37,7 @@ use clap::{crate_version, Arg, ArgMatches, Command};
|
|||
use gcd::Gcd;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::{show_error, InvalidEncodingHandling};
|
||||
use uucore::show_error;
|
||||
|
||||
const ABOUT: &str = "copy, and optionally convert, a file system resource";
|
||||
const BUF_INIT_BYTE: u8 = 0xDD;
|
||||
|
@ -706,7 +706,7 @@ fn append_dashes_if_not_present(mut acc: Vec<String>, mut s: String) -> Vec<Stri
|
|||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let dashed_args = args
|
||||
.collect_str(InvalidEncodingHandling::Ignore)
|
||||
.collect_ignore()
|
||||
.into_iter()
|
||||
.fold(Vec::new(), append_dashes_if_not_present);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ pub fn guess_syntax() -> OutputFmt {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(&args);
|
||||
|
||||
|
@ -276,7 +276,7 @@ enum ParseState {
|
|||
}
|
||||
|
||||
use std::collections::HashMap;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
fn parse<T>(lines: T, fmt: &OutputFmt, fp: &str) -> Result<String, String>
|
||||
where
|
||||
|
|
|
@ -9,7 +9,7 @@ use clap::{crate_version, Arg, Command};
|
|||
use std::path::Path;
|
||||
use uucore::display::print_verbatim;
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "strip last component from file name";
|
||||
const USAGE: &str = "{} [OPTION] NAME...";
|
||||
|
@ -28,7 +28,7 @@ fn get_long_usage() -> String {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let after_help = get_long_usage();
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ use uucore::error::{UError, UResult};
|
|||
use uucore::format_usage;
|
||||
use uucore::parse_glob;
|
||||
use uucore::parse_size::{parse_size, ParseSizeError};
|
||||
use uucore::InvalidEncodingHandling;
|
||||
#[cfg(windows)]
|
||||
use winapi::shared::minwindef::{DWORD, LPVOID};
|
||||
#[cfg(windows)]
|
||||
|
@ -516,7 +515,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
|
|||
#[uucore::main]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::io::{self, Write};
|
|||
use std::iter::Peekable;
|
||||
use std::str::Chars;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
const NAME: &str = "echo";
|
||||
const ABOUT: &str = "display a line of text";
|
||||
|
@ -110,7 +110,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
let no_newline = matches.contains_id(options::NO_NEWLINE);
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::str::from_utf8;
|
|||
use unicode_width::UnicodeWidthChar;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "Convert tabs in each FILE to spaces, writing to standard output.
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
|
@ -269,7 +269,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(expand_shortcuts(&args));
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
use clap::{crate_version, Arg, Command};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
mod syntax_tree;
|
||||
mod tokens;
|
||||
|
@ -33,7 +32,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
// For expr utility we do not want getopts.
|
||||
// The following usage should work without escaping hyphens: `expr -15 = 1 + 2 \* \( 3 - -4 \)`
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::io::{stdin, BufRead, BufReader, Read};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
const TAB_WIDTH: usize = 8;
|
||||
|
||||
|
@ -31,7 +31,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let (args, obs_width) = handle_obsolete(&args[..]);
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
|
|
@ -16,8 +16,8 @@ use nix::unistd::Pid;
|
|||
use std::io::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::signals::{signal_by_name_or_value, ALL_SIGNALS};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str = "Send signal to processes or list information about signals.";
|
||||
const USAGE: &str = "{} [OPTIONS]... PID...";
|
||||
|
@ -38,7 +38,7 @@ pub enum Mode {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let mut args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let mut args = args.collect_ignore();
|
||||
let obs_signal = handle_obsolete(&mut args);
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
|
|
@ -15,7 +15,6 @@ extern crate uucore;
|
|||
use clap::{crate_version, Command};
|
||||
use std::ffi::CStr;
|
||||
use uucore::error::UResult;
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
extern "C" {
|
||||
// POSIX requires using getlogin (or equivalent code)
|
||||
|
@ -37,7 +36,7 @@ static ABOUT: &str = "Print user's login name";
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let _ = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ use std::path::{Path, PathBuf};
|
|||
#[cfg(not(windows))]
|
||||
use uucore::error::FromIo;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
#[cfg(not(windows))]
|
||||
use uucore::mode;
|
||||
use uucore::{display::Quotable, fs::dir_strip_dot_for_creation};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static DEFAULT_PERM: u32 = 0o755;
|
||||
|
||||
|
@ -83,7 +83,7 @@ fn strip_minus_from_mode(args: &mut Vec<String>) -> bool {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let mut args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let mut args = args.collect_lossy();
|
||||
|
||||
// Before we can parse 'args' with clap (and previously getopts),
|
||||
// a possible MODE prefix '-' needs to be removed (e.g. "chmod -x FILE").
|
||||
|
|
|
@ -11,9 +11,9 @@ extern crate uucore;
|
|||
use clap::{crate_version, Arg, Command};
|
||||
use libc::mkfifo;
|
||||
use std::ffi::CString;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::{display::Quotable, InvalidEncodingHandling};
|
||||
|
||||
static NAME: &str = "mkfifo";
|
||||
static USAGE: &str = "{} [OPTION]... NAME...";
|
||||
|
@ -28,7 +28,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOT
|
|||
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UResult, USimpleError, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "Create the special file NAME of the given TYPE.";
|
||||
static USAGE: &str = "{} [OPTION]... NAME TYPE [MAJOR MINOR]";
|
||||
|
@ -81,7 +81,7 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
// Linux-specific options, not implemented
|
||||
// opts.optflag("Z", "", "set the SELinux security context to default type");
|
||||
// opts.optopt("", "context", "like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use clap::{crate_version, Arg, ArgMatches, Command};
|
||||
use uucore::display::{println_verbatim, Quotable};
|
||||
use uucore::error::{FromIo, UError, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
|
@ -316,7 +316,7 @@ impl Params {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().try_get_matches_from(&args)?;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::io::{stdin, BufRead, BufReader, Read};
|
|||
use std::iter::repeat;
|
||||
use std::path::Path;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
mod helper;
|
||||
|
||||
|
@ -84,7 +84,7 @@ pub mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::os::unix::prelude::*;
|
|||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UError, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "Run COMMAND ignoring hangup signals.";
|
||||
static LONG_HELP: &str = "
|
||||
|
@ -86,7 +86,7 @@ impl Display for NohupError {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ use std::io::{BufRead, Write};
|
|||
use units::{IEC_BASES, SI_BASES};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::UResult;
|
||||
use uucore::format_usage;
|
||||
use uucore::ranges::Range;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
pub mod errors;
|
||||
pub mod format;
|
||||
|
@ -261,7 +261,7 @@ fn concat_format_arg_and_value(args: &[String]) -> Vec<String> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(concat_format_arg_and_value(&args));
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ use uucore::display::Quotable;
|
|||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::parse_size::ParseSizeError;
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
const PEEK_BUFFER_SIZE: usize = 4; // utf-8 can be 4 bytes
|
||||
static ABOUT: &str = "dump files in octal and other formats";
|
||||
|
@ -256,7 +255,7 @@ impl OdOptions {
|
|||
/// opens the input and calls `odfunc` to process the input.
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let clap_opts = uu_app();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::fs;
|
|||
use std::io::{ErrorKind, Write};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, UResult, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
// operating mode
|
||||
enum Mode {
|
||||
|
@ -39,7 +39,7 @@ const POSIX_NAME_MAX: usize = 14;
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::os::unix::fs::MetadataExt;
|
|||
|
||||
use clap::{crate_version, Arg, Command};
|
||||
use std::path::PathBuf;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "lightweight finger";
|
||||
const USAGE: &str = "{} [OPTION]... [USER]...";
|
||||
|
@ -49,7 +49,7 @@ fn get_long_usage() -> String {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let after_help = get_long_usage();
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(uucore::InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let opt_args = recreate_arguments(&args);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use clap::{crate_version, Arg, Command};
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::InvalidEncodingHandling;
|
||||
use uucore::{format_usage, memo};
|
||||
|
||||
const VERSION: &str = "version";
|
||||
|
@ -271,7 +270,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
let format_string = matches
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
|
|||
use std::num::ParseIntError;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static NAME: &str = "ptx";
|
||||
const USAGE: &str = "\
|
||||
|
@ -722,7 +722,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
// let mut opts = Options::new();
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
|
|
@ -12,8 +12,8 @@ use std::env;
|
|||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::println_verbatim;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::format_usage;
|
||||
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str = "Convert TO destination to the relative path from the FROM dir.
|
||||
If FROM path is omitted, current working dir will be used.";
|
||||
|
@ -27,7 +27,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::io::SeekFrom;
|
|||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::{format_usage, util_name, InvalidEncodingHandling};
|
||||
use uucore::{format_usage, util_name};
|
||||
|
||||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
@ -266,7 +266,7 @@ pub mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::fs::File;
|
|||
use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
mod rand_read_adapter;
|
||||
|
||||
|
@ -56,7 +56,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ use std::str::Utf8Error;
|
|||
use unicode_width::UnicodeWidthStr;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, strip_errno, UError, UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::parse_size::{parse_size, ParseSizeError};
|
||||
use uucore::version_cmp::version_cmp;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
use crate::tmp_dir::TmpDirWrapper;
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ fn make_sort_mode_arg<'a>(mode: &'a str, short: char, help: &'a str) -> Arg<'a>
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
let mut settings: GlobalSettings = Default::default();
|
||||
|
||||
let matches = match uu_app().try_get_matches_from(args) {
|
||||
|
|
|
@ -19,8 +19,8 @@ use std::process;
|
|||
use tempfile::tempdir;
|
||||
use tempfile::TempDir;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::parse_size::parse_size;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str =
|
||||
"Run COMMAND, with modified buffering operations for its standard streams.\n\n\
|
||||
|
@ -156,7 +156,7 @@ fn get_preload_env(tmp_dir: &mut TempDir) -> io::Result<(String, PathBuf)> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::io::{stdin, Read};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static NAME: &str = "sum";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
@ -109,7 +109,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ use std::{
|
|||
use uucore::display::Quotable;
|
||||
use uucore::error::UError;
|
||||
use uucore::error::UResult;
|
||||
use uucore::InvalidEncodingHandling;
|
||||
use uucore::{format_usage, show};
|
||||
|
||||
use crate::error::TacError;
|
||||
|
@ -37,7 +36,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ use std::process::{self, Child, Stdio};
|
|||
use std::time::Duration;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::process::ChildExt;
|
||||
use uucore::signals::{signal_by_name_or_value, signal_name_by_value};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str = "Start COMMAND, and kill it if still running after DURATION.";
|
||||
const USAGE: &str = "{} [OPTION] DURATION COMMAND...";
|
||||
|
@ -106,7 +106,7 @@ impl Config {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let command = uu_app();
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ use std::io::{stdin, stdout, BufReader, BufWriter};
|
|||
use uucore::{format_usage, show};
|
||||
|
||||
use crate::operation::DeleteOperation;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
use uucore::{display::Quotable, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str = "translate or delete characters";
|
||||
const USAGE: &str = "{} [OPTION]... SET1 [SET2]";
|
||||
|
@ -40,7 +40,7 @@ fn get_long_usage() -> String {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let after_help = get_long_usage();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::io::{stdin, BufRead, BufReader, Read};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "Topological sort the strings in FILE.
|
||||
Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline).
|
||||
|
@ -25,7 +25,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use clap::{crate_version, Arg, Command};
|
|||
use std::ffi::CStr;
|
||||
use std::io::Write;
|
||||
use uucore::error::UResult;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static ABOUT: &str = "Print the file name of the terminal connected to standard input.";
|
||||
const USAGE: &str = "{} [OPTION]...";
|
||||
|
@ -24,7 +24,7 @@ mod options {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::ConvertLossy);
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::str::from_utf8;
|
|||
use unicode_width::UnicodeWidthChar;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
static NAME: &str = "unexpand";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
@ -165,7 +165,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().get_matches_from(expand_shortcuts(&args));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::ffi::CStr;
|
|||
use std::fmt::Write;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::PathBuf;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
use uucore::format_usage;
|
||||
|
||||
mod options {
|
||||
pub const ALL: &str = "all";
|
||||
|
@ -56,7 +56,7 @@ fn get_long_usage() -> String {
|
|||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_str(InvalidEncodingHandling::Ignore);
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let after_help = get_long_usage();
|
||||
|
||||
|
|
|
@ -82,8 +82,6 @@ use std::sync::atomic::Ordering;
|
|||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::display::Quotable;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! bin {
|
||||
($util:ident) => {
|
||||
|
@ -150,43 +148,15 @@ pub fn execution_phrase() -> &'static str {
|
|||
&EXECUTION_PHRASE
|
||||
}
|
||||
|
||||
pub enum InvalidEncodingHandling {
|
||||
Ignore,
|
||||
ConvertLossy,
|
||||
}
|
||||
|
||||
pub trait Args: Iterator<Item = OsString> + Sized {
|
||||
/// Converts each iterator item to a String and collects these into a vector
|
||||
/// On invalid encoding, the result will depend on the argument. This method allows to either drop entries with illegal encoding
|
||||
/// completely (```InvalidEncodingHandling::Ignore```), convert them using lossy-conversion (```InvalidEncodingHandling::ConvertLossy```)
|
||||
/// which will result in strange strings or can chosen to panic.
|
||||
/// # Arguments
|
||||
/// * `handling` - This switch allows to switch the behavior, when invalid encoding is encountered
|
||||
fn collect_str(self, handling: InvalidEncodingHandling) -> Vec<String> {
|
||||
self.map(|s| match s.into_string() {
|
||||
Ok(string) => Ok(string),
|
||||
Err(s_ret) => {
|
||||
eprintln!(
|
||||
"Input with broken encoding occurred! (s = {}) ",
|
||||
s_ret.quote()
|
||||
);
|
||||
match handling {
|
||||
InvalidEncodingHandling::Ignore => Err(String::new()),
|
||||
InvalidEncodingHandling::ConvertLossy => {
|
||||
Err(s_ret.to_string_lossy().into_owned())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(|s| match handling {
|
||||
InvalidEncodingHandling::Ignore => s.is_ok(),
|
||||
_ => true,
|
||||
})
|
||||
.map(|s| match s {
|
||||
Ok(v) => v,
|
||||
Err(e) => e,
|
||||
})
|
||||
.collect()
|
||||
/// Collects the iterator into a `Vec<String>`, lossily converting the `OsString`s to `Strings`.
|
||||
fn collect_lossy(self) -> Vec<String> {
|
||||
self.map(|s| s.to_string_lossy().into_owned()).collect()
|
||||
}
|
||||
|
||||
/// Collects the iterator into a `Vec<String>`, removing any elements that contain invalid encoding.
|
||||
fn collect_ignore(self) -> Vec<String> {
|
||||
self.filter_map(|s| s.into_string().ok()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,42 +179,34 @@ mod tests {
|
|||
]
|
||||
}
|
||||
|
||||
fn collect_os_str(vec: Vec<OsString>, handling: InvalidEncodingHandling) -> Vec<String> {
|
||||
vec.into_iter().collect_str(handling)
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
fn test_invalid_utf8_args_lossy(os_str: &OsStr) {
|
||||
//assert our string is invalid utf8
|
||||
// assert our string is invalid utf8
|
||||
assert!(os_str.to_os_string().into_string().is_err());
|
||||
let test_vec = make_os_vec(os_str);
|
||||
let collected_to_str =
|
||||
collect_os_str(test_vec.clone(), InvalidEncodingHandling::ConvertLossy);
|
||||
//conservation of length - when accepting lossy conversion no arguments may be dropped
|
||||
let collected_to_str = test_vec.clone().into_iter().collect_lossy();
|
||||
// conservation of length - when accepting lossy conversion no arguments may be dropped
|
||||
assert_eq!(collected_to_str.len(), test_vec.len());
|
||||
//first indices identical
|
||||
// first indices identical
|
||||
for index in 0..2 {
|
||||
assert_eq!(
|
||||
collected_to_str.get(index).unwrap(),
|
||||
test_vec.get(index).unwrap().to_str().unwrap()
|
||||
);
|
||||
assert_eq!(collected_to_str[index], test_vec[index].to_str().unwrap());
|
||||
}
|
||||
//lossy conversion for string with illegal encoding is done
|
||||
// lossy conversion for string with illegal encoding is done
|
||||
assert_eq!(
|
||||
*collected_to_str.get(2).unwrap(),
|
||||
*collected_to_str[2],
|
||||
os_str.to_os_string().to_string_lossy()
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
fn test_invalid_utf8_args_ignore(os_str: &OsStr) {
|
||||
//assert our string is invalid utf8
|
||||
// assert our string is invalid utf8
|
||||
assert!(os_str.to_os_string().into_string().is_err());
|
||||
let test_vec = make_os_vec(os_str);
|
||||
let collected_to_str = collect_os_str(test_vec.clone(), InvalidEncodingHandling::Ignore);
|
||||
//assert that the broken entry is filtered out
|
||||
let collected_to_str = test_vec.clone().into_iter().collect_ignore();
|
||||
// assert that the broken entry is filtered out
|
||||
assert_eq!(collected_to_str.len(), test_vec.len() - 1);
|
||||
//assert that the unbroken indices are converted as expected
|
||||
// assert that the unbroken indices are converted as expected
|
||||
for index in 0..2 {
|
||||
assert_eq!(
|
||||
collected_to_str.get(index).unwrap(),
|
||||
|
@ -255,10 +217,10 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn valid_utf8_encoding_args() {
|
||||
//create a vector containing only correct encoding
|
||||
// create a vector containing only correct encoding
|
||||
let test_vec = make_os_vec(&OsString::from("test2"));
|
||||
//expect complete conversion without losses, even when lossy conversion is accepted
|
||||
let _ = collect_os_str(test_vec, InvalidEncodingHandling::ConvertLossy);
|
||||
// expect complete conversion without losses, even when lossy conversion is accepted
|
||||
let _ = test_vec.into_iter().collect_lossy();
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
|
|
|
@ -30,7 +30,7 @@ use std::rc::Rc;
|
|||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use uucore::{Args, InvalidEncodingHandling};
|
||||
use uucore::Args;
|
||||
|
||||
#[cfg(windows)]
|
||||
static PROGNAME: &str = concat!(env!("CARGO_PKG_NAME"), ".exe");
|
||||
|
@ -1021,7 +1021,7 @@ impl UCommand {
|
|||
let strings = args
|
||||
.iter()
|
||||
.map(|s| s.as_ref().to_os_string())
|
||||
.collect_str(InvalidEncodingHandling::Ignore);
|
||||
.collect_ignore();
|
||||
|
||||
for s in strings {
|
||||
self.comm_string.push(' ');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue