From ea1608a496aaeb5b85e5a16bbe9ea70fd1ea9a93 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Thu, 22 Sep 2022 11:53:35 -0700 Subject: [PATCH 1/6] Localized messages in xmlserializer.cpp --- include/vcpkg/base/messages.h | 1 + locales/messages.en.json | 1 + locales/messages.json | 1 + src/vcpkg/base/messages.cpp | 1 + src/vcpkg/base/xmlserializer.cpp | 3 +-- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index d463672da5..c3e224b077 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1647,4 +1647,5 @@ namespace vcpkg DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:"); DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); + DECLARE_MESSAGE(UnsupportedSyntaxInCDATA, (), "", "]]> is not supported in CDATA block"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index d7d091d0cf..f578afa4bb 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -383,6 +383,7 @@ "UnsupportedPortDependency": "- dependency {value} is not supported.", "UnsupportedPortFeature": "{spec} is only supported on '{supports_expression}'", "UnsupportedShortOptions": "short options are not supported: '{value}'", + "UnsupportedSyntaxInCDATA": "]]> is not supported in CDATA block", "UnsupportedSystemName": "Could not map VCPKG_CMAKE_SYSTEM_NAME '{system_name}' to a vcvarsall platform. Supported system names are '', 'Windows' and 'WindowsStore'.", "UnsupportedToolchain": "in triplet {triplet}: Unable to find a valid toolchain for requested target architecture {arch}.\nThe selected Visual Studio instance is at: {path}\nThe available toolchain combinations are: {list}", "UpdateBaselineAddBaselineNoManifest": "the --{option} switch was passed, but there is no manifest file to add a `builtin-baseline` field to.", diff --git a/locales/messages.json b/locales/messages.json index c339ec8d63..2177d7b397 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -629,6 +629,7 @@ "_UnsupportedPortFeature.comment": "An example of {spec} is zlib:x64-windows. An example of {supports_expression} is windows & !static.", "UnsupportedShortOptions": "short options are not supported: '{value}'", "_UnsupportedShortOptions.comment": "'{value}' is the short option given", + "UnsupportedSyntaxInCDATA": "]]> is not supported in CDATA block", "UnsupportedSystemName": "Could not map VCPKG_CMAKE_SYSTEM_NAME '{system_name}' to a vcvarsall platform. Supported system names are '', 'Windows' and 'WindowsStore'.", "_UnsupportedSystemName.comment": "An example of {system_name} is Darwin.", "UnsupportedToolchain": "in triplet {triplet}: Unable to find a valid toolchain for requested target architecture {arch}.\nThe selected Visual Studio instance is at: {path}\nThe available toolchain combinations are: {list}", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 9afec73519..cc8340bdcd 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -803,4 +803,5 @@ namespace vcpkg REGISTER_MESSAGE(WhileLookingForSpec); REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); + REGISTER_MESSAGE(UnsupportedSyntaxInCDATA); } diff --git a/src/vcpkg/base/xmlserializer.cpp b/src/vcpkg/base/xmlserializer.cpp index 128a7be39e..648235bfe9 100644 --- a/src/vcpkg/base/xmlserializer.cpp +++ b/src/vcpkg/base/xmlserializer.cpp @@ -93,8 +93,7 @@ namespace vcpkg XmlSerializer& XmlSerializer::cdata(StringView sv) { emit_pending_indent(); - Checks::check_exit( - VCPKG_LINE_INFO, Strings::search(sv, "]]>") == sv.end(), "]]> is not supported in a CDATA block"); + Checks::msg_check_exit(VCPKG_LINE_INFO, Strings::search(sv, "]]>") == sv.end(), msgUnsupportedSyntaxInCDATA); buf.append(""); From 644338a0fb47db6e883fa6db4a800fabd858010f Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Thu, 22 Sep 2022 13:44:09 -0700 Subject: [PATCH 2/6] Localizes messages in unicode.cpp --- include/vcpkg/base/messages.h | 16 ++++++++++++++++ locales/messages.en.json | 10 ++++++++++ locales/messages.json | 10 ++++++++++ src/vcpkg/base/messages.cpp | 10 ++++++++++ src/vcpkg/base/unicode.cpp | 28 ++++++++++++++-------------- src/vcpkg/base/xmlserializer.cpp | 1 + 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index c3e224b077..0b453d5d32 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -1648,4 +1648,20 @@ namespace vcpkg DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); DECLARE_MESSAGE(UnsupportedSyntaxInCDATA, (), "", "]]> is not supported in CDATA block"); + DECLARE_MESSAGE(InvalidCodePoint, (), "", "Invalid code point passed to utf8_encoded_code_point_count"); + DECLARE_MESSAGE(NoError, (), "", "no error"); + DECLARE_MESSAGE(InvalidCodeUnit, (), "", "invalid code unit"); + DECLARE_MESSAGE(PairedSurrogatesAreInvalid, + (), + "", + "trailing surrogate following leading surrogate (paired surrogates are invalid)"); + DECLARE_MESSAGE(ContinueCodeUnitInStart, (), "", "found continue code unit in start position"); + DECLARE_MESSAGE(StartCodeUnitInContinue, (), "", "found start code unit in continue position"); + DECLARE_MESSAGE(EndOfStringInCodeUnit, (), "", "found end of string in middle of code point"); + DECLARE_MESSAGE(ErrorCodeOutOfRange, (), "", "error code out of range"); + DECLARE_MESSAGE(IncrementedUtf8Decoder, (), "", "Incremented Utf8Decoder at the end of the string"); + DECLARE_MESSAGE(ComparingUtf8Decoders, + (), + "", + "Comparing Utf8Decoders with different provenance; this is always an error"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index f578afa4bb..ff17fd17b3 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -83,9 +83,11 @@ "ClearingContents": "Clearing contents of {path}", "CmakeTargetsExcluded": "note: {count} additional targets are not displayed.", "CommandFailed": "command:\n{command_line}\nfailed with the following results:", + "ComparingUtf8Decoders": "Comparing Utf8Decoders with different provenance; this is always an error", "CompressFolderFailed": "Failed to compress folder \"{path}\":", "ConflictingValuesForOption": "conflicting values specified for '--{option}'.", "ConstraintViolation": "Found a constraint violation:", + "ContinueCodeUnitInStart": "found continue code unit in start position", "ControlAndManifestFilesPresent": "Both a manifest file and a CONTROL file exist in port directory: {path}", "CopyrightIsDir": "`{path}` being a directory is deprecated.", "CorruptedDatabase": "Database corrupted.", @@ -113,7 +115,9 @@ "EmailVcpkgTeam": "Send an email to {url} with any feedback.", "EmptyArg": "The option --{option} must be passed a non-empty argument.", "EmptyLicenseExpression": "SPDX license expression was empty.", + "EndOfStringInCodeUnit": "found end of string in middle of code point", "EnvStrFailedToExtract": "could not expand the environment string:", + "ErrorCodeOutOfRange": "error code out of range", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", "ErrorInvalidClassicModeOption": "The option --{option} is not supported in classic mode and no manifest was found.", @@ -214,6 +218,7 @@ "IllegalPlatformSpec": "Platform qualifier is not allowed in this context", "ImproperShaLength": "SHA512's must be 128 hex characters: {value}", "IncorrectNumberOfArgs": "'{command_name}' requires '{expected}' arguments, but '{actual}' were provided.", + "IncrementedUtf8Decoder": "Incremented Utf8Decoder at the end of the string", "InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", "InstallPackageInstruction": "With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:\n Install-Package \"{value}\" -Source \"{path}\"", @@ -245,6 +250,8 @@ "InvalidArgumentRequiresTwoOrThreeArguments": "invalid argument: binary config '{binary_source}' requires 2 or 3 arguments", "InvalidArgumentRequiresValidToken": "invalid argument: binary config '{binary_source}' requires a SAS token without a preceeding '?' as the second argument", "InvalidBuildInfo": "Invalid BUILD_INFO file for package: {error_msg}", + "InvalidCodePoint": "Invalid code point passed to utf8_encoded_code_point_count", + "InvalidCodeUnit": "invalid code unit", "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", "InvalidFilename": "Filename cannot contain invalid chars {value}, but was {path}", @@ -298,6 +305,7 @@ "NewVersionCannotBeEmpty": "--version cannot be empty.", "NoArgumentsForOption": "The option --{option} does not accept an argument.", "NoCachedPackages": "No packages are cached.", + "NoError": "no error", "NoInstalledPackages": "No packages are installed. Did you mean `search`?", "NoLocalizationForMessages": "No localized messages for the following: ", "NoRegistryForPort": "no registry configured for port {package_name}", @@ -316,6 +324,7 @@ "PackagesToRebuildSuggestRecurse": "If you are sure you want to rebuild the above packages, run the command with the --recurse option.", "PackagesToRemove": "The following packages will be removed:", "PackingVendorFailed": "Packing {vendor} failed. Use --debug for more information.", + "PairedSurrogatesAreInvalid": "trailing surrogate following leading surrogate (paired surrogates are invalid)", "ParseControlErrorInfoInvalidFields": "The following fields were not expected:", "ParseControlErrorInfoMissingFields": "The following fields were missing:", "ParseControlErrorInfoTypesEntry": "{value} was expected to be {expected}", @@ -353,6 +362,7 @@ "SpecifyDirectoriesWhenSearching": "Specify directories to be used when searching for ports.\n(also: '{env_var}')", "SpecifyHostArch": "Specify the host architecture triplet. See 'vcpkg help triplet'.\n(default: '{env_var}')", "SpecifyTargetArch": "Specify the target architecture triplet. See 'vcpkg help triplet'.\n(default: '{env_var}')", + "StartCodeUnitInContinue": "found start code unit in continue position", "StoreOptionMissingSha": "--store option is invalid without a sha512", "StoredBinaryCache": "Stored binary cache: \"{path}\"", "SuggestGitPull": "The result may be outdated. Run `git pull` to get the latest results.", diff --git a/locales/messages.json b/locales/messages.json index 2177d7b397..5b5e3ba02a 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -147,11 +147,13 @@ "_CmakeTargetsExcluded.comment": "An example of {count} is 42.", "CommandFailed": "command:\n{command_line}\nfailed with the following results:", "_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.", + "ComparingUtf8Decoders": "Comparing Utf8Decoders with different provenance; this is always an error", "CompressFolderFailed": "Failed to compress folder \"{path}\":", "_CompressFolderFailed.comment": "An example of {path} is /foo/bar.", "ConflictingValuesForOption": "conflicting values specified for '--{option}'.", "_ConflictingValuesForOption.comment": "An example of {option} is editable.", "ConstraintViolation": "Found a constraint violation:", + "ContinueCodeUnitInStart": "found continue code unit in start position", "ControlAndManifestFilesPresent": "Both a manifest file and a CONTROL file exist in port directory: {path}", "_ControlAndManifestFilesPresent.comment": "An example of {path} is /foo/bar.", "CopyrightIsDir": "`{path}` being a directory is deprecated.", @@ -201,7 +203,9 @@ "EmptyArg": "The option --{option} must be passed a non-empty argument.", "_EmptyArg.comment": "An example of {option} is editable.", "EmptyLicenseExpression": "SPDX license expression was empty.", + "EndOfStringInCodeUnit": "found end of string in middle of code point", "EnvStrFailedToExtract": "could not expand the environment string:", + "ErrorCodeOutOfRange": "error code out of range", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "_ErrorDetectingCompilerInfo.comment": "An example of {path} is /foo/bar.", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", @@ -351,6 +355,7 @@ "_ImproperShaLength.comment": "{value} is a sha.", "IncorrectNumberOfArgs": "'{command_name}' requires '{expected}' arguments, but '{actual}' were provided.", "_IncorrectNumberOfArgs.comment": "'{expected}' is the required number of arguments. '{actual}' is the number of arguments provided. An example of {command_name} is install.", + "IncrementedUtf8Decoder": "Incremented Utf8Decoder at the end of the string", "InfoSetEnvVar": "You can also set the environment variable '{env_var}' to your editor of choice.", "_InfoSetEnvVar.comment": "In this context 'editor' means IDE An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", @@ -404,6 +409,8 @@ "_InvalidArgumentRequiresValidToken.comment": "An example of {binary_source} is azblob.", "InvalidBuildInfo": "Invalid BUILD_INFO file for package: {error_msg}", "_InvalidBuildInfo.comment": "An example of {error_msg} is File Not Found.", + "InvalidCodePoint": "Invalid code point passed to utf8_encoded_code_point_count", + "InvalidCodeUnit": "invalid code unit", "InvalidCommandArgSort": "Value of --sort must be one of 'lexicographical', 'topological', 'reverse'.", "InvalidCommitId": "Invalid commit id {value}", "_InvalidCommitId.comment": "'{value}' is a commit id.", @@ -487,6 +494,7 @@ "NoArgumentsForOption": "The option --{option} does not accept an argument.", "_NoArgumentsForOption.comment": "An example of {option} is editable.", "NoCachedPackages": "No packages are cached.", + "NoError": "no error", "NoInstalledPackages": "No packages are installed. Did you mean `search`?", "_NoInstalledPackages.comment": "The name 'search' is the name of a command that is not localized.", "NoLocalizationForMessages": "No localized messages for the following: ", @@ -513,6 +521,7 @@ "PackagesToRemove": "The following packages will be removed:", "PackingVendorFailed": "Packing {vendor} failed. Use --debug for more information.", "_PackingVendorFailed.comment": "An example of {vendor} is Azure.", + "PairedSurrogatesAreInvalid": "trailing surrogate following leading surrogate (paired surrogates are invalid)", "ParseControlErrorInfoInvalidFields": "The following fields were not expected:", "ParseControlErrorInfoMissingFields": "The following fields were missing:", "ParseControlErrorInfoTypesEntry": "{value} was expected to be {expected}", @@ -578,6 +587,7 @@ "_SpecifyHostArch.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "SpecifyTargetArch": "Specify the target architecture triplet. See 'vcpkg help triplet'.\n(default: '{env_var}')", "_SpecifyTargetArch.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", + "StartCodeUnitInContinue": "found start code unit in continue position", "StoreOptionMissingSha": "--store option is invalid without a sha512", "StoredBinaryCache": "Stored binary cache: \"{path}\"", "_StoredBinaryCache.comment": "An example of {path} is /foo/bar.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index cc8340bdcd..19f677c60f 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -804,4 +804,14 @@ namespace vcpkg REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); REGISTER_MESSAGE(UnsupportedSyntaxInCDATA); + REGISTER_MESSAGE(InvalidCodePoint); + REGISTER_MESSAGE(NoError); + REGISTER_MESSAGE(InvalidCodeUnit); + REGISTER_MESSAGE(PairedSurrogatesAreInvalid); + REGISTER_MESSAGE(ContinueCodeUnitInStart); + REGISTER_MESSAGE(EndOfStringInCodeUnit); + REGISTER_MESSAGE(ErrorCodeOutOfRange); + REGISTER_MESSAGE(IncrementedUtf8Decoder); + REGISTER_MESSAGE(ComparingUtf8Decoders); + REGISTER_MESSAGE(StartCodeUnitInContinue); } diff --git a/src/vcpkg/base/unicode.cpp b/src/vcpkg/base/unicode.cpp index 04578511f0..bff9119e2f 100644 --- a/src/vcpkg/base/unicode.cpp +++ b/src/vcpkg/base/unicode.cpp @@ -56,8 +56,9 @@ namespace vcpkg::Unicode } else { - vcpkg::Checks::exit_with_message( - VCPKG_LINE_INFO, "Invalid code point passed to utf8_encoded_code_point_count (%x)", code_point); + vcpkg::Checks::msg_exit_with_message( + VCPKG_LINE_INFO, + msg::format(msgInvalidCodePoint).append_raw(fmt::format("({:x})", static_cast(code_point)))); } } @@ -223,15 +224,15 @@ namespace vcpkg::Unicode { switch (static_cast(condition)) { - case utf8_errc::NoError: return "no error"; - case utf8_errc::InvalidCodeUnit: return "invalid code unit"; - case utf8_errc::InvalidCodePoint: return "invalid code point (>0x10FFFF)"; - case utf8_errc::PairedSurrogates: - return "trailing surrogate following leading surrogate (paired surrogates are invalid)"; - case utf8_errc::UnexpectedContinue: return "found continue code unit in start position"; - case utf8_errc::UnexpectedStart: return "found start code unit in continue position"; - case utf8_errc::UnexpectedEof: return "found end of string in middle of code point"; - default: return "error code out of range"; + case utf8_errc::NoError: return msg::format(msgNoError).extract_data(); + case utf8_errc::InvalidCodeUnit: return msg::format(msgInvalidCodeUnit).extract_data(); + case utf8_errc::InvalidCodePoint: + return msg::format(msgInvalidCodePoint).append_raw(" (>0x10FFFF)").extract_data(); + case utf8_errc::PairedSurrogates: return msg::format(msgPairedSurrogatesAreInvalid).extract_data(); + case utf8_errc::UnexpectedContinue: return msg::format(msgContinueCodeUnitInStart).extract_data(); + case utf8_errc::UnexpectedStart: return msg::format(msgStartCodeUnitInContinue).extract_data(); + case utf8_errc::UnexpectedEof: return msg::format(msgEndOfStringInCodeUnit).extract_data(); + default: return msg::format(msgErrorCodeOutOfRange).extract_data(); } } @@ -269,7 +270,7 @@ namespace vcpkg::Unicode { if (is_eof()) { - vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, "Incremented Utf8Decoder at the end of the string"); + vcpkg::Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgIncrementedUtf8Decoder); } if (next_ == last_) @@ -319,8 +320,7 @@ namespace vcpkg::Unicode { if (lhs.last_ != rhs.last_) { - Checks::exit_with_message(VCPKG_LINE_INFO, - "Comparing Utf8Decoders with different provenance; this is always an error"); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgComparingUtf8Decoders); } return lhs.next_ == rhs.next_; diff --git a/src/vcpkg/base/xmlserializer.cpp b/src/vcpkg/base/xmlserializer.cpp index 648235bfe9..19c706d3b5 100644 --- a/src/vcpkg/base/xmlserializer.cpp +++ b/src/vcpkg/base/xmlserializer.cpp @@ -1,3 +1,4 @@ +#include #include #include From 3b0c7f2661e526d7f67724ea50ce9501272efc0d Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Mon, 26 Sep 2022 10:15:24 -0700 Subject: [PATCH 3/6] Localized and sorted messages for strings.cpp --- include/vcpkg/base/messages.h | 69 ++++++++++++++++++++--------------- locales/messages.en.json | 2 + locales/messages.json | 3 ++ src/vcpkg/base/messages.cpp | 29 ++++++++------- src/vcpkg/base/strings.cpp | 37 ++++++++++--------- 5 files changed, 79 insertions(+), 61 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 0b453d5d32..bc4bd43d9f 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -714,9 +714,14 @@ namespace vcpkg "command:\n" "{command_line}\n" "failed with the following results:"); + DECLARE_MESSAGE(ComparingUtf8Decoders, + (), + "", + "Comparing Utf8Decoders with different provenance; this is always an error"); DECLARE_MESSAGE(CompressFolderFailed, (msg::path), "", "Failed to compress folder \"{path}\":"); DECLARE_MESSAGE(ConflictingValuesForOption, (msg::option), "", "conflicting values specified for '--{option}'."); DECLARE_MESSAGE(ConstraintViolation, (), "", "Found a constraint violation:"); + DECLARE_MESSAGE(ContinueCodeUnitInStart, (), "", "found continue code unit in start position"); DECLARE_MESSAGE(ControlAndManifestFilesPresent, (msg::path), "", @@ -727,8 +732,8 @@ namespace vcpkg (msg::path), "", "Could not deduce nuget id and version from filename: {path}"); - DECLARE_MESSAGE(CreateFailureLogsDir, (msg::path), "", "Creating failure logs output directory {path}."); DECLARE_MESSAGE(CreatedNuGetPackage, (msg::path), "", "Created nupkg: \"{path}\""); + DECLARE_MESSAGE(CreateFailureLogsDir, (msg::path), "", "Creating failure logs output directory {path}."); DECLARE_MESSAGE(CurlReportedUnexpectedResults, (msg::command_line, msg::actual), "{command_line} is the command line to call curl.exe, {actual} is the console output " @@ -778,7 +783,9 @@ namespace vcpkg DECLARE_MESSAGE(EmailVcpkgTeam, (msg::url), "", "Send an email to {url} with any feedback."); DECLARE_MESSAGE(EmptyArg, (msg::option), "", "The option --{option} must be passed a non-empty argument."); DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty."); + DECLARE_MESSAGE(EndOfStringInCodeUnit, (), "", "found end of string in middle of code point"); DECLARE_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:"); + DECLARE_MESSAGE(ErrorCodeOutOfRange, (), "", "error code out of range"); DECLARE_MESSAGE(ErrorDetectingCompilerInfo, (msg::path), "", @@ -848,6 +855,10 @@ namespace vcpkg DECLARE_MESSAGE(ExceededRecursionDepth, (), "", "Recursion depth exceeded."); DECLARE_MESSAGE(ExcludedPackage, (msg::spec), "", "Excluded {spec}"); DECLARE_MESSAGE(ExcludedPackages, (), "", "The following packages are excluded:"); + DECLARE_MESSAGE(ExpectedAtMostOneSetOfTags, + (msg::count, msg::old_value, msg::new_value, msg::value), + "{old_value} is a left tag and {new_value} is the right tag. {value} is the input.", + "Found {count} sets of {old_value}.*{new_value} but expected at most 1, in block:\n{value}"); DECLARE_MESSAGE( ExpectedCascadeFailure, (msg::expected, msg::actual), @@ -859,39 +870,43 @@ namespace vcpkg "{expected} is a locale-invariant delimiter; for example, the ':' or '=' in 'zlib:x64-windows=skip'", "expected '{expected}' here"); DECLARE_MESSAGE(ExpectedFailOrSkip, (), "", "expected 'fail', 'skip', or 'pass' here"); + DECLARE_MESSAGE(ExpectedOneSetOfTags, + (msg::count, msg::old_value, msg::new_value, msg::value), + "{old_value} is a left tag and {new_value} is the right tag. {value} is the input.", + "Found {count} sets of {old_value}.*{new_value} but expected exactly 1, in block:\n{value}"); DECLARE_MESSAGE(ExpectedPortName, (), "", "expected a port name here"); DECLARE_MESSAGE(ExpectedTripletName, (), "", "expected a triplet name here"); DECLARE_MESSAGE(ExpectedValueForOption, (msg::option), "", "expected value after --{option}."); DECLARE_MESSAGE(ExportingPackage, (msg::package_name), "", "Exporting {package_name}..."); DECLARE_MESSAGE(ExtendedDocumentationAtUrl, (msg::url), "", "Extended documentation available at '{url}'."); DECLARE_MESSAGE(FailedToExtract, (msg::path), "", "Failed to extract \"{path}\":"); + DECLARE_MESSAGE(FailedToFindPortFeature, (msg::feature, msg::spec), "", "Could not find {feature} in {spec}."); DECLARE_MESSAGE(FailedToFormatMissingFile, (), "", "No files to format.\nPlease pass either --all, or the explicit files to format or convert."); + DECLARE_MESSAGE(FailedToLoadInstalledManifest, + (msg::spec), + "", + "The control or mnaifest file for {spec} could not be loaded due to the following error. Please " + "remove {spec} and re-attempt."); + DECLARE_MESSAGE(FailedToLocateSpec, (msg::spec), "", "Failed to locate spec in graph: {spec}"); + DECLARE_MESSAGE(FailedToObtainDependencyVersion, (), "", "Cannot find desired dependency version."); DECLARE_MESSAGE(FailedToObtainLocalPortGitSha, (), "", "Failed to obtain git SHAs for local ports."); + DECLARE_MESSAGE(FailedToObtainPackageVersion, (), "", "Cannot find desired package version."); DECLARE_MESSAGE(FailedToParseCMakeConsoleOut, (), "", "Failed to parse CMake console output to locate block start/end markers."); + DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); + DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file: {path}"); + DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); DECLARE_MESSAGE(FailedToParseSerializedBinParagraph, (msg::error_msg), "'{error_msg}' is the error message for failing to parse the Binary Paragraph.", "[sanity check] Failed to parse a serialized binary paragraph.\nPlease open an issue at " "https://github.com/microsoft/vcpkg, " "with the following output:\n{error_msg}\nSerialized Binary Paragraph:"); - DECLARE_MESSAGE(FailedToFindPortFeature, (msg::feature, msg::spec), "", "Could not find {feature} in {spec}."); - DECLARE_MESSAGE(FailedToLocateSpec, (msg::spec), "", "Failed to locate spec in graph: {spec}"); - DECLARE_MESSAGE(FailedToLoadInstalledManifest, - (msg::spec), - "", - "The control or mnaifest file for {spec} could not be loaded due to the following error. Please " - "remove {spec} and re-attempt."); - DECLARE_MESSAGE(FailedToObtainDependencyVersion, (), "", "Cannot find desired dependency version."); - DECLARE_MESSAGE(FailedToObtainPackageVersion, (), "", "Cannot find desired package version."); - DECLARE_MESSAGE(FailedToParseControl, (msg::path), "", "Failed to parse control file: {path}"); - DECLARE_MESSAGE(FailedToParseJson, (msg::path), "", "Failed to parse JSON file: {path}"); - DECLARE_MESSAGE(FailedToParseManifest, (msg::path), "", "Failed to parse manifest file: {path}"); DECLARE_MESSAGE(FailedToProvisionCe, (), "", "Failed to provision vcpkg-ce."); DECLARE_MESSAGE(FailedToRead, (msg::path, msg::error_msg), "", "Failed to read {path}: {error_msg}"); DECLARE_MESSAGE(FailedToReadParagraph, (msg::path), "", "Failed to read paragraphs from {path}"); @@ -1002,6 +1017,7 @@ namespace vcpkg (msg::command_name, msg::expected, msg::actual), "'{expected}' is the required number of arguments. '{actual}' is the number of arguments provided.", "'{command_name}' requires '{expected}' arguments, but '{actual}' were provided."); + DECLARE_MESSAGE(IncrementedUtf8Decoder, (), "", "Incremented Utf8Decoder at the end of the string"); DECLARE_MESSAGE(InfoSetEnvVar, (msg::env_var), "In this context 'editor' means IDE", @@ -1099,6 +1115,8 @@ namespace vcpkg "invalid argument: binary config '{binary_source}' requires a SAS token without a " "preceeding '?' as the second argument"); DECLARE_MESSAGE(InvalidBuildInfo, (msg::error_msg), "", "Invalid BUILD_INFO file for package: {error_msg}"); + DECLARE_MESSAGE(InvalidCodePoint, (), "", "Invalid code point passed to utf8_encoded_code_point_count"); + DECLARE_MESSAGE(InvalidCodeUnit, (), "", "invalid code unit"); DECLARE_MESSAGE(InvalidCommandArgSort, (), "", @@ -1273,6 +1291,7 @@ namespace vcpkg DECLARE_MESSAGE(NewVersionCannotBeEmpty, (), "", "--version cannot be empty."); DECLARE_MESSAGE(NoArgumentsForOption, (msg::option), "", "The option --{option} does not accept an argument."); DECLARE_MESSAGE(NoCachedPackages, (), "", "No packages are cached."); + DECLARE_MESSAGE(NoError, (), "", "no error"); DECLARE_MESSAGE(NoInstalledPackages, (), "The name 'search' is the name of a command that is not localized.", @@ -1309,6 +1328,10 @@ namespace vcpkg (msg::vendor), "", "Packing {vendor} failed. Use --debug for more information."); + DECLARE_MESSAGE(PairedSurrogatesAreInvalid, + (), + "", + "trailing surrogate following leading surrogate (paired surrogates are invalid)"); DECLARE_MESSAGE(ParseControlErrorInfoInvalidFields, (), "", "The following fields were not expected:"); DECLARE_MESSAGE(ParseControlErrorInfoMissingFields, (), "", "The following fields were missing:"); DECLARE_MESSAGE(ParseControlErrorInfoTypesEntry, @@ -1417,6 +1440,7 @@ namespace vcpkg (msg::env_var), "", "Specify the target architecture triplet. See 'vcpkg help triplet'.\n(default: '{env_var}')"); + DECLARE_MESSAGE(StartCodeUnitInContinue, (), "", "found start code unit in continue position"); DECLARE_MESSAGE(StoredBinaryCache, (msg::path), "", "Stored binary cache: \"{path}\""); DECLARE_MESSAGE(StoreOptionMissingSha, (), "", "--store option is invalid without a sha512"); DECLARE_MESSAGE(SuggestGitPull, (), "", "The result may be outdated. Run `git pull` to get the latest results."); @@ -1506,6 +1530,7 @@ namespace vcpkg (msg::value), "'{value}' is the short option given", "short options are not supported: '{value}'"); + DECLARE_MESSAGE(UnsupportedSyntaxInCDATA, (), "", "]]> is not supported in CDATA block"); DECLARE_MESSAGE(UnsupportedSystemName, (msg::system_name), "", @@ -1579,6 +1604,7 @@ namespace vcpkg "'--' at the beginning must be preserved", "-- Using community triplet {triplet}. This triplet configuration is not guaranteed to succeed."); DECLARE_MESSAGE(UsingManifestAt, (msg::path), "", "Using manifest file at {path}."); + DECLARE_MESSAGE(Utf8ConversionFailed, (), "", "Failed to convert to UTF-8"); DECLARE_MESSAGE(VcpkgCeIsExperimental, (), "", @@ -1647,21 +1673,4 @@ namespace vcpkg DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:"); DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows."); DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}."); - DECLARE_MESSAGE(UnsupportedSyntaxInCDATA, (), "", "]]> is not supported in CDATA block"); - DECLARE_MESSAGE(InvalidCodePoint, (), "", "Invalid code point passed to utf8_encoded_code_point_count"); - DECLARE_MESSAGE(NoError, (), "", "no error"); - DECLARE_MESSAGE(InvalidCodeUnit, (), "", "invalid code unit"); - DECLARE_MESSAGE(PairedSurrogatesAreInvalid, - (), - "", - "trailing surrogate following leading surrogate (paired surrogates are invalid)"); - DECLARE_MESSAGE(ContinueCodeUnitInStart, (), "", "found continue code unit in start position"); - DECLARE_MESSAGE(StartCodeUnitInContinue, (), "", "found start code unit in continue position"); - DECLARE_MESSAGE(EndOfStringInCodeUnit, (), "", "found end of string in middle of code point"); - DECLARE_MESSAGE(ErrorCodeOutOfRange, (), "", "error code out of range"); - DECLARE_MESSAGE(IncrementedUtf8Decoder, (), "", "Incremented Utf8Decoder at the end of the string"); - DECLARE_MESSAGE(ComparingUtf8Decoders, - (), - "", - "Comparing Utf8Decoders with different provenance; this is always an error"); } diff --git a/locales/messages.en.json b/locales/messages.en.json index ff17fd17b3..f7932842a1 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -145,6 +145,7 @@ "ExpectedCascadeFailure": "Expected {expected} cascade failure, but there were {actual} cascade failures.", "ExpectedCharacterHere": "expected '{expected}' here", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", + "ExpectedOneSetOfTags": "Found {count} sets of {old_value}.*{new_value} but expected exactly 1, in block:\n{value}", "ExpectedPortName": "expected a port name here", "ExpectedTripletName": "expected a triplet name here", "ExpectedValueForOption": "expected value after --{option}.", @@ -414,6 +415,7 @@ "UserWideIntegrationRemoved": "User-wide integration was removed.", "UsingCommunityTriplet": "-- Using community triplet {triplet}. This triplet configuration is not guaranteed to succeed.", "UsingManifestAt": "Using manifest file at {path}.", + "Utf8ConversionFailed": "Failed to convert to UTF-8", "Utf8DecoderDereferencedAtEof": "dereferenced Utf8Decoder at the end of a string.", "VSExaminedInstances": "The following Visual Studio instances were considered:", "VSExaminedPaths": "The following paths were examined for Visual Studio instances:", diff --git a/locales/messages.json b/locales/messages.json index 5b5e3ba02a..3219f67fa1 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -250,6 +250,8 @@ "ExpectedCharacterHere": "expected '{expected}' here", "_ExpectedCharacterHere.comment": "{expected} is a locale-invariant delimiter; for example, the ':' or '=' in 'zlib:x64-windows=skip'", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", + "ExpectedOneSetOfTags": "Found {count} sets of {old_value}.*{new_value} but expected exactly 1, in block:\n{value}", + "_ExpectedOneSetOfTags.comment": "{old_value} is a left tag and {new_value} is the right tag. {value} is the input. An example of {count} is 42.", "ExpectedPortName": "expected a port name here", "ExpectedTripletName": "expected a triplet name here", "ExpectedValueForOption": "expected value after --{option}.", @@ -675,6 +677,7 @@ "_UsingCommunityTriplet.comment": "'--' at the beginning must be preserved An example of {triplet} is x64-windows.", "UsingManifestAt": "Using manifest file at {path}.", "_UsingManifestAt.comment": "An example of {path} is /foo/bar.", + "Utf8ConversionFailed": "Failed to convert to UTF-8", "Utf8DecoderDereferencedAtEof": "dereferenced Utf8Decoder at the end of a string.", "VSExaminedInstances": "The following Visual Studio instances were considered:", "VSExaminedPaths": "The following paths were examined for Visual Studio instances:", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 19f677c60f..c6cccb9406 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -465,9 +465,11 @@ namespace vcpkg REGISTER_MESSAGE(CMakeTargetsUsageHeuristicMessage); REGISTER_MESSAGE(CMakeToolChainFile); REGISTER_MESSAGE(CommandFailed); + REGISTER_MESSAGE(ComparingUtf8Decoders); REGISTER_MESSAGE(CompressFolderFailed); - REGISTER_MESSAGE(ConstraintViolation); REGISTER_MESSAGE(ConflictingValuesForOption); + REGISTER_MESSAGE(ConstraintViolation); + REGISTER_MESSAGE(ContinueCodeUnitInStart); REGISTER_MESSAGE(ControlAndManifestFilesPresent); REGISTER_MESSAGE(CopyrightIsDir); REGISTER_MESSAGE(CorruptedDatabase); @@ -494,7 +496,9 @@ namespace vcpkg REGISTER_MESSAGE(EmailVcpkgTeam); REGISTER_MESSAGE(EmptyArg); REGISTER_MESSAGE(EmptyLicenseExpression); + REGISTER_MESSAGE(EndOfStringInCodeUnit); REGISTER_MESSAGE(EnvStrFailedToExtract); + REGISTER_MESSAGE(ErrorCodeOutOfRange); REGISTER_MESSAGE(ErrorDetectingCompilerInfo); REGISTER_MESSAGE(ErrorIndividualPackagesUnsupported); REGISTER_MESSAGE(ErrorInvalidClassicModeOption); @@ -518,9 +522,11 @@ namespace vcpkg REGISTER_MESSAGE(ExceededRecursionDepth); REGISTER_MESSAGE(ExcludedPackage); REGISTER_MESSAGE(ExcludedPackages); + REGISTER_MESSAGE(ExpectedAtMostOneSetOfTags); REGISTER_MESSAGE(ExpectedCascadeFailure); REGISTER_MESSAGE(ExpectedCharacterHere); REGISTER_MESSAGE(ExpectedFailOrSkip); + REGISTER_MESSAGE(ExpectedOneSetOfTags); REGISTER_MESSAGE(ExpectedPortName); REGISTER_MESSAGE(ExpectedTripletName); REGISTER_MESSAGE(ExpectedValueForOption); @@ -593,6 +599,7 @@ namespace vcpkg REGISTER_MESSAGE(IllegalPlatformSpec); REGISTER_MESSAGE(ImproperShaLength); REGISTER_MESSAGE(IncorrectNumberOfArgs); + REGISTER_MESSAGE(IncrementedUtf8Decoder); REGISTER_MESSAGE(InfoSetEnvVar); REGISTER_MESSAGE(InitRegistryFailedNoRepo); REGISTER_MESSAGE(InstalledPackages); @@ -622,6 +629,8 @@ namespace vcpkg REGISTER_MESSAGE(InvalidArgumentRequiresTwoOrThreeArguments); REGISTER_MESSAGE(InvalidArgumentRequiresValidToken); REGISTER_MESSAGE(InvalidBuildInfo); + REGISTER_MESSAGE(InvalidCodePoint); + REGISTER_MESSAGE(InvalidCodeUnit); REGISTER_MESSAGE(InvalidCommandArgSort); REGISTER_MESSAGE(InvalidCommitId); REGISTER_MESSAGE(InvalidFilename); @@ -661,8 +670,8 @@ namespace vcpkg REGISTER_MESSAGE(MissingDependency); REGISTER_MESSAGE(MissingExtension); REGISTER_MESSAGE(MissingOption); - REGISTER_MESSAGE(MissmatchedBinParagraphs); REGISTER_MESSAGE(MissingPortSuggestPullRequest); + REGISTER_MESSAGE(MissmatchedBinParagraphs); REGISTER_MESSAGE(MonoInstructions); REGISTER_MESSAGE(MsiexecFailedToExtract); REGISTER_MESSAGE(MultiArch); @@ -675,6 +684,7 @@ namespace vcpkg REGISTER_MESSAGE(NewVersionCannotBeEmpty); REGISTER_MESSAGE(NoArgumentsForOption); REGISTER_MESSAGE(NoCachedPackages); + REGISTER_MESSAGE(NoError); REGISTER_MESSAGE(NoInstalledPackages); REGISTER_MESSAGE(NoLocalizationForMessages); REGISTER_MESSAGE(NoRegistryForPort); @@ -692,6 +702,7 @@ namespace vcpkg REGISTER_MESSAGE(PackagesToRebuildSuggestRecurse); REGISTER_MESSAGE(PackagesToRemove); REGISTER_MESSAGE(PackingVendorFailed); + REGISTER_MESSAGE(PairedSurrogatesAreInvalid); REGISTER_MESSAGE(ParseControlErrorInfoInvalidFields); REGISTER_MESSAGE(ParseControlErrorInfoMissingFields); REGISTER_MESSAGE(ParseControlErrorInfoTypesEntry); @@ -727,6 +738,7 @@ namespace vcpkg REGISTER_MESSAGE(SpecifyDirectoriesWhenSearching); REGISTER_MESSAGE(SpecifyHostArch); REGISTER_MESSAGE(SpecifyTargetArch); + REGISTER_MESSAGE(StartCodeUnitInContinue); REGISTER_MESSAGE(StoredBinaryCache); REGISTER_MESSAGE(StoreOptionMissingSha); REGISTER_MESSAGE(SuggestGitPull); @@ -757,6 +769,7 @@ namespace vcpkg REGISTER_MESSAGE(UnsupportedPortDependency); REGISTER_MESSAGE(UnsupportedPortFeature); REGISTER_MESSAGE(UnsupportedShortOptions); + REGISTER_MESSAGE(UnsupportedSyntaxInCDATA); REGISTER_MESSAGE(UnsupportedSystemName); REGISTER_MESSAGE(UnsupportedToolchain); REGISTER_MESSAGE(UpdateBaselineAddBaselineNoManifest); @@ -777,6 +790,7 @@ namespace vcpkg REGISTER_MESSAGE(UserWideIntegrationRemoved); REGISTER_MESSAGE(UsingCommunityTriplet); REGISTER_MESSAGE(UsingManifestAt); + REGISTER_MESSAGE(Utf8ConversionFailed); REGISTER_MESSAGE(VcpkgCeIsExperimental); REGISTER_MESSAGE(VcpkgCommitTableHeader); REGISTER_MESSAGE(VcpkgCompletion); @@ -803,15 +817,4 @@ namespace vcpkg REGISTER_MESSAGE(WhileLookingForSpec); REGISTER_MESSAGE(WindowsOnlyCommand); REGISTER_MESSAGE(WroteNuGetPkgConfInfo); - REGISTER_MESSAGE(UnsupportedSyntaxInCDATA); - REGISTER_MESSAGE(InvalidCodePoint); - REGISTER_MESSAGE(NoError); - REGISTER_MESSAGE(InvalidCodeUnit); - REGISTER_MESSAGE(PairedSurrogatesAreInvalid); - REGISTER_MESSAGE(ContinueCodeUnitInStart); - REGISTER_MESSAGE(EndOfStringInCodeUnit); - REGISTER_MESSAGE(ErrorCodeOutOfRange); - REGISTER_MESSAGE(IncrementedUtf8Decoder); - REGISTER_MESSAGE(ComparingUtf8Decoders); - REGISTER_MESSAGE(StartCodeUnitInContinue); } diff --git a/src/vcpkg/base/strings.cpp b/src/vcpkg/base/strings.cpp index 779a180280..1e196c82d4 100644 --- a/src/vcpkg/base/strings.cpp +++ b/src/vcpkg/base/strings.cpp @@ -156,10 +156,11 @@ void Strings::to_utf8(std::string& output, const wchar_t* w, size_t size_in_char if (size <= 0) { unsigned long last_error = ::GetLastError(); - Checks::exit_with_message(VCPKG_LINE_INFO, - "Failed to convert to UTF-8. %08lX %s", - last_error, - std::system_category().message(static_cast(last_error))); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, + msg::format(msgUtf8ConversionFailed) + .append_raw(last_error) + .append_raw("\n") + .append_raw(std::system_category().message(static_cast(last_error)))); } output.resize(size); @@ -352,26 +353,26 @@ std::vector Strings::find_all_enclosed(StringView input, StringView StringView Strings::find_exactly_one_enclosed(StringView input, StringView left_tag, StringView right_tag) { std::vector result = find_all_enclosed(input, left_tag, right_tag); - Checks::check_maybe_upgrade(VCPKG_LINE_INFO, - result.size() == 1, - "Found %d sets of %s.*%s but expected exactly 1, in block:\n%s", - result.size(), - left_tag, - right_tag, - input); + Checks::msg_check_maybe_upgrade(VCPKG_LINE_INFO, + result.size() == 1, + msgExpectedOneSetOfTags, + msg::count = result.size(), + msg::old_value = left_tag, + msg::new_value = right_tag, + msg::value = input); return result.front(); } Optional Strings::find_at_most_one_enclosed(StringView input, StringView left_tag, StringView right_tag) { std::vector result = find_all_enclosed(input, left_tag, right_tag); - Checks::check_maybe_upgrade(VCPKG_LINE_INFO, - result.size() <= 1, - "Found %d sets of %s.*%s but expected at most 1, in block:\n%s", - result.size(), - left_tag, - right_tag, - input); + Checks::msg_check_maybe_upgrade(VCPKG_LINE_INFO, + result.size() <= 1, + msgExpectedAtMostOneSetOfTags, + msg::count = result.size(), + msg::old_value = left_tag, + msg::new_value = right_tag, + msg::value = input); if (result.empty()) { From d0cedc8e43b28f3c2733c9ff7ac18c009a3ea751 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Mon, 26 Sep 2022 11:03:14 -0700 Subject: [PATCH 4/6] Fix conversion --- locales/messages.en.json | 1 + locales/messages.json | 2 ++ src/vcpkg/base/strings.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/locales/messages.en.json b/locales/messages.en.json index f7932842a1..d878df11af 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -142,6 +142,7 @@ "ExceededRecursionDepth": "Recursion depth exceeded.", "ExcludedPackage": "Excluded {spec}", "ExcludedPackages": "The following packages are excluded:", + "ExpectedAtMostOneSetOfTags": "Found {count} sets of {old_value}.*{new_value} but expected at most 1, in block:\n{value}", "ExpectedCascadeFailure": "Expected {expected} cascade failure, but there were {actual} cascade failures.", "ExpectedCharacterHere": "expected '{expected}' here", "ExpectedFailOrSkip": "expected 'fail', 'skip', or 'pass' here", diff --git a/locales/messages.json b/locales/messages.json index 3219f67fa1..52e8f52c9f 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -245,6 +245,8 @@ "ExcludedPackage": "Excluded {spec}", "_ExcludedPackage.comment": "An example of {spec} is zlib:x64-windows.", "ExcludedPackages": "The following packages are excluded:", + "ExpectedAtMostOneSetOfTags": "Found {count} sets of {old_value}.*{new_value} but expected at most 1, in block:\n{value}", + "_ExpectedAtMostOneSetOfTags.comment": "{old_value} is a left tag and {new_value} is the right tag. {value} is the input. An example of {count} is 42.", "ExpectedCascadeFailure": "Expected {expected} cascade failure, but there were {actual} cascade failures.", "_ExpectedCascadeFailure.comment": "{expected} is the expected number of cascade failures and {actual} is the actual number of cascade failures.", "ExpectedCharacterHere": "expected '{expected}' here", diff --git a/src/vcpkg/base/strings.cpp b/src/vcpkg/base/strings.cpp index 1e196c82d4..3da693aad5 100644 --- a/src/vcpkg/base/strings.cpp +++ b/src/vcpkg/base/strings.cpp @@ -158,7 +158,7 @@ void Strings::to_utf8(std::string& output, const wchar_t* w, size_t size_in_char unsigned long last_error = ::GetLastError(); Checks::msg_exit_with_message(VCPKG_LINE_INFO, msg::format(msgUtf8ConversionFailed) - .append_raw(last_error) + .append_raw(std::system_category().message(static_cast(last_error))) .append_raw("\n") .append_raw(std::system_category().message(static_cast(last_error)))); } From c19881e9b6a7e23572f5699eb22ea9820016c139 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Wed, 5 Oct 2022 13:32:03 -0700 Subject: [PATCH 5/6] Remove extra newline. --- src/vcpkg/base/messages.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index a4e6c6a033..d8a1121d58 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -475,7 +475,6 @@ namespace vcpkg REGISTER_MESSAGE(ConstraintViolation); REGISTER_MESSAGE(ContinueCodeUnitInStart); REGISTER_MESSAGE(ControlAndManifestFilesPresent); - REGISTER_MESSAGE(CopyrightIsDir); REGISTER_MESSAGE(CorruptedDatabase); REGISTER_MESSAGE(CouldNotDeduceNugetIdAndVersion); From 5d88787576bac43fad18e1f2692d2f9c7af7dbb0 Mon Sep 17 00:00:00 2001 From: Javier Matos Denizac Date: Wed, 5 Oct 2022 16:55:21 -0700 Subject: [PATCH 6/6] Response to feedback --- include/vcpkg/base/messages.h | 1 - locales/messages.en.json | 1 - locales/messages.json | 1 - src/vcpkg/base/messages.cpp | 1 - src/vcpkg/base/unicode.cpp | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 4766ddc9ca..20041da86f 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -799,7 +799,6 @@ namespace vcpkg DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty."); DECLARE_MESSAGE(EndOfStringInCodeUnit, (), "", "found end of string in middle of code point"); DECLARE_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:"); - DECLARE_MESSAGE(ErrorCodeOutOfRange, (), "", "error code out of range"); DECLARE_MESSAGE(ErrorDetectingCompilerInfo, (msg::path), "", diff --git a/locales/messages.en.json b/locales/messages.en.json index bf5a1e9ab0..6ac97db1ca 100644 --- a/locales/messages.en.json +++ b/locales/messages.en.json @@ -122,7 +122,6 @@ "EmptyLicenseExpression": "SPDX license expression was empty.", "EndOfStringInCodeUnit": "found end of string in middle of code point", "EnvStrFailedToExtract": "could not expand the environment string:", - "ErrorCodeOutOfRange": "error code out of range", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", "ErrorInvalidClassicModeOption": "The option --{option} is not supported in classic mode and no manifest was found.", diff --git a/locales/messages.json b/locales/messages.json index ce3f2e5ed2..e25f61694c 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -212,7 +212,6 @@ "EmptyLicenseExpression": "SPDX license expression was empty.", "EndOfStringInCodeUnit": "found end of string in middle of code point", "EnvStrFailedToExtract": "could not expand the environment string:", - "ErrorCodeOutOfRange": "error code out of range", "ErrorDetectingCompilerInfo": "while detecting compiler information:\nThe log file content at \"{path}\" is:", "_ErrorDetectingCompilerInfo.comment": "An example of {path} is /foo/bar.", "ErrorIndividualPackagesUnsupported": "In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.", diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index d8a1121d58..4f39bafb4f 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -503,7 +503,6 @@ namespace vcpkg REGISTER_MESSAGE(EmptyLicenseExpression); REGISTER_MESSAGE(EndOfStringInCodeUnit); REGISTER_MESSAGE(EnvStrFailedToExtract); - REGISTER_MESSAGE(ErrorCodeOutOfRange); REGISTER_MESSAGE(ErrorDetectingCompilerInfo); REGISTER_MESSAGE(ErrorIndividualPackagesUnsupported); REGISTER_MESSAGE(ErrorInvalidClassicModeOption); diff --git a/src/vcpkg/base/unicode.cpp b/src/vcpkg/base/unicode.cpp index c3411f3f1e..bd01d90194 100644 --- a/src/vcpkg/base/unicode.cpp +++ b/src/vcpkg/base/unicode.cpp @@ -199,7 +199,7 @@ namespace vcpkg::Unicode case utf8_errc::UnexpectedContinue: return msg::format(msgContinueCodeUnitInStart).extract_data(); case utf8_errc::UnexpectedStart: return msg::format(msgStartCodeUnitInContinue).extract_data(); case utf8_errc::UnexpectedEof: return msg::format(msgEndOfStringInCodeUnit).extract_data(); - default: return msg::format(msgErrorCodeOutOfRange).extract_data(); + default: Checks::unreachable(VCPKG_LINE_INFO); } } };