mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
Shell: Convert String::format() => String::formatted()
This commit is contained in:
parent
f8dfc74f8b
commit
b41b6dd279
Notes:
sideshowbarker
2024-07-18 19:16:23 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b41b6dd2791
|
@ -842,7 +842,7 @@ CastToList::~CastToList()
|
|||
void CloseFdRedirection::dump(int level) const
|
||||
{
|
||||
Node::dump(level);
|
||||
print_indented(String::format("%d -> Close", m_fd), level);
|
||||
print_indented(String::formatted("{} -> Close", m_fd), level);
|
||||
}
|
||||
|
||||
RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>)
|
||||
|
@ -1036,7 +1036,7 @@ DynamicEvaluate::~DynamicEvaluate()
|
|||
void Fd2FdRedirection::dump(int level) const
|
||||
{
|
||||
Node::dump(level);
|
||||
print_indented(String::format("%d -> %d", m_old_fd, m_new_fd), level);
|
||||
print_indented(String::formatted("{} -> {}", m_old_fd, m_new_fd), level);
|
||||
}
|
||||
|
||||
RefPtr<Value> Fd2FdRedirection::run(RefPtr<Shell>)
|
||||
|
@ -1066,10 +1066,10 @@ Fd2FdRedirection::~Fd2FdRedirection()
|
|||
void FunctionDeclaration::dump(int level) const
|
||||
{
|
||||
Node::dump(level);
|
||||
print_indented(String::format("(name: %s)\n", m_name.name.characters()), level + 1);
|
||||
print_indented("(argument namess)", level + 1);
|
||||
print_indented(String::formatted("(name: {})\n", m_name.name), level + 1);
|
||||
print_indented("(argument names)", level + 1);
|
||||
for (auto& arg : m_arguments)
|
||||
print_indented(String::format("(name: %s)\n", arg.name.characters()), level + 2);
|
||||
print_indented(String::formatted("(name: {})\n", arg.name), level + 2);
|
||||
|
||||
print_indented("(body)", level + 1);
|
||||
if (m_block)
|
||||
|
@ -2319,7 +2319,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell
|
|||
auto& position = m_path->position();
|
||||
auto& path = path_text[0];
|
||||
if (!path.starts_with('/'))
|
||||
path = String::format("%s/%s", shell.cwd.characters(), path.characters());
|
||||
path = String::formatted("{}/{}", shell.cwd, path);
|
||||
auto url = URL::create_with_file_protocol(path);
|
||||
url.set_host(shell.hostname);
|
||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
||||
|
@ -2478,7 +2478,7 @@ void ReadRedirection::dump(int level) const
|
|||
{
|
||||
Node::dump(level);
|
||||
m_path->dump(level + 1);
|
||||
print_indented(String::format("To %d", m_fd), level + 1);
|
||||
print_indented(String::formatted("To {}", m_fd), level + 1);
|
||||
}
|
||||
|
||||
RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell)
|
||||
|
@ -2505,7 +2505,7 @@ void ReadWriteRedirection::dump(int level) const
|
|||
{
|
||||
Node::dump(level);
|
||||
m_path->dump(level + 1);
|
||||
print_indented(String::format("To/From %d", m_fd), level + 1);
|
||||
print_indented(String::formatted("To/From {}", m_fd), level + 1);
|
||||
}
|
||||
|
||||
RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell)
|
||||
|
@ -3135,7 +3135,7 @@ void WriteAppendRedirection::dump(int level) const
|
|||
{
|
||||
Node::dump(level);
|
||||
m_path->dump(level + 1);
|
||||
print_indented(String::format("From %d", m_fd), level + 1);
|
||||
print_indented(String::formatted("From {}", m_fd), level + 1);
|
||||
}
|
||||
|
||||
RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell)
|
||||
|
@ -3162,7 +3162,7 @@ void WriteRedirection::dump(int level) const
|
|||
{
|
||||
Node::dump(level);
|
||||
m_path->dump(level + 1);
|
||||
print_indented(String::format("From %d", m_fd), level + 1);
|
||||
print_indented(String::formatted("From {}", m_fd), level + 1);
|
||||
}
|
||||
|
||||
RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell)
|
||||
|
|
|
@ -1782,7 +1782,7 @@ RefPtr<AST::Node> Parser::parse_glob()
|
|||
} else {
|
||||
// FIXME: Allow composition of tilde+bareword with globs: '~/foo/bar/baz*'
|
||||
restore_to(saved_offset.offset, saved_offset.line);
|
||||
bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(String::format("Unexpected %s inside a glob", bareword_part->class_name().characters())));
|
||||
bareword_part->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Unexpected {} inside a glob", bareword_part->class_name())));
|
||||
return bareword_part;
|
||||
}
|
||||
textbuilder.append(text);
|
||||
|
|
|
@ -171,9 +171,9 @@ String Shell::expand_tilde(const String& expression)
|
|||
if (!home) {
|
||||
auto passwd = getpwuid(getuid());
|
||||
VERIFY(passwd && passwd->pw_dir);
|
||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
||||
return String::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||
}
|
||||
return String::format("%s/%s", home, path.to_string().characters());
|
||||
return String::formatted("{}/{}", home, path.to_string());
|
||||
}
|
||||
|
||||
auto passwd = getpwnam(login_name.to_string().characters());
|
||||
|
@ -181,7 +181,7 @@ String Shell::expand_tilde(const String& expression)
|
|||
return expression;
|
||||
VERIFY(passwd->pw_dir);
|
||||
|
||||
return String::format("%s/%s", passwd->pw_dir, path.to_string().characters());
|
||||
return String::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||
}
|
||||
|
||||
bool Shell::is_glob(const StringView& s)
|
||||
|
@ -347,7 +347,7 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
|
|||
String Shell::resolve_path(String path) const
|
||||
{
|
||||
if (!path.starts_with('/'))
|
||||
path = String::format("%s/%s", cwd.characters(), path.characters());
|
||||
path = String::formatted("{}/{}", cwd, path);
|
||||
|
||||
return Core::File::real_path_for(path);
|
||||
}
|
||||
|
@ -1249,7 +1249,7 @@ void Shell::cache_path()
|
|||
Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots);
|
||||
while (programs.has_next()) {
|
||||
auto program = programs.next_path();
|
||||
String program_path = String::format("%s/%s", directory.characters(), program.characters());
|
||||
auto program_path = String::formatted("{}/{}", directory, program);
|
||||
auto escaped_name = escape_token(program);
|
||||
if (cached_path.contains_slow(escaped_name))
|
||||
continue;
|
||||
|
@ -1357,7 +1357,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_path(const String& base,
|
|||
auto file = files.next_path();
|
||||
if (file.starts_with(token)) {
|
||||
struct stat program_status;
|
||||
String file_path = String::format("%s/%s", path.characters(), file.characters());
|
||||
auto file_path = String::formatted("{}/{}", path, file);
|
||||
int stat_error = stat(file_path.characters(), &program_status);
|
||||
if (!stat_error && (executable_only == ExecutableOnly::No || access(file_path.characters(), X_OK) == 0)) {
|
||||
if (S_ISDIR(program_status.st_mode)) {
|
||||
|
|
Loading…
Reference in a new issue