Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v0.23.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1ff committed Jan 20, 2025
2 parents b1677bf + 5de0909 commit b24b3c1
Show file tree
Hide file tree
Showing 27 changed files with 223 additions and 110 deletions.
20 changes: 10 additions & 10 deletions src/SongPrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ song_print_uri(Response &r, const char *uri, bool base) noexcept
uri = allocated.c_str();
}

r.Fmt(FMT_STRING(SONG_FILE "{}\n"), uri);
r.Fmt(SONG_FILE "{}\n", uri);
}

void
song_print_uri(Response &r, const LightSong &song, bool base) noexcept
{
if (!base && song.directory != nullptr)
r.Fmt(FMT_STRING(SONG_FILE "{}/{}\n"),
r.Fmt(SONG_FILE "{}/{}\n",
song.directory, song.uri);
else
song_print_uri(r, song.uri, base);
Expand All @@ -56,13 +56,13 @@ PrintRange(Response &r, SongTime start_time, SongTime end_time) noexcept
const unsigned end_ms = end_time.ToMS();

if (end_ms > 0)
r.Fmt(FMT_STRING("Range: {}.{:03}-{}.{:03}\n"),
r.Fmt("Range: {}.{:03}-{}.{:03}\n",
start_ms / 1000,
start_ms % 1000,
end_ms / 1000,
end_ms % 1000);
else if (start_ms > 0)
r.Fmt(FMT_STRING("Range: {}.{:03}-\n"),
r.Fmt("Range: {}.{:03}-\n",
start_ms / 1000,
start_ms % 1000);
}
Expand All @@ -81,14 +81,14 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
time_print(r, "Added", song.added);

if (song.audio_format.IsDefined())
r.Fmt(FMT_STRING("Format: {}\n"), song.audio_format);
r.Fmt("Format: {}\n", song.audio_format);

tag_print_values(r, song.tag);

const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3f}\n"),
r.Fmt("Time: {}\n"
"duration: {:1.3f}\n",
duration.RoundS(),
duration.ToDoubleS());
}
Expand All @@ -107,14 +107,14 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept
time_print(r, "Added", song.GetAdded());

if (const auto &f = song.GetAudioFormat(); f.IsDefined())
r.Fmt(FMT_STRING("Format: {}\n"), f);
r.Fmt("Format: {}\n", f);

tag_print_values(r, song.GetTag());

const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3f}\n"),
r.Fmt("Time: {}\n"
"duration: {:1.3f}\n",
duration.RoundS(),
duration.ToDoubleS());
}
14 changes: 7 additions & 7 deletions src/Stats.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ db_stats_print(Response &r, const Database &db)
unsigned total_duration_s =
std::chrono::duration_cast<std::chrono::seconds>(stats.total_duration).count();

r.Fmt(FMT_STRING("artists: {}\n"
"albums: {}\n"
"songs: {}\n"
"db_playtime: {}\n"),
r.Fmt("artists: {}\n"
"albums: {}\n"
"songs: {}\n"
"db_playtime: {}\n",
stats.artist_count,
stats.album_count,
stats.song_count,
total_duration_s);

const auto update_stamp = db.GetUpdateStamp();
if (!IsNegative(update_stamp))
r.Fmt(FMT_STRING("db_update: {}\n"),
r.Fmt("db_update: {}\n",
std::chrono::system_clock::to_time_t(update_stamp));
}

Expand All @@ -109,8 +109,8 @@ stats_print(Response &r, const Partition &partition)
const auto uptime = std::chrono::steady_clock::now() - start_time;
#endif

r.Fmt(FMT_STRING("uptime: {}\n"
"playtime: {}\n"),
r.Fmt("uptime: {}\n"
"playtime: {}\n",
std::chrono::duration_cast<std::chrono::seconds>(uptime).count(),
lround(partition.pc.GetTotalPlayTime().count()));

Expand Down
11 changes: 6 additions & 5 deletions src/TagPrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tag_print_types(Response &r) noexcept
const auto tag_mask = global_tag_mask & r.GetTagMask();
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (tag_mask.Test(TagType(i)))
r.Fmt(FMT_STRING("tagtype: {}\n"), tag_item_names[i]);
r.Fmt("tagtype: {}\n", tag_item_names[i]);
}

void
Expand All @@ -29,13 +29,14 @@ tag_print_types_available(Response &r) noexcept
void
tag_print(Response &r, TagType type, std::string_view value) noexcept
{
r.Fmt(FMT_STRING("{}: {}\n"), tag_item_names[type], value);
const std::string_view value{_value};
r.Fmt("{}: {}\n", tag_item_names[type], value);
}

void
tag_print(Response &r, TagType type, const char *value) noexcept
{
r.Fmt(FMT_STRING("{}: {}\n"), tag_item_names[type], value);
r.Fmt("{}: {}\n", tag_item_names[type], value);
}

void
Expand All @@ -51,8 +52,8 @@ void
tag_print(Response &r, const Tag &tag) noexcept
{
if (!tag.duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3f}\n"),
r.Fmt("Time: {}\n"
"duration: {:1.3f}\n",
tag.duration.RoundS(),
tag.duration.ToDoubleS());

Expand Down
2 changes: 1 addition & 1 deletion src/TimePrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ time_print(Response &r, const char *name,
return;
}

r.Fmt(FMT_STRING("{}: {}\n"), name, s.c_str());
r.Fmt("{}: {}\n", name, s.c_str());
}
2 changes: 1 addition & 1 deletion src/client/Idle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WriteIdleResponse(Response &r, unsigned flags) noexcept
const char *const*idle_names = idle_get_names();
for (unsigned i = 0; idle_names[i]; ++i) {
if (flags & (1 << i))
r.Fmt(FMT_STRING("changed: {}\n"), idle_names[i]);
r.Fmt("changed: {}\n", idle_names[i]);
}

r.Write("OK\n");
Expand Down
4 changes: 2 additions & 2 deletions src/client/Response.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Response::WriteBinary(std::span<const std::byte> payload) noexcept
void
Response::Error(enum ack code, const char *msg) noexcept
{
Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
Fmt("ACK [{}@{}] {{{}}} ",
(int)code, list_index, command);

Write(msg);
Expand All @@ -57,7 +57,7 @@ void
Response::VFmtError(enum ack code,
fmt::string_view format_str, fmt::format_args args) noexcept
{
Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
Fmt("ACK [{}@{}] {{{}}} ",
(int)code, list_index, command);

VFmt(format_str, args);
Expand Down
14 changes: 7 additions & 7 deletions src/command/AllCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ PrintAvailableCommands(Response &r, const Partition &partition,

if (cmd->permission == (permission & cmd->permission) &&
command_available(partition, cmd))
r.Fmt(FMT_STRING("command: {}\n"), cmd->cmd);
r.Fmt("command: {}\n", cmd->cmd);
}

return CommandResult::OK;
Expand All @@ -267,7 +267,7 @@ PrintUnavailableCommands(Response &r, unsigned permission) noexcept
const struct command *cmd = &i;

if (cmd->permission != (permission & cmd->permission))
r.Fmt(FMT_STRING("command: {}\n"), cmd->cmd);
r.Fmt("command: {}\n", cmd->cmd);
}

return CommandResult::OK;
Expand Down Expand Up @@ -325,7 +325,7 @@ command_check_request(const struct command *cmd, Response &r,
{
if (cmd->permission != (permission & cmd->permission)) {
r.FmtError(ACK_ERROR_PERMISSION,
FMT_STRING("you don't have permission for {:?}"),
"you don't have permission for {:?}",
cmd->cmd);
return false;
}
Expand All @@ -338,17 +338,17 @@ command_check_request(const struct command *cmd, Response &r,

if (min == max && unsigned(max) != args.size()) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("wrong number of arguments for {:?}"),
"wrong number of arguments for {:?}",
cmd->cmd);
return false;
} else if (args.size() < unsigned(min)) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too few arguments for {:?}"),
"too few arguments for {:?}",
cmd->cmd);
return false;
} else if (max >= 0 && args.size() > unsigned(max)) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too many arguments for {:?}"),
"too many arguments for {:?}",
cmd->cmd);
return false;
} else
Expand All @@ -362,7 +362,7 @@ command_checked_lookup(Response &r, unsigned permission,
const struct command *cmd = command_lookup(cmd_name);
if (cmd == nullptr) {
r.FmtError(ACK_ERROR_UNKNOWN,
FMT_STRING("unknown command {:?}"), cmd_name);
"unknown command {:?}", cmd_name);
return nullptr;
}

Expand Down
8 changes: 4 additions & 4 deletions src/command/DatabaseCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ handle_count_internal(Client &client, Request args, Response &r, bool fold_case)
group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
"Unknown tag type: {}", s);
return CommandResult::ERROR;
}

Expand Down Expand Up @@ -311,7 +311,7 @@ handle_list(Client &client, Request args, Response &r)
const auto tagType = tag_name_parse_i(tag_name);
if (tagType == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), tag_name);
"Unknown tag type: {}", tag_name);
return CommandResult::ERROR;
}

Expand All @@ -325,7 +325,7 @@ handle_list(Client &client, Request args, Response &r)
/* for compatibility with < 0.12.0 */
if (tagType != TAG_ALBUM) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("should be {:?} for 3 arguments"),
"should be {:?} for 3 arguments",
tag_item_names[TAG_ALBUM]);
return CommandResult::ERROR;
}
Expand All @@ -340,7 +340,7 @@ handle_list(Client &client, Request args, Response &r)
const auto group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
"Unknown tag type: {}", s);
return CommandResult::ERROR;
}

Expand Down
14 changes: 7 additions & 7 deletions src/command/FileCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ handle_listfiles_local(Response &r, Path path_fs)
continue;

if (fi.IsRegular())
r.Fmt(FMT_STRING("file: {}\n"
"size: {}\n"),
r.Fmt("file: {}\n"
"size: {}\n",
name_utf8,
fi.GetSize());
else if (fi.IsDirectory())
r.Fmt(FMT_STRING("directory: {}\n"), name_utf8);
r.Fmt("directory: {}\n", name_utf8);
else
continue;

Expand Down Expand Up @@ -111,7 +111,7 @@ class PrintCommentHandler final : public NullTagHandler {

void OnPair(std::string_view key, std::string_view value) noexcept override {
if (IsValidName(key) && IsValidValue(value))
response.Fmt(FMT_STRING("{}: {}\n"), key, value);
response.Fmt("{}: {}\n", key, value);
}
};

Expand Down Expand Up @@ -200,7 +200,7 @@ read_stream_art(Response &r, const std::string_view art_directory,
read_size = is->Read(lock, {buffer.get(), buffer_size});
}

r.Fmt(FMT_STRING("size: {}\n"), art_file_size);
r.Fmt("size: {}\n", art_file_size);

r.WriteBinary({buffer.get(), read_size});

Expand Down Expand Up @@ -330,10 +330,10 @@ class PrintPictureHandler final : public NullTagHandler {
return;
}

response.Fmt(FMT_STRING("size: {}\n"), buffer.size());
response.Fmt("size: {}\n", buffer.size());

if (mime_type != nullptr)
response.Fmt(FMT_STRING("type: {}\n"), mime_type);
response.Fmt("type: {}\n", mime_type);

buffer = buffer.subspan(offset);

Expand Down
2 changes: 1 addition & 1 deletion src/command/FingerprintCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GetChromaprintCommand final
void Run() override;

void SendResponse(Response &r) noexcept override {
r.Fmt(FMT_STRING("chromaprint: {}\n"),
r.Fmt("chromaprint: {}\n",
GetFingerprint());
}

Expand Down
4 changes: 2 additions & 2 deletions src/command/MessageCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ handle_channels(Client &client, [[maybe_unused]] Request args, Response &r)
}

for (const auto &channel : channels)
r.Fmt(FMT_STRING("channel: {}\n"), channel);
r.Fmt("channel: {}\n", channel);

return CommandResult::OK;
}
Expand All @@ -82,7 +82,7 @@ handle_read_messages(Client &client,
assert(args.empty());

client.ConsumeMessages([&r](const auto &msg){
r.Fmt(FMT_STRING("channel: {}\nmessage: {}\n"),
r.Fmt("channel: {}\nmessage: {}\n",
msg.GetChannel(), msg.GetMessage());
});

Expand Down
4 changes: 2 additions & 2 deletions src/command/NeighborCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ handle_listneighbors(Client &client, [[maybe_unused]] Request args, Response &r)
}

for (const auto &i : neighbors->GetList())
r.Fmt(FMT_STRING("neighbor: {}\n"
"name: {}\n"),
r.Fmt("neighbor: {}\n"
"name: {}\n",
i.uri,
i.display_name);
return CommandResult::OK;
Expand Down
Loading

0 comments on commit b24b3c1

Please sign in to comment.