From 577c2920b93b8ac1f76d0a638a598fae80718098 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 28 Jan 2023 23:52:42 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20use=20fmt=5Fcompile=20macro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/disk.cpp | 4 ++-- src/initcpio.cpp | 6 +++--- src/simple_tui.cpp | 18 +++++++++--------- src/tui.cpp | 12 ++++++------ src/utils.cpp | 6 +++--- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/disk.cpp b/src/disk.cpp index cc49cab..44c9dc0 100644 --- a/src/disk.cpp +++ b/src/disk.cpp @@ -178,9 +178,9 @@ std::string zfs_list_devs() noexcept { const auto& devices = utils::make_multiline("zpool status -PL 2>/dev/null | awk '{print $1}' | grep \"^/\""); for (const auto& device : devices) { // add the device - list_of_devices += fmt::format("{}\n", device); + list_of_devices += fmt::format(FMT_COMPILE("{}\n"), device); // now let's add any other forms of those devices - list_of_devices += utils::exec(fmt::format("find -L /dev/ -xtype l -samefile {} 2>/dev/null", device)); + list_of_devices += utils::exec(fmt::format(FMT_COMPILE("find -L /dev/ -xtype l -samefile {} 2>/dev/null"), device)); } return list_of_devices; } diff --git a/src/initcpio.cpp b/src/initcpio.cpp index faa2822..1daa747 100644 --- a/src/initcpio.cpp +++ b/src/initcpio.cpp @@ -42,15 +42,15 @@ bool Initcpio::write() const noexcept { if (line.starts_with("MODULES")) { auto&& formatted_modules = modules | ranges::views::join(' ') | ranges::to(); - return fmt::format("MODULES=({})", std::move(formatted_modules)); + return fmt::format(FMT_COMPILE("MODULES=({})"), std::move(formatted_modules)); } else if (line.starts_with("FILES")) { auto&& formatted_files = files | ranges::views::join(' ') | ranges::to(); - return fmt::format("FILES=({})", std::move(formatted_files)); + return fmt::format(FMT_COMPILE("FILES=({})"), std::move(formatted_files)); } else if (line.starts_with("HOOKS")) { auto&& formatted_hooks = hooks | ranges::views::join(' ') | ranges::to(); - return fmt::format("HOOKS=({})", std::move(formatted_hooks)); + return fmt::format(FMT_COMPILE("HOOKS=({})"), std::move(formatted_hooks)); } /* clang-format on */ return std::string{line.data(), line.size()}; diff --git a/src/simple_tui.cpp b/src/simple_tui.cpp index 6807f48..d5b5739 100644 --- a/src/simple_tui.cpp +++ b/src/simple_tui.cpp @@ -272,7 +272,7 @@ void menu_simple() noexcept { // so that output will be synchronized. auto logger = spdlog::get("cachyos_logger"); logger->flush(); - utils::exec(fmt::format("{} &>>/tmp/cachyos-install.log", post_install), true); + utils::exec(fmt::format(FMT_COMPILE("{} &>>/tmp/cachyos-install.log"), post_install), true); } tui::exit_done(); @@ -284,10 +284,10 @@ void menu_simple() noexcept { "│{4: ^{5}}│\n" "└{0:─^{5}}┘\n", "", - fmt::format("Mountpoint: {}", mountpoint), - fmt::format("Your device: {}", device_info), - fmt::format("Filesystem: {}", fs_name), - fmt::format("Filesystem opts: {}", mount_opts_info), 80); + fmt::format(FMT_COMPILE("Mountpoint: {}"), mountpoint), + fmt::format(FMT_COMPILE("Your device: {}"), device_info), + fmt::format(FMT_COMPILE("Filesystem: {}"), fs_name), + fmt::format(FMT_COMPILE("Filesystem opts: {}"), mount_opts_info), 80); fmt::print("┌{0:─^{5}}┐\n" "│{1: ^{5}}│\n" @@ -296,10 +296,10 @@ void menu_simple() noexcept { "│{4: ^{5}}│\n" "└{0:─^{5}}┘\n", "", - fmt::format("Kernel: {}", kernel), - fmt::format("Desktop: {}", desktop), - fmt::format("Drivers type: {}", drivers_type), - fmt::format("Bootloader: {}", bootloader), 80); + fmt::format(FMT_COMPILE("Kernel: {}"), kernel), + fmt::format(FMT_COMPILE("Desktop: {}"), desktop), + fmt::format(FMT_COMPILE("Drivers type: {}"), drivers_type), + fmt::format(FMT_COMPILE("Bootloader: {}"), bootloader), 80); } } // namespace tui diff --git a/src/tui.cpp b/src/tui.cpp index b1db63a..80d8073 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -1692,12 +1692,12 @@ void zfs_auto() noexcept { const auto& zfs_zpool_name = std::get(config_data["ZFS_ZPOOL_NAME"]); // next create the datasets including their parents - utils::zfs_create_dataset(fmt::format("{}/ROOT", zfs_zpool_name), "none"); - utils::zfs_create_dataset(fmt::format("{}/ROOT/cos", zfs_zpool_name), "none"); - utils::zfs_create_dataset(fmt::format("{}/ROOT/cos/root", zfs_zpool_name), "/"); - utils::zfs_create_dataset(fmt::format("{}/ROOT/cos/home", zfs_zpool_name), "/home"); - utils::zfs_create_dataset(fmt::format("{}/ROOT/cos/varcache", zfs_zpool_name), "/var/cache"); - utils::zfs_create_dataset(fmt::format("{}/ROOT/cos/varlog", zfs_zpool_name), "/var/log"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT"), zfs_zpool_name), "none"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT/cos"), zfs_zpool_name), "none"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT/cos/root"), zfs_zpool_name), "/"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT/cos/home"), zfs_zpool_name), "/home"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT/cos/varcache"), zfs_zpool_name), "/var/cache"); + utils::zfs_create_dataset(fmt::format(FMT_COMPILE("{}/ROOT/cos/varlog"), zfs_zpool_name), "/var/log"); #ifdef NDEVENV // set the rootfs diff --git a/src/utils.cpp b/src/utils.cpp index 2c70aa4..173bdba 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -110,7 +110,7 @@ bool check_root() noexcept { void clear_screen() noexcept { static constexpr auto CLEAR_SCREEN_ANSI = "\033[1;1H\033[2J"; - output_inter("{}", CLEAR_SCREEN_ANSI); + output_inter(FMT_COMPILE("{}"), CLEAR_SCREEN_ANSI); } void arch_chroot(const std::string_view& command, bool follow) noexcept { @@ -787,7 +787,7 @@ void install_base(const std::string_view& packages) noexcept { const auto& pkg_list = utils::get_pkglist_base(packages); const auto& base_pkgs = utils::make_multiline(pkg_list, false, " "); - spdlog::info(fmt::format("Preparing for pkgs to install: \"{}\"", base_pkgs)); + spdlog::info(fmt::format(FMT_COMPILE("Preparing for pkgs to install: \"{}\""), base_pkgs)); #ifdef NDEVENV // Prep variables @@ -882,7 +882,7 @@ void install_desktop(const std::string_view& desktop) noexcept { const auto& pkg_list = utils::get_pkglist_desktop(desktop); const std::string& packages = utils::make_multiline(pkg_list, false, " "); - spdlog::info(fmt::format("Preparing for desktop envs to install: \"{}\"", packages)); + spdlog::info(fmt::format(FMT_COMPILE("Preparing for desktop envs to install: \"{}\""), packages)); utils::install_from_pkglist(packages); auto* config_instance = Config::instance();