printf: remove all uses of length modifiers

Length modifiers are useless. This simplifies the code a bit, results in
more consistency, and allows removing a few PO messages which only
differed in the use of length modifiers.

Closes #11878
This commit is contained in:
Daniel Rainer
2025-10-02 22:10:01 +02:00
committed by Johannes Altmanninger
parent e9f5982147
commit 83af5c91bd
91 changed files with 6138 additions and 6240 deletions

View File

@@ -343,7 +343,7 @@ command-line and graphical user interface programs. For simple use, you can use
Open up the PO file, for example ``po/sv.po``, and you'll see something like::
msgid "%ls: No suitable job\n"
msgid "%s: No suitable job\n"
msgstr ""
The ``msgid`` here is the "name" of the string to translate, typically the English string to translate.
@@ -351,10 +351,10 @@ The second line (``msgstr``) is where your translation goes.
For example::
msgid "%ls: No suitable job\n"
msgstr "%ls: Inget passande jobb\n"
msgid "%s: No suitable job\n"
msgstr "%s: Inget passande jobb\n"
Any ``%s`` / ``%ls`` or ``%d`` are placeholders that fish will use for formatting at runtime. It is important that they match - the translated string should have the same placeholders in the same order.
Any ``%s`` or ``%d`` are placeholders that fish will use for formatting at runtime. It is important that they match - the translated string should have the same placeholders in the same order.
Also any escaped characters, like that ``\n`` newline at the end, should be kept so the translation has the same behavior.
@@ -381,7 +381,7 @@ macros:
::
streams.out.append(wgettext_fmt!("%ls: There are no jobs\n", argv[0]));
streams.out.append(wgettext_fmt!("%s: There are no jobs\n", argv[0]));
All messages in fish script must be enclosed in single or double quote
characters for our message extraction script to find them.

View File

@@ -77,7 +77,7 @@ fn write_str(&mut self, _s: &str) -> fmt::Result {
#[test]
fn smoke() {
assert_fmt!("Hello, %s!", "world" => "Hello, world!");
assert_fmt!("Hello, %ls!", "world" => "Hello, world!");
assert_fmt!("Hello, %ls!", "world" => "Hello, world!"); // length modifier
assert_fmt!("Hello, world! %d %%%%", 3 => "Hello, world! 3 %%");
assert_fmt!("" => "");
}
@@ -234,6 +234,7 @@ fn test_int() {
assert_fmt!("%2o", 4 => " 4");
assert_fmt!("% 12d", -4 => " -4");
assert_fmt!("% 12d", 48 => " 48");
// with length modifier
assert_fmt!("%ld", -4_i64 => "-4");
assert_fmt!("%lld", -4_i64 => "-4");
assert_fmt!("%lX", -4_i64 => "FFFFFFFFFFFFFFFC");
@@ -248,6 +249,7 @@ fn test_int() {
assert_fmt!("%9X", 492 => " 1EC");
assert_fmt!("% 12u", 4 => " 4");
assert_fmt!("% 12u", 48 => " 48");
// with length modifier
assert_fmt!("%lu", 4_u64 => "4");
assert_fmt!("%llu", 4_u64 => "4");
assert_fmt!("%lX", 4_u64 => "4");
@@ -414,6 +416,7 @@ fn test_float() {
assert_fmt1!("%f", 0.0, "0.000000");
assert_fmt1!("%g", 0.0, "0");
assert_fmt1!("%#g", 0.0, "0.00000");
// with length modifier
assert_fmt1!("%la", 0.0, "0x0p+0");
assert_fmt1!("%le", 0.0, "0.000000e+00");
assert_fmt1!("%lf", 0.0, "0.000000");
@@ -430,7 +433,7 @@ fn test_float() {
assert_fmt1!("%.4f", 1.03125, "1.0312"); /* 0x1.08p0 */
assert_fmt1!("%.2f", 1.375, "1.38");
assert_fmt1!("%.1f", 1.375, "1.4");
assert_fmt1!("%.1lf", 1.375, "1.4");
assert_fmt1!("%.1lf", 1.375, "1.4"); // length modifier
assert_fmt1!("%.15f", 1.1, "1.100000000000000");
assert_fmt1!("%.16f", 1.1, "1.1000000000000001");
assert_fmt1!("%.17f", 1.1, "1.10000000000000009");
@@ -755,8 +758,8 @@ fn test_errors() {
sprintf_err!("%1", => BadFormatString);
sprintf_err!("%%%k", => BadFormatString);
sprintf_err!("%B", => BadFormatString);
sprintf_err!("%lC", 'q' => BadFormatString);
sprintf_err!("%lS", 'q' => BadFormatString);
sprintf_err!("%lC", 'q' => BadFormatString); // length modifier
sprintf_err!("%lS", 'q' => BadFormatString); // length modifier
sprintf_err!("%d", => MissingArg);
sprintf_err!("%d %u", 1 => MissingArg);
sprintf_err!("%*d", 5 => MissingArg);

1660
po/de.po

File diff suppressed because it is too large Load Diff

1612
po/en.po

File diff suppressed because it is too large Load Diff

1624
po/fr.po

File diff suppressed because it is too large Load Diff

1600
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1584
po/sv.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ function funced --description 'Edit function definition'
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") funced 1 0
printf (_ "%s: Expected at least %d args, got only %d\n") funced 1 0
return 1
end

View File

@@ -17,7 +17,7 @@ function funcsave --description "Save the current definition of all specified fu
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") funcsave 1 0 >&2
printf (_ "%s: Expected at least %d args, got only %d\n") funcsave 1 0 >&2
return 1
end

View File

@@ -185,11 +185,11 @@ function history --description "display or manipulate interactive command histor
case clear # clear the interactive command history
if test -n "$search_mode"
or set -q show_time[1]
printf (_ "%ls: %ls: subcommand takes no options\n") history $hist_cmd >&2
printf (_ "%s: %s: subcommand takes no options\n") history $hist_cmd >&2
return 1
end
if set -q argv[1]
printf (_ "%ls: %ls: expected %d arguments; got %d\n") history $hist_cmd 0 (count $argv) >&2
printf (_ "%s: %s: expected %d arguments; got %d\n") history $hist_cmd 0 (count $argv) >&2
return 1
end
@@ -214,7 +214,7 @@ function history --description "display or manipulate interactive command histor
builtin history append $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $newitem
case '*'
printf "%ls: unexpected subcommand '%ls'\n" $cmd $hist_cmd
printf "%s: unexpected subcommand '%s'\n" $cmd $hist_cmd
return 2
end
end

View File

@@ -15,7 +15,7 @@ if not command -sq open
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") open 1 0 >&2
printf (_ "%s: Expected at least %d args, got only %d\n") open 1 0 >&2
return 1
end

View File

@@ -163,10 +163,10 @@ fn describe(&self) -> WString {
let mut res = ast_kind_to_string(self.kind()).to_owned();
if let Some(n) = self.as_token() {
let token_type = n.token_type().to_wstr();
sprintf!(=> &mut res, " '%ls'", token_type);
sprintf!(=> &mut res, " '%s'", token_type);
} else if let Some(n) = self.as_keyword() {
let keyword = n.keyword().to_wstr();
sprintf!(=> &mut res, " '%ls'", keyword);
sprintf!(=> &mut res, " '%s'", keyword);
}
res
}
@@ -1447,23 +1447,23 @@ pub fn dump(&self, orig: &wstr) -> WString {
if let Kind::Argument(n) = node.kind() {
result += "argument";
if let Some(argsrc) = n.try_source(orig) {
sprintf!(=> &mut result, ": '%ls'", argsrc);
sprintf!(=> &mut result, ": '%s'", argsrc);
}
} else if let Some(n) = node.as_keyword() {
sprintf!(=> &mut result, "keyword: %ls", n.keyword().to_wstr());
sprintf!(=> &mut result, "keyword: %s", n.keyword().to_wstr());
} else if let Some(n) = node.as_token() {
let desc = match n.token_type() {
ParseTokenType::string => {
let mut desc = WString::from_str("string");
if let Some(strsource) = n.try_source(orig) {
sprintf!(=> &mut desc, ": '%ls'", strsource);
sprintf!(=> &mut desc, ": '%s'", strsource);
}
desc
}
ParseTokenType::redirection => {
let mut desc = WString::from_str("redirection");
if let Some(strsource) = n.try_source(orig) {
sprintf!(=> &mut desc, ": '%ls'", strsource);
sprintf!(=> &mut desc, ": '%s'", strsource);
}
desc
}
@@ -1804,7 +1804,7 @@ fn visit_mut<N: NodeMut>(&mut self, node: &mut N) -> VisitResult {
fn will_visit_fields_of<N: NodeMut>(&mut self, node: &mut N) {
FLOGF!(
ast_construction,
"%*swill_visit %ls",
"%*swill_visit %s",
self.spaces(),
"",
node.describe()
@@ -1881,7 +1881,7 @@ fn did_visit_fields_of<'a, N: NodeMut>(&'a mut self, node: &'a mut N, flow: Visi
self,
header_kw_range,
ParseErrorCode::generic,
"Missing end to balance this %ls",
"Missing end to balance this %s",
enclosing_stmt
);
} else {
@@ -1889,7 +1889,7 @@ fn did_visit_fields_of<'a, N: NodeMut>(&'a mut self, node: &'a mut N, flow: Visi
self,
token,
ParseErrorCode::generic,
"Expected %ls, but found %ls",
"Expected %s, but found %s",
keywords_user_presentable_description(error.allowed_keywords),
error.token.user_presentable_description(),
);
@@ -1907,14 +1907,14 @@ fn visit_optional_mut<N: NodeMut + CheckParse>(&mut self, node: &mut Option<N>)
fn keywords_user_presentable_description(kws: &'static [ParseKeyword]) -> WString {
assert!(!kws.is_empty(), "Should not be empty list");
if kws.len() == 1 {
return sprintf!("keyword '%ls'", kws[0]);
return sprintf!("keyword '%s'", kws[0]);
}
let mut res = L!("keywords ").to_owned();
for (i, kw) in kws.iter().enumerate() {
if i != 0 {
res += L!(" or ");
}
res += &sprintf!("'%ls'", *kw)[..];
res += &sprintf!("'%s'", *kw)[..];
}
res
}
@@ -2032,7 +2032,7 @@ fn list_kind_chomps_newlines(&self, kind: Kind) -> bool {
internal_error!(
self,
list_kind_chomps_newlines,
"Type %ls not handled",
"Type %s not handled",
ast_kind_to_string(kind)
);
}
@@ -2082,7 +2082,7 @@ fn list_kind_chomps_semis(&self, kind: Kind) -> bool {
internal_error!(
self,
list_kind_chomps_semis,
"Type %ls not handled",
"Type %s not handled",
ast_kind_to_string(kind)
);
}
@@ -2155,7 +2155,7 @@ fn consume_token_type(&mut self, typ: ParseTokenType) -> SourceRange {
self,
tok,
ParseErrorCode::generic,
"Expected %ls, but found %ls",
"Expected %s, but found %s",
token_type_user_presentable_description(typ, ParseKeyword::None),
tok.user_presentable_description()
);
@@ -2180,7 +2180,7 @@ fn consume_excess_token_generating_error(&mut self) {
self,
tok,
ParseErrorCode::generic,
"Expected %ls, but found %ls",
"Expected %s, but found %s",
token_type_user_presentable_description(ParseTokenType::string, ParseKeyword::None),
tok.user_presentable_description()
);
@@ -2219,7 +2219,7 @@ fn consume_excess_token_generating_error(&mut self) {
internal_error!(
self,
consume_excess_token_generating_error,
"Token %ls should not have prevented parsing a job list",
"Token %s should not have prevented parsing a job list",
tok.user_presentable_description()
);
}
@@ -2244,7 +2244,7 @@ fn consume_excess_token_generating_error(&mut self) {
self,
tok,
ParseErrorCode::generic,
"Expected a string, but found %ls",
"Expected a string, but found %s",
tok.user_presentable_description()
);
}
@@ -2253,7 +2253,7 @@ fn consume_excess_token_generating_error(&mut self) {
self,
tok,
ParseErrorCode::from(tok.tok_error),
"%ls",
"%s",
tok.tok_error
);
}
@@ -2275,7 +2275,7 @@ fn consume_excess_token_generating_error(&mut self) {
internal_error!(
self,
consume_excess_token_generating_error,
"Unexpected excess token type: %ls",
"Unexpected excess token type: %s",
tok.user_presentable_description()
);
}
@@ -2301,7 +2301,7 @@ fn populate_list<Contents, List>(&mut self, list: &mut List, exhaust_stream: boo
// Mark in the list that it was unwound.
FLOGF!(
ast_construction,
"%*sunwinding %ls",
"%*sunwinding %s",
self.spaces(),
"",
ast_kind_to_string(list.kind())
@@ -2379,7 +2379,7 @@ fn populate_list<Contents, List>(&mut self, list: &mut List, exhaust_stream: boo
FLOGF!(
ast_construction,
"%*s%ls size: %lu",
"%*s%s size: %u",
self.spaces(),
"",
ast_kind_to_string(list.kind()),
@@ -2403,7 +2403,7 @@ fn new_decorated_statement(slf: &mut Populator<'_>) -> Statement {
slf,
slf.peek_token(0),
ParseErrorCode::generic,
"Expected %s, but found %ls",
"Expected %s, but found %s",
token_type_user_presentable_description(
ParseTokenType::end,
ParseKeyword::None
@@ -2428,7 +2428,7 @@ fn new_decorated_statement(slf: &mut Populator<'_>) -> Statement {
self,
self.peek_token(0),
ParseErrorCode::generic,
"Expected a command, but found %ls",
"Expected a command, but found %s",
self.peek_token(0).user_presentable_description()
);
return got_error(self);
@@ -2517,7 +2517,7 @@ fn new_decorated_statement(slf: &mut Populator<'_>) -> Statement {
self,
self.peek_token(0),
ParseErrorCode::generic,
"Expected a command, but found %ls",
"Expected a command, but found %s",
self.peek_token(0).user_presentable_description()
);
return got_error(self);
@@ -2659,7 +2659,7 @@ fn visit_token(&mut self, token: &mut dyn Token) {
self,
self.peek_token(0),
ParseErrorCode::generic,
"Expected %ls, but found %ls",
"Expected %s, but found %s",
token_types_user_presentable_description(token.allowed_tokens()),
self.peek_token(0).user_presentable_description()
);
@@ -2703,7 +2703,7 @@ fn visit_keyword(&mut self, keyword: &mut dyn Keyword) -> VisitResult {
self,
self.peek_token(0),
ParseErrorCode::generic,
"Expected %ls, but found %ls",
"Expected %s, but found %s",
keywords_user_presentable_description(allowed_keywords),
self.peek_token(0).user_presentable_description(),
);

View File

@@ -116,12 +116,12 @@ pub fn resolve_command(&mut self, cmd: &wstr, env: &dyn Environment) -> Option<A
match &path {
#[cfg(feature = "embed-data")]
AutoloadPath::Embedded(_) => {
FLOGF!(autoload, "Embedded: %ls", cmd);
FLOGF!(autoload, "Embedded: %s", cmd);
}
AutoloadPath::Path(path) => {
FLOGF!(
autoload,
"Loading %ls from var %ls from path %ls",
"Loading %s from var %s from path %s",
cmd,
self.env_var_name,
path
@@ -152,14 +152,14 @@ pub fn perform_autoload(path: &AutoloadPath, parser: &Parser) {
AutoloadPath::Embedded(name) => {
use crate::common::str2wcstring;
use std::sync::Arc;
FLOGF!(autoload, "Loading embedded: %ls", name);
FLOGF!(autoload, "Loading embedded: %s", name);
let emfile = Asset::get(name).expect("Embedded file not found");
let src = str2wcstring(&emfile.data);
let mut widename = L!("embedded:").to_owned();
widename.push_str(name);
let ret = parser.eval_file_wstr(src, Arc::new(widename), &IoChain::new(), None);
if let Err(msg) = ret {
eprintf!("%ls", msg);
eprintf!("%s", msg);
}
}
}
@@ -527,8 +527,8 @@ fn touch_file(path: &wstr) {
.is_none());
assert!(autoload.get_autoloaded_commands().is_empty());
run!("touch %ls/file1.fish", p1);
run!("touch %ls/file2.fish", p2);
run!("touch %s/file1.fish", p1);
run!("touch %s/file2.fish", p2);
autoload.invalidate_cache();
assert!(!autoload.autoload_in_progress(L!("file1")));
@@ -586,11 +586,11 @@ fn touch_file(path: &wstr) {
autoload.resolve_command_impl(L!("file1"), paths),
AutoloadResult::Loaded
));
touch_file(&sprintf!("%ls/file1.fish", p1));
touch_file(&sprintf!("%s/file1.fish", p1));
autoload.invalidate_cache();
assert!(autoload.resolve_command_impl(L!("file1"), paths).is_some());
autoload.mark_autoload_finished(L!("file1"));
run!(L!("rm -Rf %ls"), p1);
run!(L!("rm -Rf %ls"), p2);
run!(L!("rm -Rf %s"), p1);
run!(L!("rm -Rf %s"), p2);
}

View File

@@ -156,7 +156,7 @@ fn source_config_in_directory(parser: &Parser, dir: &wstr) -> bool {
if waccess(&config_pathname, libc::R_OK) != 0 {
FLOGF!(
config,
"not sourcing %ls (not readable or does not exist)",
"not sourcing %s (not readable or does not exist)",
escaped_pathname
);
return false;
@@ -182,7 +182,7 @@ fn read_init(parser: &Parser, paths: &ConfigPaths) {
let ret = parser.eval_file_wstr(src, fname, &IoChain::new(), None);
parser.libdata_mut().within_fish_init = false;
if let Err(msg) = ret {
eprintf!("%ls", msg);
eprintf!("%s", msg);
}
}
#[cfg(not(feature = "embed-data"))]
@@ -196,7 +196,7 @@ fn read_init(parser: &Parser, paths: &ConfigPaths) {
let escaped_pathname = escape(&datapath);
FLOGF!(
error,
"Fish cannot find its asset files in '%ls'.\n\
"Fish cannot find its asset files in '%s'.\n\
Refusing to read configuration because of this.",
escaped_pathname,
);
@@ -287,7 +287,7 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow<i
activate_flog_categories_by_pattern(w.woptarg.unwrap());
for cat in flog::categories::all_categories() {
if cat.enabled.load(Ordering::Relaxed) {
printf!("Debug enabled for category: %ls\n", cat.name);
printf!("Debug enabled for category: %s\n", cat.name);
}
}
}
@@ -315,7 +315,7 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow<i
for cat in cats.iter() {
let desc = cat.description.localize();
// this is left-justified
printf!("%-*ls %ls\n", name_width, cat.name, desc);
printf!("%-*s %s\n", name_width, cat.name, desc);
}
return ControlFlow::Break(0);
}
@@ -342,21 +342,21 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow<i
}
'?' => {
eprintf!(
"%ls\n",
"%s\n",
wgettext_fmt!(BUILTIN_ERR_UNKNOWN, "fish", args[w.wopt_index - 1])
);
return ControlFlow::Break(1);
}
':' => {
eprintf!(
"%ls\n",
"%s\n",
wgettext_fmt!(BUILTIN_ERR_MISSING, "fish", args[w.wopt_index - 1])
);
return ControlFlow::Break(1);
}
';' => {
eprintf!(
"%ls\n",
"%s\n",
wgettext_fmt!(BUILTIN_ERR_UNEXP_ARG, "fish", args[w.wopt_index - 1])
);
return ControlFlow::Break(1);
@@ -623,7 +623,7 @@ fn throwing_main() -> i32 {
if res.is_err() {
FLOGF!(
warning,
wgettext!("Error while reading file %ls\n"),
wgettext!("Error while reading file %s\n"),
path.to_string_lossy()
);
}

View File

@@ -48,7 +48,7 @@ fn validate(&mut self, streams: &mut IoStreams) -> bool {
if cmds.len() > 1 {
streams.err.append(wgettext_fmt!(
"%ls: Cannot combine options %ls\n",
"%s: Cannot combine options %s\n",
CMD,
join(&cmds, L!(", "))
));
@@ -63,28 +63,26 @@ fn validate(&mut self, streams: &mut IoStreams) -> bool {
}
if !self.add && self.position.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: --position option requires --add\n",
CMD
));
streams
.err
.append(wgettext_fmt!("%s: --position option requires --add\n", CMD));
return false;
}
if !self.add && self.regex_pattern.is_some() {
streams
.err
.append(wgettext_fmt!("%ls: --regex option requires --add\n", CMD));
.append(wgettext_fmt!("%s: --regex option requires --add\n", CMD));
return false;
}
if !self.add && self.function.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: --function option requires --add\n",
CMD
));
streams
.err
.append(wgettext_fmt!("%s: --function option requires --add\n", CMD));
return false;
}
if !self.add && self.set_cursor_marker.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: --set-cursor option requires --add\n",
"%s: --set-cursor option requires --add\n",
CMD
));
return false;
@@ -96,7 +94,7 @@ fn validate(&mut self, streams: &mut IoStreams) -> bool {
.unwrap_or(false)
{
streams.err.append(wgettext_fmt!(
"%ls: --set-cursor argument cannot be empty\n",
"%s: --set-cursor argument cannot be empty\n",
CMD
));
return false;
@@ -182,7 +180,7 @@ fn abbr_list(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
const subcmd: &wstr = L!("--list");
if !opts.args.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls %ls: Unexpected argument -- '%ls'\n",
"%s %s: Unexpected argument -- '%s'\n",
CMD,
subcmd,
&opts.args[0]
@@ -206,7 +204,7 @@ fn abbr_rename(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
if opts.args.len() != 2 {
streams.err.append(wgettext_fmt!(
"%ls %ls: Requires exactly two arguments\n",
"%s %s: Requires exactly two arguments\n",
CMD,
subcmd
));
@@ -215,17 +213,15 @@ fn abbr_rename(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
let old_name = &opts.args[0];
let new_name = &opts.args[1];
if old_name.is_empty() || new_name.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls %ls: Name cannot be empty\n",
CMD,
subcmd
));
streams
.err
.append(wgettext_fmt!("%s %s: Name cannot be empty\n", CMD, subcmd));
return Err(STATUS_INVALID_ARGS);
}
if contains_whitespace(new_name) {
streams.err.append(wgettext_fmt!(
"%ls %ls: Abbreviation '%ls' cannot have spaces in the word\n",
"%s %s: Abbreviation '%s' cannot have spaces in the word\n",
CMD,
subcmd,
new_name.as_utfstr()
@@ -235,7 +231,7 @@ fn abbr_rename(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
abbrs::with_abbrs_mut(|abbrs| -> BuiltinResult {
if !abbrs.has_name(old_name) {
streams.err.append(wgettext_fmt!(
"%ls %ls: No abbreviation named %ls\n",
"%s %s: No abbreviation named %s\n",
CMD,
subcmd,
old_name.as_utfstr()
@@ -244,7 +240,7 @@ fn abbr_rename(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
}
if abbrs.has_name(new_name) {
streams.err.append(wgettext_fmt!(
"%ls %ls: Abbreviation %ls already exists, cannot rename %ls\n",
"%s %s: Abbreviation %s already exists, cannot rename %s\n",
CMD,
subcmd,
new_name.as_utfstr(),
@@ -280,7 +276,7 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
if opts.args.len() < 2 && opts.function.is_none() {
streams.err.append(wgettext_fmt!(
"%ls %ls: Requires at least two arguments\n",
"%s %s: Requires at least two arguments\n",
CMD,
subcmd
));
@@ -288,17 +284,15 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
}
if opts.args.is_empty() || opts.args[0].is_empty() {
streams.err.append(wgettext_fmt!(
"%ls %ls: Name cannot be empty\n",
CMD,
subcmd
));
streams
.err
.append(wgettext_fmt!("%s %s: Name cannot be empty\n", CMD, subcmd));
return Err(STATUS_INVALID_ARGS);
}
let name = &opts.args[0];
if name.chars().any(|c| c.is_whitespace()) {
streams.err.append(wgettext_fmt!(
"%ls %ls: Abbreviation '%ls' cannot have spaces in the word\n",
"%s %s: Abbreviation '%s' cannot have spaces in the word\n",
CMD,
subcmd,
name.as_utfstr()
@@ -319,17 +313,15 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
if let Err(error) = result {
streams.err.append(wgettext_fmt!(
"%ls: Regular expression compile error: %ls\n",
"%s: Regular expression compile error: %s\n",
CMD,
error.error_message(),
));
if let Some(offset) = error.offset() {
streams
.err
.append(wgettext_fmt!("%ls: %ls\n", CMD, regex_pattern.as_utfstr()));
streams
.err
.append(sprintf!("%ls: %*ls\n", CMD, offset, "^"));
.append(wgettext_fmt!("%s: %s\n", CMD, regex_pattern.as_utfstr()));
streams.err.append(sprintf!("%s: %*s\n", CMD, offset, "^"));
}
return Err(STATUS_INVALID_ARGS);
}
@@ -359,7 +351,7 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
// This is to prevent accidental usage of e.g. `--function 'string replace'`
if !valid_func_name(function) || contains_whitespace(function) {
streams.err.append(wgettext_fmt!(
"%ls: Invalid function name: %ls\n",
"%s: Invalid function name: %s\n",
CMD,
function.as_utfstr()
));
@@ -387,7 +379,7 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
});
if !opts.commands.is_empty() && position == Position::Command {
streams.err.appendln(wgettext_fmt!(
"%ls: --command cannot be combined with --position command",
"%s: --command cannot be combined with --position command",
CMD,
));
return Err(STATUS_INVALID_ARGS);
@@ -501,7 +493,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
'p' => {
if opts.position.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: Cannot specify multiple positions\n",
"%s: Cannot specify multiple positions\n",
CMD
));
return Err(STATUS_INVALID_ARGS);
@@ -512,7 +504,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
opts.position = Some(Position::Anywhere);
} else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid position '%ls'\n",
"%s: Invalid position '%s'\n",
CMD,
w.woptarg.unwrap_or_default()
));
@@ -525,7 +517,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
'r' => {
if opts.regex_pattern.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: Cannot specify multiple regex patterns\n",
"%s: Cannot specify multiple regex patterns\n",
CMD
));
return Err(STATUS_INVALID_ARGS);
@@ -535,7 +527,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
SET_CURSOR_SHORT => {
if opts.set_cursor_marker.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: Cannot specify multiple set-cursor options\n",
"%s: Cannot specify multiple set-cursor options\n",
CMD
));
return Err(STATUS_INVALID_ARGS);
@@ -558,7 +550,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
'U' => {
// Kept and made ineffective, so we warn.
streams.err.append(wgettext_fmt!(
"%ls: Warning: Option '%ls' was removed and is now ignored",
"%s: Warning: Option '%s' was removed and is now ignored",
cmd,
argv_read[w.wopt_index - 1]
));

View File

@@ -10,7 +10,7 @@
localizable_consts!(
BUILTIN_ERR_INVALID_OPT_SPEC
"%ls: Invalid option spec '%ls' at char '%lc'\n"
"%s: Invalid option spec '%s' at char '%c'\n"
);
#[derive(Default)]
@@ -146,7 +146,7 @@ fn check_for_mutually_exclusive_flags(
std::mem::swap(&mut flag1, &mut flag2);
}
streams.err.append(wgettext_fmt!(
"%ls: %ls %ls: options cannot be used together\n",
"%s: %s %s: options cannot be used together\n",
opts.name,
flag1,
flag2
@@ -168,7 +168,7 @@ fn parse_exclusive_args(opts: &mut ArgParseCmdOpts, streams: &mut IoStreams) ->
let xflags: Vec<_> = raw_xflags.split(',').collect();
if xflags.len() < 2 {
streams.err.append(wgettext_fmt!(
"%ls: exclusive flag string '%ls' is not valid\n",
"%s: exclusive flag string '%s' is not valid\n",
opts.name,
raw_xflags
));
@@ -186,7 +186,7 @@ fn parse_exclusive_args(opts: &mut ArgParseCmdOpts, streams: &mut IoStreams) ->
exclusive_set.push(*short_equiv);
} else {
streams.err.append(wgettext_fmt!(
"%ls: exclusive flag '%ls' is not valid\n",
"%s: exclusive flag '%s' is not valid\n",
opts.name,
flag
));
@@ -215,7 +215,7 @@ fn parse_flag_modifiers<'args>(
&& s.char_at(0) != '&'
{
streams.err.append(wgettext_fmt!(
"%ls: Implicit int short flag '%lc' does not allow modifiers like '%lc'\n",
"%s: Implicit int short flag '%c' does not allow modifiers like '%c'\n",
opts.name,
opt_spec.short_flag,
s.char_at(0)
@@ -277,7 +277,7 @@ fn parse_flag_modifiers<'args>(
if opts.options.contains_key(&opt_spec.short_flag) {
streams.err.append(wgettext_fmt!(
"%ls: Short flag '%lc' already defined\n",
"%s: Short flag '%c' already defined\n",
opts.name,
opt_spec.short_flag
));
@@ -309,7 +309,7 @@ fn parse_option_spec_sep<'args>(
}
if opts.implicit_int_flag != '\0' {
streams.err.append(wgettext_fmt!(
"%ls: Implicit int flag '%lc' already defined\n",
"%s: Implicit int flag '%c' already defined\n",
opts.name,
opts.implicit_int_flag
));
@@ -351,7 +351,7 @@ fn parse_option_spec_sep<'args>(
'#' => {
if opts.implicit_int_flag != '\0' {
streams.err.append(wgettext_fmt!(
"%ls: Implicit int flag '%lc' already defined\n",
"%s: Implicit int flag '%c' already defined\n",
opts.name,
opts.implicit_int_flag
));
@@ -395,7 +395,7 @@ fn parse_option_spec<'args>(
) -> bool {
if option_spec.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls: An option spec must have at least a short or a long flag\n",
"%s: An option spec must have at least a short or a long flag\n",
opts.name
));
return false;
@@ -405,7 +405,7 @@ fn parse_option_spec<'args>(
if !fish_iswalnum(s.char_at(0)) && s.char_at(0) != '#' && !(s.char_at(0) == '/' && s.len() > 1)
{
streams.err.append(wgettext_fmt!(
"%ls: Short flag '%lc' invalid, must be alphanum or '#'\n",
"%s: Short flag '%c' invalid, must be alphanum or '#'\n",
opts.name,
s.char_at(0)
));
@@ -432,7 +432,7 @@ fn parse_option_spec<'args>(
opt_spec.long_flag = s.slice_to(long_flag_char_count);
if opts.long_to_short_flag.contains_key(opt_spec.long_flag) {
streams.err.append(wgettext_fmt!(
"%ls: Long flag '%ls' already defined\n",
"%s: Long flag '%s' already defined\n",
opts.name,
opt_spec.long_flag
));
@@ -480,7 +480,7 @@ fn collect_option_specs<'args>(
if *optind == argc {
streams
.err
.append(wgettext_fmt!("%ls: Missing -- separator\n", cmd));
.append(wgettext_fmt!("%s: Missing -- separator\n", cmd));
return Err(STATUS_INVALID_ARGS);
}
@@ -502,7 +502,7 @@ fn collect_option_specs<'args>(
if counter > counter_max {
streams
.err
.append(wgettext_fmt!("%ls: Too many long-only options\n", cmd));
.append(wgettext_fmt!("%s: Too many long-only options\n", cmd));
return Err(STATUS_INVALID_ARGS);
}
@@ -557,7 +557,7 @@ fn parse_cmd_opts<'args>(
ArgType::NoArgument
} else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid --unknown-arguments value '%ls'\n",
"%s: Invalid --unknown-arguments value '%s'\n",
cmd,
kind
));
@@ -574,7 +574,7 @@ fn parse_cmd_opts<'args>(
let x = fish_wcstol(w.woptarg.unwrap()).unwrap_or(-1);
if x < 0 {
streams.err.append(wgettext_fmt!(
"%ls: Invalid --min-args value '%ls'\n",
"%s: Invalid --min-args value '%s'\n",
cmd,
w.woptarg.unwrap()
));
@@ -588,7 +588,7 @@ fn parse_cmd_opts<'args>(
let x = fish_wcstol(w.woptarg.unwrap()).unwrap_or(-1);
if x < 0 {
streams.err.append(wgettext_fmt!(
"%ls: Invalid --max-args value '%ls'\n",
"%s: Invalid --max-args value '%s'\n",
cmd,
w.woptarg.unwrap()
));
@@ -642,7 +642,7 @@ fn parse_cmd_opts<'args>(
// The user didn't specify any option specs.
streams
.err
.append(wgettext_fmt!("%ls: Missing -- separator\n", cmd));
.append(wgettext_fmt!("%s: Missing -- separator\n", cmd));
return Err(STATUS_INVALID_ARGS);
}

View File

@@ -16,7 +16,7 @@ fn send_to_bg(
if !jobs[job_pos].wants_job_control() {
let job = &jobs[job_pos];
streams.err.append(wgettext_fmt!(
"%ls: Can't put job %s, '%ls' to background because it is not under job control\n",
"%s: Can't put job %s, '%s' to background because it is not under job control\n",
cmd,
job.job_id().to_wstring(),
job.command()
@@ -26,7 +26,7 @@ fn send_to_bg(
let job = &jobs[job_pos];
streams.err.append(wgettext_fmt!(
"Send job %s '%ls' to background\n",
"Send job %s '%s' to background\n",
job.job_id().to_wstring(),
job.command()
));
@@ -66,7 +66,7 @@ pub fn bg(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
let Some(job_pos) = job_pos else {
streams
.err
.append(wgettext_fmt!("%ls: There are no suitable jobs\n", cmd));
.append(wgettext_fmt!("%s: There are no suitable jobs\n", cmd));
return Err(STATUS_CMD_ERROR);
};
@@ -83,7 +83,7 @@ pub fn bg(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
Ok(Some(pid)) => Some(pid),
_ => {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a valid job specifier\n",
"%s: '%s' is not a valid job specifier\n",
cmd,
arg
));
@@ -103,7 +103,7 @@ pub fn bg(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
} else {
streams
.err
.append(wgettext_fmt!("%ls: Could not find job '%d'\n", cmd, pid));
.append(wgettext_fmt!("%s: Could not find job '%d'\n", cmd, pid));
}
}

View File

@@ -350,13 +350,13 @@ fn insert(
if !self.opts.silent {
if seq.len() == 1 {
streams.err.append(wgettext_fmt!(
"%ls: No binding found for key '%ls'\n",
"%s: No binding found for key '%s'\n",
cmd,
seq[0]
));
} else {
streams.err.append(wgettext_fmt!(
"%ls: No binding found for key sequence '%ls'\n",
"%s: No binding found for key sequence '%s'\n",
cmd,
eseq
));
@@ -432,7 +432,7 @@ fn parse_cmd_opts(
'h' => opts.print_help = true,
'k' => {
streams.err.append(wgettext_fmt!(
"%ls: the -k/--key syntax is no longer supported. See `bind --help` and `bind --key-names`\n",
"%s: the -k/--key syntax is no longer supported. See `bind --help` and `bind --key-names`\n",
cmd,
));
return Err(STATUS_INVALID_ARGS);
@@ -555,7 +555,7 @@ pub fn bind(
_ => {
streams
.err
.append(wgettext_fmt!("%ls: Invalid state\n", cmd));
.append(wgettext_fmt!("%s: Invalid state\n", cmd));
return Err(STATUS_CMD_ERROR);
}
}

View File

@@ -90,7 +90,7 @@ pub fn block(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Bu
if opts.erase {
if opts.scope != Scope::Unset {
streams.err.append(wgettext_fmt!(
"%ls: Can not specify scope when removing block\n",
"%s: Can not specify scope when removing block\n",
cmd
));
return Err(STATUS_INVALID_ARGS);
@@ -99,7 +99,7 @@ pub fn block(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Bu
if parser.global_event_blocks.load(Ordering::Relaxed) == 0 {
streams
.err
.append(wgettext_fmt!("%ls: No blocks defined\n", cmd));
.append(wgettext_fmt!("%s: No blocks defined\n", cmd));
return Err(STATUS_CMD_ERROR);
}
parser.global_event_blocks.fetch_sub(1, Ordering::Relaxed);

View File

@@ -39,7 +39,7 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
None => {
streams
.err
.append(wgettext_fmt!("%ls: Could not find home directory\n", cmd));
.append(wgettext_fmt!("%s: Could not find home directory\n", cmd));
return Err(STATUS_CMD_ERROR);
}
}
@@ -48,7 +48,7 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
// Stop `cd ""` from crashing
if dir_in.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls: Empty directory '%ls' does not exist\n",
"%s: Empty directory '%s' does not exist\n",
cmd,
dir_in
));
@@ -63,7 +63,7 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
let dirs = path_apply_cdpath(dir_in, &pwd, vars);
if dirs.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls: The directory '%ls' does not exist\n",
"%s: The directory '%s' does not exist\n",
cmd,
dir_in
));
@@ -132,41 +132,37 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built
}
if best_errno == ENOTDIR {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a directory\n",
cmd,
dir_in
));
streams
.err
.append(wgettext_fmt!("%s: '%s' is not a directory\n", cmd, dir_in));
} else if !broken_symlink.is_empty() {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is a broken symbolic link to '%ls'\n",
"%s: '%s' is a broken symbolic link to '%s'\n",
cmd,
broken_symlink,
broken_symlink_target
));
} else if best_errno == ELOOP {
streams.err.append(wgettext_fmt!(
"%ls: Too many levels of symbolic links: '%ls'\n",
"%s: Too many levels of symbolic links: '%s'\n",
cmd,
dir_in
));
} else if best_errno == ENOENT {
streams.err.append(wgettext_fmt!(
"%ls: The directory '%ls' does not exist\n",
"%s: The directory '%s' does not exist\n",
cmd,
dir_in
));
} else if best_errno == EACCES || best_errno == EPERM {
streams.err.append(wgettext_fmt!(
"%ls: Permission denied: '%ls'\n",
cmd,
dir_in
));
streams
.err
.append(wgettext_fmt!("%s: Permission denied: '%s'\n", cmd, dir_in));
} else {
errno::set_errno(Errno(best_errno));
wperror(L!("cd"));
streams.err.append(wgettext_fmt!(
"%ls: Unknown error trying to locate directory '%ls'\n",
"%s: Unknown error trying to locate directory '%s'\n",
cmd,
dir_in
));

View File

@@ -393,7 +393,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let Some(cmd) = input_function_get_code(arg) else {
streams
.err
.append(wgettext_fmt!("%ls: Unknown input function '%ls'", cmd, arg));
.append(wgettext_fmt!("%s: Unknown input function '%s'", cmd, arg));
builtin_print_error_trailer(parser, streams.err, cmd);
return Err(STATUS_INVALID_ARGS);
};
@@ -517,7 +517,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let Ok(new_coord) = usize::try_from(new_coord) else {
streams
.err
.append(wgettext_fmt!("%ls: line/column index starts at 1", cmd));
.append(wgettext_fmt!("%s: line/column index starts at 1", cmd));
builtin_print_error_trailer(parser, streams.err, cmd);
return Err(STATUS_INVALID_ARGS);
};
@@ -529,7 +529,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
) else {
streams
.err
.append(wgettext_fmt!("%ls: there is no line %ls\n", cmd, arg));
.append(wgettext_fmt!("%s: there is no line %s\n", cmd, arg));
builtin_print_error_trailer(parser, streams.err, cmd);
return Err(STATUS_INVALID_ARGS);
};
@@ -544,7 +544,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
.unwrap_or(rstate.text.len());
if line_offset + new_coord > next_line_offset {
streams.err.append(wgettext_fmt!(
"%ls: column %ls exceeds line length\n",
"%s: column %s exceeds line length\n",
cmd,
arg
));
@@ -601,7 +601,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let Some(selection) = rstate.selection else {
return Err(STATUS_CMD_ERROR);
};
streams.out.append(sprintf!("%lu\n", selection.start));
streams.out.append(sprintf!("%u\n", selection.start));
return Ok(SUCCESS);
}
@@ -609,7 +609,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let Some(selection) = rstate.selection else {
return Err(STATUS_CMD_ERROR);
};
streams.out.append(sprintf!("%lu\n", selection.end));
streams.out.append(sprintf!("%u\n", selection.end));
return Ok(SUCCESS);
}
@@ -716,7 +716,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
} else {
streams
.out
.append(sprintf!("%lu\n", current_cursor_pos - range.start));
.append(sprintf!("%u\n", current_cursor_pos - range.start));
}
return Ok(SUCCESS);
}

View File

@@ -296,7 +296,7 @@ pub fn complete(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) ->
}
} else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid token '%ls'\n",
"%s: Invalid token '%s'\n",
cmd,
w.woptarg.unwrap()
));
@@ -318,7 +318,7 @@ pub fn complete(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) ->
if arg.is_empty() {
streams
.err
.append(wgettext_fmt!("%ls: -s requires a non-empty string\n", cmd,));
.append(wgettext_fmt!("%s: -s requires a non-empty string\n", cmd,));
return Err(STATUS_INVALID_ARGS);
}
}
@@ -328,7 +328,7 @@ pub fn complete(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) ->
if arg.is_empty() {
streams
.err
.append(wgettext_fmt!("%ls: -l requires a non-empty string\n", cmd,));
.append(wgettext_fmt!("%s: -l requires a non-empty string\n", cmd,));
return Err(STATUS_INVALID_ARGS);
}
}
@@ -338,7 +338,7 @@ pub fn complete(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) ->
if arg.is_empty() {
streams
.err
.append(wgettext_fmt!("%ls: -o requires a non-empty string\n", cmd,));
.append(wgettext_fmt!("%s: -o requires a non-empty string\n", cmd,));
return Err(STATUS_INVALID_ARGS);
}
}
@@ -442,7 +442,7 @@ pub fn complete(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) ->
if let Err(err_text) = parse_util_detect_errors_in_argument_list(&comp, &prefix) {
streams.err.append(wgettext_fmt!(
"%ls: %ls: contains a syntax error\n",
"%s: %s: contains a syntax error\n",
cmd,
comp
));

View File

@@ -73,7 +73,7 @@ pub fn contains(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
} else {
streams
.err
.append(wgettext_fmt!("%ls: Key not specified\n", cmd));
.append(wgettext_fmt!("%s: Key not specified\n", cmd));
}
return Err(STATUS_CMD_ERROR);

View File

@@ -27,7 +27,7 @@ fn disown_job(cmd: &wstr, streams: &mut IoStreams, j: &Job) {
}
}
streams.err.append(wgettext_fmt!(
"%ls: job %d ('%ls') was stopped and has been signalled to continue.\n",
"%s: job %d ('%s') was stopped and has been signalled to continue.\n",
cmd,
j.job_id(),
j.command()
@@ -71,7 +71,7 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
} else {
streams
.err
.append(wgettext_fmt!("%ls: There are no suitable jobs\n", cmd));
.append(wgettext_fmt!("%s: There are no suitable jobs\n", cmd));
retval = Err(STATUS_CMD_ERROR);
}
} else {
@@ -88,7 +88,7 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
None => {
// Invalid identifier
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a valid job specifier\n",
"%s: '%s' is not a valid job specifier\n",
cmd,
arg
));
@@ -98,7 +98,7 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
Some(pid) => parser.job_get_from_pid(pid).or_else(|| {
// Valid identifier but no such job
streams.err.append(wgettext_fmt!(
"%ls: Could not find job '%d'\n",
"%s: Could not find job '%d'\n",
cmd,
pid
));

View File

@@ -16,7 +16,7 @@ pub fn emit(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
let Some(event_name) = argv.get(opts.optind) else {
streams
.err
.append(sprintf!(L!("%ls: expected event name\n"), cmd));
.append(sprintf!(L!("%s: expected event name\n"), cmd));
return Err(STATUS_INVALID_ARGS);
};

View File

@@ -38,7 +38,7 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built
None => {
streams
.err
.append(wgettext_fmt!("%ls: There are no suitable jobs\n", cmd));
.append(wgettext_fmt!("%s: There are no suitable jobs\n", cmd));
return Err(STATUS_INVALID_ARGS);
}
Some((pos, j)) => {
@@ -58,13 +58,11 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built
if found_job {
streams
.err
.append(wgettext_fmt!("%ls: Ambiguous job\n", cmd));
.append(wgettext_fmt!("%s: Ambiguous job\n", cmd));
} else {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a job\n",
cmd,
argv[optind]
));
streams
.err
.append(wgettext_fmt!("%s: '%s' is not a job\n", cmd, argv[optind]));
}
builtin_print_error_trailer(parser, streams.err, cmd);
@@ -89,7 +87,7 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built
{
streams
.err
.append(wgettext_fmt!("%ls: No suitable job: %d\n", cmd, raw_pid));
.append(wgettext_fmt!("%s: No suitable job: %d\n", cmd, raw_pid));
job_pos = None;
job = None
} else {
@@ -97,7 +95,7 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built
job_pos = Some(pos);
job = if !j.wants_job_control() {
streams.err.append(wgettext_fmt!(
"%ls: Can't put job %d, '%ls' to foreground because it is not under job control\n",
"%s: Can't put job %d, '%s' to foreground because it is not under job control\n",
cmd,
raw_pid,
j.command()

View File

@@ -997,7 +997,7 @@ enum OutputType {
if args.is_empty() && i == 0 {
if output_type == OutputType::File {
streams.err.appendln(wgettext_fmt!(
"Expected file path to read/write for -w:\n\n $ %ls -w foo.fish",
"Expected file path to read/write for -w:\n\n $ %s -w foo.fish",
PROGRAM_NAME.get().unwrap()
));
return Err(STATUS_CMD_ERROR);
@@ -1299,7 +1299,7 @@ fn html_colorize(text: &wstr, colors: &[HighlightSpec]) -> Vec<u8> {
html.push_str("</span>");
}
if i == 0 || color != last_color {
sprintf!(=> &mut html, "<span class=\"%ls\">", html_class_name_for_color(color));
sprintf!(=> &mut html, "<span class=\"%s\">", html_class_name_for_color(color));
}
last_color = color;

View File

@@ -200,7 +200,7 @@ fn parse_flags(
}
'v' => {
streams.out.appendln(wgettext_fmt!(
"%ls, version %s",
"%s, version %s",
PROGRAM_NAME.get().unwrap(),
crate::BUILD_VERSION
));

View File

@@ -94,7 +94,7 @@ fn parse_cmd_opts(
if handling_named_arguments {
if is_read_only(&woptarg) {
streams.err.append(wgettext_fmt!(
"%ls: variable '%ls' is read-only\n",
"%s: variable '%s' is read-only\n",
cmd,
woptarg
));
@@ -103,7 +103,7 @@ fn parse_cmd_opts(
opts.named_arguments.push(woptarg);
} else {
streams.err.append(wgettext_fmt!(
"%ls: %ls: unexpected positional argument",
"%s: %s: unexpected positional argument",
cmd,
woptarg
));
@@ -116,7 +116,7 @@ fn parse_cmd_opts(
's' => {
let Some(signal) = Signal::parse(w.woptarg.unwrap()) else {
streams.err.append(wgettext_fmt!(
"%ls: Unknown signal '%ls'",
"%s: Unknown signal '%s'",
cmd,
w.woptarg.unwrap()
));
@@ -149,7 +149,7 @@ fn parse_cmd_opts(
};
if caller_id == 0 {
streams.err.append(wgettext_fmt!(
"%ls: calling job for event handler not found",
"%s: calling job for event handler not found",
cmd
));
return STATUS_INVALID_ARGS;
@@ -161,7 +161,7 @@ fn parse_cmd_opts(
} else {
let Ok(pid @ 0..) = fish_wcstoi(woptarg) else {
streams.err.append(wgettext_fmt!(
"%ls: %ls: invalid process id",
"%s: %s: invalid process id",
cmd,
woptarg
));
@@ -187,7 +187,7 @@ fn parse_cmd_opts(
let name = w.woptarg.unwrap().to_owned();
if is_read_only(&name) {
streams.err.append(wgettext_fmt!(
"%ls: variable '%ls' is read-only\n",
"%s: variable '%s' is read-only\n",
cmd,
name
));
@@ -246,7 +246,7 @@ fn parse_cmd_opts(
fn validate_function_name(function_name: &wstr, cmd: &wstr, streams: &mut IoStreams) -> c_int {
if !valid_func_name(function_name) {
streams.err.append(wgettext_fmt!(
"%ls: %ls: invalid function name",
"%s: %s: invalid function name",
cmd,
function_name,
));
@@ -254,7 +254,7 @@ fn validate_function_name(function_name: &wstr, cmd: &wstr, streams: &mut IoStre
}
if parser_keywords_is_reserved(function_name) {
streams.err.append(wgettext_fmt!(
"%ls: %ls: cannot use reserved keyword as function name",
"%s: %s: cannot use reserved keyword as function name",
cmd,
function_name
));
@@ -314,7 +314,7 @@ pub fn function(
}
} else {
streams.err.append(wgettext_fmt!(
"%ls: %ls: unexpected positional argument",
"%s: %s: unexpected positional argument",
cmd,
argv[optind],
));

View File

@@ -172,7 +172,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if let Some(desc) = opts.description {
if args.len() != 1 {
streams.err.append(wgettext_fmt!(
"%ls: Expected exactly one function name\n",
"%s: Expected exactly one function name\n",
cmd
));
builtin_print_error_trailer(parser, streams.err, cmd);
@@ -182,7 +182,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if !function::exists(current_func, parser) {
streams.err.append(wgettext_fmt!(
"%ls: Function '%ls' does not exist\n",
"%s: Function '%s' does not exist\n",
cmd,
current_func
));
@@ -280,7 +280,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
&& !event::EVENT_FILTER_NAMES.contains(&opts.handlers_type.unwrap())
{
streams.err.append(wgettext_fmt!(
"%ls: Expected generic | variable | signal | exit | job-id for --handlers-type\n",
"%s: Expected generic | variable | signal | exit | job-id for --handlers-type\n",
cmd
));
return Err(STATUS_INVALID_ARGS);
@@ -320,7 +320,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if opts.copy {
if args.len() != 2 {
streams.err.append(wgettext_fmt!(
"%ls: Expected exactly two names (current function name, and new function name)\n",
"%s: Expected exactly two names (current function name, and new function name)\n",
cmd
));
builtin_print_error_trailer(parser, streams.err, cmd);
@@ -331,7 +331,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if !function::exists(current_func, parser) {
streams.err.append(wgettext_fmt!(
"%ls: Function '%ls' does not exist\n",
"%s: Function '%s' does not exist\n",
cmd,
current_func
));
@@ -341,7 +341,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if !valid_func_name(new_func) || parser_keywords_is_reserved(new_func) {
streams.err.append(wgettext_fmt!(
"%ls: Illegal function name '%ls'\n",
"%s: Illegal function name '%s'\n",
cmd,
new_func
));
@@ -351,7 +351,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if function::exists(new_func, parser) {
streams.err.append(wgettext_fmt!(
"%ls: Function '%ls' already exists. Cannot create copy of '%ls'\n",
"%s: Function '%s' already exists. Cannot create copy of '%s'\n",
cmd,
new_func,
current_func
@@ -391,7 +391,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
}
Some(path) => {
comment.push_utfstr(&wgettext_fmt!(
"Defined in %ls @ line %d",
"Defined in %s @ line %d",
path,
props.definition_lineno()
));
@@ -406,7 +406,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
}
Some(path) => {
comment.push_utfstr(&wgettext_fmt!(
", copied in %ls @ line %d",
", copied in %s @ line %d",
path,
props.copy_definition_lineno()
));
@@ -420,7 +420,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -
if !comment.is_empty() {
def.push_utfstr(&sprintf!(
"# %ls\n%ls",
"# %s\n%s",
comment,
props.annotated_definition(arg)
));

View File

@@ -113,7 +113,7 @@ fn check_for_unexpected_hist_args(
if opts.search_type.is_some() || opts.show_time_format.is_some() || opts.null_terminate {
let subcmd_str = opts.hist_cmd.to_wstr();
streams.err.append(wgettext_fmt!(
"%ls: %ls: subcommand takes no options\n",
"%s: %s: subcommand takes no options\n",
cmd,
subcmd_str
));
@@ -335,7 +335,7 @@ pub fn history(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
if in_private_mode(parser.vars()) {
streams.err.append(wgettext_fmt!(
"%ls: can't merge history in private mode\n",
"%s: can't merge history in private mode\n",
cmd
));
return Err(STATUS_INVALID_ARGS);

View File

@@ -110,7 +110,7 @@ fn builtin_jobs_print(j: &Job, mode: JobsPrintMode, header: bool, streams: &mut
}
for p in j.processes() {
out += &sprintf!("%ls\n", p.argv0().unwrap())[..];
out += &sprintf!("%s\n", p.argv0().unwrap())[..];
}
streams.out.append(out);
}
@@ -196,7 +196,7 @@ pub fn jobs(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
match fish_wcstoi(&arg[1..]).ok().filter(|&job_id| job_id >= 0) {
None => {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a valid job id\n",
"%s: '%s' is not a valid job id\n",
cmd,
arg
));
@@ -217,7 +217,7 @@ pub fn jobs(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
match fish_wcstoi(arg).ok().and_then(Pid::new) {
None => {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a valid process id\n",
"%s: '%s' is not a valid process id\n",
cmd,
arg
));
@@ -236,7 +236,7 @@ pub fn jobs(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
if mode != JobsPrintMode::PrintNothing {
streams
.err
.append(wgettext_fmt!("%ls: No suitable job: %ls\n", cmd, arg));
.append(wgettext_fmt!("%s: No suitable job: %s\n", cmd, arg));
}
return Err(STATUS_CMD_ERROR);
}
@@ -256,7 +256,7 @@ pub fn jobs(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
if !streams.out_is_redirected && mode != JobsPrintMode::PrintNothing {
streams
.out
.append(wgettext_fmt!("%ls: There are no jobs\n", argv[0]));
.append(wgettext_fmt!("%s: There are no jobs\n", argv[0]));
}
return Err(STATUS_CMD_ERROR);
}

View File

@@ -69,7 +69,7 @@ fn parse_cmd_opts(
if scale < 0 || scale > 15 {
streams
.err
.append(wgettext_fmt!("%ls: %ls: invalid scale\n", cmd, optarg));
.append(wgettext_fmt!("%s: %s: invalid scale\n", cmd, optarg));
return Err(STATUS_INVALID_ARGS);
}
// We know the value is in the range [0, 15]
@@ -89,7 +89,7 @@ fn parse_cmd_opts(
} else {
streams
.err
.append(wgettext_fmt!("%ls: %ls: invalid mode\n", cmd, optarg));
.append(wgettext_fmt!("%s: %s: invalid mode\n", cmd, optarg));
return Err(STATUS_INVALID_ARGS);
}
}
@@ -103,7 +103,7 @@ fn parse_cmd_opts(
let base = fish_wcstoi(optarg).unwrap_or(-1);
if base != 8 && base != 16 {
streams.err.append(wgettext_fmt!(
"%ls: %ls: invalid base value\n",
"%s: %s: invalid base value\n",
cmd,
optarg
));
@@ -159,7 +159,7 @@ fn format_double(mut v: f64, opts: &Options) -> WString {
if opts.base == 16 {
v = v.trunc();
let mneg = if v.is_sign_negative() { "-" } else { "" };
return sprintf!("%s0x%lx", mneg, v.abs() as u64);
return sprintf!("%s0x%x", mneg, v.abs() as u64);
} else if opts.base == 8 {
v = v.trunc();
if v == 0.0 {
@@ -167,7 +167,7 @@ fn format_double(mut v: f64, opts: &Options) -> WString {
return WString::from_str("0");
}
let mneg = if v.is_sign_negative() { "-" } else { "" };
return sprintf!("%s0%lo", mneg, v.abs() as u64);
return sprintf!("%s0%o", mneg, v.abs() as u64);
}
v *= pow(10f64, opts.scale);
@@ -245,24 +245,24 @@ fn evaluate_expression(
streams
.err
.append(sprintf!("%ls: Error: %ls\n", cmd, error_message));
streams.err.append(sprintf!("'%ls'\n", expression));
.append(sprintf!("%s: Error: %s\n", cmd, error_message));
streams.err.append(sprintf!("'%s'\n", expression));
Err(STATUS_CMD_ERROR)
}
Err(err) => {
streams.err.append(sprintf!(
L!("%ls: Error: %ls\n"),
L!("%s: Error: %s\n"),
cmd,
err.kind.describe_wstr()
));
streams.err.append(sprintf!("'%ls'\n", expression));
streams.err.append(sprintf!("'%s'\n", expression));
let padding = WString::from_chars(vec![' '; err.position + 1]);
if err.len >= 2 {
let tildes = WString::from_chars(vec!['~'; err.len - 2]);
streams.err.append(sprintf!("%ls^%ls^\n", padding, tildes));
streams.err.append(sprintf!("%s^%s^\n", padding, tildes));
} else {
streams.err.append(sprintf!("%ls^\n", padding));
streams.err.append(sprintf!("%s^\n", padding));
}
Err(STATUS_CMD_ERROR)

View File

@@ -283,7 +283,7 @@ fn parse_opts<'args>(
let types_args = split_string_tok(w.woptarg.unwrap(), L!(","), None);
for t in types_args {
let Ok(r#type) = t.try_into() else {
path_error!(streams, "%ls: Invalid type '%ls'\n", "path", t);
path_error!(streams, "%s: Invalid type '%s'\n", "path", t);
return Err(STATUS_INVALID_ARGS);
};
*types |= r#type;
@@ -295,7 +295,7 @@ fn parse_opts<'args>(
let perms_args = split_string_tok(w.woptarg.unwrap(), L!(","), None);
for p in perms_args {
let Ok(perm) = p.try_into() else {
path_error!(streams, "%ls: Invalid permission '%ls'\n", "path", p);
path_error!(streams, "%s: Invalid permission '%s'\n", "path", p);
return Err(STATUS_INVALID_ARGS);
};
*perms |= perm;
@@ -709,7 +709,7 @@ fn path_sort(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Bu
}
None => wbasename,
Some(k) => {
path_error!(streams, "%ls: Invalid sort key '%ls'\n", args[0], k);
path_error!(streams, "%s: Invalid sort key '%s'\n", args[0], k);
return Err(STATUS_INVALID_ARGS);
}
};

View File

@@ -208,10 +208,10 @@ fn verify_numeric(&mut self, s: &wstr, end: &wstr, errcode: Option<Error>) {
if errcode != None && errcode != Some(Error::InvalidChar) && errcode != Some(Error::Empty) {
match errcode.unwrap() {
Error::Overflow => {
self.fatal_error(sprintf!("%ls: %ls", s, wgettext!("Number out of range")));
self.fatal_error(sprintf!("%s: %s", s, wgettext!("Number out of range")));
}
Error::Empty => {
self.fatal_error(sprintf!("%ls: %ls", s, wgettext!("Number was empty")));
self.fatal_error(sprintf!("%s: %s", s, wgettext!("Number was empty")));
}
Error::InvalidChar => {
panic!("Unreachable");
@@ -219,11 +219,11 @@ fn verify_numeric(&mut self, s: &wstr, end: &wstr, errcode: Option<Error>) {
}
} else if !end.is_empty() {
if s.as_ptr() == end.as_ptr() {
self.fatal_error(wgettext_fmt!("%ls: expected a numeric value", s));
self.fatal_error(wgettext_fmt!("%s: expected a numeric value", s));
} else {
// This isn't entirely fatal - the value should still be printed.
self.nonfatal_error(wgettext_fmt!(
"%ls: value not completely converted (can't convert '%ls')",
"%s: value not completely converted (can't convert '%s')",
s,
end
));
@@ -472,10 +472,7 @@ fn print_formatted(&mut self, format: &wstr, mut argv: &[&wstr]) -> usize {
if (c_int::MIN as i64) <= width && width <= (c_int::MAX as i64) {
field_width = Some(width);
} else {
self.fatal_error(wgettext_fmt!(
"invalid field width: %ls",
argv[0]
));
self.fatal_error(wgettext_fmt!("invalid field width: %s", argv[0]));
}
argv = &argv[1..];
argc -= 1;
@@ -504,7 +501,7 @@ fn print_formatted(&mut self, format: &wstr, mut argv: &[&wstr]) -> usize {
precision = Some(-1);
} else if (c_int::MAX as i64) < prec {
self.fatal_error(wgettext_fmt!(
"invalid precision: %ls",
"invalid precision: %s",
argv[0]
));
} else {
@@ -530,7 +527,7 @@ fn print_formatted(&mut self, format: &wstr, mut argv: &[&wstr]) -> usize {
let conversion = f.char_at(0);
if (conversion as usize) > 0xFF || !ok[conversion as usize] {
self.fatal_error(wgettext_fmt!(
"%.*ls: invalid conversion specification",
"%.*s: invalid conversion specification",
wstr_offset_in(f, directive_start) + 1,
directive_start
));

View File

@@ -53,7 +53,7 @@ pub fn pwd(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Buil
pwd = real_pwd;
} else {
streams.err.append(wgettext_fmt!(
"%ls: realpath failed: %s\n",
"%s: realpath failed: %s\n",
cmd,
errno().to_string()
));

View File

@@ -58,7 +58,7 @@ pub fn random(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
if arg_count == 1 {
streams
.err
.append(wgettext_fmt!("%ls: nothing to choose from\n", cmd));
.append(wgettext_fmt!("%s: nothing to choose from\n", cmd));
return Err(STATUS_INVALID_ARGS);
}
@@ -71,7 +71,7 @@ fn parse_ll(streams: &mut IoStreams, cmd: &wstr, num: &wstr) -> Result<i64, wuti
if res.is_err() {
streams
.err
.append(wgettext_fmt!("%ls: %ls: invalid integer\n", cmd, num));
.append(wgettext_fmt!("%s: %s: invalid integer\n", cmd, num));
}
return res;
}
@@ -80,7 +80,7 @@ fn parse_ull(streams: &mut IoStreams, cmd: &wstr, num: &wstr) -> Result<u64, wut
if res.is_err() {
streams
.err
.append(wgettext_fmt!("%ls: %ls: invalid integer\n", cmd, num));
.append(wgettext_fmt!("%s: %s: invalid integer\n", cmd, num));
}
return res;
}
@@ -126,7 +126,7 @@ fn parse_ull(streams: &mut IoStreams, cmd: &wstr, num: &wstr) -> Result<u64, wut
Ok(0) => {
streams
.err
.append(wgettext_fmt!("%ls: STEP must be a positive integer\n", cmd,));
.append(wgettext_fmt!("%s: STEP must be a positive integer\n", cmd,));
return Err(STATUS_INVALID_ARGS);
}
Ok(x) => step = x,
@@ -140,7 +140,7 @@ fn parse_ull(streams: &mut IoStreams, cmd: &wstr, num: &wstr) -> Result<u64, wut
_ => {
streams
.err
.append(wgettext_fmt!("%ls: too many arguments\n", cmd,));
.append(wgettext_fmt!("%s: too many arguments\n", cmd,));
return Err(STATUS_CMD_ERROR);
}
}

View File

@@ -125,7 +125,7 @@ fn parse_cmd_opts(
}
'i' => {
streams.err.append(wgettext_fmt!(
"%ls: usage of -i for --silent is deprecated. Please use -s or --silent instead.\n",
"%s: usage of -i for --silent is deprecated. Please use -s or --silent instead.\n",
cmd
));
return Err(STATUS_INVALID_ARGS);
@@ -150,7 +150,7 @@ fn parse_cmd_opts(
Ok(n) if n >= 0 => NonZeroUsize::new(n.try_into().unwrap()),
Err(wutil::Error::Overflow) => {
streams.err.append(wgettext_fmt!(
"%ls: Argument '%ls' is out of range\n",
"%s: Argument '%s' is out of range\n",
cmd,
w.woptarg.unwrap()
));
@@ -457,7 +457,7 @@ fn validate_read_args(
) -> BuiltinResult {
if opts.prompt.is_some() && opts.prompt_str.is_some() {
streams.err.append(wgettext_fmt!(
"%ls: Options %ls and %ls cannot be used together\n",
"%s: Options %s and %s cannot be used together\n",
cmd,
"-p",
"-P",
@@ -468,7 +468,7 @@ fn validate_read_args(
if opts.delimiter.is_some() && opts.one_line {
streams.err.append(wgettext_fmt!(
"%ls: Options %ls and %ls cannot be used together\n",
"%s: Options %s and %s cannot be used together\n",
cmd,
"--delimiter",
"--line"
@@ -477,7 +477,7 @@ fn validate_read_args(
}
if opts.one_line && opts.split_null {
streams.err.append(wgettext_fmt!(
"%ls: Options %ls and %ls cannot be used together\n",
"%s: Options %s and %s cannot be used together\n",
cmd,
"-z",
"--line"
@@ -572,7 +572,7 @@ fn tokenize_flag(token_mode: TokenOutputMode) -> &'static wstr {
}
if EnvVar::flags_for(arg).contains(EnvVarFlags::READ_ONLY) {
streams.err.append(wgettext_fmt!(
"%ls: %ls: cannot overwrite read-only variable",
"%s: %s: cannot overwrite read-only variable",
cmd,
arg
));
@@ -613,7 +613,7 @@ pub fn read(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
if streams.stdin_fd < 0 {
streams
.err
.append(wgettext_fmt!("%ls: stdin is closed\n", cmd));
.append(wgettext_fmt!("%s: stdin is closed\n", cmd));
return Err(STATUS_CMD_ERROR);
}

View File

@@ -90,7 +90,7 @@ pub fn realpath(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
// realpath() just couldn't do it. Report the error and make it clear
// this is an error from our builtin, not the system's realpath.
streams.err.append(wgettext_fmt!(
"builtin %ls: %ls: %s\n",
"builtin %s: %s: %s\n",
cmd,
arg,
errno.to_string()
@@ -99,7 +99,7 @@ pub fn realpath(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
// Who knows. Probably a bug in our wrealpath() implementation.
streams
.err
.append(wgettext_fmt!("builtin %ls: Invalid arg: %ls\n", cmd, arg));
.append(wgettext_fmt!("builtin %s: Invalid arg: %s\n", cmd, arg));
}
return Err(STATUS_CMD_ERROR);
@@ -117,7 +117,7 @@ pub fn realpath(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
streams.out.append(normalize_path(&absolute_arg, false));
} else {
streams.err.append(wgettext_fmt!(
"builtin %ls: realpath failed: %s\n",
"builtin %s: realpath failed: %s\n",
cmd,
errno().to_string()
));

View File

@@ -22,10 +22,10 @@
localizable_consts!(
MISMATCHED_ARGS
"%ls: given %d indexes but %d values\n"
"%s: given %d indexes but %d values\n"
UVAR_ERR
"%ls: successfully set universal '%ls'; but a global by that name shadows it\n"
"%s: successfully set universal '%s'; but a global by that name shadows it\n"
);
#[derive(Debug, Clone)]
@@ -327,28 +327,28 @@ fn handle_env_return(retval: EnvStackSetResult, cmd: &wstr, key: &wstr, streams:
EnvStackSetResult::Ok => (),
EnvStackSetResult::Perm => {
streams.err.append(wgettext_fmt!(
"%ls: Tried to change the read-only variable '%ls'\n",
"%s: Tried to change the read-only variable '%s'\n",
cmd,
key
));
}
EnvStackSetResult::Scope => {
streams.err.append(wgettext_fmt!(
"%ls: Tried to modify the special variable '%ls' with the wrong scope\n",
"%s: Tried to modify the special variable '%s' with the wrong scope\n",
cmd,
key
));
}
EnvStackSetResult::Invalid => {
streams.err.append(wgettext_fmt!(
"%ls: Tried to modify the special variable '%ls' to an invalid value\n",
"%s: Tried to modify the special variable '%s' to an invalid value\n",
cmd,
key
));
}
EnvStackSetResult::NotFound => {
streams.err.append(wgettext_fmt!(
"%ls: The variable '%ls' does not exist\n",
"%s: The variable '%s' does not exist\n",
cmd,
key
));
@@ -389,7 +389,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
"{}",
match self {
EnvArrayParseError::InvalidIndex(varname) =>
wgettext_fmt!("%ls: Invalid index starting at '%ls'\n", "set", varname)
wgettext_fmt!("%s: Invalid index starting at '%s'\n", "set", varname)
.to_string(),
}
)
@@ -428,7 +428,7 @@ fn split_var_and_indexes<'a>(
Ok(split) => Some(split),
Err(EnvArrayParseError::InvalidIndex(varname)) => {
streams.err.append(wgettext_fmt!(
"%ls: Invalid index starting at '%ls'\n",
"%s: Invalid index starting at '%s'\n",
"set",
&varname,
));
@@ -657,7 +657,7 @@ fn show_scope(var_name: &wstr, scope: EnvMode, streams: &mut IoStreams, vars: &d
};
let vals = var.as_list();
streams.out.append(wgettext_fmt!(
"$%ls: set in %ls scope, %ls,%ls with %d elements",
"$%s: set in %s scope, %s,%s with %d elements",
var_name,
scope_name,
exportv,
@@ -694,7 +694,7 @@ fn show_scope(var_name: &wstr, scope: EnvMode, streams: &mut IoStreams, vars: &d
);
streams
.out
.append(sprintf!("$%ls[%d]: |%ls|\n", var_name, i + 1, &escaped_val));
.append(sprintf!("$%s[%d]: |%s|\n", var_name, i + 1, &escaped_val));
}
}
@@ -720,7 +720,7 @@ fn show(cmd: &wstr, parser: &Parser, streams: &mut IoStreams, args: &[&wstr]) ->
EscapeStringStyle::Script(EscapeFlags::NO_PRINTABLES | EscapeFlags::NO_QUOTED),
);
streams.out.append(wgettext_fmt!(
"$%ls: originally inherited as |%ls|\n",
"$%s: originally inherited as |%s|\n",
name,
escaped_val
));
@@ -738,7 +738,7 @@ fn show(cmd: &wstr, parser: &Parser, streams: &mut IoStreams, args: &[&wstr]) ->
if arg.contains('[') {
streams.err.append(wgettext_fmt!(
"%ls: `set --show` does not allow slices with the var names\n",
"%s: `set --show` does not allow slices with the var names\n",
cmd
));
builtin_print_error_trailer(parser, streams.err, cmd);
@@ -754,7 +754,7 @@ fn show(cmd: &wstr, parser: &Parser, streams: &mut IoStreams, args: &[&wstr]) ->
EscapeStringStyle::Script(EscapeFlags::NO_PRINTABLES | EscapeFlags::NO_QUOTED),
);
streams.out.append(wgettext_fmt!(
"$%ls: originally inherited as |%ls|\n",
"$%s: originally inherited as |%s|\n",
arg,
escaped_val
));
@@ -931,7 +931,7 @@ fn set_internal(
.append(wgettext_fmt!(BUILTIN_ERR_VARNAME, cmd, split.varname));
if let Some(pos) = split.varname.chars().position(|c| c == '=') {
streams.err.append(wgettext_fmt!(
"%ls: Did you mean `set %ls %ls`?",
"%s: Did you mean `set %s %s`?",
cmd,
&escape(&split.varname[..pos]),
&escape(&split.varname[pos + 1..])
@@ -948,7 +948,7 @@ fn set_internal(
if *ind <= 0 {
streams
.err
.append(wgettext_fmt!("%ls: array index out of bounds\n", cmd));
.append(wgettext_fmt!("%s: array index out of bounds\n", cmd));
builtin_print_error_trailer(parser, streams.err, cmd);
return Err(STATUS_INVALID_ARGS);
}
@@ -956,7 +956,7 @@ fn set_internal(
// Append and prepend are disallowed.
if opts.append || opts.prepend {
streams.err.append(wgettext_fmt!(
"%ls: Cannot use --append or --prepend when assigning to a slice",
"%s: Cannot use --append or --prepend when assigning to a slice",
cmd
));
builtin_print_error_trailer(parser, streams.err, cmd);

View File

@@ -99,12 +99,12 @@ pub fn set_color(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -
Err(UnknownColor(arg)) => {
streams
.err
.append(wgettext_fmt!("%ls: Unknown color '%ls'\n", argv[0], arg));
.append(wgettext_fmt!("%s: Unknown color '%s'\n", argv[0], arg));
return Err(STATUS_INVALID_ARGS);
}
Err(UnknownUnderlineStyle(arg)) => {
streams.err.append(wgettext_fmt!(
"%ls: invalid underline style: %ls\n",
"%s: invalid underline style: %s\n",
argv[0],
arg
));

View File

@@ -24,84 +24,84 @@
localizable_consts!(
/// Error message on missing argument.
pub BUILTIN_ERR_MISSING
"%ls: %ls: option requires an argument\n"
"%s: %s: option requires an argument\n"
/// Error message on unexpected argument.
pub BUILTIN_ERR_UNEXP_ARG
"%ls: %ls: option does not take an argument\n"
"%s: %s: option does not take an argument\n"
/// Error message on missing man page.
pub BUILTIN_ERR_MISSING_HELP
"fish: %ls: missing man page\nDocumentation may not be installed.\n`help %ls` will show an online version\n"
"fish: %s: missing man page\nDocumentation may not be installed.\n`help %s` will show an online version\n"
/// Error message on multiple scope levels for variables.
pub BUILTIN_ERR_GLOCAL
"%ls: scope can be only one of: universal function global local\n"
"%s: scope can be only one of: universal function global local\n"
/// Error message for specifying both export and unexport to set/read.
pub BUILTIN_ERR_EXPUNEXP
"%ls: cannot both export and unexport\n"
"%s: cannot both export and unexport\n"
/// Error message for specifying both path and unpath to set/read.
pub BUILTIN_ERR_PATHUNPATH
"%ls: cannot both path and unpath\n"
"%s: cannot both path and unpath\n"
/// Error message for unknown switch.
pub BUILTIN_ERR_UNKNOWN
"%ls: %ls: unknown option\n"
"%s: %s: unknown option\n"
/// Error message for invalid bind mode name.
pub BUILTIN_ERR_BIND_MODE
"%ls: %ls: invalid mode name. See `help identifiers`\n"
"%s: %s: invalid mode name. See `help identifiers`\n"
/// Error message when too many arguments are supplied to a builtin.
pub BUILTIN_ERR_TOO_MANY_ARGUMENTS
"%ls: too many arguments\n"
"%s: too many arguments\n"
/// Error message when integer expected
pub BUILTIN_ERR_NOT_NUMBER
"%ls: %ls: invalid integer\n"
"%s: %s: invalid integer\n"
/// Command that requires a subcommand was invoked without a recognized subcommand.
pub BUILTIN_ERR_MISSING_SUBCMD
"%ls: missing subcommand\n"
"%s: missing subcommand\n"
pub BUILTIN_ERR_INVALID_SUBCMD
"%ls: %ls: invalid subcommand\n"
"%s: %s: invalid subcommand\n"
/// Error messages for unexpected args.
pub BUILTIN_ERR_ARG_COUNT0
"%ls: missing argument\n"
"%s: missing argument\n"
pub BUILTIN_ERR_ARG_COUNT1
"%ls: expected %d arguments; got %d\n"
"%s: expected %d arguments; got %d\n"
pub BUILTIN_ERR_ARG_COUNT2
"%ls: %ls: expected %d arguments; got %d\n"
"%s: %s: expected %d arguments; got %d\n"
pub BUILTIN_ERR_MIN_ARG_COUNT1
"%ls: expected >= %d arguments; got %d\n"
"%s: expected >= %d arguments; got %d\n"
pub BUILTIN_ERR_MAX_ARG_COUNT1
"%ls: expected <= %d arguments; got %d\n"
"%s: expected <= %d arguments; got %d\n"
/// Error message for invalid variable name.
pub BUILTIN_ERR_VARNAME
"%ls: %ls: invalid variable name. See `help identifiers`\n"
"%s: %s: invalid variable name. See `help identifiers`\n"
/// Error message on invalid combination of options.
pub BUILTIN_ERR_COMBO
"%ls: invalid option combination\n"
"%s: invalid option combination\n"
pub BUILTIN_ERR_COMBO2
"%ls: invalid option combination, %ls\n"
"%s: invalid option combination, %s\n"
pub BUILTIN_ERR_COMBO2_EXCLUSIVE
"%ls: %ls %ls: options cannot be used together\n"
"%s: %s %s: options cannot be used together\n"
/// The send stuff to foreground message.
pub FG_MSG
"Send job %d (%ls) to foreground\n"
"Send job %d (%s) to foreground\n"
);
// Return values (`$status` values for fish scripts) for various situations.
@@ -530,7 +530,7 @@ pub fn builtin_run(parser: &Parser, argv: &mut [&wstr], streams: &mut IoStreams)
// and we avoid 0.
FLOGF!(
warning,
"builtin %ls returned invalid exit code %d",
"builtin %s returned invalid exit code %d",
argv[0],
code
);
@@ -631,7 +631,7 @@ pub fn builtin_print_help(parser: &Parser, streams: &mut IoStreams, cmd: &wstr)
return;
}
let name_esc = escape(cmd);
let cmd = sprintf!("__fish_print_help %ls ", &name_esc);
let cmd = sprintf!("__fish_print_help %s ", &name_esc);
let res = parser.eval(&cmd, streams.io_chain);
if res.status.normal_exited() && res.status.exit_code() == 2 {
streams
@@ -708,7 +708,7 @@ pub fn builtin_print_error_trailer(parser: &Parser, b: &mut OutputStream, cmd: &
b.push('\n');
}
b.append(wgettext_fmt!(
"(Type 'help %ls' for related documentation)\n",
"(Type 'help %s' for related documentation)\n",
cmd
));
}
@@ -991,7 +991,7 @@ fn builtin_break_continue(
if !has_loop {
streams
.err
.append(wgettext_fmt!("%ls: Not inside of loop\n", argv[0]));
.append(wgettext_fmt!("%s: Not inside of loop\n", argv[0]));
return Err(STATUS_CMD_ERROR);
}
@@ -1034,7 +1034,7 @@ fn builtin_breakpoint(
.map_or(true, |b| b.typ() == BlockType::breakpoint)
{
streams.err.append(wgettext_fmt!(
"%ls: Command not valid at an interactive prompt\n",
"%s: Command not valid at an interactive prompt\n",
cmd,
));
return Err(STATUS_ILLEGAL_CMD);

View File

@@ -39,14 +39,14 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
if streams.stdin_fd < 0 {
streams
.err
.append(wgettext_fmt!("%ls: stdin is closed\n", cmd));
.append(wgettext_fmt!("%s: stdin is closed\n", cmd));
return Err(STATUS_CMD_ERROR);
}
// Either a bare `source` which means to implicitly read from stdin or an explicit `-`.
if argc == optind && isatty(streams.stdin_fd) {
// Don't implicitly read from the terminal.
streams.err.append(wgettext_fmt!(
"%ls: missing filename argument or input redirection\n",
"%s: missing filename argument or input redirection\n",
cmd
));
return Err(STATUS_CMD_ERROR);
@@ -61,7 +61,7 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
Err(_) => {
let esc = escape(args[optind]);
streams.err.append(wgettext_fmt!(
"%ls: Error encountered while sourcing file '%ls':\n",
"%s: Error encountered while sourcing file '%s':\n",
cmd,
&esc
));
@@ -98,7 +98,7 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
Err(err) => {
let esc = escape(&func_filename);
streams.err.append(wgettext_fmt!(
"%ls: Error while reading file '%ls'\n",
"%s: Error while reading file '%s'\n",
cmd,
if esc == "-" { L!("<stdin>") } else { &esc }
));

View File

@@ -205,7 +205,7 @@ fn print_features(streams: &mut IoStreams) {
L!("off")
};
streams.out.append(sprintf!(
"%-*ls%-3s %ls %ls\n",
"%-*s%-3s %s %s\n",
max_len + 1,
md.name,
set,
@@ -237,7 +237,7 @@ fn parse_cmd_opts(
Ok(level) if level >= 0 => level,
Err(Error::Overflow) | Ok(_) => {
streams.err.append(wgettext_fmt!(
"%ls: Invalid level value '%ls'\n",
"%s: Invalid level value '%s'\n",
cmd,
arg
));
@@ -273,7 +273,7 @@ fn parse_cmd_opts(
}
let Ok(job_mode) = w.woptarg.unwrap().try_into() else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid job control mode '%ls'\n",
"%s: Invalid job control mode '%s'\n",
cmd,
w.woptarg.unwrap()
));
@@ -340,7 +340,7 @@ fn parse_cmd_opts(
pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> BuiltinResult {
localizable_consts!(
#[allow(dead_code)]
NO_EMBEDDED_FILES_MSG "%ls: fish was not built with embedded files"
NO_EMBEDDED_FILES_MSG "%s: fish was not built with embedded files"
);
let cmd = args[0];
@@ -391,7 +391,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
};
streams
.out
.append(wgettext_fmt!("Job control: %ls\n", job_control_mode));
.append(wgettext_fmt!("Job control: %s\n", job_control_mode));
streams.out.append(parser.stack_trace());
return Ok(SUCCESS);
@@ -427,7 +427,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
}
let Ok(new_mode) = args[0].try_into() else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid job control mode '%ls'\n",
"%s: Invalid job control mode '%s'\n",
cmd,
args[0]
));
@@ -554,7 +554,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
}
if args[0] != "scroll-content-up" {
streams.err.appendln(wgettext_fmt!(
"%s %s: unrecognized feature '%ls'",
"%s %s: unrecognized feature '%s'",
cmd,
c.to_wstr(),
args[0]
@@ -727,7 +727,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
let path = get_executable_path("fish");
if path.is_empty() {
streams.err.append(sprintf!(
"%ls: Could not get executable path: '%s'\n",
"%s: Could not get executable path: '%s'\n",
cmd,
Errno::last().to_string()
));

View File

@@ -179,25 +179,25 @@ fn print_error(&self, args: &[&wstr], streams: &mut IoStreams) {
Compile(pattern, e) => {
string_error!(
streams,
"%ls: Regular expression compile error: %ls\n",
"%s: Regular expression compile error: %s\n",
cmd,
&WString::from(e.error_message())
);
string_error!(streams, "%ls: %ls\n", cmd, pattern);
string_error!(streams, "%ls: %*ls\n", cmd, e.offset().unwrap_or(0), "^");
string_error!(streams, "%s: %s\n", cmd, pattern);
string_error!(streams, "%s: %*s\n", cmd, e.offset().unwrap_or(0), "^");
}
InvalidCaptureGroupName(name) => {
streams.err.append(wgettext_fmt!(
"Modification of read-only variable \"%ls\" is not allowed\n",
"Modification of read-only variable \"%s\" is not allowed\n",
name
));
}
InvalidEscape(pattern) => {
string_error!(
streams,
"%ls",
"%s",
sprintf!(
"%ls: Invalid escape sequence in pattern \"%ls\"\n",
"%s: Invalid escape sequence in pattern \"%s\"\n",
cmd,
pattern
)

View File

@@ -21,7 +21,7 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
self.style = arg
.unwrap()
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid escape style '%ls'\n", name, arg))?
.map_err(|_| invalid_args!("%s: Invalid escape style '%s'\n", name, arg))?
}
_ => return Err(StringError::UnknownOption),
}

View File

@@ -54,7 +54,7 @@ fn parse_opt(&mut self, _n: &wstr, c: char, arg: Option<&wstr>) -> Result<(), St
.and_then(|v| NonZeroUsize::new(v as usize))
.ok_or_else(|| {
StringError::InvalidArgs(wgettext_fmt!(
"%ls: Invalid max matches value '%ls'\n",
"%s: Invalid max matches value '%s'\n",
_n,
arg
))
@@ -324,7 +324,7 @@ fn report_match<'a>(
let Some(cg) = cg else {
if self.opts.invert_match && !self.opts.quiet {
if self.opts.index {
streams.out.append(sprintf!("1 %lu\n", arg.len()));
streams.out.append(sprintf!("1 %u\n", arg.len()));
} else {
streams.out.appendln(arg);
}
@@ -353,7 +353,7 @@ fn report_match<'a>(
if self.opts.index {
streams
.out
.append(sprintf!("%lu %lu\n", m.start() + 1, m.end() - m.start()));
.append(sprintf!("%u %u\n", m.start() + 1, m.end() - m.start()));
} else {
streams.out.appendln(&arg[m.start()..m.end()]);
}
@@ -401,7 +401,7 @@ fn report_matches(&mut self, arg: &wstr, streams: &mut IoStreams) {
self.total_matched += 1;
if !self.opts.quiet {
if self.opts.index {
streams.out.append(sprintf!("1 %lu\n", arg.len()));
streams.out.append(sprintf!("1 %u\n", arg.len()));
} else {
streams.out.appendln(arg);
}

View File

@@ -36,7 +36,7 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
'c' => {
let [pad_char] = arg.unwrap().as_char_slice() else {
return Err(invalid_args!(
"%ls: Padding should be a character '%ls'\n",
"%s: Padding should be a character '%s'\n",
name,
arg
));
@@ -44,7 +44,7 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
let pad_char_width = fish_wcwidth(*pad_char);
if pad_char_width <= 0 {
return Err(invalid_args!(
"%ls: Invalid padding character of width zero '%ls'\n",
"%s: Invalid padding character of width zero '%s'\n",
name,
arg
));
@@ -56,7 +56,7 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
'w' => {
self.width = fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid width value '%ls'\n", name, arg))?
.map_err(|_| invalid_args!("%s: Invalid width value '%s'\n", name, arg))?
}
'C' => self.center = true,
_ => return Err(StringError::UnknownOption),

View File

@@ -20,16 +20,17 @@ impl StringSubCommand<'_> for Repeat {
fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(), StringError> {
match c {
'n' => {
self.count =
Some(fish_wcstol(arg.unwrap())?.try_into().map_err(|_| {
invalid_args!("%ls: Invalid count value '%ls'\n", name, arg)
})?)
self.count = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%s: Invalid count value '%s'\n", name, arg))?,
)
}
'm' => {
self.max = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid max value '%ls'\n", name, arg))?,
.map_err(|_| invalid_args!("%s: Invalid max value '%s'\n", name, arg))?,
)
}
'q' => self.quiet = true,
@@ -58,7 +59,7 @@ fn take_args(
*optind += 1;
let Ok(Ok(count)) = fish_wcstol(arg).map(|count| count.try_into()) else {
string_error!(streams, "%ls: Invalid count value '%ls'\n", name, arg);
string_error!(streams, "%s: Invalid count value '%s'\n", name, arg);
return Err(STATUS_INVALID_ARGS);
};

View File

@@ -43,7 +43,7 @@ fn parse_opt(&mut self, _n: &wstr, c: char, arg: Option<&wstr>) -> Result<(), St
.and_then(|v| NonZeroUsize::new(v as usize))
.ok_or_else(|| {
StringError::InvalidArgs(wgettext_fmt!(
"%ls: Invalid max matches value '%ls'\n",
"%s: Invalid max matches value '%s'\n",
_n,
arg
))
@@ -104,7 +104,7 @@ fn handle(
Err(e) => {
string_error!(
streams,
"%ls: Regular expression substitute error: %ls\n",
"%s: Regular expression substitute error: %s\n",
cmd,
e.error_message()
);

View File

@@ -49,7 +49,7 @@ fn parse_opt(
self.max = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid max value '%ls'\n", name, arg))?,
.map_err(|_| invalid_args!("%s: Invalid max value '%s'\n", name, arg))?,
)
}
'N' => self.no_newline = true,

View File

@@ -119,17 +119,17 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
'm' => {
self.max = fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid max value '%ls'\n", name, arg))?
.map_err(|_| invalid_args!("%s: Invalid max value '%s'\n", name, arg))?
}
'n' => self.no_empty = true,
'f' => {
self.fields = arg.unwrap().try_into().map_err(|e| match e {
FieldParseError::Number => StringError::NotANumber,
FieldParseError::Range => {
invalid_args!("%ls: Invalid range value for field '%ls'\n", name, arg)
invalid_args!("%s: Invalid range value for field '%s'\n", name, arg)
}
FieldParseError::Field => {
invalid_args!("%ls: Invalid fields value '%ls'\n", name, arg)
invalid_args!("%s: Invalid fields value '%s'\n", name, arg)
}
})?;
}

View File

@@ -22,22 +22,24 @@ impl StringSubCommand<'_> for Sub {
fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(), StringError> {
match c {
'l' => {
self.length =
Some(fish_wcstol(arg.unwrap())?.try_into().map_err(|_| {
invalid_args!("%ls: Invalid length value '%ls'\n", name, arg)
})?)
self.length = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%s: Invalid length value '%s'\n", name, arg))?,
)
}
's' => {
self.start =
Some(fish_wcstol(arg.unwrap())?.try_into().map_err(|_| {
invalid_args!("%ls: Invalid start value '%ls'\n", name, arg)
})?)
self.start = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%s: Invalid start value '%s'\n", name, arg))?,
)
}
'e' => {
self.end = Some(
fish_wcstol(arg.unwrap())?
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid end value '%ls'\n", name, arg))?,
.map_err(|_| invalid_args!("%s: Invalid end value '%s'\n", name, arg))?,
)
}
'q' => self.quiet = true,

View File

@@ -23,7 +23,7 @@ fn parse_opt(&mut self, name: &wstr, c: char, arg: Option<&wstr>) -> Result<(),
self.style = arg
.unwrap()
.try_into()
.map_err(|_| invalid_args!("%ls: Invalid style value '%ls'\n", name, arg))?
.map_err(|_| invalid_args!("%s: Invalid style value '%s'\n", name, arg))?
}
_ => return Err(StringError::UnknownOption),
}

View File

@@ -757,14 +757,14 @@ pub fn parse_args(
if !parser.errors.is_empty() {
err.push_utfstr(&parser.errors[0]);
} else {
sprintf!(=> err, "unexpected argument at index %lu: '%ls'",
sprintf!(=> err, "unexpected argument at index %u: '%s'",
result.as_ref().unwrap().range().end + 1,
args[result.as_ref().unwrap().range().end]);
}
err.push('\n');
err.push_utfstr(&commandline);
err.push('\n');
err.push_utfstr(&sprintf!("%*ls%ls\n", len_to_err + 1, " ", "^"));
err.push_utfstr(&sprintf!("%*s%s\n", len_to_err + 1, " ", "^"));
}
if result.is_some() {
@@ -846,12 +846,12 @@ fn parse_number(arg: &wstr, number: &mut Number, errors: &mut Vec<WString>) -> b
if let Ok(prefix_int) = wcstoi_opts(arg, options) {
let _: i64 = prefix_int; // to help type inference
errors.push(wgettext_fmt!(
"Integer %lld in '%ls' followed by non-digit",
"Integer %d in '%s' followed by non-digit",
prefix_int,
arg
));
} else {
errors.push(wgettext_fmt!("Argument is not a number: '%ls'", arg));
errors.push(wgettext_fmt!("Argument is not a number: '%s'", arg));
}
} else if floating.is_ok_and(|x| x.is_nan()) {
// NaN is an error as far as we're concerned.
@@ -859,9 +859,9 @@ fn parse_number(arg: &wstr, number: &mut Number, errors: &mut Vec<WString>) -> b
} else if floating.is_ok_and(|x| x.is_infinite()) {
errors.push(wgettext!("Number is infinite").to_owned());
} else if integral == Err(Error::Overflow) {
errors.push(wgettext_fmt!("Result too large: %ls", arg));
errors.push(wgettext_fmt!("Result too large: %s", arg));
} else {
errors.push(wgettext_fmt!("Invalid number: %ls", arg));
errors.push(wgettext_fmt!("Invalid number: %s", arg));
}
false
}
@@ -1023,7 +1023,7 @@ pub fn test(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
if feature_test(FeatureFlag::test_require_arg) {
if argc == 0 {
streams.err.appendln(wgettext_fmt!(
"%ls: Expected at least one argument",
"%s: Expected at least one argument",
program_name
));
builtin_print_error_trailer(parser, streams.err, program_name);
@@ -1038,7 +1038,7 @@ pub fn test(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
} else if argc == 0 {
if should_flog!(deprecated_test) {
streams.err.appendln(wgettext_fmt!(
"%ls: called with no arguments. This will be an error in future.",
"%s: called with no arguments. This will be an error in future.",
program_name
));
streams.err.append(parser.current_line());
@@ -1048,7 +1048,7 @@ pub fn test(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
if should_flog!(deprecated_test) {
if args[0] != "-z" {
streams.err.appendln(wgettext_fmt!(
"%ls: called with one argument. This will return false in future.",
"%s: called with one argument. This will return false in future.",
program_name
));
streams.err.append(parser.current_line());

View File

@@ -103,7 +103,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
} else {
let lineno: i32 = props.definition_lineno();
comment.push_utfstr(&wgettext_fmt!(
"Defined in %ls @ line %d",
"Defined in %s @ line %d",
path,
lineno
));
@@ -118,7 +118,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
} else {
let lineno = props.copy_definition_lineno();
comment.push_utfstr(&wgettext_fmt!(
", copied in %ls @ line %d",
", copied in %s @ line %d",
path,
lineno
));
@@ -131,11 +131,11 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
streams.out.appendln(path);
}
} else if !opts.short_output {
streams.out.append(wgettext_fmt!("%ls is a function", arg));
streams.out.append(wgettext_fmt!("%s is a function", arg));
streams.out.appendln(wgettext!(" with definition"));
let mut def = WString::new();
def.push_utfstr(&sprintf!(
"# %ls\n%ls",
"# %s\n%s",
comment,
props.annotated_definition(arg)
));
@@ -158,8 +158,8 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
streams.out.append(def);
}
} else {
streams.out.append(wgettext_fmt!("%ls is a function", arg));
streams.out.append(wgettext_fmt!(" (%ls)\n", comment));
streams.out.append(wgettext_fmt!("%s is a function", arg));
streams.out.append(wgettext_fmt!(" (%s)\n", comment));
}
} else if opts.get_type {
streams.out.appendln(L!("function"));
@@ -177,7 +177,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
return Ok(SUCCESS);
}
if !opts.get_type {
streams.out.append(wgettext_fmt!("%ls is a builtin\n", arg));
streams.out.append(wgettext_fmt!("%s is a builtin\n", arg));
} else if opts.get_type {
streams.out.append(L!("builtin\n"));
}
@@ -205,7 +205,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
if opts.path || opts.force_path {
streams.out.appendln(path);
} else {
streams.out.append(wgettext_fmt!("%ls is %ls\n", arg, path));
streams.out.append(wgettext_fmt!("%s is %s\n", arg, path));
}
} else if opts.get_type {
streams.out.appendln(L!("file"));
@@ -221,11 +221,9 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B
}
if found == 0 && !opts.query && !opts.path {
streams.err.append(wgettext_fmt!(
"%ls: Could not find '%ls'\n",
L!("type"),
arg
));
streams
.err
.append(wgettext_fmt!("%s: Could not find '%s'\n", L!("type"), arg));
}
}

View File

@@ -117,7 +117,7 @@ fn print(resource: c_uint, hard: bool, streams: &mut IoStreams) {
} else {
streams
.out
.append(wgettext_fmt!("%lu\n", l / get_multiplier(resource)));
.append(wgettext_fmt!("%u\n", l / get_multiplier(resource)));
}
}
@@ -142,7 +142,7 @@ fn print_all(hard: bool, streams: &mut IoStreams) {
"(kB, "
};
streams.out.append(sprintf!(
"%-*ls %10ls-%lc) ",
"%-*s %10s-%c) ",
w,
resource.desc,
unit,
@@ -152,10 +152,9 @@ fn print_all(hard: bool, streams: &mut IoStreams) {
if l == RLIM_INFINITY {
streams.out.append(wgettext!("unlimited\n"));
} else {
streams.out.append(wgettext_fmt!(
"%lu\n",
l / get_multiplier(resource.resource)
));
streams
.out
.append(wgettext_fmt!("%u\n", l / get_multiplier(resource.resource)));
}
}
}
@@ -197,7 +196,7 @@ fn set_limit(
if let Err(errno) = setrlimit(resource, rlim_cur, rlim_max) {
if errno == Errno::EPERM {
streams.err.append(wgettext_fmt!(
"ulimit: Permission denied when changing resource of type '%ls'\n",
"ulimit: Permission denied when changing resource of type '%s'\n",
get_desc(resource)
));
} else {
@@ -334,7 +333,7 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
if opts.what == -1 {
streams.err.append(wgettext_fmt!(
"%ls: Resource limit not available on this operating system\n",
"%s: Resource limit not available on this operating system\n",
cmd
));
@@ -368,7 +367,7 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
let new_limit: rlim_t = if w.wopt_index == argc {
streams.err.append(wgettext_fmt!(
"%ls: New limit cannot be an empty string\n",
"%s: New limit cannot be an empty string\n",
cmd
));
builtin_print_error_trailer(parser, streams.err, cmd);
@@ -388,7 +387,7 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
} else if let Ok(limit) = fish_wcstol(w.argv[w.wopt_index]) {
let Some(x) = get_multiplier(what).checked_mul(limit as rlim_t) else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid limit '%ls'\n",
"%s: Invalid limit '%s'\n",
cmd,
w.argv[w.wopt_index]
));
@@ -398,7 +397,7 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
x
} else {
streams.err.append(wgettext_fmt!(
"%ls: Invalid limit '%ls'\n",
"%s: Invalid limit '%s'\n",
cmd,
w.argv[w.wopt_index]
));

View File

@@ -199,7 +199,7 @@ pub fn wait(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
let mpid: i32 = fish_wcstoi(item).unwrap_or(-1);
let Some(mpid) = Pid::new(mpid) else {
streams.err.append(wgettext_fmt!(
"%ls: '%ls' is not a valid process id\n",
"%s: '%s' is not a valid process id\n",
cmd,
item,
));
@@ -207,7 +207,7 @@ pub fn wait(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
};
if !find_wait_handles(WaitHandleQuery::Pid(mpid), parser, &mut wait_handles) {
streams.err.append(wgettext_fmt!(
"%ls: Could not find a job with process id '%d'\n",
"%s: Could not find a job with process id '%d'\n",
cmd,
mpid,
));
@@ -216,7 +216,7 @@ pub fn wait(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
// argument is process name
if !find_wait_handles(WaitHandleQuery::ProcName(item), parser, &mut wait_handles) {
streams.err.append(wgettext_fmt!(
"%ls: Could not find child processes with the name '%ls'\n",
"%s: Could not find child processes with the name '%s'\n",
cmd,
item,
));

View File

@@ -1458,7 +1458,7 @@ pub fn reformat_for_screen(msg: &wstr, termsize: &Termsize) -> WString {
if line_width != 0 {
buff.push('\n');
}
buff += &sprintf!("%ls-\n", token)[..];
buff += &sprintf!("%s-\n", token)[..];
line_width = 0;
} else {
// Print the token.

View File

@@ -62,13 +62,13 @@
// description strings should be defined in the same file?
/// Description for ~USER completion.
static COMPLETE_USER_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("Home for %ls"));
static COMPLETE_USER_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("Home for %s"));
/// Description for short variables. The value is concatenated to this description.
static COMPLETE_VAR_DESC_VAL: Lazy<&wstr> = Lazy::new(|| wgettext!("Variable: %ls"));
static COMPLETE_VAR_DESC_VAL: Lazy<&wstr> = Lazy::new(|| wgettext!("Variable: %s"));
/// Description for abbreviations.
static ABBR_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("Abbreviation: %ls"));
static ABBR_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("Abbreviation: %s"));
#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
pub struct CompletionMode {
@@ -1481,7 +1481,7 @@ fn complete_param_for_command(
// a completion. By default we avoid using '=' and instead rely on '--switch
// switch-arg', since it is more commonly supported by homebrew getopt-like
// functions.
let completion = sprintf!("%ls=", whole_opt.slice_from(offset));
let completion = sprintf!("%s=", whole_opt.slice_from(offset));
// Append a long-style option with a mandatory trailing equal sign
if !self.completions.add(Completion::new(
@@ -1590,7 +1590,7 @@ fn complete_param_expand(
.result,
ExpandResultCode::error | ExpandResultCode::overflow,
) {
FLOGF!(complete, "Error while expanding string '%ls'", s);
FLOGF!(complete, "Error while expanding string '%s'", s);
}
Self::escape_opening_brackets(&mut self.completions[first_from_start..], s);
}
@@ -1624,7 +1624,7 @@ fn complete_param_expand(
.result,
ExpandResultCode::error | ExpandResultCode::overflow
) {
FLOGF!(complete, "Error while expanding string '%ls'", sep_string);
FLOGF!(complete, "Error while expanding string '%s'", sep_string);
}
Self::escape_opening_brackets(&mut local_completions, s);
@@ -1823,7 +1823,7 @@ fn getpwent_name() -> Option<WString> {
));
result = true;
} else if string_prefixes_string_case_insensitive(user_name, &pw_name) {
let name = sprintf!("~%ls", &pw_name);
let name = sprintf!("~%s", &pw_name);
let desc = sprintf!(*COMPLETE_USER_DESC, &pw_name);
// Append a user name
@@ -2367,20 +2367,20 @@ fn append_switch_short_arg(out: &mut WString, opt: char, arg: &wstr) {
return;
}
sprintf!(=> out, " -%lc %ls", opt, escape(arg));
sprintf!(=> out, " -%c %s", opt, escape(arg));
}
fn append_switch_long_arg(out: &mut WString, opt: &wstr, arg: &wstr) {
if arg.is_empty() {
return;
}
sprintf!(=> out, " --%ls %ls", opt, escape(arg));
sprintf!(=> out, " --%s %s", opt, escape(arg));
}
fn append_switch_short(out: &mut WString, opt: char) {
sprintf!(=> out, " -%lc", opt);
sprintf!(=> out, " -%c", opt);
}
fn append_switch_long(out: &mut WString, opt: &wstr) {
sprintf!(=> out, " --%ls", opt);
sprintf!(=> out, " --%s", opt);
}
fn completion2string(index: &CompletionEntryIndex, o: &CompleteEntryOpt) -> WString {

View File

@@ -30,12 +30,12 @@ pub fn new(argv0: &wstr) -> Self {
let paths = Self::from_exec_path(exec_path);
FLOGF!(
config,
"paths.sysconf: %ls",
"paths.sysconf: %s",
paths.sysconf.display().to_string()
);
FLOGF!(
config,
"paths.bin: %ls",
"paths.bin: %s",
paths
.bin
.clone()
@@ -43,9 +43,9 @@ pub fn new(argv0: &wstr) -> Self {
.unwrap_or("|not found|".to_string()),
);
#[cfg(not(feature = "embed-data"))]
FLOGF!(config, "paths.data: %ls", paths.data.display().to_string());
FLOGF!(config, "paths.data: %s", paths.data.display().to_string());
#[cfg(not(feature = "embed-data"))]
FLOGF!(config, "paths.doc: %ls", paths.doc.display().to_string());
FLOGF!(config, "paths.doc: %s", paths.doc.display().to_string());
paths
}

View File

@@ -633,7 +633,7 @@ pub fn default_vars_path() -> WString {
}
/// Error message.
const PARSE_ERR: &wstr = L!("Unable to parse universal variable message: '%ls'");
const PARSE_ERR: &wstr = L!("Unable to parse universal variable message: '%s'");
/// Small note about not editing ~/.fishd manually. Inserted at the top of all .fishd files.
const SAVE_MSG: &[u8] = b"# This file contains fish universal variable definitions.\n";
@@ -747,7 +747,7 @@ fn append_file_entry(
// Append variable name like "fish_color_cwd".
if !valid_var_name(key_in) {
FLOGF!(error, "Illegal variable name: '%ls'", key_in);
FLOGF!(error, "Illegal variable name: '%s'", key_in);
success = false;
}
if success {

View File

@@ -632,7 +632,7 @@ pub fn print(streams: &mut IoStreams, type_filter: &wstr) {
}
last_type = std::mem::discriminant(&evt.desc);
streams.out.append(sprintf!("Event %ls\n", evt.desc.name()));
streams.out.append(sprintf!("Event %s\n", evt.desc.name()));
}
match &evt.desc {
@@ -640,18 +640,18 @@ pub fn print(streams: &mut IoStreams, type_filter: &wstr) {
let name: WString = signal.name().into();
streams
.out
.append(sprintf!("%ls %ls\n", name, evt.function_name));
.append(sprintf!("%s %s\n", name, evt.function_name));
}
EventDescription::ProcessExit { .. } | EventDescription::JobExit { .. } => {}
EventDescription::CallerExit { .. } => {
streams
.out
.append(sprintf!("caller-exit %ls\n", evt.function_name));
.append(sprintf!("caller-exit %s\n", evt.function_name));
}
EventDescription::Variable { name: param } | EventDescription::Generic { param } => {
streams
.out
.append(sprintf!("%ls %ls\n", param, evt.function_name));
.append(sprintf!("%s %s\n", param, evt.function_name));
}
EventDescription::Any => unreachable!(),
}

View File

@@ -212,7 +212,7 @@ pub fn exec_job(parser: &Parser, job: &Job, block_io: IoChain) -> bool {
FLOGF!(
exec_job_exec,
"Executed job %d from command '%ls'",
"Executed job %d from command '%s'",
job.job_id(),
job.command()
);
@@ -574,7 +574,7 @@ fn skip_err(&self) -> bool {
FLOGF!(
proc_internal_proc,
"Created internal proc %llu to write output for proc '%ls'",
"Created internal proc %u to write output for proc '%s'",
internal_proc.get_id(),
p.argv0().unwrap()
);
@@ -646,7 +646,7 @@ fn run_internal_process_or_short_circuit(
if p.is_last_in_job {
FLOGF!(
exec_job_status,
"Set status of job %d (%ls) to %d using short circuit",
"Set status of job %d (%s) to %d using short circuit",
j.job_id(),
j.preview(),
p.status().status_value()
@@ -759,7 +759,7 @@ fn fork_child_for_process(
let count = FORK_COUNT.fetch_add(1, Ordering::Relaxed) + 1;
FLOGF!(
exec_fork,
"Fork #%d, pid %d fork external command for '%ls'",
"Fork #%d, pid %d fork external command for '%s'",
count,
pid,
p.argv0().unwrap()
@@ -895,7 +895,7 @@ fn exec_external_command(
};
FLOGF!(
exec_fork,
"Fork #%d, pid %d: spawn external command '%s' from '%ls'",
"Fork #%d, pid %d: spawn external command '%s' from '%s'",
count,
pid,
p.actual_cmd,
@@ -1017,7 +1017,7 @@ fn get_performer_for_function(
let Some(props) = function::get_props(p.argv0().unwrap()) else {
FLOG!(
error,
wgettext_fmt!("Unknown function '%ls'", p.argv0().unwrap())
wgettext_fmt!("Unknown function '%s'", p.argv0().unwrap())
);
return Err(());
};

View File

@@ -267,7 +267,7 @@ fn apply_one_wildcard(wc_esc: &wstr, sense: bool) {
}
}
if !match_found {
eprintf!("Failed to match debug category: %ls\n", wc_esc);
eprintf!("Failed to match debug category: %s\n", wc_esc);
}
}

View File

@@ -56,11 +56,7 @@ pub fn create_temporary_file(name_template: &wstr) -> std::io::Result<(File, WSt
_ => {
FLOG!(
error,
wgettext_fmt!(
"Unable to create temporary file '%ls': %s",
name_template,
e
)
wgettext_fmt!("Unable to create temporary file '%s': %s", name_template, e)
);
return Err(e);

View File

@@ -448,10 +448,10 @@ pub fn annotated_definition(&self, name: &wstr) -> WString {
let d = &handler.desc;
match d {
EventDescription::Signal { signal } => {
sprintf!(=> &mut out, " --on-signal %ls", signal.name());
sprintf!(=> &mut out, " --on-signal %s", signal.name());
}
EventDescription::Variable { name } => {
sprintf!(=> &mut out, " --on-variable %ls", name);
sprintf!(=> &mut out, " --on-variable %s", name);
}
EventDescription::ProcessExit { pid } => {
let pid = pid.map(|p| p.get()).unwrap_or(0);
@@ -465,7 +465,7 @@ pub fn annotated_definition(&self, name: &wstr) -> WString {
out.push_str(" --on-job-exit caller");
}
EventDescription::Generic { param } => {
sprintf!(=> &mut out, " --on-event %ls", param);
sprintf!(=> &mut out, " --on-event %s", param);
}
EventDescription::Any => {
panic!("Unexpected event handler type");
@@ -476,7 +476,7 @@ pub fn annotated_definition(&self, name: &wstr) -> WString {
let named = &self.named_arguments;
if !named.is_empty() {
for name in named {
sprintf!(=> &mut out, " --argument-names %ls", name);
sprintf!(=> &mut out, " --argument-names %s", name);
}
}
@@ -490,7 +490,7 @@ pub fn annotated_definition(&self, name: &wstr) -> WString {
for (name, values) in self.inherit_vars.iter() {
// We don't know what indentation style the function uses,
// so we do what fish_indent would.
sprintf!(=> &mut out, "\n set -l %ls", name);
sprintf!(=> &mut out, "\n set -l %s", name);
for arg in values {
out.push(' ');
out.push_utfstr(&escape(arg));

View File

@@ -461,7 +461,7 @@ fn populate_from_file_contents(&mut self) {
}
}
FLOGF!(history, "Loaded %lu old items", self.old_item_offsets.len());
FLOGF!(history, "Loaded %u old items", self.old_item_offsets.len());
}
/// Loads old items if necessary.
@@ -619,7 +619,7 @@ fn rewrite_to_temporary_file(
fn save_internal_via_rewrite(&mut self, history_path: &wstr) -> std::io::Result<()> {
FLOGF!(
history,
"Saving %lu items via rewrite",
"Saving %u items via rewrite",
self.new_items.len() - self.first_unwritten_new_item_index
);
@@ -652,7 +652,7 @@ fn save_internal_via_rewrite(&mut self, history_path: &wstr) -> std::io::Result<
fn save_internal_via_appending(&mut self, history_path: &wstr) -> std::io::Result<()> {
FLOGF!(
history,
"Saving %lu items via appending",
"Saving %u items via appending",
self.new_items.len() - self.first_unwritten_new_item_index
);
// No deleting allowed.
@@ -1725,7 +1725,7 @@ pub fn history_session_id_from_var(history_name_var: Option<EnvVar>) -> WString
FLOG!(
error,
wgettext_fmt!(
"History session ID '%ls' is not a valid variable name. Falling back to `%ls`.",
"History session ID '%s' is not a valid variable name. Falling back to `%s`.",
&session_id,
DFLT_FISH_HISTORY_SESSION_ID
),

View File

@@ -229,7 +229,7 @@ const fn _assert_sizes_match() {
#[allow(dead_code)]
pub fn describe_char(c: i32) -> WString {
if c > 0 && (c as usize) < R_END_INPUT_FUNCTIONS {
return sprintf!("%02x (%ls)", c, INPUT_FUNCTION_METADATA[c as usize].name);
return sprintf!("%02x (%s)", c, INPUT_FUNCTION_METADATA[c as usize].name);
}
return sprintf!("%02x", c);
}

View File

@@ -681,7 +681,7 @@ pub fn update_wait_on_escape_ms(vars: &EnvStack) {
_ => {
eprintf!(
concat!(
"ignoring fish_escape_delay_ms: value '%ls' ",
"ignoring fish_escape_delay_ms: value '%s' ",
"is not an integer or is < 10 or >= 5000 ms\n"
),
fish_escape_delay_ms
@@ -706,7 +706,7 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) {
_ => {
eprintf!(
concat!(
"ignoring fish_sequence_key_delay_ms: value '%ls' ",
"ignoring fish_sequence_key_delay_ms: value '%s' ",
"is not an integer or is < 10 or >= 5000 ms\n"
),
sequence_key_time_ms

View File

@@ -541,9 +541,9 @@ pub fn append_from_specs(&mut self, specs: &RedirectionSpecList, pwd: &wstr) ->
let next: &wstr = wdirname(dname);
if let Ok(md) = wstat(next) {
if !md.is_dir() {
FLOGF!(warning, "Path '%ls' is not a directory", next);
FLOGF!(warning, "Path '%s' is not a directory", next);
} else {
FLOGF!(warning, "Path '%ls' does not exist", dname);
FLOGF!(warning, "Path '%s' does not exist", dname);
}
break;
}
@@ -631,12 +631,12 @@ pub fn print(&self) {
}
eprintf!(
"Chain %s (%ld items):\n",
"Chain %s (%d items):\n",
format!("{:p}", std::ptr::addr_of!(self)),
self.0.len()
);
for (i, io) in self.0.iter().enumerate() {
eprintf!("\t%lu: fd:%d, ", i, io.fd());
eprintf!("\t%u: fd:%d, ", i, io.fd());
io.print();
}
}
@@ -910,8 +910,8 @@ pub fn out_is_terminal(&self) -> bool {
}
/// File redirection error message.
const FILE_ERROR: &wstr = L!("An error occurred while redirecting file '%ls'");
const NOCLOB_ERROR: &wstr = L!("The file '%ls' already exists");
const FILE_ERROR: &wstr = L!("An error occurred while redirecting file '%s'");
const NOCLOB_ERROR: &wstr = L!("The file '%s' already exists");
/// Base open mode to pass to calls to open.
const OPEN_MASK: Mode = Mode::from_bits_truncate(0o666);

View File

@@ -447,7 +447,7 @@ pub fn char_to_symbol(c: char, is_first_in_token: bool) -> WString {
// Unmapped key from https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
sprintf!(=> buf, "\\u%04X", u32::from(c));
} else if fish_wcwidth(c) > 0 {
sprintf!(=> buf, "%lc", c);
sprintf!(=> buf, "%c", c);
} else if c <= '\u{FFFF}' {
// BMP Unicode character
sprintf!(=> buf, "\\u%04X", u32::from(c));

View File

@@ -273,7 +273,7 @@ fn completion_try_print(
assert_ne!(rendering.remaining_to_disclose, 1);
if rendering.remaining_to_disclose > 1 {
progress_text = wgettext_fmt!(
"%lsand %lu more rows",
"%sand %u more rows",
get_ellipsis_str(),
rendering.remaining_to_disclose
);
@@ -282,7 +282,7 @@ fn completion_try_print(
// to present things as 1-indexed. We do not add 1 to stop_row or row_count because
// these are the "past the last value".
progress_text =
wgettext_fmt!("rows %lu to %lu of %lu", start_row + 1, stop_row, row_count);
wgettext_fmt!("rows %u to %u of %u", start_row + 1, stop_row, row_count);
} else if self.search_field_shown && self.completion_infos.is_empty() {
// Everything is filtered.
progress_text = wgettext!("(no matches)").to_owned();

View File

@@ -416,7 +416,7 @@ pub fn token_type_user_presentable_description(
keyword: ParseKeyword,
) -> WString {
if keyword != ParseKeyword::None {
return sprintf!("keyword: '%ls'", keyword.to_wstr());
return sprintf!("keyword: '%s'", keyword.to_wstr());
}
match type_ {
ParseTokenType::string => L!("a string").to_owned(),
@@ -432,7 +432,7 @@ pub fn token_type_user_presentable_description(
ParseTokenType::error => L!("a parse error").to_owned(),
ParseTokenType::tokenizer_error => L!("an incomplete token").to_owned(),
ParseTokenType::comment => L!("a comment").to_owned(),
_ => sprintf!("a %ls", type_.to_wstr()),
_ => sprintf!("a %s", type_.to_wstr()),
}
}
@@ -464,7 +464,7 @@ pub fn parse_error_offset_source_start(errors: &mut ParseErrorList, amt: usize)
localizable_consts!(
/// Error message on a function that calls itself immediately.
pub INFINITE_FUNC_RECURSION_ERR_MSG
"The function '%ls' calls itself immediately, which would result in an infinite loop."
"The function '%s' calls itself immediately, which would result in an infinite loop."
/// Error message on reaching maximum call stack depth.
pub CALL_STACK_LIMIT_EXCEEDED_ERR_MSG
@@ -472,19 +472,19 @@ pub fn parse_error_offset_source_start(errors: &mut ParseErrorList, amt: usize)
/// Error message when encountering an unknown builtin name.
pub UNKNOWN_BUILTIN_ERR_MSG
"Unknown builtin '%ls'"
"Unknown builtin '%s'"
/// Error message when encountering a failed expansion, e.g. for the variable name in for loops.
pub FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG
"Unable to expand variable name '%ls'"
"Unable to expand variable name '%s'"
/// Error message when encountering an illegal file descriptor.
pub ILLEGAL_FD_ERR_MSG
"Illegal file descriptor in redirection '%ls'"
"Illegal file descriptor in redirection '%s'"
/// Error message for wildcards with no matches.
pub WILDCARD_ERR_MSG
"No matches for wildcard '%ls'. See `help wildcards-globbing`."
"No matches for wildcard '%s'. See `help wildcards-globbing`."
/// Error when using break outside of loop.
pub INVALID_BREAK_ERR_MSG
@@ -496,21 +496,21 @@ pub fn parse_error_offset_source_start(errors: &mut ParseErrorList, amt: usize)
/// Error message when a command may not be in a pipeline.
pub INVALID_PIPELINE_CMD_ERR_MSG
"The '%ls' command can not be used in a pipeline"
"The '%s' command can not be used in a pipeline"
// Error messages. The number is a reminder of how many format specifiers are contained.
/// Error for $^.
pub ERROR_BAD_VAR_CHAR1
"$%lc is not a valid variable in fish."
"$%c is not a valid variable in fish."
/// Error for ${a}.
pub ERROR_BRACKETED_VARIABLE1
"Variables cannot be bracketed. In fish, please use {$%ls}."
"Variables cannot be bracketed. In fish, please use {$%s}."
/// Error for "${a}".
pub ERROR_BRACKETED_VARIABLE_QUOTED1
"Variables cannot be bracketed. In fish, please use \"$%ls\"."
"Variables cannot be bracketed. In fish, please use \"$%s\"."
/// Error issued on $?.
pub ERROR_NOT_STATUS
@@ -538,7 +538,7 @@ pub fn parse_error_offset_source_start(errors: &mut ParseErrorList, amt: usize)
/// Error message for Posix-style assignment: foo=bar.
pub ERROR_BAD_COMMAND_ASSIGN_ERR_MSG
"Unsupported use of '='. In fish, please use 'set %ls %ls'."
"Unsupported use of '='. In fish, please use 'set %s %s'."
/// Error message for a command like `time foo &`.
pub ERROR_TIME_BACKGROUND

View File

@@ -277,7 +277,7 @@ fn handle_command_not_found(
ctx,
STATUS_NOT_EXECUTABLE,
&statement.command,
"Unknown command. A component of '%ls' is not a directory. Check your $PATH.",
"Unknown command. A component of '%s' is not a directory. Check your $PATH.",
cmd
);
} else {
@@ -286,7 +286,7 @@ fn handle_command_not_found(
ctx,
STATUS_NOT_EXECUTABLE,
&statement.command,
"Unknown command. A component of '%ls' is not a directory.",
"Unknown command. A component of '%s' is not a directory.",
cmd
);
}
@@ -297,7 +297,7 @@ fn handle_command_not_found(
ctx,
STATUS_NOT_EXECUTABLE,
&statement.command,
"Unknown command. '%ls' exists but is not an executable file.",
"Unknown command. '%s' exists but is not an executable file.",
cmd
);
}
@@ -903,7 +903,7 @@ fn run_for_statement(
ctx,
STATUS_INVALID_ARGS,
header.var_name,
"%ls: %ls: cannot overwrite read-only variable",
"%s: %s: cannot overwrite read-only variable",
"for",
for_var_name
);
@@ -1094,7 +1094,7 @@ fn run_switch_statement(
ctx,
STATUS_INVALID_ARGS,
&statement.argument,
"switch: Expected at most one argument, got %lu\n",
"switch: Expected at most one argument, got %u\n",
switch_values_expanded.len()
);
}
@@ -1286,7 +1286,7 @@ fn run_function_statement(
let errtext = errs.contents();
if !errtext.is_empty() {
report_error!(self, ctx, err_code, header, "%ls", errtext);
report_error!(self, ctx, err_code, header, "%s", errtext);
}
result
}
@@ -1419,7 +1419,7 @@ fn determine_redirections(
ctx,
STATUS_INVALID_ARGS,
redir_node,
"Invalid redirection: %ls",
"Invalid redirection: %s",
self.node_source(redir_node)
);
}
@@ -1445,7 +1445,7 @@ fn determine_redirections(
ctx,
STATUS_INVALID_ARGS,
redir_node,
"Invalid redirection target: %ls",
"Invalid redirection target: %s",
target
);
if oper.mode == RedirectionMode::input && {
@@ -1481,7 +1481,7 @@ fn determine_redirections(
ctx,
STATUS_INVALID_ARGS,
redir_node,
"Requested redirection to '%ls', which is not a valid file descriptor",
"Requested redirection to '%s', which is not a valid file descriptor",
&spec.target
);
}

View File

@@ -74,7 +74,7 @@ pub fn is_dash_prefix_string(&self) -> bool {
pub fn describe(&self) -> WString {
let mut result = self.typ.to_wstr().to_owned();
if self.keyword != ParseKeyword::None {
sprintf!(=> &mut result, " <%ls>", self.keyword.to_wstr())
sprintf!(=> &mut result, " <%s>", self.keyword.to_wstr())
}
result
}

View File

@@ -1410,7 +1410,7 @@ pub fn parse_util_detect_errors_in_argument(
out_errors,
source_start + begin,
end - begin,
"Incomplete escape sequence '%ls'",
"Incomplete escape sequence '%s'",
arg_src
);
return ParserTestErrorBits::ERROR;
@@ -1419,7 +1419,7 @@ pub fn parse_util_detect_errors_in_argument(
out_errors,
source_start + begin,
end - begin,
"Invalid token '%ls'",
"Invalid token '%s'",
arg_src
);
}
@@ -1948,7 +1948,7 @@ pub fn parse_util_expand_variable_error(
localizable_consts!(
/// Error message for use of backgrounded commands before and/or.
pub(crate) BOOL_AFTER_BACKGROUND_ERROR_MSG
"The '%ls' command can not be used immediately after a backgrounded job"
"The '%s' command can not be used immediately after a backgrounded job"
/// Error message for backgrounded commands as conditionals.
BACKGROUND_IN_CONDITIONAL_ERROR_MSG

View File

@@ -133,7 +133,7 @@ pub fn description(&self) -> WString {
result.push_utfstr(&sprintf!(" (line %d)", src_lineno.get()));
}
if let Some(src_filename) = &self.src_filename {
result.push_utfstr(&sprintf!(" (file %ls)", src_filename));
result.push_utfstr(&sprintf!(" (file %s)", src_filename));
}
result
}
@@ -762,7 +762,7 @@ pub fn current_line(&self) -> WString {
if !self.is_interactive() || self.is_function() {
if let Some(file) = file {
prefix.push_utfstr(&wgettext_fmt!(
"%ls (line %d): ",
"%s (line %d): ",
&user_presentable_path(&file, self.vars()),
lineno
));
@@ -1126,12 +1126,12 @@ pub fn get_backtrace(&self, src: &wstr, errors: &ParseErrorList) -> WString {
let prefix = if let Some(filename) = self.current_filename() {
if which_line > 0 {
wgettext_fmt!(
"%ls (line %lu): ",
"%s (line %u): ",
user_presentable_path(&filename, self.vars()),
which_line
)
} else {
sprintf!("%ls: ", user_presentable_path(&filename, self.vars()))
sprintf!("%s: ", user_presentable_path(&filename, self.vars()))
}
} else {
L!("fish: ").to_owned()
@@ -1283,7 +1283,7 @@ fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &m
let Some(BlockData::Function { name, args, .. }) = b.data() else {
unreachable!()
};
trace.push_utfstr(&wgettext_fmt!("in function '%ls'", name));
trace.push_utfstr(&wgettext_fmt!("in function '%s'", name));
// Print arguments on the same line.
let mut args_str = WString::new();
for arg in args {
@@ -1303,7 +1303,7 @@ fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &m
}
if !args_str.is_empty() {
// TODO: Escape these.
trace.push_utfstr(&wgettext_fmt!(" with arguments '%ls'", args_str));
trace.push_utfstr(&wgettext_fmt!(" with arguments '%s'", args_str));
}
trace.push('\n');
print_call_site = true;
@@ -1318,7 +1318,7 @@ fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &m
};
let source_dest = file;
trace.push_utfstr(&wgettext_fmt!(
"from sourcing file %ls\n",
"from sourcing file %s\n",
&user_presentable_path(source_dest, parser.vars())
));
print_call_site = true;
@@ -1328,7 +1328,7 @@ fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &m
unreachable!()
};
let description = event::get_desc(parser, event);
trace.push_utfstr(&wgettext_fmt!("in event handler: %ls\n", &description));
trace.push_utfstr(&wgettext_fmt!("in event handler: %s\n", &description));
print_call_site = true;
}
BlockType::top
@@ -1345,7 +1345,7 @@ fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &m
// Print where the function is called.
if let Some(file) = b.src_filename.as_ref() {
trace.push_utfstr(&sprintf!(
"\tcalled on line %d of file %ls\n",
"\tcalled on line %d of file %s\n",
b.src_lineno.map(|n| n.get()).unwrap_or(0),
user_presentable_path(file, parser.vars())
));

View File

@@ -150,12 +150,12 @@ fn maybe_issue_path_warning(
if path.is_empty() {
FLOG!(
warning_path,
wgettext_fmt!("Unable to locate the %ls directory.", which_dir)
wgettext_fmt!("Unable to locate the %s directory.", which_dir)
);
FLOG!(
warning_path,
wgettext_fmt!(
"Please set the %ls or HOME environment variable before starting fish.",
"Please set the %s or HOME environment variable before starting fish.",
xdg_var
)
);
@@ -164,7 +164,7 @@ fn maybe_issue_path_warning(
FLOG!(
warning_path,
wgettext_fmt!(
"Unable to locate %ls directory derived from $%ls: '%ls'.",
"Unable to locate %s directory derived from $%s: '%s'.",
which_dir,
env_var,
path
@@ -177,7 +177,7 @@ fn maybe_issue_path_warning(
FLOG!(
warning_path,
wgettext_fmt!(
"Please set $%ls to a directory where you have write access.",
"Please set $%s to a directory where you have write access.",
env_var
)
);
@@ -236,7 +236,7 @@ fn path_check_executable(path: &wstr) -> Result<(), std::io::Error> {
/// Return all the paths that match the given command.
pub fn path_get_paths(cmd: &wstr, vars: &dyn Environment) -> Vec<WString> {
FLOGF!(path, "path_get_paths('%ls')", cmd);
FLOGF!(path, "path_get_paths('%s')", cmd);
let mut paths = vec![];
// If the command has a slash, it must be an absolute or relative path and thus we don't bother

View File

@@ -782,7 +782,7 @@ pub fn posts_job_exit_events(&self) -> bool {
pub fn continue_job(&self, parser: &Parser) {
FLOGF!(
proc_job_run,
"Run job %d (%ls), %ls, %ls",
"Run job %d (%s), %s, %s",
self.job_id(),
self.command(),
if self.is_completed() {
@@ -822,7 +822,7 @@ pub fn resume(&self) -> bool {
if !self.signal(SIGCONT) {
FLOGF!(
proc_pgroup,
"Failed to send SIGCONT to procs in job %ls",
"Failed to send SIGCONT to procs in job %s",
self.command()
);
return false;
@@ -991,7 +991,7 @@ pub fn print_exit_warning_for_jobs(jobs: &JobList) {
// Unwrap safety: we can't have a background job that doesn't have an external process and
// external processes always have a pid set.
printf!(
"%6d %ls\n",
"%6d %s\n",
j.external_procs().next().and_then(|p| p.pid()).unwrap(),
j.command()
);
@@ -1251,7 +1251,7 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool) {
if status.normal_exited() || status.signal_exited() {
FLOGF!(
proc_reap_external,
"Reaped external process '%ls' (pid %d, status %d)",
"Reaped external process '%s' (pid %d, status %d)",
proc.argv0().unwrap(),
pid,
proc.status().status_value()
@@ -1260,7 +1260,7 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool) {
assert!(status.stopped() || status.continued());
FLOGF!(
proc_reap_external,
"External process '%ls' (pid %d, %s)",
"External process '%s' (pid %d, %s)",
proc.argv0().unwrap(),
proc.pid().unwrap(),
if proc.status().stopped() {
@@ -1305,7 +1305,7 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool) {
handle_child_status(j, proc, status);
FLOGF!(
proc_reap_internal,
"Reaped internal process '%ls' (id %llu, status %d)",
"Reaped internal process '%s' (id %u, status %d)",
proc.argv0().unwrap(),
internal_proc.get_id(),
proc.status().status_value(),

View File

@@ -342,7 +342,7 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue
assert!(input_data.event_storage.is_empty());
FLOGF!(
reader,
"Returning %lu pending input events",
"Returning %u pending input events",
input_data.queue.len()
);
@@ -956,7 +956,7 @@ fn read_ni(parser: &Parser, fd: RawFd, io: &IoChain) -> Result<(), ErrorCode> {
match parser.eval_wstr(s, io, None, BlockType::top) {
Ok(_) => Ok(()),
Err(msg) => {
eprintf!("%ls", msg);
eprintf!("%s", msg);
Err(STATUS_CMD_ERROR)
}
}
@@ -1750,7 +1750,7 @@ fn layout_and_repaint_before_execution(&mut self) {
/// Paint the last rendered layout.
/// `reason` is used in FLOG to explain why.
fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) {
FLOGF!(reader_render, "Repainting from %ls", reason);
FLOGF!(reader_render, "Repainting from %s", reason);
let cmd_line = &self.data.command_line;
let (full_line, autosuggested_range) = if self.conf.in_silent_mode {
@@ -5043,7 +5043,7 @@ fn autosuggest_completed(&mut self, result: AutosuggestionResult) {
if complete_load(to_load, self.parser) {
FLOGF!(
complete,
"Autosuggest found new completions for %ls, restarting",
"Autosuggest found new completions for %s, restarting",
to_load
);
loaded_new = true;
@@ -5452,7 +5452,7 @@ fn fill_history_pager(
zelf.pager.extra_progress_text =
if !result.matched_commands.is_empty() && *history_pager != (0..history_size + 1) {
wgettext_fmt!(
"Items %lu to %lu of %lu",
"Items %u to %u of %u",
match history_pager.start {
0 => 1,
_ => result.first_shown,
@@ -5491,7 +5491,7 @@ fn expand_replacer(
// Literal replacement cannot fail.
FLOGF!(
abbrs,
"Expanded literal abbreviation <%ls> -> <%ls>",
"Expanded literal abbreviation <%s> -> <%s>",
token,
&repl.replacement
);
@@ -5524,7 +5524,7 @@ fn expand_replacer(
let result = join_strings(&outputs, '\n');
FLOGF!(
abbrs,
"Expanded function abbreviation <%ls> -> <%ls>",
"Expanded function abbreviation <%s> -> <%s>",
token,
result
);

View File

@@ -863,7 +863,7 @@ pub fn setup() {
let mut path = PathBuf::from(dir);
path.push(first_char.clone());
path.push(t.clone());
FLOGF!(term_support, "Trying path '%ls'", path.to_str().unwrap());
FLOGF!(term_support, "Trying path '%s'", path.to_str().unwrap());
if let Ok(db) = terminfo::Database::from_path(path) {
return Ok(db);
}

View File

@@ -228,7 +228,7 @@ fn time_barrier() {
fn generate_history_lines(item_count: usize, idx: usize) -> Vec<WString> {
let mut result = Vec::with_capacity(item_count);
for i in 0..item_count {
result.push(sprintf!("%lu %lu", idx, i));
result.push(sprintf!("%u %u", idx, i));
}
result
}
@@ -317,7 +317,7 @@ fn test_history_races() {
// in this array were therefore not found in history.
let removed = list.drain(position..);
for line in removed.into_iter().rev() {
printf!("Item dropped from history: %ls\n", line);
printf!("Item dropped from history: %s\n", line);
}
found = true;
@@ -325,12 +325,12 @@ fn test_history_races() {
}
if !found {
printf!(
"Line '%ls' found in history, but not found in some array\n",
"Line '%s' found in history, but not found in some array\n",
item.str()
);
for list in &expected_lines {
if !list.is_empty() {
printf!("\tRemaining: %ls\n", list.last().unwrap())
printf!("\tRemaining: %s\n", list.last().unwrap())
}
}
}

View File

@@ -21,7 +21,7 @@ fn test_error_messages() {
// Given a format string, returns a list of non-empty strings separated by format specifiers. The
// format specifiers themselves are omitted.
fn separate_by_format_specifiers(format: &wstr) -> Vec<&wstr> {
let format_specifier_regex = Regex::new(L!(r"%l?[cds]").as_char_slice()).unwrap();
let format_specifier_regex = Regex::new(L!(r"%[cds]").as_char_slice()).unwrap();
let mut result = vec![];
let mut offset = 0;
for mtch in format_specifier_regex.find_iter(format.as_char_slice()) {

View File

@@ -581,7 +581,7 @@ fn try_transfer(jg: &JobGroup) -> bool {
} else {
FLOGF!(
warning,
"Could not send job %d ('%ls') with pgid %d to foreground",
"Could not send job %d ('%s') with pgid %d to foreground",
jg.job_id.to_wstring(),
jg.command,
pgid

View File

@@ -351,7 +351,7 @@ mod path_cd_tests {
fn relative_path() {
let wd = L!("/home/user/");
let path = L!("projects");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/projects"));
}
@@ -359,7 +359,7 @@ fn relative_path() {
fn absolute_path() {
let wd = L!("/home/user/");
let path = L!("/etc");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/etc"));
}
@@ -367,7 +367,7 @@ fn absolute_path() {
fn parent_directory() {
let wd = L!("/home/user/projects/");
let path = L!("../docs");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/docs"));
}
@@ -375,7 +375,7 @@ fn parent_directory() {
fn current_directory() {
let wd = L!("/home/user/");
let path = L!("./");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user"));
}
@@ -383,7 +383,7 @@ fn current_directory() {
fn nested_parent_directory() {
let wd = L!("/home/user/projects/");
let path = L!("../../");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/home"));
}
@@ -391,7 +391,7 @@ fn nested_parent_directory() {
fn complex_path() {
let wd = L!("/home/user/projects/");
let path = L!("./../other/projects/./.././../docs");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(
path_normalize_for_cd(wd, path),
L!("/home/user/other/projects/./.././../docs")
@@ -402,7 +402,7 @@ fn complex_path() {
fn root_directory() {
let wd = L!("/");
let path = L!("..");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/.."));
}
@@ -410,7 +410,7 @@ fn root_directory() {
fn up_to_root_directory() {
let wd = L!("/foo/");
let path = L!("..");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/"));
}
@@ -418,7 +418,7 @@ fn up_to_root_directory() {
fn empty_path() {
let wd = L!("/home/user/");
let path = L!("");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/"));
}
@@ -426,7 +426,7 @@ fn empty_path() {
fn trailing_slash() {
let wd = L!("/home/user/projects/");
let path = L!("docs/");
eprintf!("(%ls, %ls)\n", wd, path);
eprintf!("(%s, %s)\n", wd, path);
assert_eq!(
path_normalize_for_cd(wd, path),
L!("/home/user/projects/docs/")

View File

@@ -57,7 +57,7 @@ mod tests {
#[test]
fn test_sprintf() {
assert_eq!(sprintf!("Hello, %s!", "world"), "Hello, world!");
assert_eq!(sprintf!("Hello, %ls!", "world"), "Hello, world!");
assert_eq!(sprintf!("Hello, %ls!", "world"), "Hello, world!");
assert_eq!(sprintf!("Hello, %s!", "world"), "Hello, world!");
assert_eq!(sprintf!("Hello, %s!", "world"), "Hello, world!");
}
}

View File

@@ -7,7 +7,7 @@ printf "%d %d\n" 1 2 3
printf "Hello %d %i %f %F %g %G\n" 1 2 3 4 5 6
# CHECK: Hello 1 2 3.000000 4.000000 5 6
printf "%x %X %o %llu\n" 10 11 8 -1
printf "%x %X %o %u\n" 10 11 8 -1
# CHECK: a B 10 18446744073709551615
# %a has OS-dependent output - see #1139

View File

@@ -102,12 +102,12 @@ static void print_stdout_stderr() {
static void print_pid_then_sleep() {
// On some systems getpid is a long, on others it's an int, let's just cast it.
fprintf(stdout, "%ld\n", (long)getpid());
fprintf(stdout, "%d\n", (long)getpid());
fflush(NULL);
usleep(1000000 / 2); //.5 secs
}
static void print_pgrp() { fprintf(stdout, "%ld\n", (long)getpgrp()); }
static void print_pgrp() { fprintf(stdout, "%d\n", (long)getpgrp()); }
static void print_fds() {
bool needs_space = false;