mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
Source: reduce ostringstreams usage
This commit is contained in:
1 parent
54b098b190
commit
d9dd2d4ff5
3 files changed
+30
-50
No files matched your search
@@ -127,13 +127,14 @@ void cmExportCMakeConfigGenerator::SetImportLinkInterface(
|
||||
|
||||
if (!this->ExportOld) {
|
||||
cmLocalGenerator* lg = target->GetLocalGenerator();
|
||||
std::ostringstream e;
|
||||
e << "Target \"" << target->GetName()
|
||||
<< "\" has policy CMP0022 enabled, "
|
||||
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
|
||||
"populated, but it was exported without the "
|
||||
"EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
|
||||
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||
lg->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat(
|
||||
"Target \"", target->GetName(),
|
||||
"\" has policy CMP0022 enabled, "
|
||||
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
|
||||
"populated, but it was exported without the "
|
||||
"EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+21
-33
@@ -3,7 +3,6 @@
|
||||
#include "cmExportCommand.h"
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
@@ -152,10 +151,9 @@ static bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
} else {
|
||||
// Make sure the file has a .cmake extension.
|
||||
if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) {
|
||||
std::ostringstream e;
|
||||
e << "FILE option given filename \"" << arguments.Filename
|
||||
<< "\" which does not have an extension of \".cmake\".\n";
|
||||
status.SetError(e.str());
|
||||
status.SetError(
|
||||
cmStrCat("FILE option given filename \"", arguments.Filename,
|
||||
"\" which does not have an extension of \".cmake\".\n"));
|
||||
return false;
|
||||
}
|
||||
fname = arguments.Filename;
|
||||
@@ -166,10 +164,8 @@ static bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
// Get the file to write.
|
||||
if (cmSystemTools::FileIsFullPath(fname)) {
|
||||
if (!mf.CanIWriteThisFile(fname)) {
|
||||
std::ostringstream e;
|
||||
e << "FILE option given filename \"" << fname
|
||||
<< "\" which is in the source tree.\n";
|
||||
status.SetError(e.str());
|
||||
status.SetError(cmStrCat("FILE option given filename \"", fname,
|
||||
"\" which is in the source tree.\n"));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -297,10 +293,9 @@ static bool HandleExportMode(std::vector<std::string> const& args,
|
||||
fname = arguments.ExportSetName + ".cmake";
|
||||
} else {
|
||||
if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) {
|
||||
std::ostringstream e;
|
||||
e << "FILE option given filename \"" << arguments.Filename
|
||||
<< "\" which does not have an extension of \".cmake\".\n";
|
||||
status.SetError(e.str());
|
||||
status.SetError(
|
||||
cmStrCat("FILE option given filename \"", arguments.Filename,
|
||||
"\" which does not have an extension of \".cmake\".\n"));
|
||||
return false;
|
||||
}
|
||||
fname = arguments.Filename;
|
||||
@@ -308,10 +303,8 @@ static bool HandleExportMode(std::vector<std::string> const& args,
|
||||
|
||||
if (cmSystemTools::FileIsFullPath(fname)) {
|
||||
if (!mf.CanIWriteThisFile(fname)) {
|
||||
std::ostringstream e;
|
||||
e << "FILE option given filename \"" << fname
|
||||
<< "\" which is in the source tree.\n";
|
||||
status.SetError(e.str());
|
||||
status.SetError(cmStrCat("FILE option given filename \"", fname,
|
||||
"\" which is in the source tree.\n"));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -607,9 +600,7 @@ static bool HandlePackageMode(std::vector<std::string> const& args,
|
||||
package = args[i];
|
||||
doing = DoingNone;
|
||||
} else {
|
||||
std::ostringstream e;
|
||||
e << "PACKAGE given unknown argument: " << args[i];
|
||||
status.SetError(e.str());
|
||||
status.SetError("PACKAGE given unknown argument: " + args[i]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -622,10 +613,9 @@ static bool HandlePackageMode(std::vector<std::string> const& args,
|
||||
char const* packageExpr = "^[A-Za-z0-9_.-]+$";
|
||||
cmsys::RegularExpression packageRegex(packageExpr);
|
||||
if (!packageRegex.find(package)) {
|
||||
std::ostringstream e;
|
||||
e << "PACKAGE given invalid package name \"" << package << "\". "
|
||||
<< "Package names must match \"" << packageExpr << "\".";
|
||||
status.SetError(e.str());
|
||||
status.SetError(cmStrCat("PACKAGE given invalid package name \"", package,
|
||||
"\". Package names must match \"", packageExpr,
|
||||
"\"."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -665,17 +655,15 @@ static bool HandlePackageMode(std::vector<std::string> const& args,
|
||||
static void ReportRegistryError(cmMakefile& mf, std::string const& msg,
|
||||
std::string const& key, long err)
|
||||
{
|
||||
std::ostringstream e;
|
||||
e << msg << "\n"
|
||||
<< " HKEY_CURRENT_USER\\" << key << "\n";
|
||||
std::string e = cmStrCat(msg, "\n HKEY_CURRENT_USER\\", key, '\n');
|
||||
wchar_t winmsg[1024];
|
||||
if (FormatMessageW(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) {
|
||||
e << "Windows reported:\n"
|
||||
<< " " << cmsys::Encoding::ToNarrow(winmsg);
|
||||
e = cmStrCat(std::move(e), "Windows reported:\n ",
|
||||
cmsys::Encoding::ToNarrow(winmsg));
|
||||
}
|
||||
mf.IssueMessage(MessageType::WARNING, e.str());
|
||||
mf.IssueMessage(MessageType::WARNING, e);
|
||||
}
|
||||
|
||||
static void StorePackageRegistry(cmMakefile& mf, std::string const& package,
|
||||
@@ -698,9 +686,9 @@ static void StorePackageRegistry(cmMakefile& mf, std::string const& package,
|
||||
static_cast<DWORD>(wcontent.size() + 1) * sizeof(wchar_t));
|
||||
RegCloseKey(hKey);
|
||||
if (err != ERROR_SUCCESS) {
|
||||
std::ostringstream msg;
|
||||
msg << "Cannot set registry value \"" << hash << "\" under key";
|
||||
ReportRegistryError(mf, msg.str(), key, err);
|
||||
ReportRegistryError(
|
||||
mf, cmStrCat("Cannot set registry value \"", hash, "\" under key"), key,
|
||||
err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-10
@@ -10,7 +10,6 @@
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -846,15 +845,7 @@ bool parse_default_directory_permissions(std::string const& permissions,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
for (auto i = 0u; i < parsedPermissions.size(); i++) {
|
||||
if (i != 0) {
|
||||
oss << ';';
|
||||
}
|
||||
oss << parsedPermissions[i];
|
||||
}
|
||||
|
||||
parsedPermissionsVar = oss.str();
|
||||
parsedPermissionsVar = cmJoin(parsedPermissions, ";");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user