fix some issues with locale (replace "LANGUAGE" with "LC_ALL")

`LANGUAGE=C` is not enough, `LC_ALL=C` is needed as the environment
variable that overrides all the other localization settings.

e.g.
```bash
$ LANGUAGE=C id foobar
id: ‘foobar’: no such user

$ LC_ALL=C id foobar
id: 'foobar': no such user
```

* replace `LANGUAGE` with `LC_ALL` as environment variable in the tests
* fix the the date string of affected uutils
* replace `‘` and `’` with `'`
This commit is contained in:
Jan Scheer
2021-06-23 11:30:28 +02:00
parent d3181fa60e
commit c0be979611
41 changed files with 135 additions and 140 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ impl Config {
Some(mut values) => {
let name = values.next().unwrap();
if values.len() != 0 {
return Err(format!("extra operand {}", name));
return Err(format!("extra operand '{}'", name));
}
if name == "-" {
@@ -58,7 +58,7 @@ impl Config {
.value_of(options::WRAP)
.map(|num| {
num.parse::<usize>()
.map_err(|e| format!("Invalid wrap size: {}: {}", num, e))
.map_err(|e| format!("Invalid wrap size: '{}': {}", num, e))
})
.transpose()?;
+2 -2
View File
@@ -281,7 +281,7 @@ fn parse_spec(spec: &str) -> Result<(Option<u32>, Option<u32>), String> {
let uid = if usr_only || usr_grp {
Some(
Passwd::locate(args[0])
.map_err(|_| format!("invalid user: {}", spec))?
.map_err(|_| format!("invalid user: '{}'", spec))?
.uid(),
)
} else {
@@ -290,7 +290,7 @@ fn parse_spec(spec: &str) -> Result<(Option<u32>, Option<u32>), String> {
let gid = if grp_only || usr_grp {
Some(
Group::locate(args[1])
.map_err(|_| format!("invalid group: {}", spec))?
.map_err(|_| format!("invalid group: '{}'", spec))?
.gid(),
)
} else {
+1 -1
View File
@@ -1254,7 +1254,7 @@ fn copy_link(source: &Path, dest: &Path) -> CopyResult<()> {
Some(name) => dest.join(name).into(),
None => crash!(
EXIT_ERR,
"cannot stat {}: No such file or directory",
"cannot stat '{}': No such file or directory",
source.display()
),
}
+3 -3
View File
@@ -210,7 +210,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
if !form.starts_with('+') {
eprintln!("date: invalid date {}", form);
eprintln!("date: invalid date '{}'", form);
return 1;
}
let form = form[1..].to_string();
@@ -239,7 +239,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let set_to = match matches.value_of(OPT_SET).map(parse_date) {
None => None,
Some(Err((input, _err))) => {
eprintln!("date: invalid date {}", input);
eprintln!("date: invalid date '{}'", input);
return 1;
}
Some(Ok(date)) => Some(date),
@@ -305,7 +305,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
println!("{}", formatted);
}
Err((input, _err)) => {
println!("date: invalid date {}", input);
println!("date: invalid date '{}'", input);
}
}
}
+2 -2
View File
@@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if matches.is_present(options::PRINT_DATABASE) {
if !files.is_empty() {
show_usage_error!(
"extra operand {}\nfile operands cannot be combined with \
"extra operand '{}'\nfile operands cannot be combined with \
--print-database (-p)",
files[0]
);
@@ -155,7 +155,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
result = parse(INTERNAL_DB.lines(), out_format, "")
} else {
if files.len() > 1 {
show_usage_error!("extra operand {}", files[1]);
show_usage_error!("extra operand '{}'", files[1]);
return 1;
}
match File::open(files[0]) {
+5 -9
View File
@@ -274,7 +274,7 @@ fn du(
Err(e) => {
safe_writeln!(
stderr(),
"{}: cannot read directory {}: {}",
"{}: cannot read directory '{}': {}",
options.program_name,
my_stat.path.display(),
e
@@ -318,9 +318,7 @@ fn du(
let error_message = "Permission denied";
show_error_custom_description!(description, "{}", error_message)
}
_ => {
show_error!("cannot access '{}': {}", entry.path().display(), error)
}
_ => show_error!("cannot access '{}': {}", entry.path().display(), error),
},
},
Err(error) => show_error!("{}", error),
@@ -594,9 +592,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let files = match matches.value_of(options::FILE) {
Some(_) => matches.values_of(options::FILE).unwrap().collect(),
None => {
vec!["."]
}
None => vec!["."],
};
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();
@@ -693,8 +689,8 @@ Try '{} --help' for more information.",
time
} else {
show_error!(
"Invalid argument {} for --time.
birth and creation arguments are not supported on this platform.",
"Invalid argument '{}' for --time.
'birth' and 'creation' arguments are not supported on this platform.",
s
);
return 1;
+1 -1
View File
@@ -269,7 +269,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
match Passwd::locate(users[i].as_str()) {
Ok(p) => Some(p),
Err(_) => {
show_error!("{}: no such user", users[i]);
show_error!("'{}': no such user", users[i]);
exit_code = 1;
if i + 1 >= users.len() {
break;
+2 -2
View File
@@ -373,7 +373,7 @@ impl Config {
.value_of(options::WIDTH)
.map(|x| {
x.parse::<u16>().unwrap_or_else(|_e| {
show_error!("invalid line width: {}", x);
show_error!("invalid line width: '{}'", x);
exit(2);
})
})
@@ -756,7 +756,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Arg::with_name(options::time::CHANGE)
.short(options::time::CHANGE)
.help("If the long listing format (e.g., -l, -o) is being used, print the status \
change time (the ctime in the inode) instead of the modification time. When \
change time (the 'ctime' in the inode) instead of the modification time. When \
explicitly sorting by time (--sort=time or -t) or when not using a long listing \
format, sort according to the status change time.")
.overrides_with_all(&[
+1 -1
View File
@@ -210,7 +210,7 @@ fn valid_type(tpe: String) -> Result<(), String> {
if vec!['b', 'c', 'u', 'p'].contains(&first_char) {
Ok(())
} else {
Err(format!("invalid device type {}", tpe))
Err(format!("invalid device type '{}'", tpe))
}
})
}
+1 -1
View File
@@ -154,7 +154,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() {
show_error!(
"invalid template, {}; with --tmpdir, it may not be absolute",
"invalid template, '{}'; with --tmpdir, it may not be absolute",
template
);
return 1;
+11 -11
View File
@@ -230,7 +230,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
// lacks permission to access metadata.
if source.symlink_metadata().is_err() {
show_error!(
"cannot stat {}: No such file or directory",
"cannot stat '{}': No such file or directory",
source.display()
);
return 1;
@@ -240,7 +240,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
if b.no_target_dir {
if !source.is_dir() {
show_error!(
"cannot overwrite directory {} with non-directory",
"cannot overwrite directory '{}' with non-directory",
target.display()
);
return 1;
@@ -249,7 +249,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
return match rename(source, target, &b) {
Err(e) => {
show_error!(
"cannot move {} to {}: {}",
"cannot move '{}' to '{}': {}",
source.display(),
target.display(),
e.to_string()
@@ -263,7 +263,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
return move_files_into_dir(&[source.clone()], target, &b);
} else if target.exists() && source.is_dir() {
show_error!(
"cannot overwrite non-directory {} with directory {}",
"cannot overwrite non-directory '{}' with directory '{}'",
target.display(),
source.display()
);
@@ -278,7 +278,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
_ => {
if b.no_target_dir {
show_error!(
"mv: extra operand {}\n\
"mv: extra operand '{}'\n\
Try '{} --help' for more information.",
files[2].display(),
executable!()
@@ -294,7 +294,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i32 {
if !target_dir.is_dir() {
show_error!("target {} is not a directory", target_dir.display());
show_error!("target '{}' is not a directory", target_dir.display());
return 1;
}
@@ -304,7 +304,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
Some(name) => target_dir.join(name),
None => {
show_error!(
"cannot stat {}: No such file or directory",
"cannot stat '{}': No such file or directory",
sourcepath.display()
);
@@ -315,7 +315,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
if let Err(e) = rename(sourcepath, &targetpath, b) {
show_error!(
"cannot move {} to {}: {}",
"cannot move '{}' to '{}': {}",
sourcepath.display(),
targetpath.display(),
e.to_string()
@@ -338,7 +338,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
match b.overwrite {
OverwriteMode::NoClobber => return Ok(()),
OverwriteMode::Interactive => {
println!("{}: overwrite {}? ", executable!(), to.display());
println!("{}: overwrite '{}'? ", executable!(), to.display());
if !read_yes() {
return Ok(());
}
@@ -371,9 +371,9 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
rename_with_fallback(from, to)?;
if b.verbose {
print!("{} -> {}", from.display(), to.display());
print!("'{}' -> '{}'", from.display(), to.display());
match backup_path {
Some(path) => println!(" (backup: {})", path.display()),
Some(path) => println!(" (backup: '{}')", path.display()),
None => println!(),
}
}
+3 -3
View File
@@ -62,7 +62,7 @@ impl<'a> Iterator for WhitespaceSplitter<'a> {
fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
if s.is_empty() {
return Err("invalid number: ‘’".to_string());
return Err("invalid number: ''".to_string());
}
let with_i = s.ends_with('i');
@@ -80,7 +80,7 @@ fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
Some('Z') => Ok(Some((RawSuffix::Z, with_i))),
Some('Y') => Ok(Some((RawSuffix::Y, with_i))),
Some('0'..='9') => Ok(None),
_ => Err(format!("invalid suffix in input: {}", s)),
_ => Err(format!("invalid suffix in input: '{}'", s)),
}?;
let suffix_len = match suffix {
@@ -91,7 +91,7 @@ fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
let number = s[..s.len() - suffix_len]
.parse::<f64>()
.map_err(|_| format!("invalid number: {}", s))?;
.map_err(|_| format!("invalid number: '{}'", s))?;
Ok((number, suffix))
}
+1 -1
View File
@@ -114,7 +114,7 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
0 => Err(value),
_ => Ok(n),
})
.map_err(|value| format!("invalid header value {}", value))
.map_err(|value| format!("invalid header value '{}'", value))
}
}?;
+1 -1
View File
@@ -234,7 +234,7 @@ fn idle_string(when: i64) -> String {
}
fn time_string(ut: &Utmpx) -> String {
time::strftime("%Y-%m-%d %H:%M", &ut.login_time()).unwrap()
time::strftime("%b %e %H:%M", &ut.login_time()).unwrap() // LC_ALL=C
}
impl Pinky {
+1 -1
View File
@@ -234,7 +234,7 @@ impl LineSplitter {
fn new(settings: &Settings) -> LineSplitter {
LineSplitter {
lines_per_split: settings.strategy_param.parse().unwrap_or_else(|_| {
crash!(1, "invalid number of lines: {}", settings.strategy_param)
crash!(1, "invalid number of lines: '{}'", settings.strategy_param)
}),
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ use std::{cmp, fs, iter};
macro_rules! check_bound {
($str: ident, $bound:expr, $beg: expr, $end: expr) => {
if $end >= $bound {
return Err(format!("{}: invalid directive", &$str[$beg..$end]));
return Err(format!("'{}': invalid directive", &$str[$beg..$end]));
}
};
}
+2 -2
View File
@@ -167,7 +167,7 @@ impl Parser {
self.expr();
match self.next_token() {
Symbol::Literal(s) if s == ")" => (),
_ => panic!("expected )"),
_ => panic!("expected ')'"),
}
}
}
@@ -314,7 +314,7 @@ impl Parser {
self.expr();
match self.tokens.next() {
Some(token) => Err(format!("extra argument {}", token.to_string_lossy())),
Some(token) => Err(format!("extra argument '{}'", token.to_string_lossy())),
None => Ok(()),
}
}
+4 -4
View File
@@ -88,7 +88,7 @@ fn eval(stack: &mut Vec<Symbol>) -> Result<bool, String> {
return Ok(true);
}
_ => {
return Err(format!("missing argument after {:?}", op));
return Err(format!("missing argument after '{:?}'", op));
}
};
@@ -140,7 +140,7 @@ fn eval(stack: &mut Vec<Symbol>) -> Result<bool, String> {
}
fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result<bool, String> {
let format_err = |value| format!("invalid integer {}", value);
let format_err = |value| format!("invalid integer '{}'", value);
let a = a.to_string_lossy();
let a: i64 = a.parse().map_err(|_| format_err(a))?;
@@ -156,7 +156,7 @@ fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result<bool, String> {
"-ge" => a >= b,
"-lt" => a < b,
"-le" => a <= b,
_ => return Err(format!("unknown operator {}", operator)),
_ => return Err(format!("unknown operator '{}'", operator)),
})
}
@@ -164,7 +164,7 @@ fn isatty(fd: &OsStr) -> Result<bool, String> {
let fd = fd.to_string_lossy();
fd.parse()
.map_err(|_| format!("invalid integer {}", fd))
.map_err(|_| format!("invalid integer '{}'", fd))
.map(|i| {
#[cfg(not(target_os = "redox"))]
unsafe {
+1 -1
View File
@@ -311,7 +311,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if !(delete_flag || squeeze_flag) && sets.len() < 2 {
show_error!(
"missing operand after {}\nTry `{} --help` for more information.",
"missing operand after '{}'\nTry `{} --help` for more information.",
sets[0],
executable!()
);
+1 -1
View File
@@ -210,7 +210,7 @@ fn truncate_reference_and_size(
let mode = match parse_mode_and_size(size_string) {
Ok(m) => match m {
TruncateMode::Absolute(_) => {
crash!(1, "you must specify a relative --size with --reference")
crash!(1, "you must specify a relative '--size' with '--reference'")
}
_ => m,
},

Some files were not shown because too many files have changed in this diff Show More