1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:37:45 +00:00

Services: Convert StringBuilder::appendf() => AK::Format

This commit is contained in:
Andreas Kling 2021-05-07 20:45:35 +02:00
parent 8c3b603da3
commit f0687dbbb7
3 changed files with 10 additions and 10 deletions

View file

@ -153,12 +153,12 @@ struct ParsedDHCPv4Options {
{ {
StringBuilder builder; StringBuilder builder;
builder.append("DHCP Options ("); builder.append("DHCP Options (");
builder.appendf("%zu", options.size()); builder.appendff("{}", options.size());
builder.append(" entries)\n"); builder.append(" entries)\n");
for (auto& opt : options) { for (auto& opt : options) {
builder.appendf("\toption %d (%d bytes):", (u8)opt.key, (u8)opt.value.length); builder.appendff("\toption {} ({} bytes):", (u8)opt.key, (u8)opt.value.length);
for (auto i = 0; i < opt.value.length; ++i) for (auto i = 0; i < opt.value.length; ++i)
builder.appendf(" %u ", ((const u8*)opt.value.value)[i]); builder.appendff(" {} ", ((const u8*)opt.value.value)[i]);
builder.append('\n'); builder.append('\n');
} }
return builder.build(); return builder.build();

View file

@ -196,7 +196,7 @@ void Service::spawn(int socket_fd)
VERIFY(m_sockets.size() == 1); VERIFY(m_sockets.size() == 1);
int fd = dup(socket_fd); int fd = dup(socket_fd);
builder.appendf("%s:%d", m_sockets[0].path.characters(), fd); builder.appendff("{}:{}", m_sockets[0].path, fd);
} else { } else {
// We were spawned as a regular process, so dup every socket for this // We were spawned as a regular process, so dup every socket for this
// service and let the service know via SOCKET_TAKEOVER. // service and let the service know via SOCKET_TAKEOVER.
@ -205,8 +205,8 @@ void Service::spawn(int socket_fd)
int new_fd = dup(socket.fd); int new_fd = dup(socket.fd);
if (i != 0) if (i != 0)
builder.append(" "); builder.append(' ');
builder.appendf("%s:%d", socket.path.characters(), new_fd); builder.appendff("{}:{}", socket.path, new_fd);
} }
} }

View file

@ -214,14 +214,14 @@ void Client::handle_directory_listing(const String& requested_path, const String
bool is_directory = S_ISDIR(st.st_mode) || name.is_one_of(".", ".."); bool is_directory = S_ISDIR(st.st_mode) || name.is_one_of(".", "..");
builder.append("<tr>"); builder.append("<tr>");
builder.appendf("<td><div class=\"%s\"></div></td>", is_directory ? "folder" : "file"); builder.appendff("<td><div class=\"{}\"></div></td>", is_directory ? "folder" : "file");
builder.append("<td><a href=\""); builder.append("<td><a href=\"");
builder.append(urlencode(name)); builder.append(urlencode(name));
builder.append("\">"); builder.append("\">");
builder.append(escape_html_entities(name)); builder.append(escape_html_entities(name));
builder.append("</a></td><td>&nbsp;</td>"); builder.append("</a></td><td>&nbsp;</td>");
builder.appendf("<td>%10" PRIi64 "</td><td>&nbsp;</td>", st.st_size); builder.appendff("<td>{:10}</td><td>&nbsp;</td>", st.st_size);
builder.append("<td>"); builder.append("<td>");
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string()); builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
builder.append("</td>"); builder.append("</td>");
@ -242,11 +242,11 @@ void Client::handle_directory_listing(const String& requested_path, const String
void Client::send_error_response(unsigned code, const StringView& message, const HTTP::HttpRequest& request) void Client::send_error_response(unsigned code, const StringView& message, const HTTP::HttpRequest& request)
{ {
StringBuilder builder; StringBuilder builder;
builder.appendf("HTTP/1.0 %u ", code); builder.appendff("HTTP/1.0 {} ", code);
builder.append(message); builder.append(message);
builder.append("\r\n\r\n"); builder.append("\r\n\r\n");
builder.append("<!DOCTYPE html><html><body><h1>"); builder.append("<!DOCTYPE html><html><body><h1>");
builder.appendf("%u ", code); builder.appendff("{} ", code);
builder.append(message); builder.append(message);
builder.append("</h1></body></html>"); builder.append("</h1></body></html>");
m_socket->write(builder.to_string()); m_socket->write(builder.to_string());