Resolve Robert code review feedback.
MODIFY
include/vcpkg/archives.h
include/vcpkg/archives.h
@@ -8,6 +8,6 @@ namespace vcpkg
{
// Extract `archive` to `to_path` using `tar_tool`.
void extract_tar(const Path& tar_tool, const Path& archive, const Path& to_path);
- // Extract `archive` to `path`, deleting `path` first.
+ // Extract `archive` to `to_path`, deleting `to_path` first.
void extract_archive(const VcpkgPaths& paths, const Path& archive, const Path& to_path);
}

MODIFY
include/vcpkg/base/stringview.h
include/vcpkg/base/stringview.h
@@ -29,6 +29,9 @@ namespace vcpkg
constexpr const char* begin() const noexcept { return m_ptr; }
constexpr const char* end() const noexcept { return m_ptr + m_size; }
+ const char& front() const noexcept { return *m_ptr; }
+ const char& back() const noexcept { return m_ptr[m_size - 1]; }
+
std::reverse_iterator<const char*> rbegin() const noexcept { return std::make_reverse_iterator(end()); }
std::reverse_iterator<const char*> rend() const noexcept { return std::make_reverse_iterator(begin()); }

MODIFY
include/vcpkg/base/system.process.h
include/vcpkg/base/system.process.h
@@ -23,7 +23,7 @@ namespace vcpkg
std::string s;
};
- void append_escaped_quoted_string(std::string& target, StringView content);
+ void append_shell_escaped(std::string& target, StringView content);
struct Command
{

MODIFY
include/vcpkg/commands.new.h
include/vcpkg/commands.new.h
#include <vcpkg/commands.interface.h>
-namespace vcpkg::Commands::New
+namespace vcpkg::Commands
{
struct NewCommand : PathsCommand
{

MODIFY
include/vcpkg/commands.zbootstrap-standalone.h
include/vcpkg/commands.zbootstrap-standalone.h
namespace vcpkg::Commands
{
- struct BootstrapStandaloneCommand : BasicCommand
+ struct ZBootstrapStandaloneCommand : BasicCommand
{
virtual void perform_and_exit(const VcpkgCmdArguments& args, Filesystem& fs) const override;
};

MODIFY
include/vcpkg/configuration.h
include/vcpkg/configuration.h
@@ -37,7 +37,7 @@ namespace vcpkg
std::unique_ptr<RegistrySet> instantiate_registry_set(const VcpkgPaths& paths, const Path& config_dir) const;
- bool requests_configure_environment() const;
+ bool requests_ce() const;
static View<StringView> known_fields();
};

MODIFY
src/vcpkg/archives.cpp
src/vcpkg/archives.cpp
@@ -26,8 +26,8 @@ namespace
const std::string nugetid = match[1];
const std::string version = match[2];
- const auto code_and_output = cmd_execute_and_capture_output(Command{nuget_exe}
- .string_arg("install")
+ Command nuget_command{nuget_exe};
+ nuget_command.string_arg("install")
.string_arg(nugetid)
.string_arg("-Version")
.string_arg(version)
@@ -40,7 +40,8 @@ namespace
.string_arg("-NonInteractive")
.string_arg("-ForceEnglishOutput")
.string_arg("-PackageSaveMode")
- .string_arg("nuspec"));
+ .string_arg("nuspec");
+ const auto code_and_output = cmd_execute_and_capture_output(nuget_command);
Checks::check_exit(VCPKG_LINE_INFO,
code_and_output.exit_code == 0,
@@ -152,11 +153,10 @@ namespace
Path extract_archive_to_temp_subdirectory(const VcpkgPaths& paths, const Path& archive, const Path& to_path)
{
Filesystem& fs = paths.get_filesystem();
- Path to_path_partial = to_path + ".partial"
+ Path to_path_partial = to_path + ".partial";
#if defined(_WIN32)
- + "." + std::to_string(GetCurrentProcessId())
+ to_path_partial += "." + std::to_string(GetCurrentProcessId());
#endif
- ;
fs.remove_all(to_path_partial, VCPKG_LINE_INFO);
fs.create_directories(to_path_partial, VCPKG_LINE_INFO);

MODIFY
src/vcpkg/base/system.process.cpp
src/vcpkg/base/system.process.cpp
namespace vcpkg
{
- void append_escaped_quoted_string(std::string& target, StringView content)
+ void append_shell_escaped(std::string& target, StringView content)
{
if (Strings::find_first_of(content, " \t\n\r\"\\,;&`^|'") != content.end())
{
@@ -249,7 +249,7 @@ namespace vcpkg
Command& Command::string_arg(StringView s) &
{
if (!buf.empty()) buf.push_back(' ');
- append_escaped_quoted_string(buf, s);
+ append_shell_escaped(buf, s);
return *this;
}
@@ -261,11 +261,14 @@ namespace vcpkg
get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO);
static const std::string system32_env = system_root_env + R"(\system32)";
std::string new_path = "PATH=";
+ if (!prepend_to_path.empty())
+ {
Strings::append(new_path, prepend_to_path);
- if (new_path.back() != '=' && new_path.back() != ';')
+ if (prepend_to_path.back() != ';')
{
new_path.push_back(';');
}
+ }
Strings::append(new_path,
system32_env,
@@ -405,11 +408,10 @@ namespace vcpkg
std::string result;
if (!prepend_to_path.empty())
{
- std::string new_path = get_environment_variable("PATH").value_or_exit(VCPKG_LINE_INFO);
- new_path.insert(new_path.begin(), prepend_to_path.size() + 1, ':');
- std::copy_n(prepend_to_path.data(), prepend_to_path.size(), new_path.begin());
result = "PATH=";
- append_escaped_quoted_string(result, new_path);
+ append_shell_escaped(
+ result,
+ Strings::concat(prepend_to_path, ':', get_environment_variable("PATH").value_or_exit(VCPKG_LINE_INFO)));
}
return {result};

MODIFY
src/vcpkg/commands.cpp
src/vcpkg/commands.cpp
@@ -57,7 +57,7 @@ namespace vcpkg::Commands
static const X_Download::XDownloadCommand xdownload{};
static const GenerateDefaultMessageMapCommand generate_message_map{};
static const Hash::HashCommand hash{};
- static const BootstrapStandaloneCommand zboostrap_standalone{};
+ static const ZBootstrapStandaloneCommand zboostrap_standalone{};
#if defined(_WIN32)
static const UploadMetrics::UploadMetricsCommand upload_metrics{};
#endif // defined(_WIN32)
@@ -95,7 +95,7 @@ namespace vcpkg::Commands
static const Info::InfoCommand info{};
static const Integrate::IntegrateCommand integrate{};
static const List::ListCommand list{};
- static const New::NewCommand new_{};
+ static const NewCommand new_{};
static const Owns::OwnsCommand owns{};
static const PortHistory::PortHistoryCommand porthistory{};
static const PortsDiff::PortsDiffCommand portsdiff{};

MODIFY
src/vcpkg/commands.new.cpp
src/vcpkg/commands.new.cpp
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
-namespace vcpkg::Commands::New
+namespace vcpkg::Commands
{
void NewCommand::perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const
{

MODIFY
src/vcpkg/commands.zbootstrap-standalone.cpp
src/vcpkg/commands.zbootstrap-standalone.cpp
@@ -20,7 +20,7 @@ namespace vcpkg::Commands
nullptr,
};
- void BootstrapStandaloneCommand::perform_and_exit(const VcpkgCmdArguments& args, Filesystem& fs) const
+ void ZBootstrapStandaloneCommand::perform_and_exit(const VcpkgCmdArguments& args, Filesystem& fs) const
{
DownloadManager download_manager{{}};
const auto& vcpkg_root_arg = args.vcpkg_root_dir;

MODIFY
src/vcpkg/configuration.cpp
src/vcpkg/configuration.cpp
@@ -571,26 +571,35 @@ namespace vcpkg
}
}
- static bool registry_config_requests_configure_environment(const Optional<RegistryConfig>& target) noexcept
+ static bool registry_config_requests_ce(const RegistryConfig& target) noexcept
{
- if (auto* reg = target.get())
- {
- if (auto* kind = reg->kind.get())
+ if (auto* kind = target.kind.get())
{
if (*kind == "artifact")
{
return true;
}
}
- }
return false;
}
- bool Configuration::requests_configure_environment() const
+ bool Configuration::requests_ce() const
+ {
+ if (!ce_metadata.is_empty())
{
- return !ce_metadata.is_empty() || registry_config_requests_configure_environment(default_reg) ||
- std::any_of(registries.begin(), registries.end(), registry_config_requests_configure_environment);
+ return true;
+ }
+
+ if (const auto* pdefault = default_reg.get())
+ {
+ if (registry_config_requests_ce(*pdefault))
+ {
+ return true;
+ }
+ }
+
+ return std::any_of(registries.begin(), registries.end(), registry_config_requests_ce);
}
Json::IDeserializer<Configuration>& get_configuration_deserializer() { return ConfigurationDeserializer::instance; }

MODIFY
src/vcpkg/configure-environment.cpp
src/vcpkg/configure-environment.cpp
@@ -45,18 +45,18 @@ namespace vcpkg
}
Command cmd_provision(node_path);
- cmd_provision.string_arg(npm_path);
+ cmd_provision.path_arg(npm_path);
cmd_provision.string_arg("--force");
cmd_provision.string_arg("install");
cmd_provision.string_arg("--no-save");
cmd_provision.string_arg("--no-lockfile");
cmd_provision.string_arg("--scripts-prepend-node-path=true");
cmd_provision.string_arg("--silent");
- cmd_provision.string_arg(ce_tarball.native());
+ cmd_provision.path_arg(ce_tarball);
const auto provision_status = cmd_execute(cmd_provision, InWorkingDirectory{paths.root}, env);
+ fs.remove(ce_tarball, VCPKG_LINE_INFO);
if (provision_status != 0)
{
- fs.remove(ce_tarball, VCPKG_LINE_INFO);
fs.remove_all(node_modules, VCPKG_LINE_INFO);
Checks::exit_with_message(VCPKG_LINE_INFO, "Failed to provision vcpkg-ce.");
}
@@ -64,7 +64,7 @@ namespace vcpkg
Command cmd_run(node_path);
cmd_run.string_arg("--harmony");
- cmd_run.string_arg(ce_path);
+ cmd_run.path_arg(ce_path);
cmd_run.forwarded_args(args);
cmd_run.string_arg("--from-vcpkg");
return cmd_execute(cmd_run, InWorkingDirectory{paths.original_cwd});

MODIFY
src/vcpkg/tools.cpp
src/vcpkg/tools.cpp
@@ -665,7 +665,7 @@ gsutil version: 4.58
);
}
- return tars[0];
+ return std::move(tars[0]);
}
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unknown or unavailable tool: %s", tool);

MODIFY
src/vcpkg/vcpkgcmdarguments.cpp
src/vcpkg/vcpkgcmdarguments.cpp
@@ -236,20 +236,15 @@ namespace vcpkg
VcpkgCmdArguments args;
std::vector<std::string> feature_flags;
- if (arg_first == arg_last)
- {
- args.forwardable_arguments.clear();
- }
- else
+ if (arg_first != arg_last)
{
args.forwardable_arguments.assign(arg_first + 1, arg_last);
- }
-
- if (arg_first != arg_last && arg_first + 1 == arg_last && *arg_first == "--version")
+ if (arg_first + 1 == arg_last && *arg_first == "--version")
{
args.command = "version";
return args;
}
+ }
for (auto it = arg_first; it != arg_last; ++it)
{

MODIFY
vcpkg-init/lock-versions.ps1
vcpkg-init/lock-versions.ps1
@@ -9,10 +9,10 @@ Param(
$versionUnlockedUri = "https://github.com/microsoft/vcpkg-tool/releases/latest/download/"
$versionLockedUri = "https://github.com/microsoft/vcpkg-tool/releases/download/$VcpkgBaseVersion/"
-$pwshInstaller = Get-Content "$PSScriptRoot\vcpkg-init.ps1" -Raw
+$pwshInstaller = Get-Content "$PSScriptRoot\vcpkg-init.ps1" -Raw -Encoding ascii
$pwshInstaller = $pwshInstaller.Replace($versionUnlockedUri, $versionLockedUri)
-Set-Content -Path "$Destination\vcpkg-init.ps1" -Value $pwshInstaller -NoNewline
+Set-Content -Path "$Destination\vcpkg-init.ps1" -Value $pwshInstaller -NoNewline -Encoding ascii
-$shInstaller = Get-Content "$PSScriptRoot\vcpkg-init" -Raw
+$shInstaller = Get-Content "$PSScriptRoot\vcpkg-init" -Raw -Encoding ascii
$shInstaller = $shInstaller.Replace($versionUnlockedUri, $versionLockedUri)
-Set-Content -Path "$Destination\vcpkg-init" -Value $shInstaller -NoNewline
+Set-Content -Path "$Destination\vcpkg-init" -Value $shInstaller -NoNewline -Encoding ascii

Resolve Robert code review feedback.