diff options
Diffstat (limited to 'Source')
42 files changed, 402 insertions, 449 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3c49d03..7e8a46a 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 6) -set(CMake_VERSION_PATCH 20160616) +set(CMake_VERSION_PATCH 20160617) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index b47d46e..accba08 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -567,7 +567,7 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout) { - std::stringstream comment; + std::ostringstream comment; comment << "Generated by CPack " << CMake_VERSION << " IFW generator " << "for QtIFW "; if (IsVersionLess("2.0")) { diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c44e389..405d668 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -422,7 +422,7 @@ void cmCPackIFWPackage::GeneratePackageFile() } // Write dependencies if (!compDepSet.empty()) { - std::stringstream dependencies; + std::ostringstream dependencies; std::set<DependenceStruct>::iterator it = compDepSet.begin(); dependencies << it->NameWithCompare(); ++it; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 8777296..b5b364d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -90,7 +90,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, return false; } - std::stringstream command; + std::ostringstream command; command << QuotePath(executable); command << " -nologo"; command << " -arch " << GetArchitecture(); @@ -115,7 +115,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) return false; } - std::stringstream command; + std::ostringstream command; command << QuotePath(executable); command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); @@ -254,7 +254,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::set<std::string> usedBaseNames; - std::stringstream objectFiles; + std::ostringstream objectFiles; for (size_t i = 0; i < this->WixSources.size(); ++i) { std::string const& sourceFilename = this->WixSources[i]; @@ -265,7 +265,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::string uniqueBaseName = baseName; while (usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) { - std::stringstream tmp; + std::ostringstream tmp; tmp << baseName << ++counter; uniqueBaseName = tmp.str(); } @@ -403,7 +403,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, std::string const& name, std::string const& value) { - std::stringstream tmp; + std::ostringstream tmp; tmp << name << "=\"" << value << '"'; source.AddProcessingInstruction( @@ -1019,7 +1019,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) idPrefix = "H"; } - std::stringstream result; + std::ostringstream result; result << idPrefix << "_" << identifier; size_t ambiguityCount = ++IdAmbiguityCounter[identifier]; diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 043cdff..bbbd92d 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -127,7 +127,7 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry, std::string const& name) { if (!this->IsBooleanAttribute(name)) { - std::stringstream message; + std::ostringstream message; message << "Unknown boolean attribute '" << name << "'"; this->ReportError(entry, message.str()); } diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx index 60ecae6..de64059 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -69,7 +69,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory( if (i == installRoot.size() - 1) { AddAttribute("Id", "INSTALL_ROOT"); } else { - std::stringstream tmp; + std::ostringstream tmp; tmp << "INSTALL_PREFIX_" << i; AddAttribute("Id", tmp.str()); } diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 1341fa5..9a143cc 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -31,7 +31,7 @@ void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id, std::string const& shortcutPrefix, size_t shortcutIndex) { - std::stringstream shortcutId; + std::ostringstream shortcutId; shortcutId << shortcutPrefix << id; if (shortcutIndex > 0) { diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index b750dcf..449a70b 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -88,7 +88,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes) if (key == "Id") { if (Fragments.find(value) != Fragments.end()) { - std::stringstream tmp; + std::ostringstream tmp; tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; ReportValidationError(tmp.str()); } diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index f4379c1..640e437 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -235,7 +235,7 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target, return false; } else { // Seek to desired size - 1 byte - fout.seekp(size - 1, std::ios_base::beg); + fout.seekp(size - 1, std::ios::beg); char byte = 0; // Write one byte to ensure file grows fout.write(&byte, 1); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 96a22d9..c991a23 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1677,7 +1677,7 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml, xml.Attribute(measurementfile.match(3).c_str(), measurementfile.match(4)); xml.Attribute("encoding", "base64"); - std::stringstream ostr; + std::ostringstream ostr; for (size_t cc = 0; cc < rlen; cc++) { ostr << encoded_buffer[cc]; if (cc % 60 == 0 && cc) { diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx index ee9acde..a19dbae 100644 --- a/Source/cmCLocaleEnvironmentScope.cxx +++ b/Source/cmCLocaleEnvironmentScope.cxx @@ -45,7 +45,7 @@ void cmCLocaleEnvironmentScope::SetEnv(std::string const& key, if (value.empty()) { cmSystemTools::UnsetEnv(key.c_str()); } else { - std::stringstream tmp; + std::ostringstream tmp; tmp << key << "=" << value; cmSystemTools::PutEnv(tmp.str()); } @@ -55,7 +55,7 @@ cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope() { for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin(); i != this->EnvironmentBackup.end(); ++i) { - std::stringstream tmp; + std::ostringstream tmp; tmp << i->first << "=" << i->second; cmSystemTools::PutEnv(tmp.str()); } diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index fbec6fd..fdbd5e7 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -84,7 +84,7 @@ bool cmCMakeHostSystemInformationCommand::GetValue( std::string cmCMakeHostSystemInformationCommand::ValueToString( size_t value) const { - std::stringstream tmp; + std::ostringstream tmp; tmp << value; return tmp.str(); } diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 11ff00b..938b10e 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -9,6 +9,21 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ +#ifndef cmConfigure_h +#define cmConfigure_h + +#include <cmsys/Configure.hxx> + +#ifdef _MSC_VER +#pragma warning(disable : 4786) +#pragma warning(disable : 4503) +#endif + +#ifdef __ICL +#pragma warning(disable : 985) +#pragma warning(disable : 1572) /* floating-point equality test */ +#endif + #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER @@ -17,3 +32,5 @@ #cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" + +#endif diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h new file mode 100644 index 0000000..c67550e --- /dev/null +++ b/Source/cmCustomCommandLines.h @@ -0,0 +1,38 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCustomCommandLines_h +#define cmCustomCommandLines_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <string> +#include <vector> + +/** Data structure to represent a single command line. */ +class cmCustomCommandLine : public std::vector<std::string> +{ +public: + typedef std::vector<std::string> Superclass; + typedef Superclass::iterator iterator; + typedef Superclass::const_iterator const_iterator; +}; + +/** Data structure to represent a list of command lines. */ +class cmCustomCommandLines : public std::vector<cmCustomCommandLine> +{ +public: + typedef std::vector<cmCustomCommandLine> Superclass; + typedef Superclass::iterator iterator; + typedef Superclass::const_iterator const_iterator; +}; + +#endif diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index a20fb98..bbda688 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -633,8 +633,8 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary); cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); #else - cmsys::ifstream finModFile(modFile, std::ios::in); - cmsys::ifstream finStampFile(stampFile, std::ios::in); + cmsys::ifstream finModFile(modFile); + cmsys::ifstream finStampFile(stampFile); #endif if (!finModFile || !finStampFile) { // At least one of the files does not exist. The modules differ. diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 68a8488..413dacd 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -140,7 +140,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) cmsys::ofstream* fout = 0; std::ostream* s = &os; if (!i->Filename.empty()) { - fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out); + fout = new cmsys::ofstream(i->Filename.c_str()); if (fout) { s = fout; } else { diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h new file mode 100644 index 0000000..f50839e --- /dev/null +++ b/Source/cmDocumentationEntry.h @@ -0,0 +1,45 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmDocumentationEntry_h +#define cmDocumentationEntry_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <string> + +/** Standard documentation entry for cmDocumentation's formatting. */ +struct cmDocumentationEntry +{ + std::string Name; + std::string Brief; + cmDocumentationEntry() {} + cmDocumentationEntry(const char* doc[2]) + { + if (doc[0]) { + this->Name = doc[0]; + } + if (doc[1]) { + this->Brief = doc[1]; + } + } + cmDocumentationEntry(const char* n, const char* b) + { + if (n) { + this->Name = n; + } + if (b) { + this->Brief = b; + } + } +}; + +#endif diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 28d1d48..dee666b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -580,19 +580,20 @@ void cmExtraCodeBlocksGenerator::AppendTarget( } // the include directories for this target - std::set<std::string> uniqIncludeDirs; + std::vector<std::string> allIncludeDirs; std::vector<std::string> includes; lg->GetIncludeDirectories(includes, target, "C", buildType); - uniqIncludeDirs.insert(includes.begin(), includes.end()); + allIncludeDirs.insert(allIncludeDirs.end(), includes.begin(), + includes.end()); std::string systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) { std::vector<std::string> dirs; cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - uniqIncludeDirs.insert(dirs.begin(), dirs.end()); + allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end()); } systemIncludeDirs = makefile->GetSafeDefinition( @@ -600,13 +601,16 @@ void cmExtraCodeBlocksGenerator::AppendTarget( if (!systemIncludeDirs.empty()) { std::vector<std::string> dirs; cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - uniqIncludeDirs.insert(dirs.begin(), dirs.end()); + allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end()); } - for (std::set<std::string>::const_iterator dirIt = uniqIncludeDirs.begin(); - dirIt != uniqIncludeDirs.end(); ++dirIt) { + std::vector<std::string>::const_iterator end = + cmRemoveDuplicates(allIncludeDirs); + + for (std::vector<std::string>::const_iterator i = allIncludeDirs.begin(); + i != end; ++i) { xml.StartElement("Add"); - xml.Attribute("directory", *dirIt); + xml.Attribute("directory", *i); xml.EndElement(); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index bc217af..f964b97 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -311,7 +311,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "false"); // set project specific environment - std::stringstream environment; + std::ostringstream environment; environment << "VERBOSE=1|CMAKE_NO_VERBOSE=1|"; // verbose Makefile output // set vsvars32.bat environment available at CMake time, // but not necessarily when eclipse is open @@ -341,7 +341,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all"); // set error parsers - std::stringstream errorOutputParser; + std::ostringstream errorOutputParser; if (compilerId == "MSVC") { errorOutputParser << "org.eclipse.cdt.core.VCErrorParser;"; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4e72f36..6abc238 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -257,7 +257,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) fileName.c_str(), std::ios::in | (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in)); #else - cmsys::ifstream file(fileName.c_str(), std::ios::in); + cmsys::ifstream file(fileName.c_str()); #endif if (!file) { @@ -526,7 +526,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(fileName.c_str(), std::ios::in); + cmsys::ifstream fin(fileName.c_str()); #endif if (!fin) { std::ostringstream e; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 1a44d73..d074b05 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -672,16 +672,18 @@ bool cmFindPackageCommand::HandlePackageMode() // If there are files in ConsideredConfigs, it means that FooConfig.cmake // have been found, but they didn't have appropriate versions. else if (!this->ConsideredConfigs.empty()) { + std::vector<ConfigFileInfo>::const_iterator duplicate_end = + cmRemoveDuplicates(this->ConsideredConfigs); e << "Could not find a configuration file for package \"" << this->Name << "\" that " << (this->VersionExact ? "exactly matches" : "is compatible with") << " requested version \"" << this->Version << "\".\n" << "The following configuration files were considered but not " "accepted:\n"; - for (std::vector<ConfigFileInfo>::size_type i = 0; - i < this->ConsideredConfigs.size(); i++) { - e << " " << this->ConsideredConfigs[i].filename - << ", version: " << this->ConsideredConfigs[i].version << "\n"; + for (std::vector<ConfigFileInfo>::const_iterator i = + this->ConsideredConfigs.begin(); + i != duplicate_end; ++i) { + e << " " << i->filename << ", version: " << i->version << "\n"; } } else { std::string requestedVersionString; @@ -774,12 +776,13 @@ bool cmFindPackageCommand::HandlePackageMode() std::string consideredVersions; const char* sep = ""; - for (std::vector<ConfigFileInfo>::size_type i = 0; - i < this->ConsideredConfigs.size(); i++) { + for (std::vector<ConfigFileInfo>::const_iterator i = + this->ConsideredConfigs.begin(); + i != this->ConsideredConfigs.end(); ++i) { consideredConfigFiles += sep; consideredVersions += sep; - consideredConfigFiles += this->ConsideredConfigs[i].filename; - consideredVersions += this->ConsideredConfigs[i].version; + consideredConfigFiles += i->filename; + consideredVersions += i->version; sep = ";"; } diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 9019f1b..2d14be2 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -160,6 +160,21 @@ private: { std::string filename; std::string version; + + bool operator<(ConfigFileInfo const& rhs) const + { + return this->filename < rhs.filename; + } + + bool operator==(ConfigFileInfo const& rhs) const + { + return this->filename == rhs.filename; + } + + bool operator!=(ConfigFileInfo const& rhs) const + { + return !(*this == rhs); + } }; std::vector<ConfigFileInfo> ConsideredConfigs; }; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index dee174b..c35a1bc 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -56,7 +56,7 @@ cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name, this->Stream::open(this->TempName.c_str(), std::ios::out | std::ios::binary); } else { - this->Stream::open(this->TempName.c_str(), std::ios::out); + this->Stream::open(this->TempName.c_str()); } // Check if the file opened. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index de02395..5f4b074 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1527,7 +1527,7 @@ public: if (item.find("::") != std::string::npos) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; - std::stringstream e; + std::ostringstream e; switch (this->Target->GetLocalGenerator()->GetPolicyStatus( cmPolicies::CMP0028)) { case cmPolicies::WARN: { @@ -1628,7 +1628,7 @@ public: if (this->Preferred.empty()) { return ""; } else if (this->Preferred.size() > 1) { - std::stringstream e; + std::ostringstream e; e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index aef3f44..536c5d2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2571,7 +2571,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(pfile.c_str(), std::ios::in); + cmsys::ifstream fin(pfile.c_str()); #endif if (!fin) { return; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f74e835..3aec630 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -513,8 +513,8 @@ void cmGlobalNinjaGenerator::Generate() this->WriteBuiltinTargets(*this->BuildFileStream); if (cmSystemTools::GetErrorOccuredFlag()) { - this->RulesFileStream->setstate(std::ios_base::failbit); - this->BuildFileStream->setstate(std::ios_base::failbit); + this->RulesFileStream->setstate(std::ios::failbit); + this->BuildFileStream->setstate(std::ios::failbit); } this->CloseCompileCommandsStream(); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 45395d1..cb5ba76 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -185,12 +185,12 @@ bool cmIfCommand::InvokeInitialPass( conditionEvaluator.IsTrue(expandedArguments, errorString, status); if (!errorString.empty()) { - std::string err = cmIfCommandError(expandedArguments); + std::string err = "if " + cmIfCommandError(expandedArguments); err += errorString; if (status == cmake::FATAL_ERROR) { - this->SetError(err); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, err); cmSystemTools::SetFatalErrorOccured(); - return false; + return true; } else { this->Makefile->IssueMessage(status, err); } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index e68bac2..d56bb05 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -623,7 +623,7 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( std::string darwin_major_version_s = mf->GetSafeDefinition("DARWIN_MAJOR_VERSION"); - std::stringstream ss(darwin_major_version_s); + std::istringstream ss(darwin_major_version_s); int darwin_major_version; ss >> darwin_major_version; if (!ss.fail() && darwin_major_version <= 9 && diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 036a2b1..4460418 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -23,6 +23,7 @@ struct cmListFileParser { cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename); ~cmListFileParser(); + void IssueFileOpenError(std::string const& text) const; bool ParseFile(); bool ParseFunction(const char* name, long line); bool AddArgument(cmListFileLexer_Token* token, @@ -54,23 +55,25 @@ cmListFileParser::~cmListFileParser() cmListFileLexer_Delete(this->Lexer); } +void cmListFileParser::IssueFileOpenError(const std::string& text) const +{ + this->Makefile->IssueMessage(cmake::FATAL_ERROR, text); +} + bool cmListFileParser::ParseFile() { // Open the file. cmListFileLexer_BOM bom; if (!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom)) { - cmSystemTools::Error("cmListFileCache: error can not open file ", - this->FileName); + this->IssueFileOpenError("cmListFileCache: error can not open file."); return false; } // Verify the Byte-Order-Mark, if any. if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) { cmListFileLexer_SetFileName(this->Lexer, 0, 0); - std::ostringstream m; - m << "File\n " << this->FileName << "\n" - << "starts with a Byte-Order-Mark that is not UTF-8."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str()); + this->IssueFileOpenError( + "File starts with a Byte-Order-Mark that is not UTF-8."); return false; } @@ -115,7 +118,7 @@ bool cmListFileParser::ParseFile() return true; } -bool cmListFile::ParseFile(const char* filename, bool topLevel, cmMakefile* mf) +bool cmListFile::ParseFile(const char* filename, cmMakefile* mf) { if (!cmSystemTools::FileExists(filename) || cmSystemTools::FileIsDirectory(filename)) { @@ -129,76 +132,6 @@ bool cmListFile::ParseFile(const char* filename, bool topLevel, cmMakefile* mf) parseError = !parser.ParseFile(); } - // do we need a cmake_policy(VERSION call? - if (topLevel) { - bool hasVersion = false; - // search for the right policy command - for (std::vector<cmListFileFunction>::iterator i = this->Functions.begin(); - i != this->Functions.end(); ++i) { - if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") { - hasVersion = true; - break; - } - } - // if no policy command is found this is an error if they use any - // non advanced functions or a lot of functions - if (!hasVersion) { - bool isProblem = true; - if (this->Functions.size() < 30) { - // the list of simple commands DO NOT ADD TO THIS LIST!!!!! - // these commands must have backwards compatibility forever and - // and that is a lot longer than your tiny mind can comprehend mortal - std::set<std::string> allowedCommands; - allowedCommands.insert("project"); - allowedCommands.insert("set"); - allowedCommands.insert("if"); - allowedCommands.insert("endif"); - allowedCommands.insert("else"); - allowedCommands.insert("elseif"); - allowedCommands.insert("add_executable"); - allowedCommands.insert("add_library"); - allowedCommands.insert("target_link_libraries"); - allowedCommands.insert("option"); - allowedCommands.insert("message"); - isProblem = false; - for (std::vector<cmListFileFunction>::iterator i = - this->Functions.begin(); - i != this->Functions.end(); ++i) { - std::string name = cmSystemTools::LowerCase(i->Name); - if (allowedCommands.find(name) == allowedCommands.end()) { - isProblem = true; - break; - } - } - } - - if (isProblem) { - // Tell the top level cmMakefile to diagnose - // this violation of CMP0000. - mf->SetCheckCMP0000(true); - - // Implicitly set the version for the user. - mf->SetPolicyVersion("2.4"); - } - } - bool hasProject = false; - // search for a project command - for (std::vector<cmListFileFunction>::iterator i = this->Functions.begin(); - i != this->Functions.end(); ++i) { - if (cmSystemTools::LowerCase(i->Name) == "project") { - hasProject = true; - break; - } - } - // if no project command is found, add one - if (!hasProject) { - cmListFileFunction project; - project.Name = "PROJECT"; - cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0); - project.Arguments.push_back(prj); - this->Functions.insert(this->Functions.begin(), project); - } - } return !parseError; } diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index d72c360..f3e6f70 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -158,7 +158,7 @@ private: struct cmListFile { - bool ParseFile(const char* path, bool topLevel, cmMakefile* mf); + bool ParseFile(const char* path, cmMakefile* mf); std::vector<cmListFileFunction> Functions; }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c9192fd..5712070 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -254,9 +254,10 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->PrintCommandTrace(lff); } // Try invoking the command. - if (!pcmd->InvokeInitialPass(lff.Arguments, status) || - status.GetNestedError()) { - if (!status.GetNestedError()) { + bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status); + bool hadNestedError = status.GetNestedError(); + if (!invokeSucceeded || hadNestedError) { + if (!hadNestedError) { // The command invocation requested that we report an error. this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); } @@ -426,7 +427,7 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) IncludeScope incScope(this, filenametoread, noPolicyScope); cmListFile listFile; - if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { + if (!listFile.ParseFile(filenametoread.c_str(), this)) { return false; } @@ -475,7 +476,7 @@ bool cmMakefile::ReadListFile(const char* filename) ListFileScope scope(this, filenametoread); cmListFile listFile; - if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { + if (!listFile.ParseFile(filenametoread.c_str(), this)) { return false; } @@ -1423,10 +1424,81 @@ void cmMakefile::Configure() this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); cmListFile listFile; - if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), - this)) { + if (!listFile.ParseFile(currentStart.c_str(), this)) { return; } + if (this->IsRootMakefile()) { + bool hasVersion = false; + // search for the right policy command + for (std::vector<cmListFileFunction>::iterator i = + listFile.Functions.begin(); + i != listFile.Functions.end(); ++i) { + if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") { + hasVersion = true; + break; + } + } + // if no policy command is found this is an error if they use any + // non advanced functions or a lot of functions + if (!hasVersion) { + bool isProblem = true; + if (listFile.Functions.size() < 30) { + // the list of simple commands DO NOT ADD TO THIS LIST!!!!! + // these commands must have backwards compatibility forever and + // and that is a lot longer than your tiny mind can comprehend mortal + std::set<std::string> allowedCommands; + allowedCommands.insert("project"); + allowedCommands.insert("set"); + allowedCommands.insert("if"); + allowedCommands.insert("endif"); + allowedCommands.insert("else"); + allowedCommands.insert("elseif"); + allowedCommands.insert("add_executable"); + allowedCommands.insert("add_library"); + allowedCommands.insert("target_link_libraries"); + allowedCommands.insert("option"); + allowedCommands.insert("message"); + isProblem = false; + for (std::vector<cmListFileFunction>::iterator i = + listFile.Functions.begin(); + i != listFile.Functions.end(); ++i) { + std::string name = cmSystemTools::LowerCase(i->Name); + if (allowedCommands.find(name) == allowedCommands.end()) { + isProblem = true; + break; + } + } + } + + if (isProblem) { + // Tell the top level cmMakefile to diagnose + // this violation of CMP0000. + this->SetCheckCMP0000(true); + + // Implicitly set the version for the user. + this->SetPolicyVersion("2.4"); + } + } + bool hasProject = false; + // search for a project command + for (std::vector<cmListFileFunction>::iterator i = + listFile.Functions.begin(); + i != listFile.Functions.end(); ++i) { + if (cmSystemTools::LowerCase(i->Name) == "project") { + hasProject = true; + break; + } + } + // if no project command is found, add one + if (!hasProject) { + cmListFileFunction project; + project.Name = "PROJECT"; + cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0); + project.Arguments.push_back(prj); + listFile.Functions.insert(listFile.Functions.begin(), project); + } + } + this->ReadListFile(listFile, currentStart); if (cmSystemTools::GetFatalErrorOccured()) { scope.Quiet(); @@ -3387,7 +3459,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } } else { std::string newLineCharacters; - std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + std::ios::openmode omode = std::ios::out | std::ios::trunc; if (newLine.IsValid()) { newLineCharacters = newLine.GetCharacters(); omode |= std::ios::binary; diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 8e80bd0..da43a11 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -15,6 +15,7 @@ #include "cmake.h" #include <assert.h> +#include <sstream> #include <ctype.h> /* isalpha */ #include <string.h> /* strlen */ @@ -328,19 +329,9 @@ std::string cmOutputConverter::EscapeForShell(const std::string& str, flags |= Shell_Flag_NMake; } - // Compute the buffer size needed. - int size = (this->GetState()->UseWindowsShell() - ? Shell_GetArgumentSizeForWindows(str.c_str(), flags) - : Shell_GetArgumentSizeForUnix(str.c_str(), flags)); - - // Compute the shell argument itself. - std::vector<char> arg(size); - if (this->GetState()->UseWindowsShell()) { - Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags); - } else { - Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags); - } - return std::string(&arg[0]); + return this->GetState()->UseWindowsShell() + ? Shell_GetArgumentForWindows(str.c_str(), flags) + : Shell_GetArgumentForUnix(str.c_str(), flags); } std::string cmOutputConverter::EscapeForCMake(const std::string& str) @@ -369,18 +360,7 @@ std::string cmOutputConverter::EscapeForCMake(const std::string& str) std::string cmOutputConverter::EscapeWindowsShellArgument(const char* arg, int shell_flags) { - char local_buffer[1024]; - char* buffer = local_buffer; - int size = Shell_GetArgumentSizeForWindows(arg, shell_flags); - if (size > 1024) { - buffer = new char[size]; - } - Shell_GetArgumentForWindows(arg, buffer, shell_flags); - std::string result(buffer); - if (buffer != local_buffer) { - delete[] buffer; - } - return result; + return Shell_GetArgumentForWindows(arg, shell_flags); } cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat( @@ -586,12 +566,10 @@ int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix, return 0; } -int cmOutputConverter::Shell__GetArgumentSize(const char* in, int isUnix, - int flags) +std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, + int flags) { - /* Start with the length of the original argument, plus one for - either a terminating null or a separating space. */ - int size = (int)strlen(in) + 1; + std::ostringstream out; /* String iterator. */ const char* c; @@ -599,116 +577,17 @@ int cmOutputConverter::Shell__GetArgumentSize(const char* in, int isUnix, /* Keep track of how many backslashes have been encountered in a row. */ int windows_backslashes = 0; - /* Scan the string for characters that require escaping or quoting. */ - for (c = in; *c; ++c) { - /* Look for $(MAKEVAR) syntax if requested. */ - if (flags & Shell_Flag_AllowMakeVariables) { - /* Skip over the make variable references if any are present. */ - c = Shell__SkipMakeVariables(c); - - /* Stop if we have reached the end of the string. */ - if (!*c) { - break; - } - } - - /* Check whether this character needs escaping for the shell. */ - if (isUnix) { - /* On Unix a few special characters need escaping even inside a - quoted argument. */ - if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') { - /* This character needs a backslash to escape it. */ - ++size; - } - } else if (flags & Shell_Flag_EchoWindows) { - /* On Windows the built-in command shell echo never needs escaping. */ - } else { - /* On Windows only backslashes and double-quotes need escaping. */ - if (*c == '\\') { - /* Found a backslash. It may need to be escaped later. */ - ++windows_backslashes; - } else if (*c == '"') { - /* Found a double-quote. We need to escape it and all - immediately preceding backslashes. */ - size += windows_backslashes + 1; - windows_backslashes = 0; - } else { - /* Found another character. This eliminates the possibility - that any immediately preceding backslashes will be - escaped. */ - windows_backslashes = 0; - } - } - - /* Check whether this character needs escaping for a make tool. */ - if (*c == '$') { - if (flags & Shell_Flag_Make) { - /* In Makefiles a dollar is written $$ so we need one extra - character. */ - ++size; - } else if (flags & Shell_Flag_VSIDE) { - /* In a VS IDE a dollar is written "$" so we need two extra - characters. */ - size += 2; - } - } else if (*c == '#') { - if ((flags & Shell_Flag_Make) && (flags & Shell_Flag_WatcomWMake)) { - /* In Watcom WMake makefiles a pound is written $# so we need - one extra character. */ - ++size; - } - } else if (*c == '%') { - if ((flags & Shell_Flag_VSIDE) || - ((flags & Shell_Flag_Make) && - ((flags & Shell_Flag_MinGWMake) || (flags & Shell_Flag_NMake)))) { - /* In the VS IDE, NMake, or MinGW make a percent is written %% - so we need one extra characters. */ - size += 1; - } - } else if (*c == ';') { - if (flags & Shell_Flag_VSIDE) { - /* In a VS IDE a semicolon is written ";" so we need two extra - characters. */ - size += 2; - } - } - } - - /* Check whether the argument needs surrounding quotes. */ - if (Shell__ArgumentNeedsQuotes(in, isUnix, flags)) { - /* Surrounding quotes are needed. Allocate space for them. */ - if ((flags & Shell_Flag_WatcomQuote) && (isUnix)) { - size += 2; - } - size += 2; - - /* We must escape all ending backslashes when quoting on windows. */ - size += windows_backslashes; - } - - return size; -} - -char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, - int isUnix, int flags) -{ - /* String iterator. */ - const char* c; - - /* Keep track of how many backslashes have been encountered in a row. */ - int windows_backslashes = 0; - /* Whether the argument must be quoted. */ int needQuotes = Shell__ArgumentNeedsQuotes(in, isUnix, flags); if (needQuotes) { /* Add the opening quote for this argument. */ if (flags & Shell_Flag_WatcomQuote) { if (isUnix) { - *out++ = '"'; + out << '"'; } - *out++ = '\''; + out << '\''; } else { - *out++ = '"'; + out << '"'; } } @@ -720,7 +599,7 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, if (skip != c) { /* Copy to the end of the make variable references. */ while (c != skip) { - *out++ = *c++; + out << *c++; } /* The make variable reference eliminates any escaping needed @@ -740,7 +619,7 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, quoted argument. */ if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') { /* This character needs a backslash to escape it. */ - *out++ = '\\'; + out << '\\'; } } else if (flags & Shell_Flag_EchoWindows) { /* On Windows the built-in command shell echo never needs escaping. */ @@ -754,11 +633,11 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, backslashes. */ while (windows_backslashes > 0) { --windows_backslashes; - *out++ = '\\'; + out << '\\'; } /* Add the backslash to escape the double-quote. */ - *out++ = '\\'; + out << '\\'; } else { /* We encountered a normal character. This eliminates any escaping needed for preceding backslashes. */ @@ -771,8 +650,7 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, if (flags & Shell_Flag_Make) { /* In Makefiles a dollar is written $$. The make tool will replace it with just $ before passing it to the shell. */ - *out++ = '$'; - *out++ = '$'; + out << "$$"; } else if (flags & Shell_Flag_VSIDE) { /* In a VS IDE a dollar is written "$". If this is written in an un-quoted argument it starts a quoted segment, inserts @@ -780,34 +658,30 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, argument it ends quoting, inserts the $ and restarts quoting. Either way the $ is isolated from surrounding text to avoid looking like a variable reference. */ - *out++ = '"'; - *out++ = '$'; - *out++ = '"'; + out << "\"$\""; } else { /* Otherwise a dollar is written just $. */ - *out++ = '$'; + out << '$'; } } else if (*c == '#') { if ((flags & Shell_Flag_Make) && (flags & Shell_Flag_WatcomWMake)) { /* In Watcom WMake makefiles a pound is written $#. The make tool will replace it with just # before passing it to the shell. */ - *out++ = '$'; - *out++ = '#'; + out << "$#"; } else { /* Otherwise a pound is written just #. */ - *out++ = '#'; + out << '#'; } } else if (*c == '%') { if ((flags & Shell_Flag_VSIDE) || ((flags & Shell_Flag_Make) && ((flags & Shell_Flag_MinGWMake) || (flags & Shell_Flag_NMake)))) { /* In the VS IDE, NMake, or MinGW make a percent is written %%. */ - *out++ = '%'; - *out++ = '%'; + out << "%%"; } else { /* Otherwise a percent is written just %. */ - *out++ = '%'; + out << '%'; } } else if (*c == ';') { if (flags & Shell_Flag_VSIDE) { @@ -816,16 +690,14 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, inserts the ; and ends the segment. If it is written in a quoted argument it ends quoting, inserts the ; and restarts quoting. Either way the ; is isolated. */ - *out++ = '"'; - *out++ = ';'; - *out++ = '"'; + out << "\";\""; } else { /* Otherwise a semicolon is written just ;. */ - *out++ = ';'; + out << ';'; } } else { /* Store this character. */ - *out++ = *c; + out << *c; } } @@ -833,45 +705,31 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out, /* Add enough backslashes to escape any trailing ones. */ while (windows_backslashes > 0) { --windows_backslashes; - *out++ = '\\'; + out << '\\'; } /* Add the closing quote for this argument. */ if (flags & Shell_Flag_WatcomQuote) { - *out++ = '\''; + out << '\''; if (isUnix) { - *out++ = '"'; + out << '"'; } } else { - *out++ = '"'; + out << '"'; } } - /* Store a terminating null without incrementing. */ - *out = 0; - - return out; -} - -char* cmOutputConverter::Shell_GetArgumentForWindows(const char* in, char* out, - int flags) -{ - return Shell__GetArgument(in, out, 0, flags); -} - -char* cmOutputConverter::Shell_GetArgumentForUnix(const char* in, char* out, - int flags) -{ - return Shell__GetArgument(in, out, 1, flags); + return out.str(); } -int cmOutputConverter::Shell_GetArgumentSizeForWindows(const char* in, - int flags) +std::string cmOutputConverter::Shell_GetArgumentForWindows(const char* in, + int flags) { - return Shell__GetArgumentSize(in, 0, flags); + return Shell__GetArgument(in, 0, flags); } -int cmOutputConverter::Shell_GetArgumentSizeForUnix(const char* in, int flags) +std::string cmOutputConverter::Shell_GetArgumentForUnix(const char* in, + int flags) { - return Shell__GetArgumentSize(in, 1, flags); + return Shell__GetArgument(in, 1, flags); } diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 75d6326..f138d0e 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -126,17 +126,8 @@ public: * modify the generated quoting and escape sequences to work under * alternative environments. */ - static char* Shell_GetArgumentForWindows(const char* in, char* out, - int flags); - static char* Shell_GetArgumentForUnix(const char* in, char* out, int flags); - - /** - * Compute the size of the buffer required to store the output from - * Shell_GetArgumentForWindows or Shell_GetArgumentForUnix. The flags - * passed must be identical between the two calls. - */ - static int Shell_GetArgumentSizeForWindows(const char* in, int flags); - static int Shell_GetArgumentSizeForUnix(const char* in, int flags); + static std::string Shell_GetArgumentForWindows(const char* in, int flags); + static std::string Shell_GetArgumentForUnix(const char* in, int flags); std::string EscapeForShell(const std::string& str, bool makeVars = false, bool forEcho = false, @@ -182,9 +173,7 @@ private: static int Shell__CharIsMakeVariableName(char c); static const char* Shell__SkipMakeVariables(const char* c); static int Shell__ArgumentNeedsQuotes(const char* in, int isUnix, int flags); - static int Shell__GetArgumentSize(const char* in, int isUnix, int flags); - static char* Shell__GetArgument(const char* in, char* out, int isUnix, - int flags); + static std::string Shell__GetArgument(const char* in, int isUnix, int flags); private: cmState::Snapshot StateSnapshot; diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index dd19760..98851d6 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -464,7 +464,7 @@ static std::string cmQtAutoGeneratorsStripCR(std::string const& line) static std::string ReadAll(const std::string& filename) { cmsys::ifstream file(filename.c_str()); - std::stringstream stream; + std::ostringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); @@ -508,7 +508,7 @@ static std::string ListQt5RccInputs(cmSourceFile* sf, bool result = cmSystemTools::RunSingleCommand( command, &rccStdOut, &rccStdErr, &retVal, 0, cmSystemTools::OUTPUT_NONE); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() << " failed:\n" << rccStdOut << "\n" @@ -538,7 +538,7 @@ static std::string ListQt5RccInputs(cmSourceFile* sf, std::string::size_type pos = eline.find(searchString); if (pos == std::string::npos) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: Rcc lists unparsable output " << eline << std::endl; std::cerr << err.str(); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index dc44f3e..6a6d72f 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -432,7 +432,7 @@ void cmQtAutoGenerators::Init() static std::string ReadAll(const std::string& filename) { cmsys::ifstream file(filename.c_str()); - std::stringstream stream; + std::ostringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); @@ -477,7 +477,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) skipUic ? skippedUis : includedUis; const std::string& absFilename = *it; if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << absFilename << std::endl; this->LogInfo(err.str()); } @@ -499,7 +499,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) uicSkipped.end()) { const std::string& absFilename = *it; if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << absFilename << std::endl; this->LogInfo(err.str()); } @@ -527,19 +527,19 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) } if (this->RunMocFailed) { - std::stringstream err; + std::ostringstream err; err << "moc failed..." << std::endl; this->LogError(err.str()); return false; } if (this->RunUicFailed) { - std::stringstream err; + std::ostringstream err; err << "uic failed..." << std::endl; this->LogError(err.str()); return false; } if (this->RunRccFailed) { - std::stringstream err; + std::ostringstream err; err << "rcc failed..." << std::endl; this->LogError(err.str()); return false; @@ -560,7 +560,7 @@ void cmQtAutoGenerators::ParseCppFile( const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -620,7 +620,7 @@ void cmQtAutoGenerators::ParseCppFile( ownMocHeaderFile = headerToMoc; } } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' @@ -644,7 +644,7 @@ void cmQtAutoGenerators::ParseCppFile( // this is for KDE4 compatibility: fileToMoc = headerToMoc; if (!requiresMoc && basename == scannedFileBasename) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" @@ -656,7 +656,7 @@ void cmQtAutoGenerators::ParseCppFile( << std::endl; this->LogError(err.str()); } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" @@ -670,7 +670,7 @@ void cmQtAutoGenerators::ParseCppFile( this->LogError(err.str()); } } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" @@ -699,7 +699,7 @@ void cmQtAutoGenerators::ParseCppFile( if (!dotMocIncluded && requiresMoc) { if (mocUnderscoreIncluded) { // this is for KDE4 compatibility: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " @@ -717,7 +717,7 @@ void cmQtAutoGenerators::ParseCppFile( includedMocs.erase(ownMocHeaderFile); } else { // otherwise always error out since it will not compile: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " @@ -742,7 +742,7 @@ void cmQtAutoGenerators::StrictParseCppFile( const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -791,7 +791,7 @@ void cmQtAutoGenerators::StrictParseCppFile( if (!headerToMoc.empty()) { includedMocs[headerToMoc] = currentMoc; } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' @@ -807,7 +807,7 @@ void cmQtAutoGenerators::StrictParseCppFile( } } else { if (basename != scannedFileBasename) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" @@ -835,7 +835,7 @@ void cmQtAutoGenerators::StrictParseCppFile( std::string macroName; if (!dotMocIncluded && requiresMocing(contentsString, macroName)) { // otherwise always error out since it will not compile: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not include " << "\"" << scannedFileBasename << ".moc\" !\n" @@ -854,7 +854,7 @@ void cmQtAutoGenerators::ParseForUic( } const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -942,7 +942,7 @@ void cmQtAutoGenerators::ParseHeaders( if (!this->MocExecutable.empty() && includedMocs.find(headerName) == includedMocs.end()) { if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << headerName << std::endl; this->LogInfo(err.str()); } @@ -972,7 +972,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( std::map<std::string, std::string> mergedMocs(includedMocs); mergedMocs.insert(notIncludedMocs.begin(), notIncludedMocs.end()); if (this->NameCollisionTest(mergedMocs, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " "The same moc file will be generated " "from different sources." @@ -1013,7 +1013,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( // compose _automoc.cpp content std::string automocSource; { - std::stringstream outStream; + std::ostringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; if (notIncludedMocs.empty()) { outStream << "enum some_compilers { need_more_than_nothing };\n"; @@ -1035,7 +1035,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( if (oldContents == automocSource) { // nothing changed: don't touch the _automoc.cpp file if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: " << this->OutMocCppFilenameRel << " still up to date" << std::endl; this->LogInfo(err.str()); @@ -1106,7 +1106,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: process for " << mocFilePath << " failed:\n" << output << std::endl; this->LogError(err.str()); @@ -1147,7 +1147,7 @@ bool cmQtAutoGenerators::GenerateUiFiles( { std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(testMap, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: The same ui_NAME.h file will be generated " "from different sources." << std::endl @@ -1223,7 +1223,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOUIC: error: process for " << uiOutputFile << " needed by\n \"" << realName << "\"\nfailed:\n" << output << std::endl; @@ -1275,7 +1275,7 @@ bool cmQtAutoGenerators::GenerateQrcFiles() { std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(qrcGenMap, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: The same qrc_NAME.cpp file" " will be generated from different sources." << std::endl @@ -1344,7 +1344,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTORCC: error: process for " << qrcOutputFile << " failed:\n" << output << std::endl; this->LogError(err.str()); @@ -1435,7 +1435,7 @@ void cmQtAutoGenerators::NameCollisionLog( { typedef std::multimap<std::string, std::string>::const_iterator Iter; - std::stringstream err; + std::ostringstream err; // Add message err << message; // Append collision list @@ -1457,7 +1457,7 @@ void cmQtAutoGenerators::LogError(const std::string& message) void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) { - std::stringstream sbuf; + std::ostringstream sbuf; for (std::vector<std::string>::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { if (cmdIt != command.begin()) { diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index d3bf301..606978e 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -18,18 +18,6 @@ #include <cmConfigure.h> -#include <cmsys/Configure.hxx> - -#ifdef _MSC_VER -#pragma warning(disable : 4786) -#pragma warning(disable : 4503) -#endif - -#ifdef __ICL -#pragma warning(disable : 985) -#pragma warning(disable : 1572) /* floating-point equality test */ -#endif - // Provide fixed-size integer types. #include <cm_kwiml.h> @@ -67,77 +55,9 @@ typedef unsigned short mode_t; /* Poison this operator to avoid common mistakes. */ extern void operator<<(std::ostream&, const std::ostringstream&); -/** Standard documentation entry for cmDocumentation's formatting. */ -struct cmDocumentationEntry -{ - std::string Name; - std::string Brief; - cmDocumentationEntry() {} - cmDocumentationEntry(const char* doc[2]) - { - if (doc[0]) { - this->Name = doc[0]; - } - if (doc[1]) { - this->Brief = doc[1]; - } - } - cmDocumentationEntry(const char* n, const char* b) - { - if (n) { - this->Name = n; - } - if (b) { - this->Brief = b; - } - } -}; - -/** Data structure to represent a single command line. */ -class cmCustomCommandLine : public std::vector<std::string> -{ -public: - typedef std::vector<std::string> Superclass; - typedef Superclass::iterator iterator; - typedef Superclass::const_iterator const_iterator; -}; - -/** Data structure to represent a list of command lines. */ -class cmCustomCommandLines : public std::vector<cmCustomCommandLine> -{ -public: - typedef std::vector<cmCustomCommandLine> Superclass; - typedef Superclass::iterator iterator; - typedef Superclass::const_iterator const_iterator; -}; - -// All subclasses of cmCommand or cmCTestGenericHandler should -// invoke this macro. -#define cmTypeMacro(thisClass, superclass) \ - virtual const char* GetNameOfClass() { return #thisClass; } \ - typedef superclass Superclass; \ - static bool IsTypeOf(const char* type) \ - { \ - if (!strcmp(#thisClass, type)) { \ - return true; \ - } \ - return Superclass::IsTypeOf(type); \ - } \ - virtual bool IsA(const char* type) { return thisClass::IsTypeOf(type); } \ - static thisClass* SafeDownCast(cmObject* c) \ - { \ - if (c && c->IsA(#thisClass)) { \ - return static_cast<thisClass*>(c); \ - } \ - return 0; \ - } \ - class cmTypeMacro_UseTrailingSemicolon - -enum cmTargetLinkLibraryType -{ - GENERAL_LibraryType, - DEBUG_LibraryType, - OPTIMIZED_LibraryType -}; +#include "cmCustomCommandLines.h" +#include "cmDocumentationEntry.h" +#include "cmTargetLinkLibraryType.h" +#include "cmTypeMacro.h" #endif diff --git a/Source/cmTargetLinkLibraryType.h b/Source/cmTargetLinkLibraryType.h new file mode 100644 index 0000000..71ac9e7 --- /dev/null +++ b/Source/cmTargetLinkLibraryType.h @@ -0,0 +1,22 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmTargetLinkLibraryType_h +#define cmTargetLinkLibraryType_h + +enum cmTargetLinkLibraryType +{ + GENERAL_LibraryType, + DEBUG_LibraryType, + OPTIMIZED_LibraryType +}; + +#endif diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index c624d0f..2a70ed0 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -152,7 +152,7 @@ std::string cmTimestamp::AddTimestampComponent(char flag, return std::string(); } - std::stringstream ss; + std::ostringstream ss; ss << static_cast<long int>(difftime(timeT, unixEpoch)); return ss.str(); } diff --git a/Source/cmTypeMacro.h b/Source/cmTypeMacro.h new file mode 100644 index 0000000..5c534c3 --- /dev/null +++ b/Source/cmTypeMacro.h @@ -0,0 +1,37 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmTypeMacro_h +#define cmTypeMacro_h + +// All subclasses of cmCommand or cmCTestGenericHandler should +// invoke this macro. +#define cmTypeMacro(thisClass, superclass) \ + virtual const char* GetNameOfClass() { return #thisClass; } \ + typedef superclass Superclass; \ + static bool IsTypeOf(const char* type) \ + { \ + if (!strcmp(#thisClass, type)) { \ + return true; \ + } \ + return Superclass::IsTypeOf(type); \ + } \ + virtual bool IsA(const char* type) { return thisClass::IsTypeOf(type); } \ + static thisClass* SafeDownCast(cmObject* c) \ + { \ + if (c && c->IsA(#thisClass)) { \ + return static_cast<thisClass*>(c); \ + } \ + return 0; \ + } \ + class cmTypeMacro_UseTrailingSemicolon + +#endif diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx index 98c2680..e2dce93d 100644 --- a/Source/cmXMLWriter.cxx +++ b/Source/cmXMLWriter.cxx @@ -14,7 +14,7 @@ #include "cmXMLSafe.h" #include <cassert> -#include <fstream> +#include <cmsys/FStream.hxx> cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level) : Output(output) @@ -107,7 +107,7 @@ void cmXMLWriter::ProcessingInstruction(const char* target, const char* data) void cmXMLWriter::FragmentFile(const char* fname) { this->CloseStartElement(); - std::ifstream fin(fname, std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname, std::ios::in | std::ios::binary); this->Output << fin.rdbuf(); } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e404fa3..db0072a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2094,7 +2094,7 @@ static bool cmakeCheckStampFile(const char* stampName) #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(stampDepends.c_str(), std::ios::in); + cmsys::ifstream fin(stampDepends.c_str()); #endif if (!fin) { // The stamp dependencies file cannot be read. Just assume the diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 8b0cede..44f71f1 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -213,7 +213,7 @@ static int process(const std::string& srcfilename, const std::string& dfile, dir.c_str(), cmSystemTools::OUTPUT_NONE); // process the include directives and output everything else - std::stringstream ss(output); + std::istringstream ss(output); std::string line; std::vector<std::string> includes; bool isFirstLine = true; // cl prints always first the source filename |