diff --git a/src/ast.rs b/src/ast.rs index e15507576..ee456bf25 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -2570,7 +2570,7 @@ fn advance_1(&mut self) -> ParseToken { result.keyword = keyword_for_token(token.type_, text); result.has_dash_prefix = text.starts_with('-'); result.is_help_argument = [L!("-h"), L!("--help")].contains(&text); - result.is_newline = result.typ == ParseTokenType::end && text == L!("\n"); + result.is_newline = result.typ == ParseTokenType::end && text == "\n"; result.may_be_variable_assignment = variable_assignment_equals_pos(text).is_some(); result.tok_error = token.error; @@ -2920,14 +2920,14 @@ fn visit_token_background(&mut self, node: &mut Option) { fn keywords_user_presentable_description(kws: &'static [ParseKeyword]) -> WString { assert!(!kws.is_empty(), "Should not be empty list"); if kws.len() == 1 { - return sprintf!(L!("keyword '%ls'"), kws[0]); + return sprintf!("keyword '%ls'", kws[0]); } let mut res = L!("keywords ").to_owned(); for (i, kw) in kws.iter().enumerate() { if i != 0 { res += L!(" or "); } - res += &sprintf!(L!("'%ls'"), *kw)[..]; + res += &sprintf!("'%ls'", *kw)[..]; } res } diff --git a/src/builtins/math.rs b/src/builtins/math.rs index 368df6fee..a3861be8a 100644 --- a/src/builtins/math.rs +++ b/src/builtins/math.rs @@ -187,8 +187,8 @@ fn evaluate_expression( streams .err - .append(sprintf!(L!("%ls: Error: %ls\n"), cmd, error_message)); - streams.err.append(sprintf!(L!("'%ls'\n"), expression)); + .append(sprintf!("%ls: Error: %ls\n", cmd, error_message)); + streams.err.append(sprintf!("'%ls'\n", expression)); STATUS_CMD_ERROR } @@ -198,15 +198,13 @@ fn evaluate_expression( cmd, err.kind.describe_wstr() )); - streams.err.append(sprintf!(L!("'%ls'\n"), expression)); + streams.err.append(sprintf!("'%ls'\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!(L!("%ls^%ls^\n"), padding, tildes)); + streams.err.append(sprintf!("%ls^%ls^\n", padding, tildes)); } else { - streams.err.append(sprintf!(L!("%ls^\n"), padding)); + streams.err.append(sprintf!("%ls^\n", padding)); } STATUS_CMD_ERROR diff --git a/src/builtins/shared.rs b/src/builtins/shared.rs index 7b9af81e6..a1b06ee5d 100644 --- a/src/builtins/shared.rs +++ b/src/builtins/shared.rs @@ -842,7 +842,7 @@ fn builtin_generic(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) // Hackish - if we have no arguments other than the command, we are a "naked invocation" and we // just print help. - if argc == 1 || argv[0] == L!("time") { + if argc == 1 || argv[0] == "time" { builtin_print_help(parser, streams, argv[0]); return STATUS_INVALID_ARGS; } @@ -857,7 +857,7 @@ fn builtin_break_continue( streams: &mut IoStreams, argv: &mut [&wstr], ) -> Option { - let is_break = argv[0] == L!("break"); + let is_break = argv[0] == "break"; let argc = argv.len(); if argc != 1 { diff --git a/src/builtins/source.rs b/src/builtins/source.rs index 81cdf5e96..e0fb17646 100644 --- a/src/builtins/source.rs +++ b/src/builtins/source.rs @@ -33,7 +33,7 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O let func_filename; let optind = opts.optind; - if argc == optind || args[optind] == L!("-") { + if argc == optind || args[optind] == "-" { if streams.stdin_fd < 0 { streams .err diff --git a/src/builtins/type.rs b/src/builtins/type.rs index 4dbc9efb4..928c8eb17 100644 --- a/src/builtins/type.rs +++ b/src/builtins/type.rs @@ -88,7 +88,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> O if path.is_empty() { comment.push_utfstr(&wgettext!("Defined interactively")); - } else if path == L!("-") { + } else if path == "-" { comment.push_utfstr(&wgettext!("Defined via `source`")); } else { let lineno: i32 = props.definition_lineno(); @@ -103,7 +103,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> O let path = props.copy_definition_file().unwrap_or(L!("")); if path.is_empty() { comment.push_utfstr(&wgettext!(", copied interactively")); - } else if path == L!("-") { + } else if path == "-" { comment.push_utfstr(&wgettext!(", copied via `source`")); } else { let lineno = props.copy_definition_lineno(); diff --git a/src/common.rs b/src/common.rs index c6e715ae6..c93a61831 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1564,7 +1564,7 @@ pub fn reformat_for_screen(msg: &wstr, termsize: &Termsize) -> WString { if line_width != 0 { buff.push('\n'); } - buff += &sprintf!(L!("%ls-\n"), token)[..]; + buff += &sprintf!("%ls-\n", token)[..]; line_width = 0; } else { // Print the token. diff --git a/src/complete.rs b/src/complete.rs index e12cd9612..80b1b199c 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -766,7 +766,7 @@ pub fn perform_for_commandline(&mut self, cmdline: WString) { // Check to see if we have a preceding double-dash. for tok in &tokens[..tokens.len() - 1] { - if tok.get_source(&cmdline) == L!("--") { + if tok.get_source(&cmdline) == "--" { had_ddash = true; break; } @@ -816,7 +816,7 @@ pub fn perform_for_commandline(&mut self, cmdline: WString) { // Hack. If we're cd, handle it specially (issue #1059, others). handle_as_special_cd = - exp_command == L!("cd") || arg_data.visited_wrapped_commands.contains(L!("cd")); + exp_command == "cd" || arg_data.visited_wrapped_commands.contains(L!("cd")); } // Maybe apply variable assignments. @@ -1607,7 +1607,7 @@ fn complete_variable(&mut self, s: &wstr, start_offset: usize) -> bool { if self.flags.descriptions && self.flags.autosuggestion { // $history can be huge, don't put all of it in the completion description; see // #6288. - if env_name == L!("history") { + if env_name == "history" { let history = History::with_name(&history_session_id(self.ctx.vars())); for i in 1..std::cmp::min(history.size(), 64) { if i > 1 { diff --git a/src/env/environment_impl.rs b/src/env/environment_impl.rs index f12a1e42c..281f95078 100644 --- a/src/env/environment_impl.rs +++ b/src/env/environment_impl.rs @@ -342,12 +342,12 @@ fn try_get_computed(&self, key: &wstr) -> Option { return None; } - if key == L!("PWD") { + if key == "PWD" { Some(EnvVar::new( self.perproc_data.pwd.clone(), EnvVarFlags::EXPORT, )) - } else if key == L!("history") { + } else if key == "history" { // Big hack. We only allow getting the history on the main thread. Note that history_t // may ask for an environment variable, so don't take the lock here (we don't need it). if !is_main_thread() { @@ -362,35 +362,35 @@ fn try_get_computed(&self, key: &wstr) -> Option { L!("history"), history.get_history(), )); - } else if key == L!("fish_killring") { + } else if key == "fish_killring" { Some(EnvVar::new_from_name_vec( L!("fish_killring"), kill_entries(), )) - } else if key == L!("pipestatus") { + } else if key == "pipestatus" { let js = &self.perproc_data.statuses; let mut result = Vec::with_capacity(js.pipestatus.len()); for i in &js.pipestatus { result.push(i.to_wstring()); } Some(EnvVar::new_from_name_vec(L!("pipestatus"), result)) - } else if key == L!("status") { + } else if key == "status" { let js = &self.perproc_data.statuses; Some(EnvVar::new_from_name(L!("status"), js.status.to_wstring())) - } else if key == L!("status_generation") { + } else if key == "status_generation" { let status_generation = reader_status_count(); Some(EnvVar::new_from_name( L!("status_generation"), status_generation.to_wstring(), )) - } else if key == L!("fish_kill_signal") { + } else if key == "fish_kill_signal" { let js = &self.perproc_data.statuses; let signal = js.kill_signal.map_or(0, |ks| ks.code()); Some(EnvVar::new_from_name( L!("fish_kill_signal"), signal.to_wstring(), )) - } else if key == L!("umask") { + } else if key == "umask" { // note umask() is an absurd API: you call it to set the value and it returns the old // value. Thus we have to call it twice, to reset the value. The env_lock protects // against races. Guess what the umask is; if we guess right we don't need to reset it. diff --git a/src/event.rs b/src/event.rs index c1de62395..b698f8563 100644 --- a/src/event.rs +++ b/src/event.rs @@ -98,7 +98,7 @@ fn matches_filter(&self, filter: &wstr) -> bool { EventDescription::ProcessExit { .. } | EventDescription::JobExit { .. } | EventDescription::CallerExit { .. } - if filter == L!("exit") => + if filter == "exit" => { true } diff --git a/src/expand.rs b/src/expand.rs index 1ebc199c1..acb4d97c9 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -635,7 +635,7 @@ fn expand_variables( // this way (it cannot be shadowed, etc). let mut history = None; let mut var = None; - if var_name == L!("history") { + if var_name == "history" { history = Some(History::with_name(&history_session_id(vars))); } else if var_name.as_char_slice() != [VARIABLE_EXPAND_EMPTY] { var = vars.get(var_name); diff --git a/src/highlight.rs b/src/highlight.rs index 17b6d9631..75a4d6669 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -335,7 +335,7 @@ pub fn autosuggest_validate_from_history( }; // We handle cd specially. - if parsed_command == L!("cd") && !cd_dir.is_empty() { + if parsed_command == "cd" && !cd_dir.is_empty() { if expand_one(&mut cd_dir, ExpandFlags::SKIP_CMDSUBST, ctx, None) { if string_prefixes_string(&cd_dir, L!("--help")) || string_prefixes_string(&cd_dir, L!("-h")) @@ -809,7 +809,7 @@ pub fn is_potential_path( // We do not end with a slash; it does not have to be a directory. let dir_name = wdirname(&abs_path); let filename_fragment = wbasename(&abs_path); - if dir_name == L!("/") && filename_fragment == L!("/") { + if dir_name == "/" && filename_fragment == "/" { // cd ///.... No autosuggestion. return true; } @@ -1231,7 +1231,7 @@ fn visit_redirection(&mut self, redir: &Redirection) { let target_path = path_apply_working_directory(&target, &self.working_directory); match oper.mode { RedirectionMode::fd => { - if target == L!("-") { + if target == "-" { target_is_valid = true; } else { target_is_valid = match fish_wcstoi(&target) { @@ -1373,8 +1373,8 @@ fn visit_decorated_statement(&mut self, stmt: &DecoratedStatement) { // Color arguments and redirections. // Except if our command is 'cd' we have special logic for how arguments are colored. - let is_cd = expanded_cmd == L!("cd"); - let mut is_set = expanded_cmd == L!("set"); + let is_cd = expanded_cmd == "cd"; + let mut is_set = expanded_cmd == "set"; // If we have seen a "--" argument, color all options from then on as normal arguments. let mut have_dashdash = false; for v in &stmt.args_or_redirs { @@ -1387,7 +1387,7 @@ fn visit_decorated_statement(&mut self, stmt: &DecoratedStatement) { } } self.visit_argument(v.argument(), is_cd, !have_dashdash); - if v.argument().source(self.buff) == L!("--") { + if v.argument().source(self.buff) == "--" { have_dashdash = true; } } else { diff --git a/src/kill.rs b/src/kill.rs index 9a5bd19c7..5ec988341 100644 --- a/src/kill.rs +++ b/src/kill.rs @@ -95,16 +95,16 @@ fn test_killring() { assert!(kr.entries() == [L!("c"), L!("b"), L!("a")]); - assert!(kr.yank_rotate() == L!("b")); + assert!(kr.yank_rotate() == "b"); assert!(kr.entries() == [L!("b"), L!("a"), L!("c")]); - assert!(kr.yank_rotate() == L!("a")); + assert!(kr.yank_rotate() == "a"); assert!(kr.entries() == [L!("a"), L!("c"), L!("b")]); kr.add(WString::from_str("d")); assert!((kr.entries() == [L!("d"), L!("a"), L!("c"), L!("b")])); - assert!(kr.yank_rotate() == L!("a")); + assert!(kr.yank_rotate() == "a"); assert!((kr.entries() == [L!("a"), L!("c"), L!("b"), L!("d")])); } diff --git a/src/pager.rs b/src/pager.rs index d58cc93e6..f7f25c4c3 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -585,7 +585,7 @@ pub fn set_completions(&mut self, raw_completions: &[Completion], enable_refilte self.unfiltered_completion_infos = process_completions_into_infos(raw_completions); // Maybe join them. - if self.prefix == L!("-") { + if self.prefix == "-" { join_completions(&mut self.unfiltered_completion_infos); } diff --git a/src/parse_constants.rs b/src/parse_constants.rs index 39787e074..50a4c0820 100644 --- a/src/parse_constants.rs +++ b/src/parse_constants.rs @@ -244,24 +244,24 @@ fn to_arg(self) -> printf_compat::args::Arg<'static> { impl From<&wstr> for ParseKeyword { fn from(s: &wstr) -> Self { match s { - _ if s == L!("!") => ParseKeyword::kw_exclam, - _ if s == L!("and") => ParseKeyword::kw_and, - _ if s == L!("begin") => ParseKeyword::kw_begin, - _ if s == L!("builtin") => ParseKeyword::kw_builtin, - _ if s == L!("case") => ParseKeyword::kw_case, - _ if s == L!("command") => ParseKeyword::kw_command, - _ if s == L!("else") => ParseKeyword::kw_else, - _ if s == L!("end") => ParseKeyword::kw_end, - _ if s == L!("exec") => ParseKeyword::kw_exec, - _ if s == L!("for") => ParseKeyword::kw_for, - _ if s == L!("function") => ParseKeyword::kw_function, - _ if s == L!("if") => ParseKeyword::kw_if, - _ if s == L!("in") => ParseKeyword::kw_in, - _ if s == L!("not") => ParseKeyword::kw_not, - _ if s == L!("or") => ParseKeyword::kw_or, - _ if s == L!("switch") => ParseKeyword::kw_switch, - _ if s == L!("time") => ParseKeyword::kw_time, - _ if s == L!("while") => ParseKeyword::kw_while, + _ if s == "!" => ParseKeyword::kw_exclam, + _ if s == "and" => ParseKeyword::kw_and, + _ if s == "begin" => ParseKeyword::kw_begin, + _ if s == "builtin" => ParseKeyword::kw_builtin, + _ if s == "case" => ParseKeyword::kw_case, + _ if s == "command" => ParseKeyword::kw_command, + _ if s == "else" => ParseKeyword::kw_else, + _ if s == "end" => ParseKeyword::kw_end, + _ if s == "exec" => ParseKeyword::kw_exec, + _ if s == "for" => ParseKeyword::kw_for, + _ if s == "function" => ParseKeyword::kw_function, + _ if s == "if" => ParseKeyword::kw_if, + _ if s == "in" => ParseKeyword::kw_in, + _ if s == "not" => ParseKeyword::kw_not, + _ if s == "or" => ParseKeyword::kw_or, + _ if s == "switch" => ParseKeyword::kw_switch, + _ if s == "time" => ParseKeyword::kw_time, + _ if s == "while" => ParseKeyword::kw_while, _ => ParseKeyword::none, } } @@ -404,7 +404,7 @@ pub fn token_type_user_presentable_description( keyword: ParseKeyword, ) -> WString { if keyword != ParseKeyword::none { - return sprintf!(L!("keyword: '%ls'"), keyword.to_wstr()); + return sprintf!("keyword: '%ls'", keyword.to_wstr()); } match type_ { ParseTokenType::string => L!("a string").to_owned(), @@ -418,7 +418,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!(L!("a %ls"), type_.to_wstr()), + _ => sprintf!("a %ls", type_.to_wstr()), } } diff --git a/src/parse_util.rs b/src/parse_util.rs index 52b3d6d06..f03db2c6a 100644 --- a/src/parse_util.rs +++ b/src/parse_util.rs @@ -982,7 +982,7 @@ fn visit(&mut self, node: &'a dyn Node) { { // The newline after "begin" is optional, so it is part of the header. // The header is not in the indented block, so indent the newline here. - if node.source(self.src) == L!("\n") { + if node.source(self.src) == "\n" { inc = 1; dec = 1; } @@ -1534,7 +1534,7 @@ fn detect_errors_in_decorated_statement( } // Similarly for time (#8841). - if command == L!("time") { + if command == "time" { errored = append_syntax_error!( parse_errors, source_start, @@ -1549,7 +1549,7 @@ fn detect_errors_in_decorated_statement( // to avoid people trying `if $status`. // We see this surprisingly regularly. let com = dst.command.source(buff_src); - if com == L!("$status") { + if com == "$status" { errored = append_syntax_error!( parse_errors, source_start, @@ -1615,7 +1615,7 @@ fn detect_errors_in_decorated_statement( } if !found_loop { - errored = if command == L!("break") { + errored = if command == "break" { append_syntax_error!( parse_errors, source_start, diff --git a/src/path.rs b/src/path.rs index 567786aea..6b2cc6f26 100644 --- a/src/path.rs +++ b/src/path.rs @@ -405,7 +405,7 @@ pub fn path_as_implicit_cd(path: &wstr, wd: &wstr, vars: &dyn Environment) -> Op || exp_path.starts_with(L!("./")) || exp_path.starts_with(L!("../")) || exp_path.ends_with(L!("/")) - || exp_path == L!("..") + || exp_path == ".." { // These paths can be implicit cd, so see if you cd to the path. Note that a single period // cannot (that's used for sourcing files anyways). diff --git a/src/redirection.rs b/src/redirection.rs index 41bcca30d..2a8211b38 100644 --- a/src/redirection.rs +++ b/src/redirection.rs @@ -74,7 +74,7 @@ pub fn new(fd: RawFd, mode: RedirectionMode, target: WString) -> Self { } /// \return if this is a close-type redirection. pub fn is_close(&self) -> bool { - self.mode == RedirectionMode::fd && self.target == L!("-") + self.mode == RedirectionMode::fd && self.target == "-" } /// Attempt to parse target as an fd. diff --git a/src/tests/env.rs b/src/tests/env.rs index be41711c4..7e074a56a 100644 --- a/src/tests/env.rs +++ b/src/tests/env.rs @@ -41,7 +41,7 @@ pub fn new() -> Self { } impl Environment for PwdEnvironment { fn getf(&self, name: &wstr, mode: EnvMode) -> Option { - if name == L!("PWD") { + if name == "PWD" { return Some(EnvVar::new(wgetcwd(), EnvVarFlags::default())); } self.parent.getf(name, mode) @@ -49,7 +49,7 @@ fn getf(&self, name: &wstr, mode: EnvMode) -> Option { fn get_names(&self, flags: EnvMode) -> Vec { let mut res = self.parent.get_names(flags); - if !res.iter().any(|n| n == L!("PWD")) { + if !res.iter().any(|n| n == "PWD") { res.push(L!("PWD").to_owned()); } res diff --git a/src/tests/history.rs b/src/tests/history.rs index 0d3e96c25..03a265ffa 100644 --- a/src/tests/history.rs +++ b/src/tests/history.rs @@ -130,7 +130,7 @@ macro_rules! test_history_matches { L!("alph").to_owned(), history::SearchType::Exact, ); - let expected = set_expected(|s| s == L!("alph")); + let expected = set_expected(|s| s == "alph"); test_history_matches!(searcher, expected); // Items exactly matching "alph", case-insensitive. @@ -141,7 +141,7 @@ macro_rules! test_history_matches { nocase, 0, ); - let expected = set_expected(|s| s.to_lowercase() == L!("alph")); + let expected = set_expected(|s| s.to_lowercase() == "alph"); test_history_matches!(searcher, expected); // Test item removal case-sensitive. diff --git a/src/wildcard.rs b/src/wildcard.rs index 7ee6b4acb..be4db457c 100644 --- a/src/wildcard.rs +++ b/src/wildcard.rs @@ -1109,7 +1109,7 @@ pub fn wildcard_match( let pattern = pattern.as_ref(); // Hackish fix for issue #270. Prevent wildcards from matching . or .., but we must still allow // literal matches. - if leading_dots_fail_to_match && (name == L!(".") || name == L!("..")) { + if leading_dots_fail_to_match && (name == "." || name == "..") { // The string is '.' or '..' so the only possible match is an exact match. return name == pattern; } diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index 13bf9cb89..040c9a301 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -300,9 +300,9 @@ pub fn path_normalize_for_cd(wd: &wstr, path: &wstr) -> WString { let mut erase_count = 0; for comp in &path_comps { let mut erase_it = false; - if comp.is_empty() || comp == L!(".") { + if comp.is_empty() || comp == "." { erase_it = true; - } else if comp == L!("..") && !wd_comps.is_empty() { + } else if comp == ".." && !wd_comps.is_empty() { erase_it = true; wd_comps.pop(); } diff --git a/src/wutil/printf.rs b/src/wutil/printf.rs index 0e5f9497b..880943230 100644 --- a/src/wutil/printf.rs +++ b/src/wutil/printf.rs @@ -4,13 +4,12 @@ #[cfg(test)] mod tests { use super::*; - use crate::wchar::L; // Test basic sprintf with both literals and wide strings. #[test] fn test_sprintf() { assert_eq!(sprintf!("Hello, %s!", "world"), "Hello, world!"); - assert_eq!(sprintf!(L!("Hello, %ls!"), "world"), "Hello, world!"); - assert_eq!(sprintf!(L!("Hello, %ls!"), L!("world")), "Hello, world!"); + assert_eq!(sprintf!("Hello, %ls!", "world"), "Hello, world!"); + assert_eq!(sprintf!("Hello, %ls!", "world"), "Hello, world!"); } }