diff options
Diffstat (limited to 'Source')
558 files changed, 9255 insertions, 5318 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 40403ca..bcc3437 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -469,6 +469,8 @@ set(SRCS cmIncludeDirectoryCommand.h cmIncludeExternalMSProjectCommand.cxx cmIncludeExternalMSProjectCommand.h + cmIncludeGuardCommand.cxx + cmIncludeGuardCommand.h cmIncludeRegularExpressionCommand.cxx cmIncludeRegularExpressionCommand.h cmInstallCommand.cxx @@ -874,6 +876,7 @@ set(CPACK_SRCS CPack/cmCPackTarCompressGenerator.cxx CPack/cmCPackZIPGenerator.cxx CPack/cmCPack7zGenerator.cxx + CPack/cmCPackDebGenerator.cxx ) # CPack IFW generator set(CPACK_SRCS ${CPACK_SRCS} @@ -896,11 +899,39 @@ if(CYGWIN) ) endif() +option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) + if(UNIX) set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackDebGenerator.cxx CPack/cmCPackRPMGenerator.cxx ) + + # Optionally, try to use pkg(8) + if(CPACK_ENABLE_FREEBSD_PKG) + # On UNIX, you may find FreeBSD's pkg(8) and attendant + # library -- it can be used on FreeBSD, Dragonfly, NetBSD, + # OpenBSD and also Linux and OSX. Look for the header and + # the library; it's a warning on FreeBSD if they're not + # found, and informational on other platforms. + find_path(FREEBSD_PKG_INCLUDE_DIRS "pkg.h" PATHS /usr/local) + if(FREEBSD_PKG_INCLUDE_DIRS) + find_library(FREEBSD_PKG_LIBRARIES + pkg + DOC "FreeBSD pkg(8) library") + if(FREEBSD_PKG_LIBRARIES) + set(CPACK_SRCS ${CPACK_SRCS} + CPack/cmCPackFreeBSDGenerator.cxx + ) + endif() + endif() + + if (NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES) + message(FATAL_ERROR "CPack needs libpkg(3) to produce FreeBSD packages natively.") + endif() + else() + set(FREEBSD_PKG_INCLUDE_DIRS NOTFOUND) + set(FREEBSD_PKG_LIBRARIES NOTFOUND) + endif() endif() if(WIN32) @@ -958,6 +989,11 @@ if(APPLE) "See CMakeFiles/CMakeError.log for details of the failure.") endif() endif() +if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) + target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES}) + include_directories(${FREEBSD_PKG_INCLUDE_DIRS}) + add_definitions(-DHAVE_FREEBSD_PKG) +endif() if(APPLE) add_executable(cmakexbuild cmakexbuild.cxx) @@ -974,18 +1010,16 @@ add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE}) list(APPEND _tools cmake) target_link_libraries(cmake CMakeLib) -if(CMake_ENABLE_SERVER_MODE) - add_library(CMakeServerLib - cmFileMonitor.cxx cmFileMonitor.h - cmServer.cxx cmServer.h - cmServerConnection.cxx cmServerConnection.h - cmServerProtocol.cxx cmServerProtocol.h - ) - target_link_libraries(CMakeServerLib CMakeLib) - set_property(SOURCE cmcmd.cxx APPEND PROPERTY COMPILE_DEFINITIONS HAVE_SERVER_MODE=1) - - target_link_libraries(cmake CMakeServerLib) -endif() +add_library(CMakeServerLib + cmConnection.h cmConnection.cxx + cmFileMonitor.cxx cmFileMonitor.h + cmPipeConnection.cxx cmPipeConnection.h + cmServer.cxx cmServer.h + cmServerConnection.cxx cmServerConnection.h + cmServerProtocol.cxx cmServerProtocol.h + ) +target_link_libraries(CMakeServerLib CMakeLib) +target_link_libraries(cmake CMakeServerLib) # Build CTest executable add_executable(ctest ctest.cxx ${MANIFEST_FILE}) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8b9cbbd..0e0c748 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 9) -set(CMake_VERSION_PATCH 1) -#set(CMake_VERSION_RC 0) +set(CMake_VERSION_PATCH 20170830) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index e8f05bd..1e72641 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -15,14 +15,14 @@ #include <vector> cmCPackIFWCommon::cmCPackIFWCommon() - : Generator(CM_NULLPTR) + : Generator(nullptr) { } const char* cmCPackIFWCommon::GetOption(const std::string& op) const { return this->Generator ? this->Generator->cmCPackGenerator::GetOption(op) - : CM_NULLPTR; + : nullptr; } bool cmCPackIFWCommon::IsOn(const std::string& op) const diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 226ea0a..97e792a 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -56,6 +56,22 @@ int cmCPackIFWGenerator::PackageFiles() } } + if (!this->RepoDirsVector.empty()) { + if (!this->IsVersionLess("3.1")) { + for (std::vector<std::string>::iterator it = + this->RepoDirsVector.begin(); + it != this->RepoDirsVector.end(); ++it) { + ifwCmd += " --repository " + *it; + } + } else { + cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " + << "variable is set, but content will be skiped, " + << "because this feature available only since " + << "QtIFW 3.1. Please update your QtIFW instance." + << std::endl); + } + } + if (!this->OnlineOnly && !this->DownloadedPackages.empty()) { ifwCmd += " -i "; std::set<cmCPackIFWPackage*>::iterator it = @@ -73,7 +89,7 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl); bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output, - &output, &retVal, CM_NULLPTR, + &output, &retVal, nullptr, this->GeneratorVerbose, 0); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile.c_str()); @@ -128,6 +144,22 @@ int cmCPackIFWGenerator::PackageFiles() } } + if (!this->RepoDirsVector.empty()) { + if (!this->IsVersionLess("3.1")) { + for (std::vector<std::string>::iterator it = + this->RepoDirsVector.begin(); + it != this->RepoDirsVector.end(); ++it) { + ifwCmd += " --repository " + *it; + } + } else { + cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " + << "variable is set, but content will be skipped, " + << "because this feature available only since " + << "QtIFW 3.1. Please update your QtIFW instance." + << std::endl); + } + } + if (this->OnlineOnly) { ifwCmd += " --online-only"; } else if (!this->DownloadedPackages.empty() && @@ -164,13 +196,14 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd += " " + this->packageFileNames[0]; } else { ifwCmd += " installer"; + ifwCmd += this->OutputExtension; } cmCPackIFWLogger(VERBOSE, "Execute: " << ifwCmd << std::endl); std::string output; int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl); bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output, - &output, &retVal, CM_NULLPTR, + &output, &retVal, nullptr, this->GeneratorVerbose, 0); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile.c_str()); @@ -205,7 +238,7 @@ const char* cmCPackIFWGenerator::GetPackagingInstallPrefix() const char* cmCPackIFWGenerator::GetOutputExtension() { - return this->ExecutableSuffix.c_str(); + return this->OutputExtension.c_str(); } int cmCPackIFWGenerator::InitializeInternal() @@ -265,6 +298,13 @@ int cmCPackIFWGenerator::InitializeInternal() cmSystemTools::ExpandListArgument(dirs, this->PkgsDirsVector); } + // Additional repositories dirs + this->RepoDirsVector.clear(); + if (const char* dirs = + this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) { + cmSystemTools::ExpandListArgument(dirs, this->RepoDirsVector); + } + // Installer this->Installer.Generator = this; this->Installer.ConfigureFromOptions(); @@ -305,16 +345,29 @@ int cmCPackIFWGenerator::InitializeInternal() } // Executable suffix - if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) { - this->ExecutableSuffix = optExeSuffix; - if (this->ExecutableSuffix.empty()) { - std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME")); - if (sysName == "Linux") { - this->ExecutableSuffix = ".run"; - } - } + std::string exeSuffix(this->GetOption("CMAKE_EXECUTABLE_SUFFIX")); + std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME")); + if (sysName == "Linux") { + this->ExecutableSuffix = ".run"; + } else if (sysName == "Windows") { + this->ExecutableSuffix = ".exe"; + } else if (sysName == "Darwin") { + this->ExecutableSuffix = ".app"; } else { - this->ExecutableSuffix = this->cmCPackGenerator::GetOutputExtension(); + this->ExecutableSuffix = exeSuffix; + } + + // Output extension + if (const char* optOutExt = + this->GetOption("CPACK_IFW_PACKAGE_FILE_EXTENSION")) { + this->OutputExtension = optOutExt; + } else if (sysName == "Darwin") { + this->OutputExtension = ".dmg"; + } else { + this->OutputExtension = this->ExecutableSuffix; + } + if (this->OutputExtension.empty()) { + this->OutputExtension = this->cmCPackGenerator::GetOutputExtension(); } return this->Superclass::InitializeInternal(); @@ -520,7 +573,7 @@ cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage( { std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit = this->GroupPackages.find(group); - return pit != this->GroupPackages.end() ? pit->second : CM_NULLPTR; + return pit != this->GroupPackages.end() ? pit->second : nullptr; } cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( @@ -528,7 +581,7 @@ cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( { std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit = this->ComponentPackages.find(component); - return pit != this->ComponentPackages.end() ? pit->second : CM_NULLPTR; + return pit != this->ComponentPackages.end() ? pit->second : nullptr; } cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( @@ -550,7 +603,7 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( } } else { this->Repositories.erase(repositoryName); - repository = CM_NULLPTR; + repository = nullptr; cmCPackIFWLogger(WARNING, "Invalid repository \"" << repositoryName << "\"" << " configuration. Repository will be skipped." diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 8348cee..9fd14bd 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -61,8 +61,8 @@ protected: const char* GetPackagingInstallPrefix() CM_OVERRIDE; /** - * @brief Extension of binary installer - * @return Executable suffix or value from default implementation + * @brief Target binary extension + * @return Executable suffix or disk image format */ const char* GetOutputExtension() CM_OVERRIDE; @@ -143,10 +143,12 @@ private: std::string BinCreator; std::string FrameworkVersion; std::string ExecutableSuffix; + std::string OutputExtension; bool OnlineOnly; bool ResolveDuplicateNames; std::vector<std::string> PkgsDirsVector; + std::vector<std::string> RepoDirsVector; }; #endif diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c5311c3..8461309 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -92,7 +92,7 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const //------------------------------------------------------ cmCPackIFWPackage --- cmCPackIFWPackage::cmCPackIFWPackage() - : Installer(CM_NULLPTR) + : Installer(nullptr) { } diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 0dcc74a..b050b85 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -72,7 +72,7 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char** atts) void cmWIXPatchParser::StartFragment(const char** attributes) { - cmWIXPatchElement* new_element = CM_NULLPTR; + cmWIXPatchElement* new_element = nullptr; /* find the id of for fragment */ for (size_t i = 0; attributes[i]; i += 2) { const std::string key = attributes[i]; diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 30df878..21be8ee 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -3,7 +3,7 @@ #ifndef cmWIXRichTextFormatWriter_h #define cmWIXRichTextFormatWriter_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/FStream.hxx" #include <string> diff --git a/Source/CPack/cmCPack7zGenerator.h b/Source/CPack/cmCPack7zGenerator.h index 42a4781..31c02a4 100644 --- a/Source/CPack/cmCPack7zGenerator.h +++ b/Source/CPack/cmCPack7zGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPack7zGenerator_h #define cmCPack7zGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 575c949..1e45b48 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -79,7 +79,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( ++fileIt) { std::string rp = filePrefix + *fileIt; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl); - archive.Add(rp, 0, CM_NULLPTR, false); + archive.Add(rp, 0, nullptr, false); if (!archive) { cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: " << archive.GetError() << std::endl); @@ -146,7 +146,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { + if (compIt->second.Group == nullptr) { cmCPackLogger( cmCPackLog::LOG_VERBOSE, "Component <" << compIt->second.Name @@ -255,7 +255,7 @@ int cmCPackArchiveGenerator::PackageFiles() // Get the relative path to the file std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str()); - archive.Add(rp, 0, CM_NULLPTR, false); + archive.Add(rp, 0, nullptr, false); if (!archive) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " << *fileIt << "> to archive <" << packageFileNames[0] diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index e7116c4..72ba1b2 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackArchiveGenerator_h #define cmCPackArchiveGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmArchiveWrite.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 861fe4b..e99bf43 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackBundleGenerator_h #define cmCPackBundleGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> @@ -21,7 +21,7 @@ public: cmCPackTypeMacro(cmCPackBundleGenerator, cmCPackDragNDropGenerator); cmCPackBundleGenerator(); - virtual ~cmCPackBundleGenerator(); + ~cmCPackBundleGenerator() CM_OVERRIDE; protected: int InitializeInternal() CM_OVERRIDE; diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index 26d69ba..f2907db 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -3,7 +3,7 @@ #ifndef cmCPackComponentGroup_h #define cmCPackComponentGroup_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -36,7 +36,7 @@ class cmCPackComponent { public: cmCPackComponent() - : Group(CM_NULLPTR) + : Group(nullptr) , IsRequired(true) , IsHidden(false) , IsDisabledByDefault(false) @@ -114,7 +114,7 @@ class cmCPackComponentGroup { public: cmCPackComponentGroup() - : ParentGroup(CM_NULLPTR) + : ParentGroup(nullptr) { } diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h index 58e80bd..b5a0531 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.h +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h @@ -17,7 +17,7 @@ public: * Construct generator */ cmCPackCygwinBinaryGenerator(); - virtual ~cmCPackCygwinBinaryGenerator(); + ~cmCPackCygwinBinaryGenerator() CM_OVERRIDE; protected: virtual int InitializeInternal(); diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h index 896de1d..d19f87c 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.h +++ b/Source/CPack/cmCPackCygwinSourceGenerator.h @@ -17,7 +17,7 @@ public: * Construct generator */ cmCPackCygwinSourceGenerator(); - virtual ~cmCPackCygwinSourceGenerator(); + ~cmCPackCygwinSourceGenerator() CM_OVERRIDE; protected: const char* GetPackagingInstallPrefix(); diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index af54fce..18d559e 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -6,28 +6,18 @@ #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" +#include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cm_sys_stat.h" #include "cmsys/Glob.hxx" -#include <limits.h> #include <map> #include <ostream> #include <set> -#include <stdio.h> #include <string.h> #include <utility> -// NOTE: -// A debian package .deb is simply an 'ar' archive. The only subtle difference -// is that debian uses the BSD ar style archive whereas most Linux distro have -// a GNU ar. -// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info -// Therefore we provide our own implementation of a BSD-ar: -static int ar_append(const char* archive, - const std::vector<std::string>& files); - cmCPackDebGenerator::cmCPackDebGenerator() { } @@ -128,7 +118,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { + if (compIt->second.Group == nullptr) { cmCPackLogger( cmCPackLog::LOG_VERBOSE, "Component <" << compIt->second.Name @@ -479,6 +469,25 @@ int cmCPackDebGenerator::createDeb() cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir << "\"" << std::endl); +#ifdef WIN32 + std::string mode_t_adt_filename = *fileIt + ":cmake_mode_t"; + cmsys::ifstream permissionStream(mode_t_adt_filename.c_str()); + + mode_t permissions = 0; + + if (permissionStream) { + permissionStream >> std::oct >> permissions; + } + + if (permissions != 0) { + data_tar.SetPermissions(permissions); + } else if (cmSystemTools::FileIsDirectory(*fileIt)) { + data_tar.SetPermissions(0755); + } else { + data_tar.ClearPermissions(); + } +#endif + // do not recurse because the loop will do it if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:" @@ -508,15 +517,13 @@ int cmCPackDebGenerator::createDeb() continue; } - char md5sum[33]; - if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) { + std::string output = + cmSystemTools::ComputeFileHash(*fileIt, cmCryptoHash::AlgoMD5); + if (output.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " << *fileIt << std::endl); } - md5sum[32] = 0; - - std::string output(md5sum); output += " " + *fileIt + "\n"; // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake @@ -553,8 +560,8 @@ int cmCPackDebGenerator::createDeb() and https://lintian.debian.org/tags/control-file-has-bad-permissions.html */ - const mode_t permission644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - const mode_t permissionExecute = S_IXUSR | S_IXGRP | S_IXOTH; + const mode_t permission644 = 0644; + const mode_t permissionExecute = 0111; const mode_t permission755 = permission644 | permissionExecute; // for md5sum and control (that we have generated here), we use 644 @@ -654,23 +661,25 @@ int cmCPackDebGenerator::createDeb() } // ar -r your-package-name.deb debian-binary control.tar.* data.tar.* - // since debian packages require BSD ar (most Linux distros and even - // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. - std::vector<std::string> arFiles; - std::string topLevelString = strGenWDIR + "/"; - arFiles.push_back(topLevelString + "debian-binary"); - arFiles.push_back(topLevelString + "control.tar.gz"); - arFiles.push_back(topLevelString + "data.tar" + compression_suffix); - std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - outputFileName += "/"; - outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); - int res = ar_append(outputFileName.c_str(), arFiles); - if (res != 0) { - std::string tmpFile = - this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME"); - tmpFile += "/Deb.log"; - cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Problem creating archive using: " << res << std::endl; + // A debian package .deb is simply an 'ar' archive. The only subtle + // difference is that debian uses the BSD ar style archive whereas most + // Linux distro have a GNU ar. + // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info + std::string const outputDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + std::string const outputName = this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); + std::string const outputPath = outputDir + "/" + outputName; + std::string const tlDir = strGenWDIR + "/"; + cmGeneratedFileStream debStream; + debStream.Open(outputPath.c_str(), false, true); + cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); + if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || + !deb.Add(tlDir + "control.tar.gz", tlDir.length()) || + !deb.Add(tlDir + "data.tar" + compression_suffix, tlDir.length())) { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating debian package:" + << std::endl + << "#top level directory: " << outputDir << std::endl + << "#file: " << outputName << std::endl + << "#error:" << deb.GetError() << std::endl); return 0; } return 1; @@ -695,252 +704,8 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (CM_NULLPTR != GetOption(groupVar)) { + if (nullptr != GetOption(groupVar)) { return std::string(GetOption(groupVar)); } return componentName; } - -// The following code is taken from OpenBSD ar: -// http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/ -// It has been slightly modified: -// -return error codes instead exit() in functions -// -use the stdio file I/O functions instead the file descriptor based ones -// -merged into one cxx file -// -no additional options supported -// The coding style hasn't been modified. - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define ARMAG "!<arch>\n" /* ar "magic number" */ -#define SARMAG 8 /* strlen(ARMAG); */ - -#define AR_EFMT1 "#1/" /* extended format #1 */ -#define ARFMAG "`\n" - -/* Header format strings. */ -#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s" -#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s" - -struct ar_hdr -{ - char ar_name[16]; /* name */ - char ar_date[12]; /* modification time */ - char ar_uid[6]; /* user id */ - char ar_gid[6]; /* group id */ - char ar_mode[8]; /* octal file permissions */ - char ar_size[10]; /* size in bytes */ - char ar_fmag[2]; /* consistency check */ -}; - -/* Set up file copy. */ -#define SETCF(from, fromname, to, toname, pad) \ - { \ - cf.rFile = from; \ - cf.rname = fromname; \ - cf.wFile = to; \ - cf.wname = toname; \ - cf.flags = pad; \ - } - -/* File copy structure. */ -typedef struct -{ - FILE* rFile; /* read file descriptor */ - const char* rname; /* read name */ - FILE* wFile; /* write file descriptor */ - const char* wname; /* write name */ -#define NOPAD 0x00 /* don't pad */ -#define WPAD 0x02 /* pad on writes */ - unsigned int flags; /* pad flags */ -} CF; - -/* misc.c */ - -static const char* ar_rname(const char* path) -{ - const char* ind = strrchr(path, '/'); - return (ind) ? ind + 1 : path; -} - -/* archive.c */ - -typedef struct ar_hdr HDR; -static char ar_hb[sizeof(HDR) + 1]; /* real header */ - -static size_t ar_already_written; - -/* copy_ar -- - * Copy size bytes from one file to another - taking care to handle the - * extra byte (for odd size files) when reading archives and writing an - * extra byte if necessary when adding files to archive. The length of - * the object is the long name plus the object itself; the variable - * already_written gets set if a long name was written. - * - * The padding is really unnecessary, and is almost certainly a remnant - * of early archive formats where the header included binary data which - * a PDP-11 required to start on an even byte boundary. (Or, perhaps, - * because 16-bit word addressed copies were faster?) Anyhow, it should - * have been ripped out long ago. - */ -static int copy_ar(CF* cfp, off_t size) -{ - static char pad = '\n'; - off_t sz = size; - size_t nr, nw; - char buf[8 * 1024]; - - if (sz == 0) { - return 0; - } - - FILE* from = cfp->rFile; - FILE* to = cfp->wFile; - while (sz && - (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf)) - ? static_cast<size_t>(sz) - : sizeof(buf), - from)) > 0) { - sz -= nr; - for (size_t off = 0; off < nr; nr -= off, off += nw) { - if ((nw = fwrite(buf + off, 1, nr, to)) < nr) { - return -1; - } - } - } - if (sz) { - return -2; - } - - if (cfp->flags & WPAD && (size + ar_already_written) & 1 && - fwrite(&pad, 1, 1, to) != 1) { - return -4; - } - - return 0; -} - -/* put_arobj -- Write an archive member to a file. */ -static int put_arobj(CF* cfp, struct stat* sb) -{ - int result = 0; - struct ar_hdr* hdr; - - /* If passed an sb structure, reading a file from disk. Get stat(2) - * information, build a name and construct a header. (Files are named - * by their last component in the archive.) */ - const char* name = ar_rname(cfp->rname); - (void)stat(cfp->rname, sb); - - /* If not truncating names and the name is too long or contains - * a space, use extended format 1. */ - size_t lname = strlen(name); - uid_t uid = sb->st_uid; - gid_t gid = sb->st_gid; - if (uid > USHRT_MAX) { - uid = USHRT_MAX; - } - if (gid > USHRT_MAX) { - gid = USHRT_MAX; - } - if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) { - (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, - (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode, - (long long)sb->st_size + lname, ARFMAG); - } else { - lname = 0; - (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid, - (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size, - ARFMAG); - } - off_t size = sb->st_size; - - if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) { - return -1; - } - - if (lname) { - if (fwrite(name, 1, lname, cfp->wFile) != lname) { - return -2; - } - ar_already_written = lname; - } - result = copy_ar(cfp, size); - ar_already_written = 0; - return result; -} - -/* append.c */ - -/* append -- - * Append files to the archive - modifies original archive or creates - * a new archive if named archive does not exist. - */ -static int ar_append(const char* archive, - const std::vector<std::string>& files) -{ - int eval = 0; - FILE* aFile = cmSystemTools::Fopen(archive, "wb+"); - if (aFile != CM_NULLPTR) { - fwrite(ARMAG, SARMAG, 1, aFile); - if (fseek(aFile, 0, SEEK_END) != -1) { - CF cf; - struct stat sb; - /* Read from disk, write to an archive; pad on write. */ - SETCF(CM_NULLPTR, CM_NULLPTR, aFile, archive, WPAD); - for (std::vector<std::string>::const_iterator fileIt = files.begin(); - fileIt != files.end(); ++fileIt) { - const char* filename = fileIt->c_str(); - FILE* file = cmSystemTools::Fopen(filename, "rb"); - if (file == CM_NULLPTR) { - eval = -1; - continue; - } - cf.rFile = file; - cf.rname = filename; - int result = put_arobj(&cf, &sb); - (void)fclose(file); - if (result != 0) { - eval = -2; - break; - } - } - } else { - eval = -3; - } - fclose(aFile); - } else { - eval = -4; - } - return eval; -} diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index e7cde11..21fc3be 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackDebGenerator_h #define cmCPackDebGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index d26d5bc..8758d32 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -448,6 +448,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*"); mountpoint_regex.find(attach_output.c_str()); std::string const temp_mount = mountpoint_regex.match(1); + std::string const temp_mount_name = + temp_mount.substr(sizeof("/Volumes/") - 1); // Remove dummy padding file so we have enough space on RW image ... std::ostringstream dummy_padding; @@ -481,7 +483,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::ostringstream setup_script_command; setup_script_command << "osascript" << " \"" << cpack_dmg_ds_store_setup_script << "\"" - << " \"" << cpack_dmg_volume_name << "\""; + << " \"" << temp_mount_name << "\""; std::string error; if (!this->RunCommand(setup_script_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index ae2cc17..4606c3c 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackDragNDropGenerator_h #define cmCPackDragNDropGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <sstream> #include <stddef.h> @@ -23,7 +23,7 @@ public: cmCPackTypeMacro(cmCPackDragNDropGenerator, cmCPackGenerator); cmCPackDragNDropGenerator(); - virtual ~cmCPackDragNDropGenerator(); + ~cmCPackDragNDropGenerator() CM_OVERRIDE; protected: int InitializeInternal() CM_OVERRIDE; @@ -40,8 +40,6 @@ protected: int CreateDMG(const std::string& src_dir, const std::string& output_file); - std::string InstallPrefix; - private: std::string slaDirectory; bool singleLicense; diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx new file mode 100644 index 0000000..ae17b79 --- /dev/null +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -0,0 +1,359 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCPackFreeBSDGenerator.h" + +#include "cmArchiveWrite.h" +#include "cmCPackArchiveGenerator.h" +#include "cmCPackLog.h" +#include "cmGeneratedFileStream.h" +#include "cmSystemTools.h" + +// Needed for ::open() and ::stat() +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + +#include <pkg.h> + +#include <algorithm> + +cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() + : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr") +{ +} + +int cmCPackFreeBSDGenerator::InitializeInternal() +{ + this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr/local"); + this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0"); + return this->Superclass::InitializeInternal(); +} + +cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() +{ +} + +// This is a wrapper, for use only in stream-based output, +// that will output a string in UCL escaped fashion (in particular, +// quotes and backslashes are escaped). The list of characters +// to escape is taken from https://github.com/vstakhov/libucl +// (which is the reference implementation pkg(8) refers to). +class EscapeQuotes +{ +public: + const std::string& value; + + EscapeQuotes(const std::string& s) + : value(s) + { + } +}; + +// Output a string as "string" with escaping applied. +cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s, + const EscapeQuotes& v) +{ + s << '"'; + for (std::string::size_type i = 0; i < v.value.length(); ++i) { + char c = v.value[i]; + switch (c) { + case '\n': + s << "\\n"; + break; + case '\r': + s << "\\r"; + break; + case '\b': + s << "\\b"; + break; + case '\t': + s << "\\t"; + break; + case '\f': + s << "\\f"; + break; + case '\\': + s << "\\\\"; + break; + case '"': + s << "\\\""; + break; + default: + s << c; + break; + } + } + s << '"'; + return s; +} + +// The following classes are all helpers for writing out the UCL +// manifest file (it also looks like JSON). ManifestKey just has +// a (string-valued) key; subclasses add a specific kind of +// value-type to the key, and implement write_value() to output +// the corresponding UCL. +class ManifestKey +{ +public: + std::string key; + + ManifestKey(const std::string& k) + : key(k) + { + } + + virtual ~ManifestKey() {} + + // Output the value associated with this key to the stream @p s. + // Format is to be decided by subclasses. + virtual void write_value(cmGeneratedFileStream& s) const = 0; +}; + +// Basic string-value (e.g. "name": "cmake") +class ManifestKeyValue : public ManifestKey +{ +public: + std::string value; + + ManifestKeyValue(const std::string& k, const std::string& v) + : ManifestKey(k) + , value(v) + { + } + + void write_value(cmGeneratedFileStream& s) const CM_OVERRIDE + { + s << EscapeQuotes(value); + } +}; + +// List-of-strings values (e.g. "licenses": ["GPLv2", "LGPLv2"]) +class ManifestKeyListValue : public ManifestKey +{ +public: + typedef std::vector<std::string> VList; + VList value; + + ManifestKeyListValue(const std::string& k) + : ManifestKey(k) + { + } + + ManifestKeyListValue& operator<<(const std::string& v) + { + value.push_back(v); + return *this; + } + + ManifestKeyListValue& operator<<(const std::vector<std::string>& v) + { + for (VList::const_iterator it = v.begin(); it != v.end(); ++it) { + (*this) << (*it); + } + return *this; + } + + void write_value(cmGeneratedFileStream& s) const CM_OVERRIDE + { + bool with_comma = false; + + s << '['; + for (VList::const_iterator it = value.begin(); it != value.end(); ++it) { + s << (with_comma ? ',' : ' '); + s << EscapeQuotes(*it); + with_comma = true; + } + s << " ]"; + } +}; + +// Deps: actually a dictionary, but we'll treat it as a +// list so we only name the deps, and produce dictionary- +// like output via write_value() +class ManifestKeyDepsValue : public ManifestKeyListValue +{ +public: + ManifestKeyDepsValue(const std::string& k) + : ManifestKeyListValue(k) + { + } + + void write_value(cmGeneratedFileStream& s) const CM_OVERRIDE + { + s << "{\n"; + for (VList::const_iterator it = value.begin(); it != value.end(); ++it) { + s << " \"" << *it << "\": {\"origin\": \"" << *it << "\"},\n"; + } + s << '}'; + } +}; + +// Write one of the key-value classes (above) to the stream @p s +cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s, + const ManifestKey& v) +{ + s << '"' << v.key << "\": "; + v.write_value(s); + s << ",\n"; + return s; +} + +// Look up variable; if no value is set, returns an empty string; +// basically a wrapper that handles the NULL-ptr return from GetOption(). +std::string cmCPackFreeBSDGenerator::var_lookup(const char* var_name) +{ + const char* pv = this->GetOption(var_name); + if (!pv) { + return std::string(); + } else { + return pv; + } +} + +// Produce UCL in the given @p manifest file for the common +// manifest fields (common to the compact and regular formats), +// by reading the CPACK_FREEBSD_* variables. +void cmCPackFreeBSDGenerator::write_manifest_fields( + cmGeneratedFileStream& manifest) +{ + manifest << ManifestKeyValue("name", + var_lookup("CPACK_FREEBSD_PACKAGE_NAME")); + manifest << ManifestKeyValue("origin", + var_lookup("CPACK_FREEBSD_PACKAGE_ORIGIN")); + manifest << ManifestKeyValue("version", + var_lookup("CPACK_FREEBSD_PACKAGE_VERSION")); + manifest << ManifestKeyValue("maintainer", + var_lookup("CPACK_FREEBSD_PACKAGE_MAINTAINER")); + manifest << ManifestKeyValue("comment", + var_lookup("CPACK_FREEBSD_PACKAGE_COMMENT")); + manifest << ManifestKeyValue( + "desc", var_lookup("CPACK_FREEBSD_PACKAGE_DESCRIPTION")); + manifest << ManifestKeyValue("www", var_lookup("CPACK_FREEBSD_PACKAGE_WWW")); + std::vector<std::string> licenses; + cmSystemTools::ExpandListArgument( + var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE"), licenses); + std::string licenselogic("single"); + if (licenses.size() < 1) { + cmSystemTools::SetFatalErrorOccured(); + } else if (licenses.size() > 1) { + licenselogic = var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE_LOGIC"); + } + manifest << ManifestKeyValue("licenselogic", licenselogic); + manifest << (ManifestKeyListValue("licenses") << licenses); + std::vector<std::string> categories; + cmSystemTools::ExpandListArgument( + var_lookup("CPACK_FREEBSD_PACKAGE_CATEGORIES"), categories); + manifest << (ManifestKeyListValue("categories") << categories); + manifest << ManifestKeyValue("prefix", var_lookup("CMAKE_INSTALL_PREFIX")); + std::vector<std::string> deps; + cmSystemTools::ExpandListArgument(var_lookup("CPACK_FREEBSD_PACKAGE_DEPS"), + deps); + if (deps.size() > 0) { + manifest << (ManifestKeyDepsValue("deps") << deps); + } +} + +// Package only actual files; others are ignored (in particular, +// intermediate subdirectories are ignored). +static bool ignore_file(const std::string& filename) +{ + struct stat statbuf; + + if (!((stat(filename.c_str(), &statbuf) >= 0) && + ((statbuf.st_mode & S_IFMT) == S_IFREG))) { + return true; + } + // May be other reasons to return false + return false; +} + +// Write the given list of @p files to the manifest stream @p s, +// as the UCL field "files" (which is dictionary-valued, to +// associate filenames with hashes). All the files are transformed +// to paths relative to @p toplevel, with a leading / (since the paths +// in FreeBSD package files are supposed to be absolute). +void write_manifest_files(cmGeneratedFileStream& s, + const std::string& toplevel, + const std::vector<std::string>& files) +{ + const char* c_toplevel = toplevel.c_str(); + std::vector<std::string>::const_iterator it; + + s << "\"files\": {\n"; + for (it = files.begin(); it != files.end(); ++it) { + s << " \"/" << cmSystemTools::RelativePath(c_toplevel, it->c_str()) + << "\": \"" + << "<sha256>" + << "\",\n"; + } + s << " },\n"; +} + +static bool has_suffix(const std::string& str, const std::string& suffix) +{ + return str.size() >= suffix.size() && + str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; +} + +int cmCPackFreeBSDGenerator::PackageFiles() +{ + if (!this->ReadListFile("CPackFreeBSD.cmake")) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackFreeBSD.cmake" << std::endl); + return 0; + } + + std::vector<std::string>::const_iterator fileIt; + std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(toplevel); + + files.erase(std::remove_if(files.begin(), files.end(), ignore_file), + files.end()); + + std::string manifestname = toplevel + "/+MANIFEST"; + { + cmGeneratedFileStream manifest(manifestname.c_str()); + manifest << "{\n"; + write_manifest_fields(manifest); + write_manifest_files(manifest, toplevel, files); + manifest << "}\n"; + } + + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); + + if (WantsComponentInstallation()) { + // CASE 1 : COMPONENT ALL-IN-ONE package + // If ALL COMPONENTS in ONE package has been requested + // then the package file is unique and should be open here. + if (componentPackageMethod == ONE_PACKAGE) { + return PackageComponentsAllInOne(); + } + // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) + // There will be 1 package for each component group + // however one may require to ignore component group and + // in this case you'll get 1 package for each component. + return PackageComponents(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); + } + + std::string output_dir = + cmSystemTools::CollapseCombinedPath(toplevel, "../"); + pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(), + manifestname.c_str(), NULL); + + std::string broken_suffix = std::string("-") + + var_lookup("CPACK_TOPLEVEL_TAG") + std::string(GetOutputExtension()); + for (std::vector<std::string>::iterator it = packageFileNames.begin(); + it != packageFileNames.end(); ++it) { + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << *it << std::endl); + if (has_suffix(*it, broken_suffix)) { + it->replace(it->size() - broken_suffix.size(), std::string::npos, + GetOutputExtension()); + break; + } + } + + cmSystemTools::ChangeDirectory(dir); + return 1; +} diff --git a/Source/CPack/cmCPackFreeBSDGenerator.h b/Source/CPack/cmCPackFreeBSDGenerator.h new file mode 100644 index 0000000..230f728 --- /dev/null +++ b/Source/CPack/cmCPackFreeBSDGenerator.h @@ -0,0 +1,37 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackFreeBSDGenerator_h +#define cmCPackFreeBSDGenerator_h + +#include <cmConfigure.h> + +#include "cmCPackArchiveGenerator.h" +#include "cmCPackGenerator.h" + +class cmGeneratedFileStream; + +/** \class cmCPackFreeBSDGenerator + * \brief A generator for FreeBSD package files (TXZ with a manifest) + * + */ +class cmCPackFreeBSDGenerator : public cmCPackArchiveGenerator +{ +public: + cmCPackTypeMacro(cmCPackFreeBSDGenerator, cmCPackArchiveGenerator); + /** + * Construct generator + */ + cmCPackFreeBSDGenerator(); + ~cmCPackFreeBSDGenerator() CM_OVERRIDE; + + int InitializeInternal() CM_OVERRIDE; + int PackageFiles() CM_OVERRIDE; + +protected: + const char* GetOutputExtension() CM_OVERRIDE { return ".txz"; } + + std::string var_lookup(const char* var_name); + void write_manifest_fields(cmGeneratedFileStream&); +}; + +#endif diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index d8e2753..b65eb64 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -28,14 +28,14 @@ cmCPackGenerator::cmCPackGenerator() { this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE; - this->MakefileMap = CM_NULLPTR; - this->Logger = CM_NULLPTR; + this->MakefileMap = nullptr; + this->Logger = nullptr; this->componentPackageMethod = ONE_PACKAGE_PER_GROUP; } cmCPackGenerator::~cmCPackGenerator() { - this->MakefileMap = CM_NULLPTR; + this->MakefileMap = nullptr; } void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr) @@ -156,7 +156,7 @@ int cmCPackGenerator::PrepareNames() } const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM"); if (algoSignature) { - if (cmCryptoHash::New(algoSignature).get() == CM_NULLPTR) { + if (cmCryptoHash::New(algoSignature).get() == nullptr) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: " << algoSignature << std::endl); return 0; @@ -256,7 +256,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( int retVal = 1; bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output, &output, &retVal, - CM_NULLPTR, this->GeneratorVerbose, 0); + nullptr, this->GeneratorVerbose, 0); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; @@ -820,8 +820,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } } - if (CM_NULLPTR != - mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { + if (nullptr != mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (!absoluteDestFiles.empty()) { absoluteDestFiles += ";"; } @@ -835,7 +834,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string absoluteDestFileComponent = std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + GetComponentInstallDirNameSuffix(installComponent); - if (CM_NULLPTR != this->GetOption(absoluteDestFileComponent)) { + if (nullptr != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = this->GetOption(absoluteDestFileComponent); absoluteDestFilesListComponent += ";"; @@ -1016,7 +1015,7 @@ int cmCPackGenerator::DoPackage() << packageFileName << " generated." << std::endl); /* Generate checksum file */ - if (crypto.get() != CM_NULLPTR) { + if (crypto.get() != nullptr) { std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); hashFile += "/" + filename.substr(0, filename.rfind(this->GetOutputExtension())); @@ -1225,7 +1224,7 @@ int cmCPackGenerator::PrepareGroupingKind() std::string groupingType; // Second way to specify grouping - if (CM_NULLPTR != this->GetOption("CPACK_COMPONENTS_GROUPING")) { + if (nullptr != this->GetOption("CPACK_COMPONENTS_GROUPING")) { groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING"); } @@ -1407,7 +1406,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( component->Group = GetComponentGroup(projectName, groupName); component->Group->Components.push_back(component); } else { - component->Group = CM_NULLPTR; + component->Group = nullptr; } const char* description = this->GetOption(macroPrefix + "_DESCRIPTION"); @@ -1475,7 +1474,7 @@ cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup( group->ParentGroup = GetComponentGroup(projectName, parentGroupName); group->ParentGroup->Subgroups.push_back(group); } else { - group->ParentGroup = CM_NULLPTR; + group->ParentGroup = nullptr; } } return group; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 45777fa..194d4e5 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackGenerator_h #define cmCPackGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <sstream> @@ -105,7 +105,7 @@ protected: cmInstalledFile const* GetInstalledFile(std::string const& name) const; virtual const char* GetOutputExtension() { return ".cpack"; } - virtual const char* GetOutputPostfix() { return CM_NULLPTR; } + virtual const char* GetOutputPostfix() { return nullptr; } /** * Prepare requested grouping kind from CPACK_xxx vars diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 31f48c7..4b81bbc 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -2,13 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackGeneratorFactory.h" -#include "cmConfigure.h" #include <ostream> #include <utility> #include "IFW/cmCPackIFWGenerator.h" #include "cmAlgorithms.h" #include "cmCPack7zGenerator.h" +#ifdef HAVE_FREEBSD_PKG +#include "cmCPackFreeBSDGenerator.h" +#endif +#include "cmCPackDebGenerator.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" @@ -34,7 +37,6 @@ #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ !defined(__HAIKU__) -#include "cmCPackDebGenerator.h" #include "cmCPackRPMGenerator.h" #endif @@ -99,6 +101,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("TZ", "Tar Compress compression", cmCPackTarCompressGenerator::CreateGenerator); } + if (cmCPackDebGenerator::CanGenerate()) { + this->RegisterGenerator("DEB", "Debian packages", + cmCPackDebGenerator::CreateGenerator); + } #ifdef __APPLE__ if (cmCPackDragNDropGenerator::CanGenerate()) { this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", @@ -123,15 +129,17 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() #endif #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ !defined(__HAIKU__) - if (cmCPackDebGenerator::CanGenerate()) { - this->RegisterGenerator("DEB", "Debian packages", - cmCPackDebGenerator::CreateGenerator); - } if (cmCPackRPMGenerator::CanGenerate()) { this->RegisterGenerator("RPM", "RPM packages", cmCPackRPMGenerator::CreateGenerator); } #endif +#ifdef HAVE_FREEBSD_PKG + if (cmCPackFreeBSDGenerator::CanGenerate()) { + this->RegisterGenerator("FREEBSD", "FreeBSD pkg(8) packages", + cmCPackFreeBSDGenerator::CreateGenerator); + } +#endif } cmCPackGeneratorFactory::~cmCPackGeneratorFactory() @@ -144,7 +152,7 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( { cmCPackGenerator* gen = this->NewGeneratorInternal(name); if (!gen) { - return CM_NULLPTR; + return nullptr; } this->Generators.push_back(gen); gen->SetLogger(this->Logger); @@ -157,7 +165,7 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it = this->GeneratorCreators.find(name); if (it == this->GeneratorCreators.end()) { - return CM_NULLPTR; + return nullptr; } return (it->second)(); } diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 5c71239..a3ca4b5 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackLog.h" -#include "cmConfigure.h" #include <iostream> #include "cmGeneratedFileStream.h" @@ -19,13 +18,13 @@ cmCPackLog::cmCPackLog() this->DefaultOutput = &std::cout; this->DefaultError = &std::cerr; - this->LogOutput = CM_NULLPTR; + this->LogOutput = nullptr; this->LogOutputCleanup = false; } cmCPackLog::~cmCPackLog() { - this->SetLogOutputStream(CM_NULLPTR); + this->SetLogOutputStream(nullptr); } void cmCPackLog::SetLogOutputStream(std::ostream* os) @@ -39,13 +38,13 @@ void cmCPackLog::SetLogOutputStream(std::ostream* os) bool cmCPackLog::SetLogOutputFile(const char* fname) { - cmGeneratedFileStream* cg = CM_NULLPTR; + cmGeneratedFileStream* cg = nullptr; if (fname) { cg = new cmGeneratedFileStream(fname); } if (cg && !*cg) { delete cg; - cg = CM_NULLPTR; + cg = nullptr; } this->SetLogOutputStream(cg); if (!cg) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 9697a38..d04ea13 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -222,7 +222,7 @@ int cmCPackNSISGenerator::PackageFiles() std::map<std::string, cmCPackComponentGroup>::iterator groupIt; for (groupIt = this->ComponentGroups.begin(); groupIt != this->ComponentGroups.end(); ++groupIt) { - if (groupIt->second.ParentGroup == CM_NULLPTR) { + if (groupIt->second.ParentGroup == nullptr) { componentCode += this->CreateComponentGroupDescription(&groupIt->second, macrosOut); } @@ -313,7 +313,7 @@ int cmCPackNSISGenerator::PackageFiles() int retVal = 1; bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal, - CM_NULLPTR, this->GeneratorVerbose, 0); + nullptr, this->GeneratorVerbose, 0); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Run command: " << nsisCmd << std::endl @@ -337,7 +337,7 @@ int cmCPackNSISGenerator::InitializeInternal() "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. " "This option will be reset to 0 (for this generator only)." << std::endl); - this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", CM_NULLPTR); + this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", nullptr); } cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()" @@ -412,7 +412,7 @@ int cmCPackNSISGenerator::InitializeInternal() int retVal = 1; bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal, - CM_NULLPTR, this->GeneratorVerbose, 0); + nullptr, this->GeneratorVerbose, 0); cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs"); if (!resS || retVal || diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 77be325..bdd1955 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackNSISGenerator_h #define cmCPackNSISGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 0eebc6d..0a1f686 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -3,7 +3,7 @@ #ifndef cmCPackOSXX11Generator_h #define cmCPackOSXX11Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> @@ -23,7 +23,7 @@ public: * Construct generator */ cmCPackOSXX11Generator(); - virtual ~cmCPackOSXX11Generator(); + ~cmCPackOSXX11Generator() CM_OVERRIDE; protected: virtual int InitializeInternal() CM_OVERRIDE; diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h index f873c59..aef795f 100644 --- a/Source/CPack/cmCPackPKGGenerator.h +++ b/Source/CPack/cmCPackPKGGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackPKGGenerator_h #define cmCPackPKGGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <sstream> @@ -27,7 +27,7 @@ public: * Construct generator */ cmCPackPKGGenerator(); - virtual ~cmCPackPKGGenerator(); + ~cmCPackPKGGenerator() CM_OVERRIDE; bool SupportsComponentInstallation() const CM_OVERRIDE; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 6274515..a2f58ff 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackPackageMakerGenerator_h #define cmCPackPackageMakerGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackGenerator.h" #include "cmCPackPKGGenerator.h" @@ -25,7 +25,7 @@ public: * Construct generator */ cmCPackPackageMakerGenerator(); - virtual ~cmCPackPackageMakerGenerator(); + ~cmCPackPackageMakerGenerator() CM_OVERRIDE; bool SupportsComponentInstallation() const CM_OVERRIDE; protected: diff --git a/Source/CPack/cmCPackProductBuildGenerator.h b/Source/CPack/cmCPackProductBuildGenerator.h index 12093a0..984dcaa 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.h +++ b/Source/CPack/cmCPackProductBuildGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackProductBuildGenerator_h #define cmCPackProductBuildGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> @@ -25,7 +25,7 @@ public: * Construct generator */ cmCPackProductBuildGenerator(); - virtual ~cmCPackProductBuildGenerator(); + ~cmCPackProductBuildGenerator() CM_OVERRIDE; protected: int InitializeInternal() CM_OVERRIDE; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 8ec03c2..e40b74d 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -148,7 +148,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { + if (compIt->second.Group == nullptr) { std::string component(compIt->first); std::transform(component.begin(), component.end(), component.begin(), ::toupper); @@ -214,7 +214,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { + if (compIt->second.Group == nullptr) { std::string component(compIt->first); std::transform(component.begin(), component.end(), component.begin(), ::toupper); @@ -299,7 +299,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { + if (compIt->second.Group == nullptr) { cmCPackLogger( cmCPackLog::LOG_VERBOSE, "Component <" << compIt->second.Name @@ -430,7 +430,7 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (CM_NULLPTR != GetOption(groupVar)) { + if (nullptr != GetOption(groupVar)) { return std::string(GetOption(groupVar)); } return componentName; diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 52cfc13..bfba289 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackRPMGenerator_h #define cmCPackRPMGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h index 8304e80..72f525c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackSTGZGenerator_h #define cmCPackSTGZGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackGenerator.h" #include "cmCPackTGZGenerator.h" diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h index 9426b3a..e904ab5 100644 --- a/Source/CPack/cmCPackTGZGenerator.h +++ b/Source/CPack/cmCPackTGZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTGZGenerator_h #define cmCPackTGZGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h index 3b96e2d..f38758d 100644 --- a/Source/CPack/cmCPackTXZGenerator.h +++ b/Source/CPack/cmCPackTXZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTXZGenerator_h #define cmCPackTXZGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h index 9b4b8f4..f3dd953 100644 --- a/Source/CPack/cmCPackTarBZip2Generator.h +++ b/Source/CPack/cmCPackTarBZip2Generator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTarBZip2Generator_h #define cmCPackTarBZip2Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTarCompressGenerator.h b/Source/CPack/cmCPackTarCompressGenerator.h index 381d6eb..8eedb24 100644 --- a/Source/CPack/cmCPackTarCompressGenerator.h +++ b/Source/CPack/cmCPackTarCompressGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTarCompressGenerator_h #define cmCPackTarCompressGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h index 00c8720..2f81c65 100644 --- a/Source/CPack/cmCPackZIPGenerator.h +++ b/Source/CPack/cmCPackZIPGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackZIPGenerator_h #define cmCPackZIPGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a44bc3d..9970721 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -1,6 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmConfigure.h" #include "cmsys/CommandLineArguments.hxx" #include "cmsys/Encoding.hxx" @@ -29,13 +28,13 @@ #include "cmake.h" static const char* cmDocumentationName[][2] = { - { CM_NULLPTR, " cpack - Packaging driver provided by CMake." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " cpack - Packaging driver provided by CMake." }, + { nullptr, nullptr } }; static const char* cmDocumentationUsage[][2] = { - { CM_NULLPTR, " cpack -G <generator> [options]" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " cpack -G <generator> [options]" }, + { nullptr, nullptr } }; static const char* cmDocumentationOptions[][2] = { @@ -49,7 +48,7 @@ static const char* cmDocumentationOptions[][2] = { { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" }, { "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" }, { "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; int cpackUnknownArgument(const char* /*unused*/, void* /*unused*/) @@ -208,7 +207,7 @@ int main(int argc, char const* const* argv) cmCPackGeneratorFactory generators; generators.SetLogger(&log); - cmCPackGenerator* cpackGenerator = CM_NULLPTR; + cmCPackGenerator* cpackGenerator = nullptr; cmDocumentation doc; doc.addCPackStandardDocSections(); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 94f39c2..4c9c5ca 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -136,13 +136,13 @@ std::string cmCTestBZR::LoadInfo() { // Run "bzr info" to get the repository info from the work tree. const char* bzr = this->CommandLineTool.c_str(); - const char* bzr_info[] = { bzr, "info", CM_NULLPTR }; + const char* bzr_info[] = { bzr, "info", nullptr }; InfoParser iout(this, "info-out> "); OutputLogger ierr(this->Log, "info-err> "); this->RunChild(bzr_info, &iout, &ierr); // Run "bzr revno" to get the repository revision number from the work tree. - const char* bzr_revno[] = { bzr, "revno", CM_NULLPTR }; + const char* bzr_revno[] = { bzr, "revno", nullptr }; std::string rev; RevnoParser rout(this, "revno-out> ", rev); OutputLogger rerr(this->Log, "revno-err> "); @@ -190,7 +190,7 @@ public: if (res) { XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser), cmBZRXMLParserUnknownEncodingHandler, - CM_NULLPTR); + nullptr); } return res; } @@ -380,7 +380,7 @@ bool cmCTestBZR::UpdateImpl() bzr_update.push_back(this->URL.c_str()); - bzr_update.push_back(CM_NULLPTR); + bzr_update.push_back(nullptr); // For some reason bzr uses stderr to display the update status. OutputLogger out(this->Log, "pull-out> "); @@ -408,8 +408,7 @@ bool cmCTestBZR::LoadRevisions() // Run "bzr log" to get all global revisions of interest. const char* bzr = this->CommandLineTool.c_str(); const char* bzr_log[] = { - bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), - CM_NULLPTR + bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), nullptr }; { LogParser out(this, "log-out> "); @@ -467,7 +466,7 @@ bool cmCTestBZR::LoadModifications() { // Run "bzr status" which reports local modifications. const char* bzr = this->CommandLineTool.c_str(); - const char* bzr_status[] = { bzr, "status", "-SV", CM_NULLPTR }; + const char* bzr_status[] = { bzr, "status", "-SV", nullptr }; StatusParser out(this, "status-out> "); OutputLogger err(this->Log, "status-err> "); this->RunChild(bzr_status, &out, &err); diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h index 2e8e88f..b313b25 100644 --- a/Source/CTest/cmCTestBZR.h +++ b/Source/CTest/cmCTestBZR.h @@ -3,7 +3,7 @@ #ifndef cmCTestBZR_h #define cmCTestBZR_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGlobalVC.h" diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h index 4a5dac1..3b58b13 100644 --- a/Source/CTest/cmCTestBatchTestHandler.h +++ b/Source/CTest/cmCTestBatchTestHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestBatchTestHandler_h #define cmCTestBatchTestHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestMultiProcessHandler.h" #include "cmsys/FStream.hxx" diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index cc29071..b6c25b8 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -65,7 +65,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, args.push_back(toolset); } - const char* config = CM_NULLPTR; + const char* config = nullptr; if (!this->CTest->GetConfigType().empty()) { config = this->CTest->GetConfigType().c_str(); } @@ -115,21 +115,21 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, void CMakeMessageCallback(const char* m, const char* /*unused*/, bool& /*unused*/, void* s) { - std::string* out = (std::string*)s; + std::string* out = reinterpret_cast<std::string*>(s); *out += m; *out += "\n"; } void CMakeProgressCallback(const char* msg, float /*unused*/, void* s) { - std::string* out = (std::string*)s; + std::string* out = reinterpret_cast<std::string*>(s); *out += msg; *out += "\n"; } void CMakeOutputCallback(const char* m, size_t len, void* s) { - std::string* out = (std::string*)s; + std::string* out = reinterpret_cast<std::string*>(s); out->append(m, len); } @@ -148,10 +148,10 @@ public: } ~cmCTestBuildAndTestCaptureRAII() { - this->CM.SetProgressCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetStderrCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetStdoutCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetMessageCallback(CM_NULLPTR, CM_NULLPTR); + this->CM.SetProgressCallback(nullptr, nullptr); + cmSystemTools::SetStderrCallback(nullptr, nullptr); + cmSystemTools::SetStdoutCallback(nullptr, nullptr); + cmSystemTools::SetMessageCallback(nullptr, nullptr); } }; @@ -236,7 +236,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } } std::string output; - const char* config = CM_NULLPTR; + const char* config = nullptr; if (!this->CTest->GetConfigType().empty()) { config = this->CTest->GetConfigType().c_str(); } @@ -308,7 +308,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) { testCommand.push_back(this->TestCommandArgs[k].c_str()); } - testCommand.push_back(CM_NULLPTR); + testCommand.push_back(nullptr); std::string outs; int retval = 0; // run the test from the this->BuildRunDir if set @@ -334,8 +334,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } } - int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, - CM_NULLPTR, remainingTime, CM_NULLPTR); + int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, nullptr, + remainingTime, nullptr); if (runTestRes != cmsysProcess_State_Exited || retval != 0) { out << "Test command failed: " << testCommand[0] << "\n"; diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index 2e85e9f..a0d3674 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestBuildAndTestHandler_h #define cmCTestBuildAndTestHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 4c82760..ce27da1 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -17,14 +17,14 @@ class cmExecutionStatus; cmCTestBuildCommand::cmCTestBuildCommand() { - this->GlobalGenerator = CM_NULLPTR; + this->GlobalGenerator = nullptr; this->Arguments[ctb_NUMBER_ERRORS] = "NUMBER_ERRORS"; this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS"; this->Arguments[ctb_TARGET] = "TARGET"; this->Arguments[ctb_CONFIGURATION] = "CONFIGURATION"; this->Arguments[ctb_FLAGS] = "FLAGS"; this->Arguments[ctb_PROJECT_NAME] = "PROJECT_NAME"; - this->Arguments[ctb_LAST] = CM_NULLPTR; + this->Arguments[ctb_LAST] = nullptr; this->Last = ctb_LAST; } @@ -32,7 +32,7 @@ cmCTestBuildCommand::~cmCTestBuildCommand() { if (this->GlobalGenerator) { delete this->GlobalGenerator; - this->GlobalGenerator = CM_NULLPTR; + this->GlobalGenerator = nullptr; } } @@ -41,9 +41,9 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build"); if (!handler) { this->SetError("internal CTest error. Cannot instantiate build handler"); - return CM_NULLPTR; + return nullptr; } - this->Handler = (cmCTestBuildHandler*)handler; + this->Handler = static_cast<cmCTestBuildHandler*>(handler); const char* ctestBuildCommand = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); @@ -89,7 +89,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() if (this->GlobalGenerator) { if (this->GlobalGenerator->GetName() != cmakeGeneratorName) { delete this->GlobalGenerator; - this->GlobalGenerator = CM_NULLPTR; + this->GlobalGenerator = nullptr; } } if (!this->GlobalGenerator) { @@ -102,11 +102,11 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() e += "\""; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e); cmSystemTools::SetFatalErrorOccured(); - return CM_NULLPTR; + return nullptr; } } if (strlen(cmakeBuildConfiguration) == 0) { - const char* config = CM_NULLPTR; + const char* config = nullptr; #ifdef CMAKE_INTDIR config = CMAKE_INTDIR; #endif @@ -143,7 +143,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() "with a custom command line."; /* clang-format on */ this->SetError(ostr.str()); - return CM_NULLPTR; + return nullptr; } } @@ -153,6 +153,12 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Quiet); } + if (const char* labelsForSubprojects = + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->CTest->SetCTestConfiguration("LabelsForSubprojects", + labelsForSubprojects, this->Quiet); + } + handler->SetQuiet(this->Quiet); return handler; } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 9cf6a96..f03bb2c 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestBuildCommand_h #define cmCTestBuildCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 18ef05c..3762e13 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -74,7 +74,7 @@ static const char* cmCTestErrorMatches[] = { "^The project cannot be built\\.", "^\\[ERROR\\]", "^Command .* failed with exit code", - CM_NULLPTR + nullptr }; static const char* cmCTestErrorExceptions[] = { @@ -89,7 +89,7 @@ static const char* cmCTestErrorExceptions[] = { ":[ \\t]+Where:", "([^ :]+):([0-9]+): Warning", "------ Build started: .* ------", - CM_NULLPTR + nullptr }; static const char* cmCTestWarningMatches[] = { @@ -114,7 +114,7 @@ static const char* cmCTestWarningMatches[] = { "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", "^CMake Warning.*:", "^\\[WARNING\\]", - CM_NULLPTR + nullptr }; static const char* cmCTestWarningExceptions[] = { @@ -134,7 +134,7 @@ static const char* cmCTestWarningExceptions[] = { "ld32: WARNING 85: definition of dataKey in", "cc: warning 422: Unknown option \"\\+b", "_with_warning_C", - CM_NULLPTR + nullptr }; struct cmCTestBuildCompileErrorWarningRex @@ -152,7 +152,7 @@ static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = { { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 }, { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 }, { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 }, - { CM_NULLPTR, 0, 0 } + { nullptr, 0, 0 } }; cmCTestBuildHandler::cmCTestBuildHandler() @@ -488,6 +488,7 @@ int cmCTestBuildHandler::ProcessHandler() void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml) { this->CTest->StartXML(xml, this->AppendXML); + this->CTest->GenerateSubprojectsOutput(xml); xml.StartElement("Build"); xml.Element("StartDateTime", this->StartBuild); xml.Element("StartBuildTime", @@ -503,7 +504,7 @@ public: { } FragmentCompare() - : FTC(CM_NULLPTR) + : FTC(nullptr) { } bool operator()(std::string const& l, std::string const& r) const @@ -780,7 +781,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, a != args.end(); ++a) { argv.push_back(a->c_str()); } - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:", this->Quiet); @@ -834,7 +835,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, // For every chunk of data int res; - while ((res = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR))) { + while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { // Replace '\0' with '\n', since '\0' does not really make sense. This is // for Visual Studio output for (int cc = 0; cc < length; ++cc) { @@ -865,9 +866,9 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, &this->BuildProcessingQueue); } - this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs, + this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs, &this->BuildProcessingQueue); - this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs, + this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs, &this->BuildProcessingErrorQueue); cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: " << ((this->BuildOutputLogSize + 512) / 1024) << "K" @@ -875,7 +876,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, this->Quiet); // Properly handle output of the build command - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); int result = cmsysProcess_GetState(cp); if (result == cmsysProcess_State_Exited) { diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index ef3cddf..ca11143 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestBuildHandler_h #define cmCTestBuildHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index fad360b..f2a9a85 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -96,7 +96,7 @@ bool cmCTestCVS::UpdateImpl() ai != args.end(); ++ai) { cvs_update.push_back(ai->c_str()); } - cvs_update.push_back(CM_NULLPTR); + cvs_update.push_back(nullptr); UpdateParser out(this, "up-out> "); UpdateParser err(this, "up-err> "); @@ -221,8 +221,9 @@ void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag, // Run "cvs log" to get revisions of this file on this branch. const char* cvs = this->CommandLineTool.c_str(); - const char* cvs_log[] = { cvs, "log", "-N", - branchFlag, file.c_str(), CM_NULLPTR }; + const char* cvs_log[] = { + cvs, "log", "-N", branchFlag, file.c_str(), nullptr + }; LogParser out(this, "log-out> ", revisions); OutputLogger err(this->Log, "log-err> "); diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h index 1208cfa..171460e 100644 --- a/Source/CTest/cmCTestCVS.h +++ b/Source/CTest/cmCTestCVS.h @@ -3,7 +3,7 @@ #ifndef cmCTestCVS_h #define cmCTestCVS_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestVC.h" diff --git a/Source/CTest/cmCTestCommand.h b/Source/CTest/cmCTestCommand.h index 6fc237a..8efb419 100644 --- a/Source/CTest/cmCTestCommand.h +++ b/Source/CTest/cmCTestCommand.h @@ -20,8 +20,8 @@ class cmCTestCommand : public cmCommand public: cmCTestCommand() { - this->CTest = CM_NULLPTR; - this->CTestScriptHandler = CM_NULLPTR; + this->CTest = nullptr; + this->CTestScriptHandler = nullptr; } cmCTest* CTest; diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 73e893d..faa75d3 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -16,7 +16,7 @@ cmCTestConfigureCommand::cmCTestConfigureCommand() { this->Arguments[ctc_OPTIONS] = "OPTIONS"; - this->Arguments[ctc_LAST] = CM_NULLPTR; + this->Arguments[ctc_LAST] = nullptr; this->Last = ctc_LAST; } @@ -33,7 +33,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() "Build directory not specified. Either use BUILD " "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " "variable"); - return CM_NULLPTR; + return nullptr; } const char* ctestConfigureCommand = @@ -53,7 +53,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() "Source directory not specified. Either use SOURCE " "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY " "variable"); - return CM_NULLPTR; + return nullptr; } const std::string cmakelists_file = source_dir + "/CMakeLists.txt"; @@ -61,7 +61,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() std::ostringstream e; e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]"; this->SetError(e.str()); - return CM_NULLPTR; + return nullptr; } bool multiConfig = false; @@ -88,9 +88,8 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmakeConfigureCommand += option; cmakeConfigureCommand += "\""; - if ((CM_NULLPTR != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) || - (CM_NULLPTR != - strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) { + if ((nullptr != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) || + (nullptr != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) { cmakeBuildTypeInOptions = true; } } @@ -137,16 +136,22 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() "Configure command is not specified. If this is a " "\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, " "set CTEST_CONFIGURE_COMMAND."); - return CM_NULLPTR; + return nullptr; } } + if (const char* labelsForSubprojects = + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->CTest->SetCTestConfiguration("LabelsForSubprojects", + labelsForSubprojects, this->Quiet); + } + cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("configure"); if (!handler) { this->SetError( "internal CTest error. Cannot instantiate configure handler"); - return CM_NULLPTR; + return nullptr; } handler->SetQuiet(this->Quiet); return handler; diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 917f5ab..dfb3a59 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestConfigureCommand_h #define cmCTestConfigureCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 5d87f3f..56a038e 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -73,6 +73,7 @@ int cmCTestConfigureHandler::ProcessHandler() if (os) { cmXMLWriter xml(os); this->CTest->StartXML(xml, this->AppendXML); + this->CTest->GenerateSubprojectsOutput(xml); xml.StartElement("Configure"); xml.Element("StartDateTime", start_time); xml.Element("StartConfigureTime", start_time_time); diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h index 2b45282..32a6ba7 100644 --- a/Source/CTest/cmCTestConfigureHandler.h +++ b/Source/CTest/cmCTestConfigureHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestConfigureHandler_h #define cmCTestConfigureHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 535da58..d2003ba 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -23,7 +23,7 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() this->CTest->GetInitializedHandler("coverage")); if (!handler) { this->SetError("internal CTest error. Cannot instantiate test handler"); - return CM_NULLPTR; + return nullptr; } // If a LABELS option was given, select only files with the labels. diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 78c4f61..9ea0223 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestCoverageCommand_h #define cmCTestCoverageCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 877cd24..e3d68c6 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -72,7 +72,7 @@ public: i != this->CommandLineStrings.end(); ++i) { args.push_back(i->c_str()); } - args.push_back(CM_NULLPTR); // null terminate + args.push_back(nullptr); // null terminate cmsysProcess_SetCommand(this->Process, &*args.begin()); if (!this->WorkingDirectory.empty()) { cmsysProcess_SetWorkingDirectory(this->Process, @@ -97,7 +97,7 @@ public: { cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDERR, fname); } - int WaitForExit(double* timeout = CM_NULLPTR) + int WaitForExit(double* timeout = nullptr) { this->PipeState = cmsysProcess_WaitForExit(this->Process, timeout); return this->PipeState; @@ -1759,7 +1759,7 @@ const char* bullseyeHelp[] = { " condition evaluated true or false, respectively.", " * A k indicates a constant decision or condition.", " * The slash / means this probe is excluded from summary results. ", - CM_NULLPTR + nullptr }; } @@ -1787,7 +1787,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "run covbr: " << std::endl, this->Quiet); - if (!this->RunBullseyeCommand(cont, "covbr", CM_NULLPTR, outputFile)) { + if (!this->RunBullseyeCommand(cont, "covbr", nullptr, outputFile)) { cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for." << "\n"); return -1; @@ -1860,7 +1860,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( covLogXML.StartElement("Report"); // write the bullseye header line = 0; - for (int k = 0; bullseyeHelp[k] != CM_NULLPTR; ++k) { + for (int k = 0; bullseyeHelp[k] != nullptr; ++k) { covLogXML.StartElement("Line"); covLogXML.Attribute("Number", line); covLogXML.Attribute("Count", -1); diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 933f606..83eb561 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestCoverageHandler_h #define cmCTestCoverageHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index b80ea5a..b175d44 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -5,7 +5,6 @@ #include "cmCTest.h" #include "cmSystemTools.h" -#include "cmConfigure.h" #include <ostream> #include <stdio.h> @@ -42,7 +41,7 @@ namespace { size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { - int realsize = (int)(size * nmemb); + int realsize = static_cast<int>(size * nmemb); std::vector<char>* vec = static_cast<std::vector<char>*>(data); const char* chPtr = static_cast<char*>(ptr); @@ -145,7 +144,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback); // Set Content-Type to satisfy fussy modsecurity rules. struct curl_slist* headers = - ::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml"); + ::curl_slist_append(nullptr, "Content-Type: text/xml"); // Add any additional headers that the user specified. for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin(); h != this->HttpHeaders.end(); ++h) { @@ -157,8 +156,8 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers); std::vector<char> responseData; std::vector<char> debugData; - ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData); - ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData); + ::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData); + ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData); ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1); // Now run off and do what you've been told! ::curl_easy_perform(this->Curl); @@ -207,12 +206,12 @@ bool cmCTestCurl::HttpRequest(std::string const& url, ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback); std::vector<char> responseData; std::vector<char> debugData; - ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData); - ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData); + ::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData); + ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData); ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1); // Add headers if any were specified. - struct curl_slist* headers = CM_NULLPTR; + struct curl_slist* headers = nullptr; if (!this->HttpHeaders.empty()) { for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin(); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 503ed23..9a8b735 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestEmptyBinaryDirectoryCommand_h #define cmCTestEmptyBinaryDirectoryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 230aedf..ed8d932 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -58,8 +58,8 @@ std::string cmCTestGIT::GetWorkingRevision() { // Run plumbing "git rev-list" to get work tree revision. const char* git = this->CommandLineTool.c_str(); - const char* git_rev_list[] = { git, "rev-list", "-n", "1", - "HEAD", "--", CM_NULLPTR }; + const char* git_rev_list[] = { git, "rev-list", "-n", "1", + "HEAD", "--", nullptr }; std::string rev; OneLineParser out(this, "rl-out> ", rev); OutputLogger err(this->Log, "rl-err> "); @@ -90,11 +90,11 @@ std::string cmCTestGIT::FindGitDir() // Run "git rev-parse --git-dir" to locate the real .git directory. const char* git = this->CommandLineTool.c_str(); - char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", CM_NULLPTR }; + char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", nullptr }; std::string git_dir_line; OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line); OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); - if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR, + if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, nullptr, cmProcessOutput::UTF8)) { git_dir = git_dir_line; } @@ -118,7 +118,7 @@ std::string cmCTestGIT::FindGitDir() 0 }; OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); OutputLogger cygpath_err(this->Log, "cygpath-err> "); - if (this->RunChild(cygpath, &cygpath_out, &cygpath_err, CM_NULLPTR, + if (this->RunChild(cygpath, &cygpath_out, &cygpath_err, nullptr, cmProcessOutput::UTF8)) { git_dir = git_dir_line; } @@ -134,12 +134,11 @@ std::string cmCTestGIT::FindTopDir() // Run "git rev-parse --show-cdup" to locate the top of the tree. const char* git = this->CommandLineTool.c_str(); - char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup", - CM_NULLPTR }; + char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup", nullptr }; std::string cdup; OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); - if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR, + if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, nullptr, cmProcessOutput::UTF8) && !cdup.empty()) { top_dir += "/"; @@ -170,7 +169,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() } // Sentinel argument. - git_fetch.push_back(CM_NULLPTR); + git_fetch.push_back(nullptr); // Fetch upstream refs. OutputLogger fetch_out(this->Log, "fetch-out> "); @@ -205,8 +204,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() } // Reset the local branch to point at that tracked from upstream. - char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(), - CM_NULLPTR }; + char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(), nullptr }; OutputLogger reset_out(this->Log, "reset-out> "); OutputLogger reset_err(this->Log, "reset-err> "); return this->RunChild(&git_reset[0], &reset_out, &reset_err); @@ -221,7 +219,7 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom) i != git_custom_command.end(); ++i) { git_custom.push_back(i->c_str()); } - git_custom.push_back(CM_NULLPTR); + git_custom.push_back(nullptr); OutputLogger custom_out(this->Log, "custom-out> "); OutputLogger custom_err(this->Log, "custom-err> "); @@ -250,7 +248,7 @@ bool cmCTestGIT::UpdateImpl() // Git < 1.6.5 did not support submodule --recursive if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) { - recursive = CM_NULLPTR; + recursive = nullptr; // No need to require >= 1.6.5 if there are no submodules. if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) { this->Log << "Git < 1.6.5 cannot update submodules recursively\n"; @@ -259,7 +257,7 @@ bool cmCTestGIT::UpdateImpl() // Git < 1.8.1 did not support sync --recursive if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) { - sync_recursive = CM_NULLPTR; + sync_recursive = nullptr; // No need to require >= 1.8.1 if there are no submodules. if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) { this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n"; @@ -274,8 +272,7 @@ bool cmCTestGIT::UpdateImpl() std::string init_submodules = this->CTest->GetCTestConfiguration("GITInitSubmodules"); if (cmSystemTools::IsOn(init_submodules.c_str())) { - char const* git_submodule_init[] = { git, "submodule", "init", - CM_NULLPTR }; + char const* git_submodule_init[] = { git, "submodule", "init", nullptr }; ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err, top_dir.c_str()); @@ -285,7 +282,7 @@ bool cmCTestGIT::UpdateImpl() } char const* git_submodule_sync[] = { git, "submodule", "sync", - sync_recursive, CM_NULLPTR }; + sync_recursive, nullptr }; ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err, top_dir.c_str()); @@ -294,7 +291,7 @@ bool cmCTestGIT::UpdateImpl() } char const* git_submodule[] = { git, "submodule", "update", recursive, - CM_NULLPTR }; + nullptr }; return this->RunChild(git_submodule, &submodule_out, &submodule_err, top_dir.c_str()); } @@ -303,7 +300,7 @@ unsigned int cmCTestGIT::GetGitVersion() { if (!this->CurrentGitVersion) { const char* git = this->CommandLineTool.c_str(); - char const* git_version[] = { git, "--version", CM_NULLPTR }; + char const* git_version[] = { git, "--version", nullptr }; std::string version; OneLineParser version_out(this, "version-out> ", version); OutputLogger version_err(this->Log, "version-err> "); @@ -513,8 +510,8 @@ private: const char* email_last = *c ? c++ : c; person.EMail.assign(email_first, email_last - email_first); - person.Time = strtoul(c, (char**)&c, 10); - person.TimeZone = strtol(c, (char**)&c, 10); + person.Time = strtoul(c, const_cast<char**>(&c), 10); + person.TimeZone = strtol(c, const_cast<char**>(&c), 10); } bool ProcessLine() CM_OVERRIDE @@ -615,10 +612,10 @@ bool cmCTestGIT::LoadRevisions() std::string range = this->OldRevision + ".." + this->NewRevision; const char* git = this->CommandLineTool.c_str(); const char* git_rev_list[] = { git, "rev-list", "--reverse", - range.c_str(), "--", CM_NULLPTR }; + range.c_str(), "--", nullptr }; const char* git_diff_tree[] = { git, "diff-tree", "--stdin", "--always", "-z", - "-r", "--pretty=raw", "--encoding=utf-8", CM_NULLPTR + "-r", "--pretty=raw", "--encoding=utf-8", nullptr }; this->Log << this->ComputeCommandLine(git_rev_list) << " | " << this->ComputeCommandLine(git_diff_tree) << "\n"; @@ -645,19 +642,18 @@ bool cmCTestGIT::LoadModifications() // Use 'git update-index' to refresh the index w.r.t. the work tree. const char* git_update_index[] = { git, "update-index", "--refresh", - CM_NULLPTR }; + nullptr }; OutputLogger ui_out(this->Log, "ui-out> "); OutputLogger ui_err(this->Log, "ui-err> "); - this->RunChild(git_update_index, &ui_out, &ui_err, CM_NULLPTR, + this->RunChild(git_update_index, &ui_out, &ui_err, nullptr, cmProcessOutput::UTF8); // Use 'git diff-index' to get modified files. const char* git_diff_index[] = { git, "diff-index", "-z", - "HEAD", "--", CM_NULLPTR }; + "HEAD", "--", nullptr }; DiffParser out(this, "di-out> "); OutputLogger err(this->Log, "di-err> "); - this->RunChild(git_diff_index, &out, &err, CM_NULLPTR, - cmProcessOutput::UTF8); + this->RunChild(git_diff_index, &out, &err, nullptr, cmProcessOutput::UTF8); for (std::vector<Change>::const_iterator ci = out.Changes.begin(); ci != out.Changes.end(); ++ci) { diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h index 4bf8294..222bc50 100644 --- a/Source/CTest/cmCTestGIT.h +++ b/Source/CTest/cmCTestGIT.h @@ -3,7 +3,7 @@ #ifndef cmCTestGIT_h #define cmCTestGIT_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGlobalVC.h" diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 19034c0..53a4018 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGenericHandler.h" -#include "cmConfigure.h" #include <sstream> #include <utility> @@ -12,7 +11,7 @@ cmCTestGenericHandler::cmCTestGenericHandler() { this->HandlerVerbose = cmSystemTools::OUTPUT_NONE; - this->CTest = CM_NULLPTR; + this->CTest = nullptr; this->SubmitIndex = 0; this->AppendXML = false; this->Quiet = false; @@ -70,7 +69,7 @@ const char* cmCTestGenericHandler::GetOption(const std::string& op) cmCTestGenericHandler::t_StringToString::iterator remit = this->Options.find(op); if (remit == this->Options.end()) { - return CM_NULLPTR; + return nullptr; } return remit->second.c_str(); } diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index a5273d3..b4bf077 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -3,7 +3,7 @@ #ifndef cmCTestGlobalVC_h #define cmCTestGlobalVC_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestVC.h" diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 49f9a65..7bf5b67 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -96,7 +96,7 @@ std::string cmCTestHG::GetWorkingRevision() { // Run plumbing "hg identify" to get work tree revision. const char* hg = this->CommandLineTool.c_str(); - const char* hg_identify[] = { hg, "identify", "-i", CM_NULLPTR }; + const char* hg_identify[] = { hg, "identify", "-i", nullptr }; std::string rev; IdentifyParser out(this, "rev-out> ", rev); OutputLogger err(this->Log, "rev-err> "); @@ -126,7 +126,7 @@ bool cmCTestHG::UpdateImpl() // Use "hg pull" followed by "hg update" to update the working tree. { const char* hg = this->CommandLineTool.c_str(); - const char* hg_pull[] = { hg, "pull", "-v", CM_NULLPTR }; + const char* hg_pull[] = { hg, "pull", "-v", nullptr }; OutputLogger out(this->Log, "pull-out> "); OutputLogger err(this->Log, "pull-err> "); this->RunChild(&hg_pull[0], &out, &err); @@ -151,7 +151,7 @@ bool cmCTestHG::UpdateImpl() } // Sentinel argument. - hg_update.push_back(CM_NULLPTR); + hg_update.push_back(nullptr); OutputLogger out(this->Log, "update-out> "); OutputLogger err(this->Log, "update-err> "); @@ -286,7 +286,7 @@ bool cmCTestHG::LoadRevisions() "</logentry>\n"; const char* hg_log[] = { hg, "log", "--removed", "-r", range.c_str(), - "--template", hgXMLTemplate, CM_NULLPTR + "--template", hgXMLTemplate, nullptr }; LogParser out(this, "log-out> "); @@ -302,7 +302,7 @@ bool cmCTestHG::LoadModifications() { // Use 'hg status' to get modified files. const char* hg = this->CommandLineTool.c_str(); - const char* hg_status[] = { hg, "status", CM_NULLPTR }; + const char* hg_status[] = { hg, "status", nullptr }; StatusParser out(this, "status-out> "); OutputLogger err(this->Log, "status-err> "); this->RunChild(hg_status, &out, &err); diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h index ec9eaff..90c38dc 100644 --- a/Source/CTest/cmCTestHG.h +++ b/Source/CTest/cmCTestHG.h @@ -3,7 +3,7 @@ #ifndef cmCTestHG_h #define cmCTestHG_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGlobalVC.h" diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index c99e450..9266d1f 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -20,7 +20,7 @@ cmCTestHandlerCommand::cmCTestHandlerCommand() size_t cc; this->Arguments.reserve(INIT_SIZE); for (cc = 0; cc < INIT_SIZE; ++cc) { - this->Arguments.push_back(CM_NULLPTR); + this->Arguments.push_back(nullptr); } this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE"; this->Arguments[ct_CAPTURE_CMAKE_ERROR] = "CAPTURE_CMAKE_ERROR"; @@ -89,7 +89,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, SaveRestoreErrorState errorState; // Allocate space for argument values. this->Values.clear(); - this->Values.resize(this->Last, CM_NULLPTR); + this->Values.resize(this->Last, nullptr); // Process input arguments. this->ArgumentDoing = ArgumentDoingNone; diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h index 0ea0612..b838074 100644 --- a/Source/CTest/cmCTestHandlerCommand.h +++ b/Source/CTest/cmCTestHandlerCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestHandlerCommand_h #define cmCTestHandlerCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 5b21351..041cc92 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestLaunch.h" -#include "cmConfigure.h" - #include "cmsys/FStream.hxx" #include "cmsys/Process.h" #include "cmsys/RegularExpression.hxx" @@ -31,7 +29,7 @@ cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv) { this->Passthru = true; - this->Process = CM_NULLPTR; + this->Process = nullptr; this->ExitCode = 1; this->CWD = cmSystemTools::GetCurrentWorkingDirectory(); @@ -129,7 +127,7 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) return true; } this->RealArgC = 0; - this->RealArgV = CM_NULLPTR; + this->RealArgV = nullptr; std::cerr << "No launch/command separator ('--') found!\n"; return false; } @@ -224,11 +222,11 @@ void cmCTestLaunch::RunChild() // Record child stdout and stderr if necessary. if (!this->Passthru) { - char* data = CM_NULLPTR; + char* data = nullptr; int length = 0; cmProcessOutput processOutput; std::string strdata; - while (int p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + while (int p = cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { if (p == cmsysProcess_Pipe_STDOUT) { processOutput.DecodeText(data, length, strdata, 1); fout.write(strdata.c_str(), strdata.size()); @@ -254,7 +252,7 @@ void cmCTestLaunch::RunChild() } // Wait for the real command to finish. - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); this->ExitCode = cmsysProcess_GetExitValue(cp); } @@ -396,7 +394,7 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml) } // OutputType - const char* outputType = CM_NULLPTR; + const char* outputType = nullptr; if (!this->OptionTargetType.empty()) { if (this->OptionTargetType == "EXECUTABLE") { outputType = "executable"; @@ -508,7 +506,11 @@ void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname) if (MatchesFilterPrefix(line)) { continue; } - + if (this->Match(line, this->RegexWarningSuppress)) { + line = "[CTest: warning suppressed] " + line; + } else if (this->Match(line, this->RegexWarning)) { + line = "[CTest: warning matched] " + line; + } xml.Content(sep); xml.Content(line); sep = "\n"; diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index b9cae3b..a5d5995 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -14,7 +14,7 @@ cmCTestMemCheckCommand::cmCTestMemCheckCommand() { this->Arguments[ctm_DEFECT_COUNT] = "DEFECT_COUNT"; - this->Arguments[ctm_LAST] = CM_NULLPTR; + this->Arguments[ctm_LAST] = nullptr; this->Last = ctm_LAST; } diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index fa59559..aaa8c6b 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestMemCheckCommand_h #define cmCTestMemCheckCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestTestCommand.h" diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index c35f0bc..7d11550 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -28,12 +28,12 @@ static CatToErrorType cmCTestMemCheckBoundsChecker[] = { { "Allocation Conflict", cmCTestMemCheckHandler::FMM }, { "Bad Pointer Use", cmCTestMemCheckHandler::FMW }, { "Dangling Pointer", cmCTestMemCheckHandler::FMR }, - { CM_NULLPTR, 0 } + { nullptr, 0 } }; static void xmlReportError(int line, const char* msg, void* data) { - cmCTest* ctest = (cmCTest*)data; + cmCTest* ctest = reinterpret_cast<cmCTest*>(data); cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line " << line << ": " << msg << std::endl); } @@ -45,7 +45,7 @@ public: cmBoundsCheckerParser(cmCTest* c) { this->CTest = c; - this->SetErrorCallback(xmlReportError, (void*)c); + this->SetErrorCallback(xmlReportError, c); } void StartElement(const std::string& name, const char** atts) CM_OVERRIDE { @@ -58,7 +58,7 @@ public: std::ostringstream ostr; ostr << name << ":\n"; int i = 0; - for (; atts[i] != CM_NULLPTR; i += 2) { + for (; atts[i] != nullptr; i += 2) { ostr << " " << atts[i] << " - " << atts[i + 1] << "\n"; } ostr << "\n"; @@ -69,12 +69,12 @@ public: const char* GetAttribute(const char* name, const char** atts) { int i = 0; - for (; atts[i] != CM_NULLPTR; ++i) { + for (; atts[i] != nullptr; ++i) { if (strcmp(name, atts[i]) == 0) { return atts[i + 1]; } } - return CM_NULLPTR; + return nullptr; } void ParseError(const char** atts) { @@ -228,9 +228,9 @@ void cmCTestMemCheckHandler::InitializeResultsVectors() // define the standard set of errors //---------------------------------------------------------------------- static const char* cmCTestMemCheckResultStrings[] = { - "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM", - "FMR", "FMW", "FUM", "IPR", "IPW", "MAF", "MLK", "MPK", - "NPR", "ODS", "PAR", "PLK", "UMC", "UMR", CM_NULLPTR + "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM", + "FMR", "FMW", "FUM", "IPR", "IPW", "MAF", "MLK", "MPK", + "NPR", "ODS", "PAR", "PLK", "UMC", "UMR", nullptr }; static const char* cmCTestMemCheckResultLongStrings[] = { "Threading Problem", @@ -255,10 +255,10 @@ void cmCTestMemCheckHandler::InitializeResultsVectors() "PLK", "Uninitialized Memory Conditional", "Uninitialized Memory Read", - CM_NULLPTR + nullptr }; this->GlobalResults.clear(); - for (int i = 0; cmCTestMemCheckResultStrings[i] != CM_NULLPTR; ++i) { + for (int i = 0; cmCTestMemCheckResultStrings[i] != nullptr; ++i) { this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]); this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]); this->GlobalResults.push_back(0); @@ -291,6 +291,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) return; } this->CTest->StartXML(xml, this->AppendXML); + this->CTest->GenerateSubprojectsOutput(xml); xml.StartElement("DynamicAnalysis"); switch (this->MemoryTesterStyle) { case cmCTestMemCheckHandler::VALGRIND: diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 333c2e2..1228c42 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestMemCheckHandler_h #define cmCTestMemCheckHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestTestHandler.h" diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index c802216..ab057ad 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -155,7 +155,7 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) p4_users.push_back("-m"); p4_users.push_back("1"); p4_users.push_back(username.c_str()); - p4_users.push_back(CM_NULLPTR); + p4_users.push_back(nullptr); UserParser out(this, "users-out> "); OutputLogger err(this->Log, "users-err> "); @@ -350,7 +350,7 @@ std::string cmCTestP4::GetWorkingRevision() std::string source = this->SourceDirectory + "/...#have"; p4_identify.push_back(source.c_str()); - p4_identify.push_back(CM_NULLPTR); + p4_identify.push_back(nullptr); std::string rev; IdentifyParser out(this, "p4_changes-out> ", rev); @@ -411,7 +411,7 @@ bool cmCTestP4::LoadRevisions() p4_changes.push_back("changes"); p4_changes.push_back(range.c_str()); - p4_changes.push_back(CM_NULLPTR); + p4_changes.push_back(nullptr); ChangesParser out(this, "p4_changes-out> "); OutputLogger err(this->Log, "p4_changes-err> "); @@ -431,7 +431,7 @@ bool cmCTestP4::LoadRevisions() p4_describe.push_back("describe"); p4_describe.push_back("-s"); p4_describe.push_back(i->c_str()); - p4_describe.push_back(CM_NULLPTR); + p4_describe.push_back(nullptr); DescribeParser outDescribe(this, "p4_describe-out> "); OutputLogger errDescribe(this->Log, "p4_describe-err> "); @@ -451,7 +451,7 @@ bool cmCTestP4::LoadModifications() p4_diff.push_back("-dn"); std::string source = this->SourceDirectory + "/..."; p4_diff.push_back(source.c_str()); - p4_diff.push_back(CM_NULLPTR); + p4_diff.push_back(nullptr); DiffParser out(this, "p4_diff-out> "); OutputLogger err(this->Log, "p4_diff-err> "); @@ -469,7 +469,7 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) i != p4_custom_command.end(); ++i) { p4_custom.push_back(i->c_str()); } - p4_custom.push_back(CM_NULLPTR); + p4_custom.push_back(nullptr); OutputLogger custom_out(this->Log, "p4_customsync-out> "); OutputLogger custom_err(this->Log, "p4_customsync-err> "); @@ -520,7 +520,7 @@ bool cmCTestP4::UpdateImpl() } p4_sync.push_back(source.c_str()); - p4_sync.push_back(CM_NULLPTR); + p4_sync.push_back(nullptr); OutputLogger out(this->Log, "p4_sync-out> "); OutputLogger err(this->Log, "p4_sync-err> "); diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h index e234efb..faeeaf2 100644 --- a/Source/CTest/cmCTestP4.h +++ b/Source/CTest/cmCTestP4.h @@ -3,7 +3,7 @@ #ifndef cmCTestP4_h #define cmCTestP4_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGlobalVC.h" diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index 5989fa0..157710a 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestReadCustomFilesCommand_h #define cmCTestReadCustomFilesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 9bd0965..9821c2e 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestRunScriptCommand_h #define cmCTestRunScriptCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 0c4269e..1a339b7 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -9,7 +9,6 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" -#include "cmConfigure.h" #include "cm_curl.h" #include "cm_zlib.h" #include "cmsys/Base64.h" @@ -25,12 +24,12 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler) { this->CTest = handler->CTest; this->TestHandler = handler; - this->TestProcess = CM_NULLPTR; + this->TestProcess = nullptr; this->TestResult.ExecutionTime = 0; this->TestResult.ReturnValue = 0; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; this->TestResult.TestCount = 0; - this->TestResult.Properties = CM_NULLPTR; + this->TestResult.Properties = nullptr; this->ProcessOutput = ""; this->CompressedOutput = ""; this->CompressionRatio = 2; @@ -237,6 +236,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) } else if (res == cmsysProcess_State_Exception) { outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: "); + this->TestResult.ExceptionStatus = + this->TestProcess->GetExitExceptionString(); switch (this->TestProcess->GetExitException()) { case cmsysProcess_Exception_Fault: cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault"); @@ -255,7 +256,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) this->TestResult.Status = cmCTestTestHandler::NUMERICAL; break; default: - cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, + this->TestResult.ExceptionStatus); this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT; } } else if ("Disabled" == this->TestResult.CompletionStatus) { @@ -618,7 +620,7 @@ double cmCTestRunTest::ResolveTimeout() return timeout; } struct tm* lctime; - time_t current_time = time(CM_NULLPTR); + time_t current_time = time(nullptr); lctime = gmtime(¤t_time); int gm_hour = lctime->tm_hour; time_t gm_time = mktime(lctime); diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index f60f78c..36582a2 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -290,7 +290,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, args.push_back(i->c_str()); } - args.push_back(CM_NULLPTR); + args.push_back(nullptr); if (strcmp(parameters[0], "update") == 0) { return RunUpdateCommand(&args[0], out, err); diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index 46b0778..94af837 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -3,7 +3,7 @@ #ifndef cmCTestSVN_h #define cmCTestSVN_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGlobalVC.h" diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 1d29dfa..6fd24a5 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -75,9 +75,9 @@ cmCTestScriptHandler::cmCTestScriptHandler() this->Backup = false; this->EmptyBinDir = false; this->EmptyBinDirOnce = false; - this->Makefile = CM_NULLPTR; - this->CMake = CM_NULLPTR; - this->GlobalGenerator = CM_NULLPTR; + this->Makefile = nullptr; + this->CMake = nullptr; + this->GlobalGenerator = nullptr; this->ScriptStartTime = 0; @@ -114,10 +114,10 @@ void cmCTestScriptHandler::Initialize() this->ScriptStartTime = 0; delete this->Makefile; - this->Makefile = CM_NULLPTR; + this->Makefile = nullptr; delete this->GlobalGenerator; - this->GlobalGenerator = CM_NULLPTR; + this->GlobalGenerator = nullptr; delete this->CMake; } @@ -193,7 +193,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) for (size_t i = 1; i < initArgs.size(); ++i) { argv.push_back(initArgs[i].c_str()); } - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); // Now create process object cmsysProcess* cp = cmsysProcess_New(); @@ -219,7 +219,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) } // Properly handle output of the build command - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); int result = cmsysProcess_GetState(cp); int retVal = 0; bool failed = false; @@ -394,7 +394,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) return 0; } -// extract variabels from the script to set ivars +// extract variables from the script to set ivars int cmCTestScriptHandler::ExtractVariables() { // Temporary variables @@ -852,7 +852,7 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory, return false; } - if (text != CM_NULLPTR) { + if (text != nullptr) { fout.write(text, strlen(text)); } diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 6678702..c2631ce 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestScriptHandler_h #define cmCTestScriptHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index f0b5f1e..ade9c96 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestSleepCommand_h #define cmCTestSleepCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 01a874b..4f0d87b 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -29,12 +29,12 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, size_t cnt = 0; const char* smodel = args[cnt].c_str(); - const char* src_dir = CM_NULLPTR; - const char* bld_dir = CM_NULLPTR; + const char* src_dir = nullptr; + const char* bld_dir = nullptr; cnt++; - this->CTest->SetSpecificTrack(CM_NULLPTR); + this->CTest->SetSpecificTrack(nullptr); if (cnt < args.size() - 1) { if (args[cnt] == "TRACK") { cnt++; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index b4943f9..2e02838 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestStartCommand_h #define cmCTestStartCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 409eb51..1794ca6 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -86,7 +86,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() extraFiles.end()); if (!this->CTest->SubmitExtraFiles(newExtraFiles)) { this->SetError("problem submitting extra files."); - return CM_NULLPTR; + return nullptr; } } @@ -94,7 +94,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->CTest->GetInitializedHandler("submit"); if (!handler) { this->SetError("internal CTest error. Cannot instantiate submit handler"); - return CM_NULLPTR; + return nullptr; } // If no FILES or PARTS given, *all* PARTS are submitted by default. diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index cf65cdc..44f0d68 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestSubmitCommand_h #define cmCTestSubmitCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTest.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 8d62fa1..b7d0d1f 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -13,6 +13,7 @@ #include "cmCTest.h" #include "cmCTestCurl.h" #include "cmCTestScriptHandler.h" +#include "cmCryptoHash.h" #include "cmCurl.h" #include "cmGeneratedFileStream.h" #include "cmProcessOutput.h" @@ -99,7 +100,7 @@ private: static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { - int realsize = (int)(size * nmemb); + int realsize = static_cast<int>(size * nmemb); cmCTestSubmitHandlerVectorOfChar* vec = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data); @@ -144,7 +145,7 @@ void cmCTestSubmitHandler::Initialize() this->HTTPProxyAuth = ""; this->FTPProxy = ""; this->FTPProxyType = 0; - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; this->Files.clear(); } @@ -238,8 +239,8 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunkDebug; - ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk); - ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug); + ::curl_easy_setopt(curl, CURLOPT_FILE, &chunk); + ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); // Now run off and do what you've been told! res = ::curl_easy_perform(curl); @@ -303,7 +304,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, char error_buffer[1024]; // Set Content-Type to satisfy fussy modsecurity rules. struct curl_slist* headers = - ::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml"); + ::curl_slist_append(nullptr, "Content-Type: text/xml"); // Add any additional headers that the user specified. for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin(); @@ -412,7 +413,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, case ' ': case '=': case '%': - sprintf(hexCh, "%%%02X", (int)c); + sprintf(hexCh, "%%%02X", static_cast<int>(c)); ofile.append(hexCh); break; default: @@ -428,10 +429,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) { upload_as += "bad_md5sum"; } else { - char md5[33]; - cmSystemTools::ComputeFileMD5(local_file, md5); - md5[32] = 0; - upload_as += md5; + upload_as += + cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5); } if (!cmSystemTools::FileExists(local_file.c_str())) { @@ -472,8 +471,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunkDebug; - ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk); - ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug); + ::curl_easy_setopt(curl, CURLOPT_FILE, &chunk); + ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); // Now run off and do what you've been told! res = ::curl_easy_perform(curl); @@ -496,10 +495,10 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, // If curl failed for any reason, or checksum fails, wait and retry // if (res != CURLE_OK || this->HasErrors) { - std::string retryDelay = this->GetOption("RetryDelay") == CM_NULLPTR + std::string retryDelay = this->GetOption("RetryDelay") == nullptr ? "" : this->GetOption("RetryDelay"); - std::string retryCount = this->GetOption("RetryCount") == CM_NULLPTR + std::string retryCount = this->GetOption("RetryCount") == nullptr ? "" : this->GetOption("RetryCount"); @@ -668,8 +667,8 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files, /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunkDebug; - ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk); - ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug); + ::curl_easy_setopt(curl, CURLOPT_FILE, &chunk); + ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); std::string ofile; @@ -687,7 +686,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files, case ' ': case '=': case '%': - sprintf(hexCh, "%%%02X", (int)c); + sprintf(hexCh, "%%%02X", static_cast<int>(c)); ofile.append(hexCh); break; default: @@ -765,7 +764,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, argv.push_back(scp_command.c_str()); // Scp command argv.push_back(scp_command.c_str()); // Dummy string for file argv.push_back(scp_command.c_str()); // Dummy string for remote url - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); @@ -798,7 +797,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, cmProcessOutput processOutput; std::string strdata; - while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { processOutput.DecodeText(data, length, strdata); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(strdata.c_str(), strdata.size()), @@ -811,7 +810,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, this->Quiet); } - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); int result = cmsysProcess_GetState(cp); @@ -949,8 +948,9 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC( char remoteCommand[] = "Submit.put"; char* pRealURL = const_cast<char*>(realURL.c_str()); - result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)", - fileBuffer, (xmlrpc_int32)fileSize); + result = + xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)", fileBuffer, + static_cast<xmlrpc_int32>(fileSize)); delete[] fileBuffer; @@ -1037,10 +1037,10 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, bool internalTest = cmSystemTools::IsOn(this->GetOption("InternalTest")); // Get RETRY_COUNT and RETRY_DELAY values if they were set. - std::string retryDelayString = this->GetOption("RetryDelay") == CM_NULLPTR + std::string retryDelayString = this->GetOption("RetryDelay") == nullptr ? "" : this->GetOption("RetryDelay"); - std::string retryCountString = this->GetOption("RetryCount") == CM_NULLPTR + std::string retryCountString = this->GetOption("RetryCount") == nullptr ? "" : this->GetOption("RetryCount"); unsigned long retryDelay = 0; @@ -1058,9 +1058,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, } } - char md5sum[33]; - md5sum[32] = 0; - cmSystemTools::ComputeFileMD5(file, md5sum); + std::string md5sum = + cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); // 1. request the buildid and check to see if the file // has already been uploaded // TODO I added support for subproject. You would need to add @@ -1084,8 +1083,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&" << "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&" - << "starttime=" << (int)cmSystemTools::GetTime() << "&" - << "endtime=" << (int)cmSystemTools::GetTime() << "&" + << "starttime=" << static_cast<int>(cmSystemTools::GetTime()) << "&" + << "endtime=" << static_cast<int>(cmSystemTools::GetTime()) << "&" << "datafilesmd5[0]=" << md5sum << "&" << "type=" << curl.Escape(typeString); std::string fields = str.str(); diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 2923f4f..7b409fb 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestSubmitHandler_h #define cmCTestSubmitHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTest.h" #include "cmCTestGenericHandler.h" @@ -25,7 +25,7 @@ public: typedef cmCTestGenericHandler Superclass; cmCTestSubmitHandler(); - ~cmCTestSubmitHandler() CM_OVERRIDE { this->LogFile = CM_NULLPTR; } + ~cmCTestSubmitHandler() CM_OVERRIDE { this->LogFile = nullptr; } /* * The main entry point for this class diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 075b140..febd39e 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -27,7 +27,7 @@ cmCTestTestCommand::cmCTestTestCommand() this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM"; this->Arguments[ctt_STOP_TIME] = "STOP_TIME"; this->Arguments[ctt_TEST_LOAD] = "TEST_LOAD"; - this->Arguments[ctt_LAST] = CM_NULLPTR; + this->Arguments[ctt_LAST] = nullptr; this->Last = ctt_LAST; } @@ -124,6 +124,12 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } handler->SetTestLoad(testLoad); + if (const char* labelsForSubprojects = + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->CTest->SetCTestConfiguration("LabelsForSubprojects", + labelsForSubprojects, this->Quiet); + } + handler->SetQuiet(this->Quiet); return handler; } diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index be7e783..e8c8c60 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestTestCommand_h #define cmCTestTestCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 674be60..57075c7 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1,12 +1,10 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" - -#include "cmsys/Base64.h" -#include "cmsys/Directory.hxx" -#include "cmsys/FStream.hxx" -#include "cmsys/RegularExpression.hxx" #include <algorithm> +#include <cmsys/Base64.h> +#include <cmsys/Directory.hxx> +#include <cmsys/RegularExpression.hxx> #include <functional> #include <iomanip> #include <iterator> @@ -33,6 +31,7 @@ #include "cm_auto_ptr.hxx" #include "cm_utf8.h" #include "cmake.h" +#include "cmsys/FStream.hxx" class cmExecutionStatus; @@ -238,6 +237,36 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass( return this->TestHandler->SetTestsProperties(args); } +class cmCTestSetDirectoryPropertiesCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + cmCommand* Clone() CM_OVERRIDE + { + cmCTestSetDirectoryPropertiesCommand* c = + new cmCTestSetDirectoryPropertiesCommand; + c->TestHandler = this->TestHandler; + return c; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + bool InitialPass(std::vector<std::string> const& /*unused*/, + cmExecutionStatus& /*unused*/) CM_OVERRIDE; + + cmCTestTestHandler* TestHandler; +}; + +bool cmCTestSetDirectoryPropertiesCommand::InitialPass( + std::vector<std::string> const& args, cmExecutionStatus&) +{ + return this->TestHandler->SetDirectoryProperties(args); +} + // get the next number in a string with numbers separated by , // pos is the start of the search and pos2 is the end of the search // pos becomes pos2 after a call to GetNextNumber. @@ -305,7 +334,7 @@ cmCTestTestHandler::cmCTestTestHandler() this->MemCheck = false; - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; // regex to detect <DartMeasurement>...</DartMeasurement> this->DartStuff.compile("(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)"); @@ -506,11 +535,16 @@ int cmCTestTestHandler::ProcessHandler() << static_cast<int>(percent + .5f) << "% tests passed, " << failed.size() << " tests failed out of " << total << std::endl); - if (this->CTest->GetLabelSummary()) { + + if (!this->CTest->GetLabelsForSubprojects().empty() && + this->CTest->GetSubprojectSummary()) { + this->PrintSubprojectSummary(); + } else if (this->CTest->GetLabelSummary()) { this->PrintLabelSummary(); } + char realBuf[1024]; - sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start)); + sprintf(realBuf, "%6.2f sec", clock_finish - clock_start); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = " << realBuf << "\n", this->Quiet); @@ -549,10 +583,10 @@ int cmCTestTestHandler::ProcessHandler() !cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") && ftit->CompletionStatus != "Disabled") { ofs << ftit->TestCount << ":" << ftit->Name << std::endl; - cmCTestLog( - this->CTest, HANDLER_OUTPUT, "\t" - << std::setw(3) << ftit->TestCount << " - " << ftit->Name << " (" - << this->GetTestStatus(ftit->Status) << ")" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" + << std::setw(3) << ftit->TestCount << " - " + << ftit->Name << " (" << this->GetTestStatus(&*ftit) + << ")" << std::endl); } } } @@ -566,7 +600,7 @@ int cmCTestTestHandler::ProcessHandler() cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create " << (this->MemCheck ? "memory check" : "testing") << " XML file" << std::endl); - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; return 1; } cmXMLWriter xml(xmlfile); @@ -574,15 +608,15 @@ int cmCTestTestHandler::ProcessHandler() } if (!this->PostProcessHandler()) { - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; return -1; } if (!failed.empty()) { - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; return -1; } - this->LogFile = CM_NULLPTR; + this->LogFile = nullptr; return 0; } @@ -658,6 +692,84 @@ void cmCTestTestHandler::PrintLabelSummary() } } +void cmCTestTestHandler::PrintSubprojectSummary() +{ + std::vector<std::string> subprojects = + this->CTest->GetLabelsForSubprojects(); + + cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); + std::map<std::string, double> labelTimes; + std::map<std::string, int> labelCounts; + std::set<std::string> labels; + // initialize maps + std::string::size_type maxlen = 0; + for (; it != this->TestList.end(); ++it) { + cmCTestTestProperties& p = *it; + for (std::vector<std::string>::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) { + std::vector<std::string>::iterator subproject = + std::find(subprojects.begin(), subprojects.end(), *l); + if (subproject != subprojects.end()) { + if ((*l).size() > maxlen) { + maxlen = (*l).size(); + } + labels.insert(*l); + labelTimes[*l] = 0; + labelCounts[*l] = 0; + } + } + } + cmCTestTestHandler::TestResultsVector::iterator ri = + this->TestResults.begin(); + // fill maps + for (; ri != this->TestResults.end(); ++ri) { + cmCTestTestResult& result = *ri; + cmCTestTestProperties& p = *result.Properties; + for (std::vector<std::string>::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) { + std::vector<std::string>::iterator subproject = + std::find(subprojects.begin(), subprojects.end(), *l); + if (subproject != subprojects.end()) { + labelTimes[*l] += result.ExecutionTime; + ++labelCounts[*l]; + } + } + } + // now print times + if (!labels.empty()) { + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + "\nSubproject Time Summary:", this->Quiet); + } + for (std::set<std::string>::const_iterator i = labels.begin(); + i != labels.end(); ++i) { + std::string label = *i; + label.resize(maxlen + 3, ' '); + + char buf[1024]; + sprintf(buf, "%6.2f sec", labelTimes[*i]); + + std::ostringstream labelCountStr; + labelCountStr << "(" << labelCounts[*i] << " test"; + if (labelCounts[*i] > 1) { + labelCountStr << "s"; + } + labelCountStr << ")"; + + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n" + << label << " = " << buf << " " + << labelCountStr.str(), + this->Quiet); + if (this->LogFile) { + *this->LogFile << "\n" << *i << " = " << buf << "\n"; + } + } + if (!labels.empty()) { + if (this->LogFile) { + *this->LogFile << "\n"; + } + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet); + } +} void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) { // if not using Labels to filter then return @@ -739,7 +851,7 @@ void cmCTestTestHandler::ComputeTestList() } // expand the test list based on the union flag if (this->UseUnion) { - this->ExpandTestsToRunInformation((int)tmsize); + this->ExpandTestsToRunInformation(static_cast<int>(tmsize)); } else { this->ExpandTestsToRunInformation(inREcnt); } @@ -1215,7 +1327,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, bool randomSchedule = this->CTest->GetScheduleType() == "Random"; if (randomSchedule) { - srand((unsigned)time(CM_NULLPTR)); + srand(static_cast<unsigned>(time(nullptr))); } for (ListOfTests::iterator it = this->TestList.begin(); @@ -1277,6 +1389,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) } this->CTest->StartXML(xml, this->AppendXML); + this->CTest->GenerateSubprojectsOutput(xml); xml.StartElement("Testing"); xml.Element("StartDateTime", this->StartTest); xml.Element("StartTestTime", this->StartTestTime); @@ -1299,7 +1412,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("NamedMeasurement"); xml.Attribute("type", "text/string"); xml.Attribute("name", "Exit Code"); - xml.Element("Value", this->GetTestStatus(result->Status)); + xml.Element("Value", this->GetTestStatus(result)); xml.EndElement(); // NamedMeasurement xml.StartElement("NamedMeasurement"); @@ -1328,6 +1441,12 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) } xml.StartElement("NamedMeasurement"); + xml.Attribute("type", "numeric/double"); + xml.Attribute("name", "Processors"); + xml.Element("Value", result->Properties->Processors); + xml.EndElement(); // NamedMeasurement + + xml.StartElement("NamedMeasurement"); xml.Attribute("type", "text/string"); xml.Attribute("name", "Completion Status"); xml.Element("Value", result->CompletionStatus); @@ -1437,8 +1556,8 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) int retVal = 0; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl, this->Quiet); - if (!cmSystemTools::RunSingleCommand(it->c_str(), CM_NULLPTR, CM_NULLPTR, - &retVal, CM_NULLPTR, + if (!cmSystemTools::RunSingleCommand(it->c_str(), nullptr, nullptr, + &retVal, nullptr, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0) { @@ -1660,6 +1779,12 @@ void cmCTestTestHandler::GetListOfTests() newCom4->TestHandler = this; cm.GetState()->AddBuiltinCommand("set_tests_properties", newCom4); + // Add handler for SET_DIRECTORY_PROPERTIES + cmCTestSetDirectoryPropertiesCommand* newCom5 = + new cmCTestSetDirectoryPropertiesCommand; + newCom5->TestHandler = this; + cm.GetState()->AddBuiltinCommand("set_directory_properties", newCom5); + const char* testFilename; if (cmSystemTools::FileExists("CTestTestfile.cmake")) { // does the CTestTestfile.cmake exist ? @@ -1693,17 +1818,20 @@ void cmCTestTestHandler::UseExcludeRegExp() this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag; } -const char* cmCTestTestHandler::GetTestStatus(int status) +const char* cmCTestTestHandler::GetTestStatus(const cmCTestTestResult* result) { static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT", "ILLEGAL", "INTERRUPT", "NUMERICAL", "OTHER_FAULT", "Failed", "BAD_COMMAND", "Completed" }; - + int status = result->Status; if (status < cmCTestTestHandler::NOT_RUN || status > cmCTestTestHandler::COMPLETED) { return "No Status"; } + if (status == cmCTestTestHandler::OTHER_FAULT) { + return result->ExceptionStatus.c_str(); + } return statuses[status]; } @@ -2171,7 +2299,16 @@ bool cmCTestTestHandler::SetTestsProperties( cmSystemTools::ExpandListArgument(val, rtit->Environment); } if (key == "LABELS") { - cmSystemTools::ExpandListArgument(val, rtit->Labels); + std::vector<std::string> Labels; + cmSystemTools::ExpandListArgument(val, Labels); + rtit->Labels.insert(rtit->Labels.end(), Labels.begin(), + Labels.end()); + // sort the array + std::sort(rtit->Labels.begin(), rtit->Labels.end()); + // remove duplicates + std::vector<std::string>::iterator new_end = + std::unique(rtit->Labels.begin(), rtit->Labels.end()); + rtit->Labels.erase(new_end, rtit->Labels.end()); } if (key == "MEASUREMENT") { size_t pos = val.find_first_of('='); @@ -2224,6 +2361,54 @@ bool cmCTestTestHandler::SetTestsProperties( return true; } +bool cmCTestTestHandler::SetDirectoryProperties( + const std::vector<std::string>& args) +{ + std::vector<std::string>::const_iterator it; + std::vector<std::string> tests; + bool found = false; + for (it = args.begin(); it != args.end(); ++it) { + if (*it == "PROPERTIES") { + found = true; + break; + } + tests.push_back(*it); + } + + if (!found) { + return false; + } + ++it; // skip PROPERTIES + for (; it != args.end(); ++it) { + std::string key = *it; + ++it; + if (it == args.end()) { + break; + } + std::string val = *it; + cmCTestTestHandler::ListOfTests::iterator rtit; + for (rtit = this->TestList.begin(); rtit != this->TestList.end(); ++rtit) { + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + if (cwd == rtit->Directory) { + if (key == "LABELS") { + std::vector<std::string> DirectoryLabels; + cmSystemTools::ExpandListArgument(val, DirectoryLabels); + rtit->Labels.insert(rtit->Labels.end(), DirectoryLabels.begin(), + DirectoryLabels.end()); + + // sort the array + std::sort(rtit->Labels.begin(), rtit->Labels.end()); + // remove duplicates + std::vector<std::string>::iterator new_end = + std::unique(rtit->Labels.begin(), rtit->Labels.end()); + rtit->Labels.erase(new_end, rtit->Labels.end()); + } + } + } + } + return true; +} + bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) { const std::string& testname = args[0]; diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 0edcb14..d8627b1 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestTestHandler_h #define cmCTestTestHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" @@ -90,6 +90,11 @@ public: */ bool SetTestsProperties(const std::vector<std::string>& args); + /** + * Set directory properties + */ + bool SetDirectoryProperties(const std::vector<std::string>& args); + void Initialize() CM_OVERRIDE; // NOTE: This struct is Saved/Restored @@ -144,6 +149,7 @@ public: double ExecutionTime; int ReturnValue; int Status; + std::string ExceptionStatus; bool CompressOutput; std::string CompletionStatus; std::string Output; @@ -227,6 +233,8 @@ private: virtual void GenerateDartOutput(cmXMLWriter& xml); void PrintLabelSummary(); + void PrintSubprojectSummary(); + /** * Run the tests for a directory and any subdirectories */ @@ -262,7 +270,7 @@ private: */ std::string FindTheExecutable(const char* exe); - const char* GetTestStatus(int status); + const char* GetTestStatus(const cmCTestTestResult*); void ExpandTestsToRunInformation(size_t numPossibleTests); void ExpandTestsToRunInformationForRerunFailed(); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 8c03754..3d800f8 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -78,12 +78,12 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->CTest->GetInitializedHandler("update"); if (!handler) { this->SetError("internal CTest error. Cannot instantiate update handler"); - return CM_NULLPTR; + return nullptr; } handler->SetCommand(this); if (source_dir.empty()) { this->SetError("source directory not specified. Please use SOURCE tag"); - return CM_NULLPTR; + return nullptr; } handler->SetOption("SourceDirectory", source_dir.c_str()); handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 3b8f0a6..ac8e85c 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestUpdateCommand_h #define cmCTestUpdateCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index e08a9b7..0504f90 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -309,7 +309,7 @@ bool cmCTestUpdateHandler::SelectVCS() // If no update command was specified, lookup one for this VCS tool. if (this->UpdateCommand.empty()) { - const char* key = CM_NULLPTR; + const char* key = nullptr; switch (this->UpdateType) { case e_CVS: key = "CVSCommand"; diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 0cd2844..5e7237c 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestUpdateHandler_h #define cmCTestUpdateHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 717117a..d85f35f 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -18,7 +18,7 @@ cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() this->CTest->GetInitializedHandler("upload"); if (!handler) { this->SetError("internal CTest error. Cannot instantiate upload handler"); - return CM_NULLPTR; + return nullptr; } static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files); diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 6e72179..e8e882f 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestUploadCommand_h #define cmCTestUploadCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTest.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h index 1e8d3c8..3dc9c10 100644 --- a/Source/CTest/cmCTestUploadHandler.h +++ b/Source/CTest/cmCTestUploadHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestUploadHandler_h #define cmCTestUploadHandler_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index fb2742e..186d2d4 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -60,7 +60,7 @@ bool cmCTestVC::InitialCheckout(const char* command) ai != args.end(); ++ai) { vc_co.push_back(ai->c_str()); } - vc_co.push_back(CM_NULLPTR); + vc_co.push_back(nullptr); // Run the initial checkout command and log its output. this->Log << "--- Begin Initial Checkout ---\n"; @@ -113,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out, } // Run the command. - return this->RunChild(cmd, out, err, CM_NULLPTR, encoding); + return this->RunChild(cmd, out, err, nullptr, encoding); } std::string cmCTestVC::GetNightlyTime() diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index 6400bcd..69a3bf0 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -3,7 +3,7 @@ #ifndef cmCTestVC_h #define cmCTestVC_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> @@ -100,8 +100,8 @@ protected: Revision const* PriorRev; File() : Status(PathUpdated) - , Rev(CM_NULLPTR) - , PriorRev(CM_NULLPTR) + , Rev(nullptr) + , PriorRev(nullptr) { } File(PathStatus status, Revision const* rev, Revision const* priorRev) @@ -117,12 +117,12 @@ protected: /** Run a command line and send output to given parsers. */ bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err, - const char* workDir = CM_NULLPTR, + const char* workDir = nullptr, Encoding encoding = cmProcessOutput::Auto); /** Run VC update command line and send output to given parsers. */ bool RunUpdateCommand(char const* const* cmd, OutputParser* out, - OutputParser* err = CM_NULLPTR, + OutputParser* err = nullptr, Encoding encoding = cmProcessOutput::Auto); /** Write xml element for one file. */ diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h index 005d272..7b0442a 100644 --- a/Source/CTest/cmParseCacheCoverage.h +++ b/Source/CTest/cmParseCacheCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseCacheCoverage_h #define cmParseCacheCoverage_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmParseMumpsCoverage.h" diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index ba55cd7..4a16a48 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -5,7 +5,6 @@ #include "cmSystemTools.h" #include "cmXMLParser.h" -#include "cmConfigure.h" #include "cmsys/FStream.hxx" #include <stdlib.h> #include <string.h> diff --git a/Source/CTest/cmParseGTMCoverage.h b/Source/CTest/cmParseGTMCoverage.h index c4949d4..81766f9 100644 --- a/Source/CTest/cmParseGTMCoverage.h +++ b/Source/CTest/cmParseGTMCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseGTMCoverage_h #define cmParseGTMCoverage_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmParseMumpsCoverage.h" diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index d15864a..6d884ef 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -1,7 +1,5 @@ #include "cmParseJacocoCoverage.h" -#include "cmConfigure.h" - #include "cmCTest.h" #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index eb29f55..8cb1170 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -4,7 +4,6 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include "cmConfigure.h" #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include <map> @@ -135,8 +134,8 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine, return true; } // try some alternate names - const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR }; - for (int k = 0; tryname[k] != CM_NULLPTR; k++) { + const char* tryname[] = { "GUX", "GTM", "ONT", nullptr }; + for (int k = 0; tryname[k] != nullptr; k++) { std::string routine2 = routine + tryname[k]; i = this->RoutineToDirectory.find(routine2); if (i != this->RoutineToDirectory.end()) { diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index f4ec6da..5ada25d 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -2,14 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcess.h" -#include "cmConfigure.h" #include "cmProcessOutput.h" #include "cmSystemTools.h" #include <iostream> cmProcess::cmProcess() { - this->Process = CM_NULLPTR; + this->Process = nullptr; this->Timeout = 0; this->TotalTime = 0; this->ExitValue = 0; @@ -45,7 +44,7 @@ bool cmProcess::StartProcess() i != this->Arguments.end(); ++i) { this->ProcessArgs.push_back(i->c_str()); } - this->ProcessArgs.push_back(CM_NULLPTR); // null terminate the list + this->ProcessArgs.push_back(nullptr); // null terminate the list this->Process = cmsysProcess_New(); cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin()); if (!this->WorkingDirectory.empty()) { @@ -240,3 +239,8 @@ int cmProcess::GetExitException() { return cmsysProcess_GetExitException(this->Process); } + +std::string cmProcess::GetExitExceptionString() +{ + return cmsysProcess_GetExceptionString(this->Process); +} diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index 86e905a..dfb02fe 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -38,6 +38,7 @@ public: int GetExitValue() { return this->ExitValue; } double GetTotalTime() { return this->TotalTime; } int GetExitException(); + std::string GetExitExceptionString(); /** * Read one line of output but block for no more than timeout. * Returns: diff --git a/Source/Checks/cm_cxx_attribute_fallthrough.cxx b/Source/Checks/cm_cxx_attribute_fallthrough.cxx index df43625..50605b7 100644 --- a/Source/Checks/cm_cxx_attribute_fallthrough.cxx +++ b/Source/Checks/cm_cxx_attribute_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_fallthrough.cxx b/Source/Checks/cm_cxx_fallthrough.cxx index 7b35a5f..2825bed 100644 --- a/Source/Checks/cm_cxx_fallthrough.cxx +++ b/Source/Checks/cm_cxx_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 3b08025..7f2b8a0 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -51,8 +51,5 @@ cm_check_cxx_feature(make_unique) if(CMake_HAVE_CXX_MAKE_UNIQUE) set(CMake_HAVE_CXX_UNIQUE_PTR 1) endif() -cm_check_cxx_feature(nullptr) cm_check_cxx_feature(override) cm_check_cxx_feature(unique_ptr) -cm_check_cxx_feature(unordered_map) -cm_check_cxx_feature(unordered_set) diff --git a/Source/Checks/cm_cxx_gnu_fallthrough.cxx b/Source/Checks/cm_cxx_gnu_fallthrough.cxx index 6021094..ebc15f4 100644 --- a/Source/Checks/cm_cxx_gnu_fallthrough.cxx +++ b/Source/Checks/cm_cxx_gnu_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_nullptr.cxx b/Source/Checks/cm_cxx_nullptr.cxx deleted file mode 100644 index 500684a..0000000 --- a/Source/Checks/cm_cxx_nullptr.cxx +++ /dev/null @@ -1,14 +0,0 @@ -int test(int) -{ - return -1; -} - -int test(int*) -{ - return 0; -} - -int main() -{ - return test(nullptr); -} diff --git a/Source/Checks/cm_cxx_unordered_map.cxx b/Source/Checks/cm_cxx_unordered_map.cxx deleted file mode 100644 index be3de25..0000000 --- a/Source/Checks/cm_cxx_unordered_map.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include <unordered_map> -int main() -{ - std::unordered_map<int, int> map; - map[0] = 0; - return 0; -} diff --git a/Source/Checks/cm_cxx_unordered_set.cxx b/Source/Checks/cm_cxx_unordered_set.cxx deleted file mode 100644 index de4bb77..0000000 --- a/Source/Checks/cm_cxx_unordered_set.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include <unordered_set> -int main() -{ - std::unordered_set<int> set; - set.insert(0); - return 0; -} diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index c5ac1f1..6023c83 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -17,10 +17,6 @@ set( CURSES_SRCS CursesDialog/ccmake ) -if( NOT CMAKE_USE_SYSTEM_FORM ) - include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form - ${CMake_BINARY_DIR}/Source/CursesDialog/form) -endif() include_directories(${CURSES_INCLUDE_PATH}) diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 28a0e95..97d5579 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -1,6 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmConfigure.h" #include "cmCursesForm.h" #include "cmCursesMainForm.h" @@ -18,30 +17,29 @@ #include <vector> static const char* cmDocumentationName[][2] = { - { CM_NULLPTR, " ccmake - Curses Interface for CMake." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " ccmake - Curses Interface for CMake." }, + { nullptr, nullptr } }; static const char* cmDocumentationUsage[][2] = { - { CM_NULLPTR, " ccmake <path-to-source>\n" - " ccmake <path-to-existing-build>" }, - { CM_NULLPTR, - "Specify a source directory to (re-)generate a build system for " - "it in the current working directory. Specify an existing build " - "directory to re-generate its build system." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " ccmake <path-to-source>\n" + " ccmake <path-to-existing-build>" }, + { nullptr, "Specify a source directory to (re-)generate a build system for " + "it in the current working directory. Specify an existing build " + "directory to re-generate its build system." }, + { nullptr, nullptr } }; static const char* cmDocumentationUsageNote[][2] = { - { CM_NULLPTR, "Run 'ccmake --help' for more information." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, "Run 'ccmake --help' for more information." }, + { nullptr, nullptr } }; static const char* cmDocumentationOptions[] [2] = { CMAKE_STANDARD_OPTIONS_TABLE, - { CM_NULLPTR, CM_NULLPTR } }; + { nullptr, nullptr } }; -cmCursesForm* cmCursesForm::CurrentForm = CM_NULLPTR; +cmCursesForm* cmCursesForm::CurrentForm = nullptr; extern "C" { @@ -169,7 +167,7 @@ int main(int argc, char const* const* argv) touchwin(stdscr); endwin(); delete cmCursesForm::CurrentForm; - cmCursesForm::CurrentForm = CM_NULLPTR; + cmCursesForm::CurrentForm = nullptr; std::cout << std::endl << std::endl; diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h index 90bcc22..bd565cd 100644 --- a/Source/CursesDialog/cmCursesBoolWidget.h +++ b/Source/CursesDialog/cmCursesBoolWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesBoolWidget_h #define cmCursesBoolWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index d071c91..8596281 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -25,7 +25,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( { this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " "); - this->Entry = CM_NULLPTR; + this->Entry = nullptr; this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); } @@ -43,7 +43,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " "); } - this->Entry = CM_NULLPTR; + this->Entry = nullptr; const char* value = cm->GetState()->GetCacheEntryValue(key); assert(value); switch (cm->GetState()->GetCacheEntryType(key)) { @@ -104,5 +104,5 @@ const char* cmCursesCacheEntryComposite::GetValue() if (this->Label) { return this->Label->GetValue(); } - return CM_NULLPTR; + return nullptr; } diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 3c50078..54b2f1f 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -3,7 +3,7 @@ #ifndef cmCursesCacheEntryComposite_h #define cmCursesCacheEntryComposite_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h index d9bb6ba..b0c270c 100644 --- a/Source/CursesDialog/cmCursesDummyWidget.h +++ b/Source/CursesDialog/cmCursesDummyWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesDummyWidget_h #define cmCursesDummyWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h index 6ad535b..0a30402 100644 --- a/Source/CursesDialog/cmCursesFilePathWidget.h +++ b/Source/CursesDialog/cmCursesFilePathWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesFilePathWidget_h #define cmCursesFilePathWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesPathWidget.h" diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx index 06c1e9c..bd65c4a 100644 --- a/Source/CursesDialog/cmCursesForm.cxx +++ b/Source/CursesDialog/cmCursesForm.cxx @@ -7,7 +7,7 @@ bool cmCursesForm::Debug = false; cmCursesForm::cmCursesForm() { - this->Form = CM_NULLPTR; + this->Form = nullptr; } cmCursesForm::~cmCursesForm() @@ -15,7 +15,7 @@ cmCursesForm::~cmCursesForm() if (this->Form) { unpost_form(this->Form); free_form(this->Form); - this->Form = CM_NULLPTR; + this->Form = nullptr; } } diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h index 553105c..249b349 100644 --- a/Source/CursesDialog/cmCursesForm.h +++ b/Source/CursesDialog/cmCursesForm.h @@ -3,7 +3,7 @@ #ifndef cmCursesForm_h #define cmCursesForm_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" diff --git a/Source/CursesDialog/cmCursesLabelWidget.h b/Source/CursesDialog/cmCursesLabelWidget.h index 267de7c..79ae241 100644 --- a/Source/CursesDialog/cmCursesLabelWidget.h +++ b/Source/CursesDialog/cmCursesLabelWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesLabelWidget_h #define cmCursesLabelWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 7fb065d..9bd1c11 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -26,8 +26,8 @@ cmCursesLongMessageForm::cmCursesLongMessageForm( this->Messages += "\n\n"; } this->Title = title; - this->Fields[0] = CM_NULLPTR; - this->Fields[1] = CM_NULLPTR; + this->Fields[0] = nullptr; + this->Fields[1] = nullptr; } cmCursesLongMessageForm::~cmCursesLongMessageForm() @@ -105,7 +105,7 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, if (this->Form) { unpost_form(this->Form); free_form(this->Form); - this->Form = CM_NULLPTR; + this->Form = nullptr; } const char* msg = this->Messages.c_str(); @@ -114,7 +114,7 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, if (this->Fields[0]) { free_field(this->Fields[0]); - this->Fields[0] = CM_NULLPTR; + this->Fields[0] = nullptr; } this->Fields[0] = new_field(y - 6, x - 2, 1, 1, 0, 0); diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h index cd8e095..099c722 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.h +++ b/Source/CursesDialog/cmCursesLongMessageForm.h @@ -3,7 +3,7 @@ #ifndef cmCursesLongMessageForm_h #define cmCursesLongMessageForm_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 026320a..f79e72a 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -31,8 +31,8 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, , InitialWidth(initWidth) { this->NumberOfPages = 0; - this->Fields = CM_NULLPTR; - this->Entries = CM_NULLPTR; + this->Fields = nullptr; + this->Entries = nullptr; this->AdvancedMode = false; this->NumberOfVisibleEntries = 0; this->OkToGenerate = false; @@ -59,7 +59,7 @@ cmCursesMainForm::~cmCursesMainForm() if (this->Form) { unpost_form(this->Form); free_form(this->Form); - this->Form = CM_NULLPTR; + this->Form = nullptr; } delete[] this->Fields; @@ -70,7 +70,7 @@ cmCursesMainForm::~cmCursesMainForm() delete this->Entries; if (this->CMakeInstance) { delete this->CMakeInstance; - this->CMakeInstance = CM_NULLPTR; + this->CMakeInstance = nullptr; } } @@ -180,7 +180,7 @@ void cmCursesMainForm::RePost() if (this->Form) { unpost_form(this->Form); free_form(this->Form); - this->Form = CM_NULLPTR; + this->Form = nullptr; } delete[] this->Fields; if (this->AdvancedMode) { @@ -210,7 +210,7 @@ void cmCursesMainForm::RePost() this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1]; size_t cc; for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) { - this->Fields[cc] = CM_NULLPTR; + this->Fields[cc] = nullptr; } // Assign fields @@ -239,7 +239,7 @@ void cmCursesMainForm::RePost() this->NumberOfVisibleEntries = 1; } // Has to be null terminated. - this->Fields[3 * this->NumberOfVisibleEntries] = CM_NULLPTR; + this->Fields[3 * this->NumberOfVisibleEntries] = nullptr; } void cmCursesMainForm::Render(int left, int top, int width, int height) @@ -259,7 +259,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) // Delete the previous form unpost_form(this->Form); free_form(this->Form); - this->Form = CM_NULLPTR; + this->Form = nullptr; } // Wrong window size @@ -341,14 +341,14 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) } // Give the current widget (if it exists), a chance to print keys - cmCursesWidget* cw = CM_NULLPTR; + cmCursesWidget* cw = nullptr; if (this->Form) { FIELD* currentField = current_field(this->Form); cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField)); } char fmt_s[] = "%s"; - if (cw == CM_NULLPTR || !cw->PrintKeys()) { + if (cw == nullptr || !cw->PrintKeys()) { char firstLine[512] = ""; char secondLine[512] = ""; char thirdLine[512] = ""; @@ -425,7 +425,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) // Get the key of the current entry FIELD* cur = current_field(this->Form); int findex = field_index(cur); - cmCursesWidget* lbl = CM_NULLPTR; + cmCursesWidget* lbl = nullptr; if (findex >= 0) { lbl = reinterpret_cast<cmCursesWidget*>( field_userptr(this->Fields[findex - 2])); @@ -529,7 +529,7 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp) char tmp[1024]; const char* cmsg = tmp; if (prog >= 0) { - sprintf(tmp, "%s %i%%", msg, (int)(100 * prog)); + sprintf(tmp, "%s %i%%", msg, static_cast<int>(100 * prog)); } else { cmsg = msg; } @@ -557,7 +557,7 @@ int cmCursesMainForm::Configure(int noconfigure) this->FillCacheManagerFromUI(); this->CMakeInstance->SaveCache( this->CMakeInstance->GetHomeOutputDirectory()); - this->LoadCache(CM_NULLPTR); + this->LoadCache(nullptr); // Get rid of previous errors this->Errors = std::vector<std::string>(); @@ -574,7 +574,7 @@ int cmCursesMainForm::Configure(int noconfigure) } else { retVal = this->CMakeInstance->Configure(); } - this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR); + this->CMakeInstance->SetProgressCallback(nullptr, nullptr); keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ @@ -628,7 +628,7 @@ int cmCursesMainForm::Generate() // run the generate process int retVal = this->CMakeInstance->Generate(); - this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR); + this->CMakeInstance->SetProgressCallback(nullptr, nullptr); keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ if (retVal != 0 || !this->Errors.empty()) { @@ -877,7 +877,7 @@ void cmCursesMainForm::HandleInput() cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>( field_userptr(this->Fields[findex - 2])); const char* curField = lbl->GetValue(); - const char* helpString = CM_NULLPTR; + const char* helpString = nullptr; const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(curField); @@ -962,7 +962,7 @@ void cmCursesMainForm::HandleInput() // (findex always corresponds to the value field) FIELD* nextCur; if (findex == 2) { - nextCur = CM_NULLPTR; + nextCur = nullptr; } else if (findex == 3 * this->NumberOfVisibleEntries - 1) { nextCur = this->Fields[findex - 5]; } else { @@ -992,7 +992,7 @@ void cmCursesMainForm::HandleInput() if (nextCur) { // make the next or prev. current field after deletion - nextCur = CM_NULLPTR; + nextCur = nullptr; std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { @@ -1041,7 +1041,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) int findex = start_index; for (;;) { if (!str.empty()) { - cmCursesWidget* lbl = CM_NULLPTR; + cmCursesWidget* lbl = nullptr; if (findex >= 0) { lbl = reinterpret_cast<cmCursesWidget*>( field_userptr(this->Fields[findex - 2])); diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index e35cf3e..96dd5c0 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -3,7 +3,7 @@ #ifndef cmCursesMainForm_h #define cmCursesMainForm_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" @@ -64,7 +64,7 @@ public: * exception is during a resize. The optional argument specifies the * string to be displayed in the status bar. */ - void UpdateStatusBar() CM_OVERRIDE { this->UpdateStatusBar(CM_NULLPTR); } + void UpdateStatusBar() CM_OVERRIDE { this->UpdateStatusBar(nullptr); } virtual void UpdateStatusBar(const char* message); /** diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h index 7f4416f..86a6946 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.h +++ b/Source/CursesDialog/cmCursesOptionsWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesOptionsWidget_h #define cmCursesOptionsWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesPathWidget.h b/Source/CursesDialog/cmCursesPathWidget.h index ae6c16d..6a72402 100644 --- a/Source/CursesDialog/cmCursesPathWidget.h +++ b/Source/CursesDialog/cmCursesPathWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesPathWidget_h #define cmCursesPathWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesStringWidget.h" diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h index 5c59504..332d2af 100644 --- a/Source/CursesDialog/cmCursesStandardIncludes.h +++ b/Source/CursesDialog/cmCursesStandardIncludes.h @@ -3,7 +3,7 @@ #ifndef cmCursesStandardIncludes_h #define cmCursesStandardIncludes_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #if defined(__hpux) #define _BOOL_DEFINED diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index ff189f0..8cb9c1f 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -74,7 +74,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, return false; } - this->OriginalString = CM_NULLPTR; + this->OriginalString = nullptr; this->Done = false; char debugMessage[128]; diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h index 5eb3366..5787098 100644 --- a/Source/CursesDialog/cmCursesStringWidget.h +++ b/Source/CursesDialog/cmCursesStringWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesStringWidget_h #define cmCursesStringWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index 054f27e..cc07411 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -14,7 +14,7 @@ cmCursesWidget::~cmCursesWidget() { if (this->Field) { free_field(this->Field); - this->Field = CM_NULLPTR; + this->Field = nullptr; } } diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h index 3470d70..a44c5e6 100644 --- a/Source/CursesDialog/cmCursesWidget.h +++ b/Source/CursesDialog/cmCursesWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesWidget_h #define cmCursesWidget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmStateTypes.h" diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index 0677043..b468f5b 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -3,12 +3,9 @@ project(CMAKE_FORM) -include_regular_expression("^.*$") -include_directories(${CURSES_INCLUDE_PATH} "${CMAKE_CURRENT_BINARY_DIR}") - configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") -set( FORM_SRCS +add_library(cmForm fld_arg.c fld_attr.c fld_current.c @@ -49,10 +46,16 @@ set( FORM_SRCS fty_num.c fty_regex.c ) - -include_directories(${CMAKE_FORM_SOURCE_DIR}) -add_library(cmForm ${FORM_SRCS} ) + +target_include_directories(cmForm + PUBLIC + ${CURSES_INCLUDE_PATH} + ${CMAKE_FORM_BINARY_DIR} + ${CMAKE_FORM_SOURCE_DIR} + ) + target_link_libraries(cmForm ${CURSES_LIBRARY}) + if(CURSES_EXTRA_LIBRARY) target_link_libraries(cmForm ${CURSES_EXTRA_LIBRARY}) endif() diff --git a/Source/LexerParser/cmCommandArgumentLexer.cxx b/Source/LexerParser/cmCommandArgumentLexer.cxx index 12dce37..bf6bc2f 100644 --- a/Source/LexerParser/cmCommandArgumentLexer.cxx +++ b/Source/LexerParser/cmCommandArgumentLexer.cxx @@ -1,7 +1,4 @@ #include "cmStandardLexer.h" -#line 2 "cmCommandArgumentLexer.cxx" - -#line 4 "cmCommandArgumentLexer.cxx" #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -11,11 +8,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmCommandArgument_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmCommandArgument_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmCommandArgument_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmCommandArgument_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmCommandArgument_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmCommandArgument_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmCommandArgument_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmCommandArgument_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmCommandArgument_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmCommandArgument_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmCommandArgument_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmCommandArgument_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmCommandArgument_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmCommandArgument_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmCommandArgument_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmCommandArgument_yylex_ALREADY_DEFINED +#else +#define yylex cmCommandArgument_yylex +#endif + +#ifdef yyrestart +#define cmCommandArgument_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmCommandArgument_yyrestart +#endif + +#ifdef yylex_init +#define cmCommandArgument_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmCommandArgument_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmCommandArgument_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmCommandArgument_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmCommandArgument_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmCommandArgument_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmCommandArgument_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmCommandArgument_yyget_debug +#endif + +#ifdef yyset_debug +#define cmCommandArgument_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmCommandArgument_yyset_debug +#endif + +#ifdef yyget_extra +#define cmCommandArgument_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmCommandArgument_yyget_extra +#endif + +#ifdef yyset_extra +#define cmCommandArgument_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmCommandArgument_yyset_extra +#endif + +#ifdef yyget_in +#define cmCommandArgument_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmCommandArgument_yyget_in +#endif + +#ifdef yyset_in +#define cmCommandArgument_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmCommandArgument_yyset_in +#endif + +#ifdef yyget_out +#define cmCommandArgument_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmCommandArgument_yyget_out +#endif + +#ifdef yyset_out +#define cmCommandArgument_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmCommandArgument_yyset_out +#endif + +#ifdef yyget_leng +#define cmCommandArgument_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmCommandArgument_yyget_leng +#endif + +#ifdef yyget_text +#define cmCommandArgument_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmCommandArgument_yyget_text +#endif + +#ifdef yyget_lineno +#define cmCommandArgument_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmCommandArgument_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmCommandArgument_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmCommandArgument_yyset_lineno +#endif + +#ifdef yyget_column +#define cmCommandArgument_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmCommandArgument_yyget_column +#endif + +#ifdef yyset_column +#define cmCommandArgument_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmCommandArgument_yyset_column +#endif + +#ifdef yywrap +#define cmCommandArgument_yywrap_ALREADY_DEFINED +#else +#define yywrap cmCommandArgument_yywrap +#endif + +#ifdef yyalloc +#define cmCommandArgument_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmCommandArgument_yyalloc +#endif + +#ifdef yyrealloc +#define cmCommandArgument_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmCommandArgument_yyrealloc +#endif + +#ifdef yyfree +#define cmCommandArgument_yyfree_ALREADY_DEFINED +#else +#define yyfree cmCommandArgument_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t; /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -131,20 +342,16 @@ typedef void* yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE cmCommandArgument_yyrestart(yyin ,yyscanner ) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -194,7 +401,6 @@ typedef size_t yy_size_t; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -254,7 +460,7 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmCommandArgument_yyrestart()), so that the user can continue scanning by + * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -271,73 +477,67 @@ struct yy_buffer_state #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner ); - -static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner ); -static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner ); -static void cmCommandArgument_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER cmCommandArgument_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer cmCommandArgument_yy_create_buffer +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - cmCommandArgument_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - cmCommandArgument_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define cmCommandArgument_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; - #define YY_NUM_RULES 14 #define YY_END_OF_BUFFER 15 /* This struct is not used in this scanner, @@ -358,14 +557,14 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[30] = +static const flex_int16_t yy_accept[30] = { 0, 0, 0, 0, 0, 0, 0, 15, 9, 10, 7, 6, 14, 11, 5, 12, 13, 9, 0, 0, 4, 7, 0, 8, 2, 0, 3, 0, 1, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -397,13 +596,13 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[12] = +static const YY_CHAR yy_meta[12] = { 0, 1, 2, 3, 4, 3, 4, 4, 4, 3, 5, 3 } ; -static yyconst flex_uint16_t yy_base[35] = +static const flex_int16_t yy_base[35] = { 0, 0, 0, 31, 30, 29, 28, 36, 0, 6, 16, 0, 41, 41, 41, 0, 41, 0, 22, 22, 41, @@ -411,7 +610,7 @@ static yyconst flex_uint16_t yy_base[35] = 21, 26, 9, 30 } ; -static yyconst flex_int16_t yy_def[35] = +static const flex_int16_t yy_def[35] = { 0, 29, 1, 1, 1, 1, 1, 29, 30, 31, 32, 33, 29, 29, 29, 34, 29, 30, 31, 18, 29, @@ -419,7 +618,7 @@ static yyconst flex_int16_t yy_def[35] = 29, 29, 29, 29 } ; -static yyconst flex_uint16_t yy_nxt[53] = +static const flex_int16_t yy_nxt[53] = { 0, 8, 8, 9, 10, 11, 10, 10, 10, 12, 13, 14, 19, 22, 28, 27, 20, 17, 17, 17, 17, @@ -429,7 +628,7 @@ static yyconst flex_uint16_t yy_nxt[53] = 29, 29 } ; -static yyconst flex_int16_t yy_chk[53] = +static const flex_int16_t yy_chk[53] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 33, 27, 25, 9, 10, 10, 21, 21, @@ -446,8 +645,6 @@ static yyconst flex_int16_t yy_chk[53] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "cmCommandArgumentLexer.in.l" -#line 2 "cmCommandArgumentLexer.in.l" /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /* @@ -456,13 +653,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l Modify cmCommandArgumentLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in cmCommandArgument_yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCommandArgumentLexer.cxx */ @@ -480,9 +676,6 @@ Modify cmCommandArgumentLexer.cxx: /*--------------------------------------------------------------------------*/ - -#line 484 "cmCommandArgumentLexer.cxx" - #define INITIAL 0 #define ESCAPES 1 #define NOESCAPES 2 @@ -525,44 +718,44 @@ struct yyguts_t }; /* end struct yyguts_t */ -static int yy_init_globals (yyscan_t yyscanner ); +static int yy_init_globals ( yyscan_t yyscanner ); -int cmCommandArgument_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmCommandArgument_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmCommandArgument_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmCommandArgument_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmCommandArgument_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmCommandArgument_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmCommandArgument_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmCommandArgument_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -570,9 +763,9 @@ void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmCommandArgument_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmCommandArgument_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif @@ -581,19 +774,18 @@ extern int cmCommandArgument_yywrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (yyscan_t yyscanner ); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -624,7 +816,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -637,7 +829,7 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -678,9 +870,9 @@ static int input (yyscan_t yyscanner ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmCommandArgument_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -725,19 +917,15 @@ YY_DECL yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - cmCommandArgument_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmCommandArgument_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } { -#line 42 "cmCommandArgumentLexer.in.l" - - -#line 740 "cmCommandArgumentLexer.cxx" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -765,9 +953,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 30 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 41 ); @@ -796,7 +984,6 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 44 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); @@ -805,7 +992,6 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 50 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); @@ -814,7 +1000,6 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 56 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); @@ -823,7 +1008,6 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 62 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); @@ -833,7 +1017,6 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 69 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); @@ -843,7 +1026,6 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 76 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); @@ -853,7 +1035,6 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 83 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); @@ -862,7 +1043,6 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 89 "cmCommandArgumentLexer.in.l" { if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) ) { @@ -874,7 +1054,6 @@ YY_RULE_SETUP case 9: /* rule 9 can match eol */ YY_RULE_SETUP -#line 97 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); @@ -883,7 +1062,6 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 103 "cmCommandArgumentLexer.in.l" { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->DOLLARVariable; @@ -892,7 +1070,6 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 109 "cmCommandArgumentLexer.in.l" { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->LCURLYVariable; @@ -901,7 +1078,6 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 115 "cmCommandArgumentLexer.in.l" { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->BSLASHVariable; @@ -910,7 +1086,6 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 121 "cmCommandArgumentLexer.in.l" { //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->BSLASHVariable; @@ -919,10 +1094,8 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 127 "cmCommandArgumentLexer.in.l" ECHO; YY_BREAK -#line 925 "cmCommandArgumentLexer.cxx" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(ESCAPES): case YY_STATE_EOF(NOESCAPES): @@ -942,7 +1115,7 @@ case YY_STATE_EOF(NOESCAPES): /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called - * cmCommandArgument_yylex(). If so, then we have to assure + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a @@ -1002,7 +1175,7 @@ case YY_STATE_EOF(NOESCAPES): { yyg->yy_did_buffer_switch_on_eof = 0; - if ( cmCommandArgument_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1056,7 +1229,7 @@ case YY_STATE_EOF(NOESCAPES): } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of cmCommandArgument_yylex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1070,7 +1243,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1099,7 +1272,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1135,7 +1308,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - cmCommandArgument_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1167,7 +1341,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - cmCommandArgument_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); } else @@ -1181,12 +1355,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmCommandArgument_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } yyg->yy_n_chars += number_to_move; @@ -1220,9 +1397,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 30 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1249,9 +1426,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 30 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 29); (void)yyg; @@ -1287,7 +1464,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1304,13 +1481,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ /* Reset buffer status. */ - cmCommandArgument_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( cmCommandArgument_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) @@ -1342,34 +1519,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void cmCommandArgument_yyrestart (FILE * input_file , yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - cmCommandArgument_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmCommandArgument_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - cmCommandArgument_yy_load_buffer_state(yyscanner ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with - * cmCommandArgument_yypop_buffer_state(); - * cmCommandArgument_yypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - cmCommandArgument_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1382,17 +1559,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - cmCommandArgument_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (cmCommandArgument_yywrap()) processing, but the only time this flag - * is looked at is after cmCommandArgument_yywrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } -static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -1407,35 +1584,35 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) cmCommandArgument_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - cmCommandArgument_yy_init_buffer(b,file ,yyscanner); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with cmCommandArgument_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ - void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1446,28 +1623,28 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - cmCommandArgument_yyfree((void *) b->yy_ch_buf ,yyscanner ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - cmCommandArgument_yyfree((void *) b ,yyscanner ); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a cmCommandArgument_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void cmCommandArgument_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - cmCommandArgument_yy_flush_buffer(b ,yyscanner); + yy_flush_buffer( b , yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then cmCommandArgument_yy_init_buffer was _probably_ - * called from cmCommandArgument_yyrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1484,7 +1661,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -1505,7 +1682,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - cmCommandArgument_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1514,15 +1691,15 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; - cmCommandArgument_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from cmCommandArgument_yy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1536,8 +1713,8 @@ void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_ yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from cmCommandArgument_yy_switch_to_buffer. */ - cmCommandArgument_yy_load_buffer_state(yyscanner ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } @@ -1545,19 +1722,19 @@ void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_ * The next element becomes the new top. * @param yyscanner The scanner object. */ -void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; - cmCommandArgument_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - cmCommandArgument_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -1565,9 +1742,9 @@ void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1577,11 +1754,11 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -1596,12 +1773,12 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyrealloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -1615,7 +1792,7 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -1625,11 +1802,11 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size /* They forgot to leave room for the EOB's. */ return NULL; - b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = NULL; @@ -1639,53 +1816,53 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - cmCommandArgument_yy_switch_to_buffer(b ,yyscanner ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to cmCommandArgument_yylex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * cmCommandArgument_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return cmCommandArgument_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to cmCommandArgument_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) _yybytes_len + 2; - buf = (char *) cmCommandArgument_yyalloc(n ,yyscanner ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < (size_t)_yybytes_len; ++i ) + for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = cmCommandArgument_yy_scan_buffer(buf,n ,yyscanner); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in cmCommandArgument_yy_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -1699,11 +1876,11 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _ #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1729,7 +1906,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; @@ -1738,7 +1915,7 @@ YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner) /** Get the current line number. * @param yyscanner The scanner object. */ -int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1751,7 +1928,7 @@ int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) /** Get the current column number. * @param yyscanner The scanner object. */ -int cmCommandArgument_yyget_column (yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1764,7 +1941,7 @@ int cmCommandArgument_yyget_column (yyscan_t yyscanner) /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; @@ -1773,7 +1950,7 @@ FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner) /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; @@ -1782,7 +1959,7 @@ FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int cmCommandArgument_yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -1792,7 +1969,7 @@ int cmCommandArgument_yyget_leng (yyscan_t yyscanner) * @param yyscanner The scanner object. */ -char *cmCommandArgument_yyget_text (yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; @@ -1802,7 +1979,7 @@ char *cmCommandArgument_yyget_text (yyscan_t yyscanner) * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; @@ -1812,13 +1989,13 @@ void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yysca * @param _line_number line number * @param yyscanner The scanner object. */ -void cmCommandArgument_yyset_lineno (int _line_number , yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmCommandArgument_yyset_lineno called with no buffer" ); + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = _line_number; } @@ -1827,13 +2004,13 @@ void cmCommandArgument_yyset_lineno (int _line_number , yyscan_t yyscanner) * @param _column_no column number * @param yyscanner The scanner object. */ -void cmCommandArgument_yyset_column (int _column_no , yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmCommandArgument_yyset_column called with no buffer" ); + YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = _column_no; } @@ -1842,27 +2019,27 @@ void cmCommandArgument_yyset_column (int _column_no , yyscan_t yyscanner) * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see cmCommandArgument_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void cmCommandArgument_yyset_in (FILE * _in_str , yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } -void cmCommandArgument_yyset_out (FILE * _out_str , yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } -int cmCommandArgument_yyget_debug (yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } -void cmCommandArgument_yyset_debug (int _bdebug , yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; @@ -1872,20 +2049,18 @@ void cmCommandArgument_yyset_debug (int _bdebug , yyscan_t yyscanner) /* User-visible API */ -/* cmCommandArgument_yylex_init is special because it creates the scanner itself, so it is +/* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ - -int cmCommandArgument_yylex_init(yyscan_t* ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -1898,27 +2073,25 @@ int cmCommandArgument_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } -/* cmCommandArgument_yylex_init_extra has the same functionality as cmCommandArgument_yylex_init, but follows the +/* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to cmCommandArgument_yyalloc in + * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ - -int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; - cmCommandArgument_yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -1929,7 +2102,7 @@ int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* p yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - cmCommandArgument_yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } @@ -1938,7 +2111,7 @@ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. - * This function is called from cmCommandArgument_yylex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = NULL; @@ -1962,37 +2135,37 @@ static int yy_init_globals (yyscan_t yyscanner) #endif /* For future reference: Set errno on error, since we are called by - * cmCommandArgument_yylex_init() + * yylex_init() */ return 0; } -/* cmCommandArgument_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int cmCommandArgument_yylex_destroy (yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - cmCommandArgument_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - cmCommandArgument_yypop_buffer_state(yyscanner); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - cmCommandArgument_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyfree(yyg->yy_buffer_stack , yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - cmCommandArgument_yyfree(yyg->yy_start_stack ,yyscanner ); + yyfree( yyg->yy_start_stack , yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * cmCommandArgument_yylex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ - cmCommandArgument_yyfree ( yyscanner , yyscanner ); + yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } @@ -2002,7 +2175,7 @@ int cmCommandArgument_yylex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2014,7 +2187,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -2024,14 +2197,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmCommandArgument_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; return malloc(size); } -void *cmCommandArgument_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2046,19 +2219,15 @@ void *cmCommandArgument_yyrealloc (void * ptr, yy_size_t size , yyscan_t yysca return realloc(ptr, size); } -void cmCommandArgument_yyfree (void * ptr , yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - free( (char *) ptr ); /* see cmCommandArgument_yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 127 "cmCommandArgumentLexer.in.l" - - - /*--------------------------------------------------------------------------*/ void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes) { diff --git a/Source/LexerParser/cmCommandArgumentLexer.h b/Source/LexerParser/cmCommandArgumentLexer.h index 82e87b5..5677513 100644 --- a/Source/LexerParser/cmCommandArgumentLexer.h +++ b/Source/LexerParser/cmCommandArgumentLexer.h @@ -2,10 +2,6 @@ #define cmCommandArgument_yyHEADER_H 1 #define cmCommandArgument_yyIN_HEADER 1 -#line 6 "cmCommandArgumentLexer.h" - -#line 8 "cmCommandArgumentLexer.h" - #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -14,11 +10,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmCommandArgument_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmCommandArgument_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmCommandArgument_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmCommandArgument_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmCommandArgument_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmCommandArgument_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmCommandArgument_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmCommandArgument_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmCommandArgument_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmCommandArgument_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmCommandArgument_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmCommandArgument_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmCommandArgument_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmCommandArgument_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmCommandArgument_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmCommandArgument_yylex_ALREADY_DEFINED +#else +#define yylex cmCommandArgument_yylex +#endif + +#ifdef yyrestart +#define cmCommandArgument_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmCommandArgument_yyrestart +#endif + +#ifdef yylex_init +#define cmCommandArgument_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmCommandArgument_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmCommandArgument_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmCommandArgument_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmCommandArgument_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmCommandArgument_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmCommandArgument_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmCommandArgument_yyget_debug +#endif + +#ifdef yyset_debug +#define cmCommandArgument_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmCommandArgument_yyset_debug +#endif + +#ifdef yyget_extra +#define cmCommandArgument_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmCommandArgument_yyget_extra +#endif + +#ifdef yyset_extra +#define cmCommandArgument_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmCommandArgument_yyset_extra +#endif + +#ifdef yyget_in +#define cmCommandArgument_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmCommandArgument_yyget_in +#endif + +#ifdef yyset_in +#define cmCommandArgument_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmCommandArgument_yyset_in +#endif + +#ifdef yyget_out +#define cmCommandArgument_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmCommandArgument_yyget_out +#endif + +#ifdef yyset_out +#define cmCommandArgument_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmCommandArgument_yyset_out +#endif + +#ifdef yyget_leng +#define cmCommandArgument_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmCommandArgument_yyget_leng +#endif + +#ifdef yyget_text +#define cmCommandArgument_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmCommandArgument_yyget_text +#endif + +#ifdef yyget_lineno +#define cmCommandArgument_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmCommandArgument_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmCommandArgument_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmCommandArgument_yyset_lineno +#endif + +#ifdef yyget_column +#define cmCommandArgument_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmCommandArgument_yyget_column +#endif + +#ifdef yyset_column +#define cmCommandArgument_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmCommandArgument_yyset_column +#endif + +#ifdef yywrap +#define cmCommandArgument_yywrap_ALREADY_DEFINED +#else +#define yywrap cmCommandArgument_yywrap +#endif + +#ifdef yyalloc +#define cmCommandArgument_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmCommandArgument_yyalloc +#endif + +#ifdef yyrealloc +#define cmCommandArgument_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmCommandArgument_yyrealloc +#endif + +#ifdef yyfree +#define cmCommandArgument_yyfree_ALREADY_DEFINED +#else +#define yyfree cmCommandArgument_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -193,21 +405,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner ); +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); /* Begin user sect3 */ @@ -227,42 +439,42 @@ void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner ); #define YY_EXTRA_TYPE void * #endif -int cmCommandArgument_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmCommandArgument_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmCommandArgument_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmCommandArgument_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmCommandArgument_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmCommandArgument_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmCommandArgument_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmCommandArgument_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -270,18 +482,18 @@ void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmCommandArgument_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmCommandArgument_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT @@ -309,9 +521,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmCommandArgument_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* yy_get_previous_state - get the state just before the EOB char was reached */ @@ -328,9 +540,150 @@ extern int cmCommandArgument_yylex (yyscan_t yyscanner); #undef YY_DECL #endif -#line 127 "cmCommandArgumentLexer.in.l" - +#ifndef cmCommandArgument_yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef cmCommandArgument_yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef cmCommandArgument_yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef cmCommandArgument_yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef cmCommandArgument_yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef cmCommandArgument_yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef cmCommandArgument_yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef cmCommandArgument_yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef cmCommandArgument_yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef cmCommandArgument_yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef cmCommandArgument_yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef cmCommandArgument_yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef cmCommandArgument_yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef cmCommandArgument_yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef cmCommandArgument_yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef cmCommandArgument_yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef cmCommandArgument_yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef cmCommandArgument_yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef cmCommandArgument_yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef cmCommandArgument_yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef cmCommandArgument_yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef cmCommandArgument_yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef cmCommandArgument_yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef cmCommandArgument_yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef cmCommandArgument_yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef cmCommandArgument_yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef cmCommandArgument_yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef cmCommandArgument_yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef cmCommandArgument_yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef cmCommandArgument_yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef cmCommandArgument_yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef cmCommandArgument_yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef cmCommandArgument_yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef cmCommandArgument_yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef cmCommandArgument_yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef cmCommandArgument_yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef cmCommandArgument_yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef cmCommandArgument_yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef cmCommandArgument_yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif -#line 335 "cmCommandArgumentLexer.h" #undef cmCommandArgument_yyIN_HEADER #endif /* cmCommandArgument_yyHEADER_H */ diff --git a/Source/LexerParser/cmCommandArgumentLexer.in.l b/Source/LexerParser/cmCommandArgumentLexer.in.l index e3a8094..acf18f3 100644 --- a/Source/LexerParser/cmCommandArgumentLexer.in.l +++ b/Source/LexerParser/cmCommandArgumentLexer.in.l @@ -7,13 +7,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l Modify cmCommandArgumentLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCommandArgumentLexer.cxx */ @@ -32,6 +31,8 @@ Modify cmCommandArgumentLexer.cxx: /*--------------------------------------------------------------------------*/ %} +%option prefix="cmCommandArgument_yy" + %option reentrant %option noyywrap %option nounput diff --git a/Source/LexerParser/cmDependsJavaLexer.cxx b/Source/LexerParser/cmDependsJavaLexer.cxx index 8159f47..36cac61 100644 --- a/Source/LexerParser/cmDependsJavaLexer.cxx +++ b/Source/LexerParser/cmDependsJavaLexer.cxx @@ -1,7 +1,4 @@ #include "cmStandardLexer.h" -#line 2 "cmDependsJavaLexer.cxx" - -#line 4 "cmDependsJavaLexer.cxx" #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -11,11 +8,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmDependsJava_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmDependsJava_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmDependsJava_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmDependsJava_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmDependsJava_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmDependsJava_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmDependsJava_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmDependsJava_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmDependsJava_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmDependsJava_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmDependsJava_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmDependsJava_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmDependsJava_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmDependsJava_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmDependsJava_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmDependsJava_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmDependsJava_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmDependsJava_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmDependsJava_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmDependsJava_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmDependsJava_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmDependsJava_yylex_ALREADY_DEFINED +#else +#define yylex cmDependsJava_yylex +#endif + +#ifdef yyrestart +#define cmDependsJava_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmDependsJava_yyrestart +#endif + +#ifdef yylex_init +#define cmDependsJava_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmDependsJava_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmDependsJava_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmDependsJava_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmDependsJava_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmDependsJava_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmDependsJava_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmDependsJava_yyget_debug +#endif + +#ifdef yyset_debug +#define cmDependsJava_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmDependsJava_yyset_debug +#endif + +#ifdef yyget_extra +#define cmDependsJava_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmDependsJava_yyget_extra +#endif + +#ifdef yyset_extra +#define cmDependsJava_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmDependsJava_yyset_extra +#endif + +#ifdef yyget_in +#define cmDependsJava_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmDependsJava_yyget_in +#endif + +#ifdef yyset_in +#define cmDependsJava_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmDependsJava_yyset_in +#endif + +#ifdef yyget_out +#define cmDependsJava_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmDependsJava_yyget_out +#endif + +#ifdef yyset_out +#define cmDependsJava_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmDependsJava_yyset_out +#endif + +#ifdef yyget_leng +#define cmDependsJava_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmDependsJava_yyget_leng +#endif + +#ifdef yyget_text +#define cmDependsJava_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmDependsJava_yyget_text +#endif + +#ifdef yyget_lineno +#define cmDependsJava_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmDependsJava_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmDependsJava_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmDependsJava_yyset_lineno +#endif + +#ifdef yyget_column +#define cmDependsJava_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmDependsJava_yyget_column +#endif + +#ifdef yyset_column +#define cmDependsJava_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmDependsJava_yyset_column +#endif + +#ifdef yywrap +#define cmDependsJava_yywrap_ALREADY_DEFINED +#else +#define yywrap cmDependsJava_yywrap +#endif + +#ifdef yyalloc +#define cmDependsJava_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmDependsJava_yyalloc +#endif + +#ifdef yyrealloc +#define cmDependsJava_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmDependsJava_yyrealloc +#endif + +#ifdef yyfree +#define cmDependsJava_yyfree_ALREADY_DEFINED +#else +#define yyfree cmDependsJava_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t; /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -131,20 +342,16 @@ typedef void* yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE cmDependsJava_yyrestart(yyin ,yyscanner ) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -194,7 +401,6 @@ typedef size_t yy_size_t; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -254,7 +460,7 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmDependsJava_yyrestart()), so that the user can continue scanning by + * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -271,73 +477,67 @@ struct yy_buffer_state #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner ); -static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner ); -static void cmDependsJava_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -#define YY_FLUSH_BUFFER cmDependsJava_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmDependsJava_yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer cmDependsJava_yy_create_buffer +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - cmDependsJava_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - cmDependsJava_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define cmDependsJava_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; - #define YY_NUM_RULES 111 #define YY_END_OF_BUFFER 112 /* This struct is not used in this scanner, @@ -358,7 +557,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[327] = +static const flex_int16_t yy_accept[327] = { 0, 0, 0, 0, 0, 0, 0, 112, 110, 109, 109, 77, 4, 73, 94, 60, 110, 93, 92, 105, 99, @@ -398,7 +597,7 @@ static yyconst flex_int16_t yy_accept[327] = 27, 29, 107, 107, 45, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, @@ -430,7 +629,7 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[65] = +static const YY_CHAR yy_meta[65] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, @@ -441,7 +640,7 @@ static yyconst YY_CHAR yy_meta[65] = 1, 1, 1, 1 } ; -static yyconst flex_uint16_t yy_base[334] = +static const flex_int16_t yy_base[334] = { 0, 0, 0, 401, 400, 62, 63, 411, 414, 414, 414, 386, 414, 414, 385, 61, 374, 414, 414, 383, 57, @@ -482,7 +681,7 @@ static yyconst flex_uint16_t yy_base[334] = 232, 96, 235 } ; -static yyconst flex_int16_t yy_def[334] = +static const flex_int16_t yy_def[334] = { 0, 326, 1, 327, 327, 328, 328, 326, 326, 326, 326, 326, 326, 326, 326, 326, 329, 326, 326, 326, 326, @@ -523,7 +722,7 @@ static yyconst flex_int16_t yy_def[334] = 326, 326, 326 } ; -static yyconst flex_uint16_t yy_nxt[479] = +static const flex_int16_t yy_nxt[479] = { 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, @@ -579,7 +778,7 @@ static yyconst flex_uint16_t yy_nxt[479] = 326, 326, 326, 326, 326, 326, 326, 326 } ; -static yyconst flex_int16_t yy_chk[479] = +static const flex_int16_t yy_chk[479] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -642,8 +841,6 @@ static yyconst flex_int16_t yy_chk[479] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "cmDependsJavaLexer.in.l" -#line 2 "cmDependsJavaLexer.in.l" /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /* @@ -652,13 +849,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l Modify cmDependsJavaLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in cmDependsJava_yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmDependsJavaLexer.h cmDependsJavaLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmDependsJavaLexer.cxx */ @@ -682,9 +878,6 @@ Modify cmDependsJavaLexer.cxx: /*--------------------------------------------------------------------------*/ - -#line 686 "cmDependsJavaLexer.cxx" - #define INITIAL 0 #define comment 1 #define string 2 @@ -727,44 +920,44 @@ struct yyguts_t }; /* end struct yyguts_t */ -static int yy_init_globals (yyscan_t yyscanner ); +static int yy_init_globals ( yyscan_t yyscanner ); -int cmDependsJava_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmDependsJava_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmDependsJava_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmDependsJava_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmDependsJava_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmDependsJava_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmDependsJava_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmDependsJava_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmDependsJava_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmDependsJava_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmDependsJava_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmDependsJava_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmDependsJava_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmDependsJava_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -772,32 +965,31 @@ void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmDependsJava_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmDependsJava_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (yyscan_t yyscanner ); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -828,7 +1020,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -841,7 +1033,7 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -882,9 +1074,9 @@ static int input (yyscan_t yyscanner ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmDependsJava_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -929,18 +1121,15 @@ YY_DECL yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - cmDependsJava_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmDependsJava_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } { -#line 48 "cmDependsJavaLexer.in.l" - -#line 943 "cmDependsJavaLexer.cxx" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -968,9 +1157,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 327 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 414 ); @@ -999,539 +1188,432 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 49 "cmDependsJavaLexer.in.l" { BEGIN(comment); } YY_BREAK case 2: YY_RULE_SETUP -#line 50 "cmDependsJavaLexer.in.l" { BEGIN(INITIAL); } YY_BREAK case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 51 "cmDependsJavaLexer.in.l" {} YY_BREAK case 4: YY_RULE_SETUP -#line 53 "cmDependsJavaLexer.in.l" { BEGIN(string); } YY_BREAK case 5: YY_RULE_SETUP -#line 54 "cmDependsJavaLexer.in.l" { BEGIN(INITIAL); return jp_STRINGLITERAL; } YY_BREAK case 6: YY_RULE_SETUP -#line 55 "cmDependsJavaLexer.in.l" {} YY_BREAK case 7: YY_RULE_SETUP -#line 57 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_ABSTRACT; } YY_BREAK case 8: YY_RULE_SETUP -#line 58 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_ASSERT; } YY_BREAK case 9: YY_RULE_SETUP -#line 59 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_BOOLEAN_TYPE; } YY_BREAK case 10: YY_RULE_SETUP -#line 60 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_BREAK; } YY_BREAK case 11: YY_RULE_SETUP -#line 61 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_BYTE_TYPE; } YY_BREAK case 12: YY_RULE_SETUP -#line 62 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_CASE; } YY_BREAK case 13: YY_RULE_SETUP -#line 63 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_CATCH; } YY_BREAK case 14: YY_RULE_SETUP -#line 64 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_CHAR_TYPE; } YY_BREAK case 15: YY_RULE_SETUP -#line 65 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_CLASS; } YY_BREAK case 16: YY_RULE_SETUP -#line 66 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_CONTINUE; } YY_BREAK case 17: YY_RULE_SETUP -#line 67 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_DEFAULT; } YY_BREAK case 18: YY_RULE_SETUP -#line 68 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_DO; } YY_BREAK case 19: YY_RULE_SETUP -#line 69 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_DOUBLE_TYPE; } YY_BREAK case 20: YY_RULE_SETUP -#line 70 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_ELSE; } YY_BREAK case 21: YY_RULE_SETUP -#line 71 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_EXTENDS; } YY_BREAK case 22: YY_RULE_SETUP -#line 72 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_FINAL; } YY_BREAK case 23: YY_RULE_SETUP -#line 73 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_FINALLY; } YY_BREAK case 24: YY_RULE_SETUP -#line 74 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_FLOAT_TYPE; } YY_BREAK case 25: YY_RULE_SETUP -#line 75 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_FOR; } YY_BREAK case 26: YY_RULE_SETUP -#line 76 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_IF; } YY_BREAK case 27: YY_RULE_SETUP -#line 77 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_IMPLEMENTS; } YY_BREAK case 28: YY_RULE_SETUP -#line 78 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_IMPORT; } YY_BREAK case 29: YY_RULE_SETUP -#line 79 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_INSTANCEOF; } YY_BREAK case 30: YY_RULE_SETUP -#line 80 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_INT_TYPE; } YY_BREAK case 31: YY_RULE_SETUP -#line 81 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_INTERFACE; } YY_BREAK case 32: YY_RULE_SETUP -#line 82 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_LONG_TYPE; } YY_BREAK case 33: YY_RULE_SETUP -#line 83 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_NATIVE; } YY_BREAK case 34: YY_RULE_SETUP -#line 84 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_NEW; } YY_BREAK case 35: YY_RULE_SETUP -#line 85 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_PACKAGE; } YY_BREAK case 36: YY_RULE_SETUP -#line 86 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_PRIVATE; } YY_BREAK case 37: YY_RULE_SETUP -#line 87 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_PROTECTED; } YY_BREAK case 38: YY_RULE_SETUP -#line 88 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_PUBLIC; } YY_BREAK case 39: YY_RULE_SETUP -#line 89 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_RETURN; } YY_BREAK case 40: YY_RULE_SETUP -#line 90 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_SHORT_TYPE; } YY_BREAK case 41: YY_RULE_SETUP -#line 91 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_STATIC; } YY_BREAK case 42: YY_RULE_SETUP -#line 92 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_STRICTFP; } YY_BREAK case 43: YY_RULE_SETUP -#line 93 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_SUPER; } YY_BREAK case 44: YY_RULE_SETUP -#line 94 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_SWITCH; } YY_BREAK case 45: YY_RULE_SETUP -#line 95 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_SYNCHRONIZED; } YY_BREAK case 46: YY_RULE_SETUP -#line 96 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_THIS; } YY_BREAK case 47: YY_RULE_SETUP -#line 97 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_THROW; } YY_BREAK case 48: YY_RULE_SETUP -#line 98 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_THROWS; } YY_BREAK case 49: YY_RULE_SETUP -#line 99 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_TRANSIENT; } YY_BREAK case 50: YY_RULE_SETUP -#line 100 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_TRY; } YY_BREAK case 51: YY_RULE_SETUP -#line 101 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_VOID; } YY_BREAK case 52: YY_RULE_SETUP -#line 102 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_VOLATILE; } YY_BREAK case 53: YY_RULE_SETUP -#line 103 "cmDependsJavaLexer.in.l" { KEYWORD; return jp_WHILE; } YY_BREAK case 54: YY_RULE_SETUP -#line 105 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_BOOLEANLITERAL; } YY_BREAK case 55: /* rule 55 can match eol */ YY_RULE_SETUP -#line 106 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_CHARACTERLITERAL; } YY_BREAK case 56: YY_RULE_SETUP -#line 107 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_DECIMALINTEGERLITERAL; } YY_BREAK case 57: YY_RULE_SETUP -#line 108 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_FLOATINGPOINTLITERAL; } YY_BREAK case 58: YY_RULE_SETUP -#line 109 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_HEXINTEGERLITERAL; } YY_BREAK case 59: YY_RULE_SETUP -#line 110 "cmDependsJavaLexer.in.l" { PRIMITIVE; return jp_NULLLITERAL; } YY_BREAK case 60: YY_RULE_SETUP -#line 112 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_AND; } YY_BREAK case 61: YY_RULE_SETUP -#line 113 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_ANDAND; } YY_BREAK case 62: YY_RULE_SETUP -#line 114 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_ANDEQUALS; } YY_BREAK case 63: YY_RULE_SETUP -#line 115 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_BRACKETEND; } YY_BREAK case 64: YY_RULE_SETUP -#line 116 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_BRACKETSTART; } YY_BREAK case 65: YY_RULE_SETUP -#line 117 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_CARROT; } YY_BREAK case 66: YY_RULE_SETUP -#line 118 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_CARROTEQUALS; } YY_BREAK case 67: YY_RULE_SETUP -#line 119 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_COLON; } YY_BREAK case 68: YY_RULE_SETUP -#line 120 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_COMMA; } YY_BREAK case 69: YY_RULE_SETUP -#line 121 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_CURLYEND; } YY_BREAK case 70: YY_RULE_SETUP -#line 122 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_CURLYSTART; } YY_BREAK case 71: YY_RULE_SETUP -#line 123 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_DIVIDE; } YY_BREAK case 72: YY_RULE_SETUP -#line 124 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_DIVIDEEQUALS; } YY_BREAK case 73: YY_RULE_SETUP -#line 125 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_DOLLAR; } YY_BREAK case 74: YY_RULE_SETUP -#line 126 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_DOT; } YY_BREAK case 75: YY_RULE_SETUP -#line 127 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_EQUALS; } YY_BREAK case 76: YY_RULE_SETUP -#line 128 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_EQUALSEQUALS; } YY_BREAK case 77: YY_RULE_SETUP -#line 129 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_EXCLAMATION; } YY_BREAK case 78: YY_RULE_SETUP -#line 130 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_EXCLAMATIONEQUALS; } YY_BREAK case 79: YY_RULE_SETUP -#line 131 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GREATER; } YY_BREAK case 80: YY_RULE_SETUP -#line 132 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GTEQUALS; } YY_BREAK case 81: YY_RULE_SETUP -#line 133 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GTGT; } YY_BREAK case 82: YY_RULE_SETUP -#line 134 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GTGTEQUALS; } YY_BREAK case 83: YY_RULE_SETUP -#line 135 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GTGTGT; } YY_BREAK case 84: YY_RULE_SETUP -#line 136 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_GTGTGTEQUALS; } YY_BREAK case 85: YY_RULE_SETUP -#line 137 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_LESLESEQUALS; } YY_BREAK case 86: YY_RULE_SETUP -#line 138 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_LESSTHAN; } YY_BREAK case 87: YY_RULE_SETUP -#line 139 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_LTEQUALS; } YY_BREAK case 88: YY_RULE_SETUP -#line 140 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_LTLT; } YY_BREAK case 89: YY_RULE_SETUP -#line 141 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_MINUS; } YY_BREAK case 90: YY_RULE_SETUP -#line 142 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_MINUSEQUALS; } YY_BREAK case 91: YY_RULE_SETUP -#line 143 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_MINUSMINUS; } YY_BREAK case 92: YY_RULE_SETUP -#line 144 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PAREEND; } YY_BREAK case 93: YY_RULE_SETUP -#line 145 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PARESTART; } YY_BREAK case 94: YY_RULE_SETUP -#line 146 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PERCENT; } YY_BREAK case 95: YY_RULE_SETUP -#line 147 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PERCENTEQUALS; } YY_BREAK case 96: YY_RULE_SETUP -#line 148 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PIPE; } YY_BREAK case 97: YY_RULE_SETUP -#line 149 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PIPEEQUALS; } YY_BREAK case 98: YY_RULE_SETUP -#line 150 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PIPEPIPE; } YY_BREAK case 99: YY_RULE_SETUP -#line 151 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PLUS; } YY_BREAK case 100: YY_RULE_SETUP -#line 152 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PLUSEQUALS; } YY_BREAK case 101: YY_RULE_SETUP -#line 153 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_PLUSPLUS; } YY_BREAK case 102: YY_RULE_SETUP -#line 154 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_QUESTION; } YY_BREAK case 103: YY_RULE_SETUP -#line 155 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_SEMICOL; } YY_BREAK case 104: YY_RULE_SETUP -#line 156 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_TILDE; } YY_BREAK case 105: YY_RULE_SETUP -#line 157 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_TIMES; } YY_BREAK case 106: YY_RULE_SETUP -#line 158 "cmDependsJavaLexer.in.l" { SYMBOL; return jp_TIMESEQUALS; } YY_BREAK case 107: YY_RULE_SETUP -#line 160 "cmDependsJavaLexer.in.l" { yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); return jp_NAME; @@ -1540,18 +1622,15 @@ YY_RULE_SETUP case 108: /* rule 108 can match eol */ YY_RULE_SETUP -#line 165 "cmDependsJavaLexer.in.l" { } YY_BREAK case 109: /* rule 109 can match eol */ YY_RULE_SETUP -#line 166 "cmDependsJavaLexer.in.l" { } YY_BREAK case 110: YY_RULE_SETUP -#line 167 "cmDependsJavaLexer.in.l" { std::cerr << "Unknown character: " << yytext[0] << " (" << (int)yytext[0] << ")" << std::endl; @@ -1561,10 +1640,8 @@ YY_RULE_SETUP YY_BREAK case 111: YY_RULE_SETUP -#line 174 "cmDependsJavaLexer.in.l" ECHO; YY_BREAK -#line 1567 "cmDependsJavaLexer.cxx" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(comment): case YY_STATE_EOF(string): @@ -1584,7 +1661,7 @@ case YY_STATE_EOF(string): /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called - * cmDependsJava_yylex(). If so, then we have to assure + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a @@ -1644,7 +1721,7 @@ case YY_STATE_EOF(string): { yyg->yy_did_buffer_switch_on_eof = 0; - if ( cmDependsJava_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1698,7 +1775,7 @@ case YY_STATE_EOF(string): } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of cmDependsJava_yylex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1712,7 +1789,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1741,7 +1818,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1777,7 +1854,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - cmDependsJava_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1809,7 +1887,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - cmDependsJava_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); } else @@ -1823,12 +1901,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmDependsJava_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } yyg->yy_n_chars += number_to_move; @@ -1862,9 +1943,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 327 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1891,9 +1972,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 327 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 326); (void)yyg; @@ -1967,7 +2048,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1984,13 +2065,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ /* Reset buffer status. */ - cmDependsJava_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( cmDependsJava_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) @@ -2022,34 +2103,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void cmDependsJava_yyrestart (FILE * input_file , yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - cmDependsJava_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmDependsJava_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - cmDependsJava_yy_load_buffer_state(yyscanner ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with - * cmDependsJava_yypop_buffer_state(); - * cmDependsJava_yypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - cmDependsJava_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -2062,17 +2143,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - cmDependsJava_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (cmDependsJava_yywrap()) processing, but the only time this flag - * is looked at is after cmDependsJava_yywrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } -static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -2087,35 +2168,35 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) cmDependsJava_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - cmDependsJava_yy_init_buffer(b,file ,yyscanner); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with cmDependsJava_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ - void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2126,28 +2207,28 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - cmDependsJava_yyfree((void *) b->yy_ch_buf ,yyscanner ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - cmDependsJava_yyfree((void *) b ,yyscanner ); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a cmDependsJava_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void cmDependsJava_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - cmDependsJava_yy_flush_buffer(b ,yyscanner); + yy_flush_buffer( b , yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then cmDependsJava_yy_init_buffer was _probably_ - * called from cmDependsJava_yyrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -2164,7 +2245,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -2185,7 +2266,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - cmDependsJava_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -2194,15 +2275,15 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; - cmDependsJava_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from cmDependsJava_yy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -2216,8 +2297,8 @@ void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yy yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from cmDependsJava_yy_switch_to_buffer. */ - cmDependsJava_yy_load_buffer_state(yyscanner ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } @@ -2225,19 +2306,19 @@ void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yy * The next element becomes the new top. * @param yyscanner The scanner object. */ -void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; - cmDependsJava_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - cmDependsJava_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -2245,9 +2326,9 @@ void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -2257,11 +2338,11 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -2276,12 +2357,12 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyrealloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2295,7 +2376,7 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -2305,11 +2386,11 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy /* They forgot to leave room for the EOB's. */ return NULL; - b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = NULL; @@ -2319,53 +2400,53 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - cmDependsJava_yy_switch_to_buffer(b ,yyscanner ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to cmDependsJava_yylex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * cmDependsJava_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return cmDependsJava_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to cmDependsJava_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) _yybytes_len + 2; - buf = (char *) cmDependsJava_yyalloc(n ,yyscanner ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < (size_t)_yybytes_len; ++i ) + for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = cmDependsJava_yy_scan_buffer(buf,n ,yyscanner); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in cmDependsJava_yy_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2379,11 +2460,11 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * yybytes, int _yyby #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2409,7 +2490,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; @@ -2418,7 +2499,7 @@ YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner) /** Get the current line number. * @param yyscanner The scanner object. */ -int cmDependsJava_yyget_lineno (yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2431,7 +2512,7 @@ int cmDependsJava_yyget_lineno (yyscan_t yyscanner) /** Get the current column number. * @param yyscanner The scanner object. */ -int cmDependsJava_yyget_column (yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2444,7 +2525,7 @@ int cmDependsJava_yyget_column (yyscan_t yyscanner) /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *cmDependsJava_yyget_in (yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; @@ -2453,7 +2534,7 @@ FILE *cmDependsJava_yyget_in (yyscan_t yyscanner) /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *cmDependsJava_yyget_out (yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; @@ -2462,7 +2543,7 @@ FILE *cmDependsJava_yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int cmDependsJava_yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -2472,7 +2553,7 @@ int cmDependsJava_yyget_leng (yyscan_t yyscanner) * @param yyscanner The scanner object. */ -char *cmDependsJava_yyget_text (yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; @@ -2482,7 +2563,7 @@ char *cmDependsJava_yyget_text (yyscan_t yyscanner) * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; @@ -2492,13 +2573,13 @@ void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner * @param _line_number line number * @param yyscanner The scanner object. */ -void cmDependsJava_yyset_lineno (int _line_number , yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmDependsJava_yyset_lineno called with no buffer" ); + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = _line_number; } @@ -2507,13 +2588,13 @@ void cmDependsJava_yyset_lineno (int _line_number , yyscan_t yyscanner) * @param _column_no column number * @param yyscanner The scanner object. */ -void cmDependsJava_yyset_column (int _column_no , yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmDependsJava_yyset_column called with no buffer" ); + YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = _column_no; } @@ -2522,27 +2603,27 @@ void cmDependsJava_yyset_column (int _column_no , yyscan_t yyscanner) * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see cmDependsJava_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void cmDependsJava_yyset_in (FILE * _in_str , yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } -void cmDependsJava_yyset_out (FILE * _out_str , yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } -int cmDependsJava_yyget_debug (yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } -void cmDependsJava_yyset_debug (int _bdebug , yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; @@ -2552,20 +2633,18 @@ void cmDependsJava_yyset_debug (int _bdebug , yyscan_t yyscanner) /* User-visible API */ -/* cmDependsJava_yylex_init is special because it creates the scanner itself, so it is +/* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ - -int cmDependsJava_yylex_init(yyscan_t* ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmDependsJava_yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2578,27 +2657,25 @@ int cmDependsJava_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } -/* cmDependsJava_yylex_init_extra has the same functionality as cmDependsJava_yylex_init, but follows the +/* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to cmDependsJava_yyalloc in + * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ - -int cmDependsJava_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; - cmDependsJava_yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmDependsJava_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2609,7 +2686,7 @@ int cmDependsJava_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_y yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - cmDependsJava_yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } @@ -2618,7 +2695,7 @@ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. - * This function is called from cmDependsJava_yylex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = NULL; @@ -2642,37 +2719,37 @@ static int yy_init_globals (yyscan_t yyscanner) #endif /* For future reference: Set errno on error, since we are called by - * cmDependsJava_yylex_init() + * yylex_init() */ return 0; } -/* cmDependsJava_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int cmDependsJava_yylex_destroy (yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - cmDependsJava_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - cmDependsJava_yypop_buffer_state(yyscanner); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - cmDependsJava_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyfree(yyg->yy_buffer_stack , yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - cmDependsJava_yyfree(yyg->yy_start_stack ,yyscanner ); + yyfree( yyg->yy_start_stack , yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * cmDependsJava_yylex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ - cmDependsJava_yyfree ( yyscanner , yyscanner ); + yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } @@ -2682,7 +2759,7 @@ int cmDependsJava_yylex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2694,7 +2771,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -2704,14 +2781,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmDependsJava_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; return malloc(size); } -void *cmDependsJava_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2726,13 +2803,11 @@ void *cmDependsJava_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner return realloc(ptr, size); } -void cmDependsJava_yyfree (void * ptr , yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - free( (char *) ptr ); /* see cmDependsJava_yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" - -#line 174 "cmDependsJavaLexer.in.l" diff --git a/Source/LexerParser/cmDependsJavaLexer.h b/Source/LexerParser/cmDependsJavaLexer.h index ccadd70..f1e87d2 100644 --- a/Source/LexerParser/cmDependsJavaLexer.h +++ b/Source/LexerParser/cmDependsJavaLexer.h @@ -2,10 +2,6 @@ #define cmDependsJava_yyHEADER_H 1 #define cmDependsJava_yyIN_HEADER 1 -#line 6 "cmDependsJavaLexer.h" - -#line 8 "cmDependsJavaLexer.h" - #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -14,11 +10,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmDependsJava_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmDependsJava_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmDependsJava_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmDependsJava_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmDependsJava_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmDependsJava_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmDependsJava_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmDependsJava_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmDependsJava_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmDependsJava_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmDependsJava_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmDependsJava_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmDependsJava_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmDependsJava_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmDependsJava_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmDependsJava_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmDependsJava_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmDependsJava_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmDependsJava_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmDependsJava_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmDependsJava_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmDependsJava_yylex_ALREADY_DEFINED +#else +#define yylex cmDependsJava_yylex +#endif + +#ifdef yyrestart +#define cmDependsJava_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmDependsJava_yyrestart +#endif + +#ifdef yylex_init +#define cmDependsJava_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmDependsJava_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmDependsJava_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmDependsJava_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmDependsJava_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmDependsJava_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmDependsJava_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmDependsJava_yyget_debug +#endif + +#ifdef yyset_debug +#define cmDependsJava_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmDependsJava_yyset_debug +#endif + +#ifdef yyget_extra +#define cmDependsJava_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmDependsJava_yyget_extra +#endif + +#ifdef yyset_extra +#define cmDependsJava_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmDependsJava_yyset_extra +#endif + +#ifdef yyget_in +#define cmDependsJava_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmDependsJava_yyget_in +#endif + +#ifdef yyset_in +#define cmDependsJava_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmDependsJava_yyset_in +#endif + +#ifdef yyget_out +#define cmDependsJava_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmDependsJava_yyget_out +#endif + +#ifdef yyset_out +#define cmDependsJava_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmDependsJava_yyset_out +#endif + +#ifdef yyget_leng +#define cmDependsJava_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmDependsJava_yyget_leng +#endif + +#ifdef yyget_text +#define cmDependsJava_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmDependsJava_yyget_text +#endif + +#ifdef yyget_lineno +#define cmDependsJava_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmDependsJava_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmDependsJava_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmDependsJava_yyset_lineno +#endif + +#ifdef yyget_column +#define cmDependsJava_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmDependsJava_yyget_column +#endif + +#ifdef yyset_column +#define cmDependsJava_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmDependsJava_yyset_column +#endif + +#ifdef yywrap +#define cmDependsJava_yywrap_ALREADY_DEFINED +#else +#define yywrap cmDependsJava_yywrap +#endif + +#ifdef yyalloc +#define cmDependsJava_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmDependsJava_yyalloc +#endif + +#ifdef yyrealloc +#define cmDependsJava_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmDependsJava_yyrealloc +#endif + +#ifdef yyfree +#define cmDependsJava_yyfree_ALREADY_DEFINED +#else +#define yyfree cmDependsJava_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -193,21 +405,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmDependsJava_yyfree (void * ,yyscan_t yyscanner ); +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); /* Begin user sect3 */ @@ -227,42 +439,42 @@ void cmDependsJava_yyfree (void * ,yyscan_t yyscanner ); #define YY_EXTRA_TYPE void * #endif -int cmDependsJava_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmDependsJava_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmDependsJava_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmDependsJava_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmDependsJava_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmDependsJava_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmDependsJava_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmDependsJava_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmDependsJava_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmDependsJava_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmDependsJava_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmDependsJava_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmDependsJava_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmDependsJava_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -270,18 +482,18 @@ void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmDependsJava_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmDependsJava_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT @@ -309,9 +521,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmDependsJava_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* yy_get_previous_state - get the state just before the EOB char was reached */ @@ -328,9 +540,150 @@ extern int cmDependsJava_yylex (yyscan_t yyscanner); #undef YY_DECL #endif -#line 174 "cmDependsJavaLexer.in.l" - +#ifndef cmDependsJava_yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef cmDependsJava_yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef cmDependsJava_yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef cmDependsJava_yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef cmDependsJava_yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef cmDependsJava_yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef cmDependsJava_yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef cmDependsJava_yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef cmDependsJava_yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef cmDependsJava_yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef cmDependsJava_yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef cmDependsJava_yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef cmDependsJava_yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef cmDependsJava_yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef cmDependsJava_yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef cmDependsJava_yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef cmDependsJava_yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef cmDependsJava_yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef cmDependsJava_yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef cmDependsJava_yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef cmDependsJava_yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef cmDependsJava_yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef cmDependsJava_yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef cmDependsJava_yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef cmDependsJava_yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef cmDependsJava_yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef cmDependsJava_yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef cmDependsJava_yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef cmDependsJava_yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef cmDependsJava_yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef cmDependsJava_yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef cmDependsJava_yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef cmDependsJava_yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef cmDependsJava_yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef cmDependsJava_yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef cmDependsJava_yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef cmDependsJava_yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef cmDependsJava_yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef cmDependsJava_yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef cmDependsJava_yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef cmDependsJava_yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef cmDependsJava_yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef cmDependsJava_yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef cmDependsJava_yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef cmDependsJava_yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif -#line 335 "cmDependsJavaLexer.h" #undef cmDependsJava_yyIN_HEADER #endif /* cmDependsJava_yyHEADER_H */ diff --git a/Source/LexerParser/cmDependsJavaLexer.in.l b/Source/LexerParser/cmDependsJavaLexer.in.l index 8cb42b1..01a0fa3 100644 --- a/Source/LexerParser/cmDependsJavaLexer.in.l +++ b/Source/LexerParser/cmDependsJavaLexer.in.l @@ -7,13 +7,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l Modify cmDependsJavaLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmDependsJavaLexer.h cmDependsJavaLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmDependsJavaLexer.cxx */ @@ -38,6 +37,8 @@ Modify cmDependsJavaLexer.cxx: /*--------------------------------------------------------------------------*/ %} +%option prefix="cmDependsJava_yy" + %option reentrant %option noyywrap %pointer diff --git a/Source/LexerParser/cmExprLexer.cxx b/Source/LexerParser/cmExprLexer.cxx index fb6f0db..81a1ec5 100644 --- a/Source/LexerParser/cmExprLexer.cxx +++ b/Source/LexerParser/cmExprLexer.cxx @@ -1,7 +1,4 @@ #include "cmStandardLexer.h" -#line 2 "cmExprLexer.cxx" - -#line 4 "cmExprLexer.cxx" #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -11,11 +8,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmExpr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmExpr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmExpr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmExpr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmExpr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmExpr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmExpr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmExpr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmExpr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmExpr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmExpr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmExpr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmExpr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmExpr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmExpr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmExpr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmExpr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmExpr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmExpr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmExpr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmExpr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmExpr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmExpr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmExpr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmExpr_yylex_ALREADY_DEFINED +#else +#define yylex cmExpr_yylex +#endif + +#ifdef yyrestart +#define cmExpr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmExpr_yyrestart +#endif + +#ifdef yylex_init +#define cmExpr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmExpr_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmExpr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmExpr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmExpr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmExpr_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmExpr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmExpr_yyget_debug +#endif + +#ifdef yyset_debug +#define cmExpr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmExpr_yyset_debug +#endif + +#ifdef yyget_extra +#define cmExpr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmExpr_yyget_extra +#endif + +#ifdef yyset_extra +#define cmExpr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmExpr_yyset_extra +#endif + +#ifdef yyget_in +#define cmExpr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmExpr_yyget_in +#endif + +#ifdef yyset_in +#define cmExpr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmExpr_yyset_in +#endif + +#ifdef yyget_out +#define cmExpr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmExpr_yyget_out +#endif + +#ifdef yyset_out +#define cmExpr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmExpr_yyset_out +#endif + +#ifdef yyget_leng +#define cmExpr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmExpr_yyget_leng +#endif + +#ifdef yyget_text +#define cmExpr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmExpr_yyget_text +#endif + +#ifdef yyget_lineno +#define cmExpr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmExpr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmExpr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmExpr_yyset_lineno +#endif + +#ifdef yyget_column +#define cmExpr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmExpr_yyget_column +#endif + +#ifdef yyset_column +#define cmExpr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmExpr_yyset_column +#endif + +#ifdef yywrap +#define cmExpr_yywrap_ALREADY_DEFINED +#else +#define yywrap cmExpr_yywrap +#endif + +#ifdef yyalloc +#define cmExpr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmExpr_yyalloc +#endif + +#ifdef yyrealloc +#define cmExpr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmExpr_yyrealloc +#endif + +#ifdef yyfree +#define cmExpr_yyfree_ALREADY_DEFINED +#else +#define yyfree cmExpr_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t; /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -131,20 +342,16 @@ typedef void* yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE cmExpr_yyrestart(yyin ,yyscanner ) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -194,7 +401,6 @@ typedef size_t yy_size_t; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -254,7 +460,7 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmExpr_yyrestart()), so that the user can continue scanning by + * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -271,73 +477,67 @@ struct yy_buffer_state #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmExpr_yypop_buffer_state (yyscan_t yyscanner ); - -static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner ); -static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner ); -static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER cmExpr_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmExpr_yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer cmExpr_yy_create_buffer +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - cmExpr_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - cmExpr_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define cmExpr_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; - #define YY_NUM_RULES 15 #define YY_END_OF_BUFFER 16 /* This struct is not used in this scanner, @@ -358,14 +557,14 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[23] = +static const flex_int16_t yy_accept[23] = { 0, 0, 0, 16, 15, 6, 8, 13, 14, 4, 2, 3, 5, 1, 15, 15, 9, 7, 10, 1, 11, 12, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -397,27 +596,27 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[16] = +static const YY_CHAR yy_meta[16] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_uint16_t yy_base[23] = +static const flex_int16_t yy_base[23] = { 0, 0, 0, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 9, 7, 5, 21, 21, 21, 6, 21, 21, 21 } ; -static yyconst flex_int16_t yy_def[23] = +static const flex_int16_t yy_def[23] = { 0, 22, 1, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0 } ; -static yyconst flex_uint16_t yy_nxt[37] = +static const flex_int16_t yy_nxt[37] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 20, 19, 22, @@ -425,7 +624,7 @@ static yyconst flex_uint16_t yy_nxt[37] = 22, 22, 22, 22, 22, 22 } ; -static yyconst flex_int16_t yy_chk[37] = +static const flex_int16_t yy_chk[37] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 15, 14, 13, 3, @@ -440,8 +639,6 @@ static yyconst flex_int16_t yy_chk[37] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "cmExprLexer.in.l" -#line 2 "cmExprLexer.in.l" /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /* @@ -450,13 +647,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l Modify cmExprLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in cmExpr_yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx */ @@ -473,7 +669,6 @@ Modify cmExprLexer.cxx: #include "cmExprParserTokens.h" /*--------------------------------------------------------------------------*/ -#line 476 "cmExprLexer.cxx" #define INITIAL 0 @@ -515,44 +710,44 @@ struct yyguts_t }; /* end struct yyguts_t */ -static int yy_init_globals (yyscan_t yyscanner ); +static int yy_init_globals ( yyscan_t yyscanner ); -int cmExpr_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmExpr_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmExpr_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmExpr_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmExpr_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmExpr_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmExpr_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmExpr_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmExpr_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmExpr_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmExpr_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmExpr_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmExpr_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -560,32 +755,31 @@ void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmExpr_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmExpr_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (yyscan_t yyscanner ); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -616,7 +810,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -629,7 +823,7 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -670,9 +864,9 @@ static int input (yyscan_t yyscanner ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmExpr_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -717,19 +911,15 @@ YY_DECL yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - cmExpr_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmExpr_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } { -#line 39 "cmExprLexer.in.l" - - -#line 732 "cmExprLexer.cxx" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -757,9 +947,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 21 ); @@ -788,80 +978,64 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 41 "cmExprLexer.in.l" { yylvalp->Number = atoi(yytext); return exp_NUMBER; } YY_BREAK case 2: YY_RULE_SETUP -#line 43 "cmExprLexer.in.l" { return exp_PLUS; } YY_BREAK case 3: YY_RULE_SETUP -#line 44 "cmExprLexer.in.l" { return exp_MINUS; } YY_BREAK case 4: YY_RULE_SETUP -#line 45 "cmExprLexer.in.l" { return exp_TIMES; } YY_BREAK case 5: YY_RULE_SETUP -#line 46 "cmExprLexer.in.l" { return exp_DIVIDE; } YY_BREAK case 6: YY_RULE_SETUP -#line 47 "cmExprLexer.in.l" { return exp_MOD; } YY_BREAK case 7: YY_RULE_SETUP -#line 48 "cmExprLexer.in.l" { return exp_OR; } YY_BREAK case 8: YY_RULE_SETUP -#line 49 "cmExprLexer.in.l" { return exp_AND; } YY_BREAK case 9: YY_RULE_SETUP -#line 50 "cmExprLexer.in.l" { return exp_XOR; } YY_BREAK case 10: YY_RULE_SETUP -#line 51 "cmExprLexer.in.l" { return exp_NOT; } YY_BREAK case 11: YY_RULE_SETUP -#line 52 "cmExprLexer.in.l" { return exp_SHIFTLEFT; } YY_BREAK case 12: YY_RULE_SETUP -#line 53 "cmExprLexer.in.l" { return exp_SHIFTRIGHT; } YY_BREAK case 13: YY_RULE_SETUP -#line 54 "cmExprLexer.in.l" { return exp_OPENPARENT; } YY_BREAK case 14: YY_RULE_SETUP -#line 55 "cmExprLexer.in.l" { return exp_CLOSEPARENT; } YY_BREAK case 15: YY_RULE_SETUP -#line 57 "cmExprLexer.in.l" ECHO; YY_BREAK -#line 864 "cmExprLexer.cxx" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -879,7 +1053,7 @@ case YY_STATE_EOF(INITIAL): /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called - * cmExpr_yylex(). If so, then we have to assure + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a @@ -939,7 +1113,7 @@ case YY_STATE_EOF(INITIAL): { yyg->yy_did_buffer_switch_on_eof = 0; - if ( cmExpr_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -993,7 +1167,7 @@ case YY_STATE_EOF(INITIAL): } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of cmExpr_yylex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1007,7 +1181,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1036,7 +1210,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1072,7 +1246,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - cmExpr_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1104,7 +1279,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - cmExpr_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); } else @@ -1118,12 +1293,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmExpr_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } yyg->yy_n_chars += number_to_move; @@ -1157,9 +1335,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1186,9 +1364,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 22); (void)yyg; @@ -1262,7 +1440,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1279,13 +1457,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ /* Reset buffer status. */ - cmExpr_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( cmExpr_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) @@ -1317,34 +1495,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void cmExpr_yyrestart (FILE * input_file , yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - cmExpr_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmExpr_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - cmExpr_yy_load_buffer_state(yyscanner ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with - * cmExpr_yypop_buffer_state(); - * cmExpr_yypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - cmExpr_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1357,17 +1535,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - cmExpr_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (cmExpr_yywrap()) processing, but the only time this flag - * is looked at is after cmExpr_yywrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } -static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -1382,35 +1560,35 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) cmExpr_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - cmExpr_yy_init_buffer(b,file ,yyscanner); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with cmExpr_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ - void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1421,28 +1599,28 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - cmExpr_yyfree((void *) b->yy_ch_buf ,yyscanner ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - cmExpr_yyfree((void *) b ,yyscanner ); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a cmExpr_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - cmExpr_yy_flush_buffer(b ,yyscanner); + yy_flush_buffer( b , yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then cmExpr_yy_init_buffer was _probably_ - * called from cmExpr_yyrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1459,7 +1637,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -1480,7 +1658,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - cmExpr_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1489,15 +1667,15 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; - cmExpr_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from cmExpr_yy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1511,8 +1689,8 @@ void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from cmExpr_yy_switch_to_buffer. */ - cmExpr_yy_load_buffer_state(yyscanner ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } @@ -1520,19 +1698,19 @@ void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner * The next element becomes the new top. * @param yyscanner The scanner object. */ -void cmExpr_yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; - cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - cmExpr_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -1540,9 +1718,9 @@ void cmExpr_yypop_buffer_state (yyscan_t yyscanner) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1552,11 +1730,11 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -1571,12 +1749,12 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyrealloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -1590,7 +1768,7 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -1600,11 +1778,11 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t /* They forgot to leave room for the EOB's. */ return NULL; - b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = NULL; @@ -1614,53 +1792,53 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - cmExpr_yy_switch_to_buffer(b ,yyscanner ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to cmExpr_yylex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * cmExpr_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return cmExpr_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to cmExpr_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) _yybytes_len + 2; - buf = (char *) cmExpr_yyalloc(n ,yyscanner ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < (size_t)_yybytes_len; ++i ) + for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = cmExpr_yy_scan_buffer(buf,n ,yyscanner); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in cmExpr_yy_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -1674,11 +1852,11 @@ YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1704,7 +1882,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; @@ -1713,7 +1891,7 @@ YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner) /** Get the current line number. * @param yyscanner The scanner object. */ -int cmExpr_yyget_lineno (yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1726,7 +1904,7 @@ int cmExpr_yyget_lineno (yyscan_t yyscanner) /** Get the current column number. * @param yyscanner The scanner object. */ -int cmExpr_yyget_column (yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1739,7 +1917,7 @@ int cmExpr_yyget_column (yyscan_t yyscanner) /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *cmExpr_yyget_in (yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; @@ -1748,7 +1926,7 @@ FILE *cmExpr_yyget_in (yyscan_t yyscanner) /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *cmExpr_yyget_out (yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; @@ -1757,7 +1935,7 @@ FILE *cmExpr_yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int cmExpr_yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -1767,7 +1945,7 @@ int cmExpr_yyget_leng (yyscan_t yyscanner) * @param yyscanner The scanner object. */ -char *cmExpr_yyget_text (yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; @@ -1777,7 +1955,7 @@ char *cmExpr_yyget_text (yyscan_t yyscanner) * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; @@ -1787,13 +1965,13 @@ void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) * @param _line_number line number * @param yyscanner The scanner object. */ -void cmExpr_yyset_lineno (int _line_number , yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmExpr_yyset_lineno called with no buffer" ); + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = _line_number; } @@ -1802,13 +1980,13 @@ void cmExpr_yyset_lineno (int _line_number , yyscan_t yyscanner) * @param _column_no column number * @param yyscanner The scanner object. */ -void cmExpr_yyset_column (int _column_no , yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmExpr_yyset_column called with no buffer" ); + YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = _column_no; } @@ -1817,27 +1995,27 @@ void cmExpr_yyset_column (int _column_no , yyscan_t yyscanner) * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see cmExpr_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void cmExpr_yyset_in (FILE * _in_str , yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } -void cmExpr_yyset_out (FILE * _out_str , yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } -int cmExpr_yyget_debug (yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } -void cmExpr_yyset_debug (int _bdebug , yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; @@ -1847,20 +2025,18 @@ void cmExpr_yyset_debug (int _bdebug , yyscan_t yyscanner) /* User-visible API */ -/* cmExpr_yylex_init is special because it creates the scanner itself, so it is +/* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ - -int cmExpr_yylex_init(yyscan_t* ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmExpr_yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -1873,27 +2049,25 @@ int cmExpr_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } -/* cmExpr_yylex_init_extra has the same functionality as cmExpr_yylex_init, but follows the +/* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to cmExpr_yyalloc in + * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ - -int cmExpr_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; - cmExpr_yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmExpr_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -1904,7 +2078,7 @@ int cmExpr_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globa yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - cmExpr_yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } @@ -1913,7 +2087,7 @@ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. - * This function is called from cmExpr_yylex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = NULL; @@ -1937,37 +2111,37 @@ static int yy_init_globals (yyscan_t yyscanner) #endif /* For future reference: Set errno on error, since we are called by - * cmExpr_yylex_init() + * yylex_init() */ return 0; } -/* cmExpr_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int cmExpr_yylex_destroy (yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - cmExpr_yypop_buffer_state(yyscanner); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - cmExpr_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyfree(yyg->yy_buffer_stack , yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - cmExpr_yyfree(yyg->yy_start_stack ,yyscanner ); + yyfree( yyg->yy_start_stack , yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * cmExpr_yylex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ - cmExpr_yyfree ( yyscanner , yyscanner ); + yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } @@ -1977,7 +2151,7 @@ int cmExpr_yylex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -1989,7 +2163,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -1999,14 +2173,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmExpr_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; return malloc(size); } -void *cmExpr_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2021,13 +2195,11 @@ void *cmExpr_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) return realloc(ptr, size); } -void cmExpr_yyfree (void * ptr , yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - free( (char *) ptr ); /* see cmExpr_yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" - -#line 57 "cmExprLexer.in.l" diff --git a/Source/LexerParser/cmExprLexer.h b/Source/LexerParser/cmExprLexer.h index 835a7a3..b55ee92 100644 --- a/Source/LexerParser/cmExprLexer.h +++ b/Source/LexerParser/cmExprLexer.h @@ -2,10 +2,6 @@ #define cmExpr_yyHEADER_H 1 #define cmExpr_yyIN_HEADER 1 -#line 6 "cmExprLexer.h" - -#line 8 "cmExprLexer.h" - #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -14,11 +10,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmExpr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmExpr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmExpr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmExpr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmExpr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmExpr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmExpr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmExpr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmExpr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmExpr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmExpr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmExpr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmExpr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmExpr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmExpr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmExpr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmExpr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmExpr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmExpr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmExpr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmExpr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmExpr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmExpr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmExpr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmExpr_yylex_ALREADY_DEFINED +#else +#define yylex cmExpr_yylex +#endif + +#ifdef yyrestart +#define cmExpr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmExpr_yyrestart +#endif + +#ifdef yylex_init +#define cmExpr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmExpr_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmExpr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmExpr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmExpr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmExpr_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmExpr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmExpr_yyget_debug +#endif + +#ifdef yyset_debug +#define cmExpr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmExpr_yyset_debug +#endif + +#ifdef yyget_extra +#define cmExpr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmExpr_yyget_extra +#endif + +#ifdef yyset_extra +#define cmExpr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmExpr_yyset_extra +#endif + +#ifdef yyget_in +#define cmExpr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmExpr_yyget_in +#endif + +#ifdef yyset_in +#define cmExpr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmExpr_yyset_in +#endif + +#ifdef yyget_out +#define cmExpr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmExpr_yyget_out +#endif + +#ifdef yyset_out +#define cmExpr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmExpr_yyset_out +#endif + +#ifdef yyget_leng +#define cmExpr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmExpr_yyget_leng +#endif + +#ifdef yyget_text +#define cmExpr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmExpr_yyget_text +#endif + +#ifdef yyget_lineno +#define cmExpr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmExpr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmExpr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmExpr_yyset_lineno +#endif + +#ifdef yyget_column +#define cmExpr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmExpr_yyget_column +#endif + +#ifdef yyset_column +#define cmExpr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmExpr_yyset_column +#endif + +#ifdef yywrap +#define cmExpr_yywrap_ALREADY_DEFINED +#else +#define yywrap cmExpr_yywrap +#endif + +#ifdef yyalloc +#define cmExpr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmExpr_yyalloc +#endif + +#ifdef yyrealloc +#define cmExpr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmExpr_yyrealloc +#endif + +#ifdef yyfree +#define cmExpr_yyfree_ALREADY_DEFINED +#else +#define yyfree cmExpr_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -193,21 +405,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmExpr_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmExpr_yyfree (void * ,yyscan_t yyscanner ); +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); /* Begin user sect3 */ @@ -225,42 +437,42 @@ void cmExpr_yyfree (void * ,yyscan_t yyscanner ); #define YY_EXTRA_TYPE void * #endif -int cmExpr_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmExpr_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmExpr_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmExpr_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmExpr_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmExpr_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmExpr_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmExpr_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmExpr_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmExpr_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmExpr_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmExpr_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmExpr_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -268,18 +480,18 @@ void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmExpr_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmExpr_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT @@ -307,9 +519,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmExpr_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* yy_get_previous_state - get the state just before the EOB char was reached */ @@ -326,9 +538,150 @@ extern int cmExpr_yylex (yyscan_t yyscanner); #undef YY_DECL #endif -#line 57 "cmExprLexer.in.l" - +#ifndef cmExpr_yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef cmExpr_yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef cmExpr_yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef cmExpr_yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef cmExpr_yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef cmExpr_yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef cmExpr_yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef cmExpr_yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef cmExpr_yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef cmExpr_yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef cmExpr_yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef cmExpr_yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef cmExpr_yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef cmExpr_yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef cmExpr_yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef cmExpr_yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef cmExpr_yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef cmExpr_yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef cmExpr_yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef cmExpr_yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef cmExpr_yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef cmExpr_yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef cmExpr_yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef cmExpr_yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef cmExpr_yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef cmExpr_yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef cmExpr_yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef cmExpr_yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef cmExpr_yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef cmExpr_yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef cmExpr_yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef cmExpr_yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef cmExpr_yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef cmExpr_yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef cmExpr_yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef cmExpr_yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef cmExpr_yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef cmExpr_yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef cmExpr_yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef cmExpr_yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef cmExpr_yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef cmExpr_yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef cmExpr_yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef cmExpr_yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef cmExpr_yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef cmExpr_yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef cmExpr_yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef cmExpr_yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif -#line 333 "cmExprLexer.h" #undef cmExpr_yyIN_HEADER #endif /* cmExpr_yyHEADER_H */ diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l index 25ddba4..e5f177a 100644 --- a/Source/LexerParser/cmExprLexer.in.l +++ b/Source/LexerParser/cmExprLexer.in.l @@ -7,13 +7,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l + flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l Modify cmExprLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t + - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx */ @@ -32,6 +31,8 @@ Modify cmExprLexer.cxx: /*--------------------------------------------------------------------------*/ %} +%option prefix="cmExpr_yy" + %option reentrant %option noyywrap %pointer diff --git a/Source/LexerParser/cmFortranLexer.cxx b/Source/LexerParser/cmFortranLexer.cxx index 01c09ac..dec0f5e 100644 --- a/Source/LexerParser/cmFortranLexer.cxx +++ b/Source/LexerParser/cmFortranLexer.cxx @@ -1,7 +1,4 @@ #include "cmStandardLexer.h" -#line 2 "cmFortranLexer.cxx" - -#line 4 "cmFortranLexer.cxx" #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -11,11 +8,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmFortran_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmFortran_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmFortran_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmFortran_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmFortran_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmFortran_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmFortran_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmFortran_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmFortran_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmFortran_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmFortran_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmFortran_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmFortran_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmFortran_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmFortran_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmFortran_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmFortran_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmFortran_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmFortran_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmFortran_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmFortran_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmFortran_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmFortran_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmFortran_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmFortran_yylex_ALREADY_DEFINED +#else +#define yylex cmFortran_yylex +#endif + +#ifdef yyrestart +#define cmFortran_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmFortran_yyrestart +#endif + +#ifdef yylex_init +#define cmFortran_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmFortran_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmFortran_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmFortran_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmFortran_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmFortran_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmFortran_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmFortran_yyget_debug +#endif + +#ifdef yyset_debug +#define cmFortran_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmFortran_yyset_debug +#endif + +#ifdef yyget_extra +#define cmFortran_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmFortran_yyget_extra +#endif + +#ifdef yyset_extra +#define cmFortran_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmFortran_yyset_extra +#endif + +#ifdef yyget_in +#define cmFortran_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmFortran_yyget_in +#endif + +#ifdef yyset_in +#define cmFortran_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmFortran_yyset_in +#endif + +#ifdef yyget_out +#define cmFortran_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmFortran_yyget_out +#endif + +#ifdef yyset_out +#define cmFortran_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmFortran_yyset_out +#endif + +#ifdef yyget_leng +#define cmFortran_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmFortran_yyget_leng +#endif + +#ifdef yyget_text +#define cmFortran_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmFortran_yyget_text +#endif + +#ifdef yyget_lineno +#define cmFortran_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmFortran_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmFortran_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmFortran_yyset_lineno +#endif + +#ifdef yyget_column +#define cmFortran_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmFortran_yyget_column +#endif + +#ifdef yyset_column +#define cmFortran_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmFortran_yyset_column +#endif + +#ifdef yywrap +#define cmFortran_yywrap_ALREADY_DEFINED +#else +#define yywrap cmFortran_yywrap +#endif + +#ifdef yyalloc +#define cmFortran_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmFortran_yyalloc +#endif + +#ifdef yyrealloc +#define cmFortran_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmFortran_yyrealloc +#endif + +#ifdef yyfree +#define cmFortran_yyfree_ALREADY_DEFINED +#else +#define yyfree cmFortran_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t; /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -131,20 +342,16 @@ typedef void* yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE cmFortran_yyrestart(yyin ,yyscanner ) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -194,7 +401,6 @@ typedef size_t yy_size_t; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -254,7 +460,7 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmFortran_yyrestart()), so that the user can continue scanning by + * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -271,73 +477,67 @@ struct yy_buffer_state #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmFortran_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner ); -static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner ); -static void cmFortran_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -#define YY_FLUSH_BUFFER cmFortran_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmFortran_yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer cmFortran_yy_create_buffer +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - cmFortran_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - cmFortran_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define cmFortran_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; - #define YY_NUM_RULES 54 #define YY_END_OF_BUFFER 55 /* This struct is not used in this scanner, @@ -358,7 +557,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[210] = +static const flex_int16_t yy_accept[210] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 49, 51, 50, 53, 1, 49, 33, 2, 47, @@ -368,16 +567,16 @@ static yyconst flex_int16_t yy_accept[210] = 0, 0, 33, 33, 34, 36, 39, 49, 46, 46, 46, 46, 46, 46, 0, 52, 46, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 49, 0, 11, - 46, 0, 0, 5, 0, 0, 0, 29, 0, 0, + 46, 0, 0, 5, 0, 0, 0, 0, 29, 0, 33, 33, 33, 33, 0, 0, 40, 46, 46, 46, 46, 45, 12, 12, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 30, 31, 0, 0, 0, 0, 0, 0, 46, 46, + 0, 30, 31, 0, 0, 0, 0, 0, 46, 46, 46, 46, 0, 24, 25, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 32, 27, 0, 0, 20, 0, + 0, 0, 0, 0, 20, 32, 27, 0, 0, 0, 46, 46, 43, 46, 0, 26, 21, 0, 0, 0, 19, 0, 0, 18, 28, 0, 0, 41, 46, 46, 17, 22, 0, 7, 38, 7, 15, 0, 46, 46, @@ -385,7 +584,7 @@ static yyconst flex_int16_t yy_accept[210] = 14, 16, 42, 44, 0, 0, 0, 13, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -394,13 +593,13 @@ static yyconst YY_CHAR yy_ec[256] = 13, 14, 1, 15, 1, 1, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 19, 20, 21, 22, 1, 23, 24, 25, 26, 27, 28, - 29, 29, 30, 29, 29, 31, 32, 33, 34, 29, - 29, 35, 36, 37, 38, 29, 29, 29, 29, 29, - 1, 39, 1, 1, 40, 1, 23, 24, 41, 42, + 24, 24, 29, 24, 24, 30, 31, 32, 33, 24, + 24, 34, 35, 36, 37, 24, 24, 24, 24, 24, + 1, 38, 1, 1, 39, 1, 23, 40, 41, 42, - 43, 44, 29, 29, 45, 29, 29, 46, 32, 47, - 34, 29, 29, 35, 48, 37, 49, 29, 29, 29, - 29, 29, 1, 1, 1, 1, 1, 1, 1, 1, + 43, 44, 24, 24, 45, 24, 24, 46, 31, 47, + 33, 24, 24, 34, 48, 36, 49, 24, 24, 24, + 24, 24, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -417,49 +616,49 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[50] = +static const YY_CHAR yy_meta[50] = { 0, 1, 2, 2, 3, 4, 3, 3, 1, 1, 3, 3, 3, 3, 1, 3, 5, 3, 3, 1, 3, 6, 1, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 1, 5, + 7, 7, 7, 7, 7, 7, 7, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 } ; -static yyconst flex_uint16_t yy_base[219] = +static const flex_int16_t yy_base[219] = { 0, - 0, 48, 0, 49, 513, 56, 52, 57, 62, 68, - 515, 0, 583, 583, 509, 583, 97, 74, 583, 583, - 583, 583, 491, 583, 423, 421, 0, 19, 40, 392, - 36, 47, 86, 146, 88, 186, 413, 235, 275, 583, - 407, 98, 583, 583, 0, 386, 583, 323, 65, 73, - 81, 74, 127, 146, 583, 583, 583, 108, 0, 89, - 120, 92, 362, 116, 161, 583, 0, 167, 371, 0, - 168, 131, 146, 171, 81, 89, 352, 420, 353, 583, - 0, 349, 178, 196, 175, 197, 188, 208, 196, 197, - 256, 262, 324, 330, 337, 143, 0, 151, 220, 56, - - 305, 0, 336, 139, 225, 315, 305, 322, 318, 163, - 320, 268, 266, 369, 583, 340, 347, 350, 350, 351, - 357, 350, 357, 363, 140, 235, 359, 218, 362, 375, - 379, 380, 381, 385, 384, 404, 405, 243, 235, 213, - 583, 583, 405, 407, 410, 171, 410, 409, 419, 418, - 423, 426, 311, 583, 583, 428, 429, 431, 173, 462, - 435, 166, 145, 438, 583, 583, 441, 444, 583, 433, - 448, 89, 0, 438, 450, 583, 583, 452, 457, 487, - 583, 114, 0, 583, 583, 457, 462, 0, 465, 463, - 583, 583, 468, 583, 583, 583, 583, 470, 471, 474, - - 500, 583, 0, 0, 505, 0, 65, 583, 583, 524, - 531, 537, 540, 547, 554, 561, 568, 575 + 0, 48, 0, 49, 464, 56, 52, 57, 62, 68, + 466, 0, 468, 468, 462, 468, 74, 81, 468, 468, + 468, 468, 447, 468, 442, 440, 0, 41, 42, 428, + 43, 42, 91, 119, 97, 157, 455, 206, 245, 468, + 454, 101, 468, 468, 0, 455, 468, 105, 430, 424, + 62, 68, 119, 141, 468, 468, 468, 111, 0, 59, + 98, 88, 415, 109, 158, 468, 0, 162, 293, 0, + 163, 411, 107, 122, 408, 405, 446, 342, 447, 468, + 0, 444, 169, 173, 420, 421, 132, 404, 90, 404, + 179, 185, 191, 227, 295, 397, 0, 146, 178, 149, + + 412, 0, 208, 206, 398, 171, 399, 170, 399, 391, + 387, 422, 417, 221, 468, 374, 365, 347, 347, 334, + 335, 335, 330, 334, 259, 340, 188, 340, 327, 327, + 327, 324, 325, 325, 320, 322, 319, 355, 354, 325, + 327, 468, 468, 310, 309, 309, 300, 301, 273, 273, + 275, 277, 297, 468, 468, 293, 289, 283, 275, 305, + 261, 238, 237, 214, 468, 468, 468, 196, 197, 189, + 277, 181, 0, 274, 112, 468, 468, 105, 103, 311, + 468, 233, 0, 468, 468, 83, 76, 0, 281, 282, + 468, 468, 52, 468, 468, 468, 468, 23, 287, 298, + + 327, 468, 0, 0, 329, 0, 31, 468, 468, 381, + 388, 394, 397, 404, 411, 418, 425, 432 } ; -static yyconst flex_int16_t yy_def[219] = +static const flex_int16_t yy_def[219] = { 0, 209, 1, 1, 1, 1, 1, 210, 210, 210, 210, 209, 211, 209, 209, 212, 209, 211, 209, 209, 209, 209, 209, 209, 209, 209, 211, 213, 213, 213, 213, - 213, 213, 211, 213, 209, 209, 209, 214, 209, 209, + 213, 213, 211, 213, 209, 211, 209, 214, 209, 209, 209, 209, 209, 209, 211, 212, 209, 209, 209, 209, 209, 209, 209, 215, 209, 209, 209, 211, 213, 213, 213, 213, 213, 213, 209, 209, 34, 209, 209, 69, @@ -482,152 +681,126 @@ static yyconst flex_int16_t yy_def[219] = 209, 209, 209, 209, 209, 209, 209, 209 } ; -static yyconst flex_uint16_t yy_nxt[633] = +static const flex_int16_t yy_nxt[518] = { 0, 12, 13, 14, 13, 13, 15, 16, 12, 17, 18, 19, 20, 21, 12, 22, 12, 23, 24, 12, 25, - 12, 26, 27, 27, 27, 27, 28, 27, 27, 29, - 27, 30, 27, 27, 27, 31, 27, 32, 33, 34, + 12, 26, 27, 27, 27, 27, 28, 27, 29, 27, + 30, 27, 27, 27, 31, 27, 32, 33, 34, 27, 27, 27, 28, 27, 29, 27, 27, 31, 32, 35, - 35, 60, 35, 35, 41, 36, 36, 35, 37, 41, - 35, 42, 43, 36, 41, 60, 42, 43, 44, 38, - 41, 42, 61, 63, 44, 53, 53, 42, 53, 54, - 39, 39, 64, 55, 63, 208, 61, 65, 66, 68, - 65, 85, 68, 127, 64, 69, 39, 39, 48, 83, - - 84, 48, 83, 86, 127, 87, 90, 85, 88, 95, - 110, 189, 95, 89, 97, 195, 195, 100, 86, 87, - 90, 111, 49, 50, 88, 110, 51, 89, 53, 53, - 97, 53, 54, 100, 52, 111, 55, 96, 49, 50, - 104, 51, 102, 104, 98, 52, 45, 92, 53, 183, - 92, 93, 96, 45, 45, 94, 99, 105, 102, 45, - 98, 67, 65, 66, 45, 65, 45, 45, 68, 104, - 182, 68, 104, 105, 69, 124, 106, 149, 107, 83, - 84, 125, 83, 71, 45, 67, 45, 70, 149, 124, - 70, 106, 107, 45, 45, 136, 125, 114, 108, 45, - - 114, 71, 116, 109, 45, 115, 45, 45, 168, 136, - 179, 72, 73, 119, 108, 74, 75, 109, 116, 168, - 122, 179, 123, 76, 45, 45, 117, 72, 73, 119, - 74, 75, 118, 120, 76, 78, 122, 80, 123, 163, - 121, 117, 78, 78, 118, 164, 126, 162, 78, 120, - 78, 152, 129, 78, 121, 78, 78, 92, 53, 164, - 92, 93, 126, 92, 53, 94, 92, 93, 129, 150, - 139, 94, 138, 78, 78, 79, 79, 80, 79, 79, + 35, 208, 35, 35, 41, 36, 36, 35, 37, 41, + 35, 42, 43, 36, 41, 202, 42, 43, 44, 38, + 41, 42, 60, 61, 44, 48, 64, 42, 48, 63, + 39, 39, 53, 53, 97, 53, 54, 60, 61, 64, + 55, 63, 65, 66, 201, 65, 39, 39, 68, 49, + + 97, 68, 83, 84, 69, 83, 48, 87, 88, 48, + 50, 89, 95, 100, 90, 95, 51, 198, 52, 45, + 53, 53, 98, 53, 54, 197, 45, 45, 55, 100, + 49, 121, 45, 99, 67, 102, 122, 45, 98, 45, + 45, 50, 92, 53, 193, 92, 93, 51, 192, 52, + 94, 102, 106, 107, 191, 96, 45, 67, 70, 65, + 66, 70, 65, 68, 104, 108, 68, 104, 109, 69, + 83, 84, 71, 83, 114, 125, 118, 114, 71, 119, + 92, 53, 115, 92, 93, 127, 92, 53, 94, 92, + 93, 125, 92, 53, 94, 92, 93, 127, 72, 73, + + 94, 74, 75, 189, 126, 76, 78, 104, 80, 104, + 104, 133, 104, 78, 78, 130, 134, 151, 131, 78, + 126, 78, 114, 103, 78, 114, 78, 78, 92, 53, + 115, 92, 93, 151, 195, 195, 94, 187, 186, 185, + 184, 183, 182, 78, 78, 79, 79, 80, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 79, 79, 79, 79, 79, 79, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 79, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 48, 92, 53, 48, 92, 93, - 132, 92, 53, 94, 92, 93, 128, 104, 95, 94, - 104, 95, 135, 175, 130, 137, 132, 133, 49, 50, - 131, 103, 51, 113, 134, 80, 112, 175, 135, 130, - 52, 137, 131, 133, 49, 50, 96, 51, 134, 140, - 114, 52, 70, 114, 141, 70, 142, 144, 115, 143, - 146, 96, 145, 147, 140, 101, 103, 148, 47, 151, - 141, 153, 142, 144, 143, 146, 72, 73, 145, 147, - - 74, 75, 154, 148, 151, 155, 153, 157, 76, 156, - 158, 82, 72, 73, 159, 74, 75, 77, 154, 76, - 78, 155, 80, 157, 156, 62, 158, 78, 78, 159, - 160, 161, 165, 78, 166, 78, 167, 169, 78, 170, - 78, 78, 58, 57, 171, 172, 160, 161, 165, 173, - 166, 174, 167, 169, 170, 176, 177, 178, 78, 78, - 171, 172, 181, 180, 184, 173, 180, 174, 185, 186, - 187, 176, 177, 178, 188, 190, 191, 103, 181, 192, - 184, 187, 193, 197, 185, 186, 190, 198, 180, 199, - 188, 180, 191, 200, 201, 192, 202, 203, 193, 197, - - 204, 205, 103, 198, 205, 199, 205, 56, 200, 205, - 201, 47, 202, 203, 209, 37, 204, 209, 206, 209, - 209, 209, 209, 206, 40, 40, 40, 40, 40, 40, - 40, 45, 209, 209, 209, 45, 45, 46, 46, 46, - 46, 46, 46, 46, 59, 209, 59, 79, 79, 79, - 79, 79, 79, 79, 91, 91, 91, 91, 91, 91, - 91, 194, 194, 194, 209, 194, 194, 194, 196, 209, - 196, 209, 196, 196, 196, 207, 207, 207, 207, 207, - 209, 207, 11, 209, 209, 209, 209, 209, 209, 209, + 81, 81, 79, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 70, 149, 95, 70, 171, 95, + + 172, 173, 174, 188, 181, 199, 180, 149, 103, 180, + 190, 200, 180, 203, 171, 180, 172, 173, 174, 188, + 103, 199, 190, 179, 204, 178, 103, 200, 205, 203, + 205, 205, 177, 205, 72, 73, 176, 74, 75, 96, + 204, 76, 78, 175, 80, 206, 170, 206, 169, 78, + 78, 168, 167, 166, 165, 78, 164, 78, 163, 162, + 78, 161, 78, 78, 160, 159, 158, 157, 156, 155, + 154, 153, 152, 150, 148, 147, 146, 145, 144, 78, + 78, 40, 40, 40, 40, 40, 40, 40, 45, 143, + 142, 141, 45, 45, 46, 46, 46, 46, 46, 46, + + 46, 59, 140, 59, 79, 79, 79, 79, 79, 79, + 79, 91, 91, 91, 91, 91, 91, 91, 194, 194, + 194, 139, 194, 194, 194, 196, 138, 196, 137, 196, + 196, 196, 207, 207, 207, 207, 207, 136, 207, 135, + 132, 129, 128, 124, 123, 120, 117, 116, 113, 80, + 112, 111, 110, 105, 101, 86, 85, 47, 82, 77, + 62, 58, 57, 56, 47, 209, 37, 11, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, + 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209 + 209, 209, 209, 209, 209, 209, 209 } ; -static yyconst flex_int16_t yy_chk[633] = +static const flex_int16_t yy_chk[518] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 4, 28, 2, 4, 7, 2, 4, 6, 6, 8, - 6, 7, 7, 6, 9, 28, 8, 8, 9, 6, - 10, 9, 29, 31, 10, 18, 18, 10, 18, 18, - 6, 6, 32, 18, 31, 207, 29, 33, 33, 35, - 33, 49, 35, 100, 32, 35, 6, 6, 17, 42, - - 42, 17, 42, 50, 100, 50, 52, 49, 51, 58, - 75, 172, 58, 51, 60, 182, 182, 62, 50, 50, - 52, 76, 17, 17, 51, 75, 17, 51, 53, 53, - 60, 53, 53, 62, 17, 76, 53, 58, 17, 17, - 104, 17, 64, 104, 61, 17, 34, 54, 54, 163, - 54, 54, 58, 34, 34, 54, 61, 72, 64, 34, - 61, 34, 65, 65, 34, 65, 34, 34, 68, 71, - 162, 68, 71, 72, 68, 96, 73, 125, 73, 83, - 83, 98, 83, 71, 34, 34, 36, 36, 125, 96, - 36, 73, 73, 36, 36, 110, 98, 84, 74, 36, - - 84, 36, 85, 74, 36, 84, 36, 36, 146, 110, - 159, 36, 36, 87, 74, 36, 36, 74, 85, 146, - 89, 159, 90, 36, 36, 36, 86, 36, 36, 87, - 36, 36, 86, 88, 36, 38, 89, 38, 90, 139, - 88, 86, 38, 38, 86, 140, 99, 138, 38, 88, - 38, 128, 105, 38, 88, 38, 38, 91, 91, 140, - 91, 91, 99, 92, 92, 91, 92, 92, 105, 126, - 113, 92, 112, 38, 38, 39, 39, 39, 39, 39, + 4, 207, 2, 4, 7, 2, 4, 6, 6, 8, + 6, 7, 7, 6, 9, 198, 8, 8, 9, 6, + 10, 9, 28, 29, 10, 17, 32, 10, 17, 31, + 6, 6, 18, 18, 60, 18, 18, 28, 29, 32, + 18, 31, 33, 33, 193, 33, 6, 6, 35, 17, + + 60, 35, 42, 42, 35, 42, 48, 51, 51, 48, + 17, 52, 58, 62, 52, 58, 17, 187, 17, 34, + 53, 53, 61, 53, 53, 186, 34, 34, 53, 62, + 48, 89, 34, 61, 34, 64, 89, 34, 61, 34, + 34, 48, 54, 54, 179, 54, 54, 48, 178, 48, + 54, 64, 73, 73, 175, 58, 34, 34, 36, 65, + 65, 36, 65, 68, 71, 74, 68, 71, 74, 68, + 83, 83, 36, 83, 84, 98, 87, 84, 71, 87, + 91, 91, 84, 91, 91, 100, 92, 92, 91, 92, + 92, 98, 93, 93, 92, 93, 93, 100, 36, 36, + + 93, 36, 36, 172, 99, 36, 38, 104, 38, 103, + 104, 108, 103, 38, 38, 106, 108, 127, 106, 38, + 99, 38, 114, 103, 38, 114, 38, 38, 94, 94, + 114, 94, 94, 127, 182, 182, 94, 170, 169, 168, + 164, 163, 162, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 48, 93, 93, 48, 93, 93, - 107, 94, 94, 93, 94, 94, 101, 103, 95, 94, - 103, 95, 109, 153, 106, 111, 107, 108, 48, 48, - 106, 103, 48, 82, 108, 79, 77, 153, 109, 106, - 48, 111, 106, 108, 48, 48, 95, 48, 108, 116, - 114, 48, 69, 114, 117, 69, 118, 120, 114, 119, - 122, 95, 121, 123, 116, 63, 69, 124, 46, 127, - 117, 129, 118, 120, 119, 122, 69, 69, 121, 123, - - 69, 69, 130, 124, 127, 131, 129, 133, 69, 132, - 134, 41, 69, 69, 135, 69, 69, 37, 130, 69, - 78, 131, 78, 133, 132, 30, 134, 78, 78, 135, - 136, 137, 143, 78, 144, 78, 145, 147, 78, 148, - 78, 78, 26, 25, 149, 150, 136, 137, 143, 151, - 144, 152, 145, 147, 148, 156, 157, 158, 78, 78, - 149, 150, 161, 160, 164, 151, 160, 152, 167, 168, - 170, 156, 157, 158, 171, 174, 175, 160, 161, 178, - 164, 170, 179, 186, 167, 168, 174, 187, 180, 189, - 171, 180, 175, 190, 193, 178, 198, 199, 179, 186, - - 200, 201, 180, 187, 201, 189, 205, 23, 190, 205, - 193, 15, 198, 199, 11, 5, 200, 0, 201, 0, - 0, 0, 0, 205, 210, 210, 210, 210, 210, 210, - 210, 211, 0, 0, 0, 211, 211, 212, 212, 212, - 212, 212, 212, 212, 213, 0, 213, 214, 214, 214, - 214, 214, 214, 214, 215, 215, 215, 215, 215, 215, - 215, 216, 216, 216, 0, 216, 216, 216, 217, 0, - 217, 0, 217, 217, 217, 218, 218, 218, 218, 218, - 0, 218, 209, 209, 209, 209, 209, 209, 209, 209, + 39, 39, 39, 39, 69, 125, 95, 69, 149, 95, + + 150, 151, 152, 171, 161, 189, 160, 125, 69, 160, + 174, 190, 180, 199, 149, 180, 150, 151, 152, 171, + 160, 189, 174, 159, 200, 158, 180, 190, 201, 199, + 205, 201, 157, 205, 69, 69, 156, 69, 69, 95, + 200, 69, 78, 153, 78, 201, 148, 205, 147, 78, + 78, 146, 145, 144, 141, 78, 140, 78, 139, 138, + 78, 137, 78, 78, 136, 135, 134, 133, 132, 131, + 130, 129, 128, 126, 124, 123, 122, 121, 120, 78, + 78, 210, 210, 210, 210, 210, 210, 210, 211, 119, + 118, 117, 211, 211, 212, 212, 212, 212, 212, 212, + + 212, 213, 116, 213, 214, 214, 214, 214, 214, 214, + 214, 215, 215, 215, 215, 215, 215, 215, 216, 216, + 216, 113, 216, 216, 216, 217, 112, 217, 111, 217, + 217, 217, 218, 218, 218, 218, 218, 110, 218, 109, + 107, 105, 101, 96, 90, 88, 86, 85, 82, 79, + 77, 76, 75, 72, 63, 50, 49, 46, 41, 37, + 30, 26, 25, 23, 15, 11, 5, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, + 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209 + 209, 209, 209, 209, 209, 209, 209 } ; /* The intent behind this definition is that it'll catch @@ -637,8 +810,6 @@ static yyconst flex_int16_t yy_chk[633] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "cmFortranLexer.in.l" -#line 2 "cmFortranLexer.in.l" /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /*------------------------------------------------------------------------- @@ -657,14 +828,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex -i --nounistd -DFLEXINT_H --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l + flex -i --nounistd -DFLEXINT_H --noline --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l Modify cmFortranLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in cmFortran_yy_scan_bytes for loop condition of _yybytes_len to size_t - + - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmFortranLexer.h cmFortranLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmFortranLexer.cxx */ /* IWYU pragma: no_forward_declare yyguts_t */ @@ -684,9 +853,6 @@ Modify cmFortranLexer.cxx: /*--------------------------------------------------------------------------*/ - -#line 688 "cmFortranLexer.cxx" - #define INITIAL 0 #define free_fmt 1 #define fixed_fmt 2 @@ -731,44 +897,44 @@ struct yyguts_t }; /* end struct yyguts_t */ -static int yy_init_globals (yyscan_t yyscanner ); +static int yy_init_globals ( yyscan_t yyscanner ); -int cmFortran_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmFortran_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmFortran_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmFortran_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmFortran_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmFortran_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmFortran_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmFortran_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmFortran_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmFortran_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmFortran_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmFortran_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -776,32 +942,31 @@ void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmFortran_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmFortran_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (yyscan_t yyscanner ); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -832,7 +997,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -845,7 +1010,7 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -886,9 +1051,9 @@ static int input (yyscan_t yyscanner ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmFortran_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -936,19 +1101,15 @@ YY_DECL yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - cmFortran_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmFortran_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } { -#line 56 "cmFortranLexer.in.l" - - -#line 951 "cmFortranLexer.cxx" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -977,12 +1138,12 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 210 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 583 ); + while ( yy_base[yy_current_state] != 468 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1008,7 +1169,6 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 58 "cmFortranLexer.in.l" { cmFortranParser_StringStart(yyextra); cmFortranParser_SetOldStartcond(yyextra, YY_START); @@ -1017,7 +1177,6 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 64 "cmFortranLexer.in.l" { cmFortranParser_StringStart(yyextra); cmFortranParser_SetOldStartcond(yyextra, YY_START); @@ -1025,10 +1184,8 @@ YY_RULE_SETUP } YY_BREAK case 3: -#line 71 "cmFortranLexer.in.l" case 4: YY_RULE_SETUP -#line 71 "cmFortranLexer.in.l" { BEGIN(cmFortranParser_GetOldStartcond(yyextra) ); yylvalp->string = strdup(cmFortranParser_StringEnd(yyextra)); @@ -1037,17 +1194,14 @@ YY_RULE_SETUP YY_BREAK case 5: /* rule 5 can match eol */ -#line 78 "cmFortranLexer.in.l" case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 78 "cmFortranLexer.in.l" /* Ignore (continued strings, free fmt) */ YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 80 "cmFortranLexer.in.l" { if (cmFortranParser_GetOldStartcond(yyextra) == fixed_fmt) ; /* Ignore (cont. strings, fixed fmt) */ @@ -1060,7 +1214,6 @@ YY_RULE_SETUP case 8: /* rule 8 can match eol */ YY_RULE_SETUP -#line 90 "cmFortranLexer.in.l" { unput ('\n'); BEGIN(INITIAL); @@ -1069,7 +1222,6 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 96 "cmFortranLexer.in.l" { cmFortranParser_StringAppend(yyextra, yytext[0]); } @@ -1077,24 +1229,20 @@ YY_RULE_SETUP case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 100 "cmFortranLexer.in.l" { return EOSTMT; } /* Treat comments like */ YY_BREAK case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 101 "cmFortranLexer.in.l" { return EOSTMT; } /* empty lines */ YY_BREAK case 12: YY_RULE_SETUP -#line 103 "cmFortranLexer.in.l" { return CPP_LINE_DIRECTIVE; } YY_BREAK case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 104 "cmFortranLexer.in.l" { yytext[yyleng-1] = 0; yylvalp->string = strdup(strchr(yytext, '<')+1); @@ -1103,171 +1251,138 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 109 "cmFortranLexer.in.l" { return CPP_INCLUDE; } YY_BREAK case 15: YY_RULE_SETUP -#line 110 "cmFortranLexer.in.l" { return F90PPR_INCLUDE; } YY_BREAK case 16: YY_RULE_SETUP -#line 111 "cmFortranLexer.in.l" { return COCO_INCLUDE; } YY_BREAK case 17: YY_RULE_SETUP -#line 113 "cmFortranLexer.in.l" { return CPP_DEFINE; } YY_BREAK case 18: YY_RULE_SETUP -#line 114 "cmFortranLexer.in.l" { return F90PPR_DEFINE; } YY_BREAK case 19: YY_RULE_SETUP -#line 116 "cmFortranLexer.in.l" { return CPP_UNDEF; } YY_BREAK case 20: YY_RULE_SETUP -#line 117 "cmFortranLexer.in.l" { return F90PPR_UNDEF; } YY_BREAK case 21: YY_RULE_SETUP -#line 119 "cmFortranLexer.in.l" { return CPP_IFDEF; } YY_BREAK case 22: YY_RULE_SETUP -#line 120 "cmFortranLexer.in.l" { return CPP_IFNDEF; } YY_BREAK case 23: YY_RULE_SETUP -#line 121 "cmFortranLexer.in.l" { return CPP_IF; } YY_BREAK case 24: YY_RULE_SETUP -#line 122 "cmFortranLexer.in.l" { return CPP_ELIF; } YY_BREAK case 25: YY_RULE_SETUP -#line 123 "cmFortranLexer.in.l" { return CPP_ELSE; } YY_BREAK case 26: YY_RULE_SETUP -#line 124 "cmFortranLexer.in.l" { return CPP_ENDIF; } YY_BREAK case 27: YY_RULE_SETUP -#line 126 "cmFortranLexer.in.l" { return F90PPR_IFDEF; } YY_BREAK case 28: YY_RULE_SETUP -#line 127 "cmFortranLexer.in.l" { return F90PPR_IFNDEF; } YY_BREAK case 29: YY_RULE_SETUP -#line 128 "cmFortranLexer.in.l" { return F90PPR_IF; } YY_BREAK case 30: YY_RULE_SETUP -#line 129 "cmFortranLexer.in.l" { return F90PPR_ELIF; } YY_BREAK case 31: YY_RULE_SETUP -#line 130 "cmFortranLexer.in.l" { return F90PPR_ELSE; } YY_BREAK case 32: YY_RULE_SETUP -#line 131 "cmFortranLexer.in.l" { return F90PPR_ENDIF; } YY_BREAK /* Line continuations, possible involving comments. */ case 33: /* rule 33 can match eol */ YY_RULE_SETUP -#line 134 "cmFortranLexer.in.l" YY_BREAK case 34: /* rule 34 can match eol */ YY_RULE_SETUP -#line 135 "cmFortranLexer.in.l" YY_BREAK case 35: YY_RULE_SETUP -#line 137 "cmFortranLexer.in.l" { return COMMA; } YY_BREAK case 36: YY_RULE_SETUP -#line 139 "cmFortranLexer.in.l" { return DCOLON; } YY_BREAK case 37: YY_RULE_SETUP -#line 140 "cmFortranLexer.in.l" { return COLON; } YY_BREAK case 38: /* rule 38 can match eol */ YY_RULE_SETUP -#line 142 "cmFortranLexer.in.l" { return GARBAGE; } YY_BREAK case 39: YY_RULE_SETUP -#line 144 "cmFortranLexer.in.l" { return ASSIGNMENT_OP; } YY_BREAK case 40: YY_RULE_SETUP -#line 146 "cmFortranLexer.in.l" { return END; } YY_BREAK case 41: YY_RULE_SETUP -#line 147 "cmFortranLexer.in.l" { return INCLUDE; } YY_BREAK case 42: YY_RULE_SETUP -#line 148 "cmFortranLexer.in.l" { return INTERFACE; } YY_BREAK case 43: YY_RULE_SETUP -#line 149 "cmFortranLexer.in.l" { return MODULE; } YY_BREAK case 44: YY_RULE_SETUP -#line 150 "cmFortranLexer.in.l" { return SUBMODULE; } YY_BREAK case 45: YY_RULE_SETUP -#line 151 "cmFortranLexer.in.l" { return USE; } YY_BREAK case 46: YY_RULE_SETUP -#line 153 "cmFortranLexer.in.l" { yylvalp->string = strdup(yytext); return WORD; @@ -1275,39 +1390,32 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -#line 158 "cmFortranLexer.in.l" { return LPAREN; } YY_BREAK case 48: YY_RULE_SETUP -#line 159 "cmFortranLexer.in.l" { return RPAREN; } YY_BREAK case 49: YY_RULE_SETUP -#line 161 "cmFortranLexer.in.l" { return GARBAGE; } YY_BREAK case 50: /* rule 50 can match eol */ YY_RULE_SETUP -#line 163 "cmFortranLexer.in.l" { return EOSTMT; } YY_BREAK case 51: YY_RULE_SETUP -#line 166 "cmFortranLexer.in.l" /* Ignore */ YY_BREAK case 52: /* rule 52 can match eol */ YY_RULE_SETUP -#line 167 "cmFortranLexer.in.l" /* Ignore line-endings preceded by \ */ YY_BREAK case 53: YY_RULE_SETUP -#line 169 "cmFortranLexer.in.l" { return *yytext; } YY_BREAK case YY_STATE_EOF(INITIAL): @@ -1315,7 +1423,6 @@ case YY_STATE_EOF(free_fmt): case YY_STATE_EOF(fixed_fmt): case YY_STATE_EOF(str_sq): case YY_STATE_EOF(str_dq): -#line 171 "cmFortranLexer.in.l" { if(!cmFortranParser_FilePop(yyextra) ) { @@ -1325,10 +1432,8 @@ case YY_STATE_EOF(str_dq): YY_BREAK case 54: YY_RULE_SETUP -#line 178 "cmFortranLexer.in.l" ECHO; YY_BREAK -#line 1331 "cmFortranLexer.cxx" case YY_END_OF_BUFFER: { @@ -1344,7 +1449,7 @@ ECHO; /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called - * cmFortran_yylex(). If so, then we have to assure + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a @@ -1404,7 +1509,7 @@ ECHO; { yyg->yy_did_buffer_switch_on_eof = 0; - if ( cmFortran_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1458,7 +1563,7 @@ ECHO; } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of cmFortran_yylex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1472,7 +1577,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1501,7 +1606,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1537,7 +1642,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - cmFortran_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1569,7 +1675,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - cmFortran_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); } else @@ -1583,12 +1689,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmFortran_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } yyg->yy_n_chars += number_to_move; @@ -1623,9 +1732,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 210 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1652,9 +1761,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 210 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 209); (void)yyg; @@ -1728,7 +1837,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1745,13 +1854,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ /* Reset buffer status. */ - cmFortran_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( cmFortran_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) @@ -1785,34 +1894,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void cmFortran_yyrestart (FILE * input_file , yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - cmFortran_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmFortran_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - cmFortran_yy_load_buffer_state(yyscanner ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with - * cmFortran_yypop_buffer_state(); - * cmFortran_yypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - cmFortran_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1825,17 +1934,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - cmFortran_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (cmFortran_yywrap()) processing, but the only time this flag - * is looked at is after cmFortran_yywrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } -static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -1850,35 +1959,35 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) cmFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) cmFortran_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - cmFortran_yy_init_buffer(b,file ,yyscanner); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with cmFortran_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ - void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1889,28 +1998,28 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - cmFortran_yyfree((void *) b->yy_ch_buf ,yyscanner ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - cmFortran_yyfree((void *) b ,yyscanner ); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a cmFortran_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void cmFortran_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - cmFortran_yy_flush_buffer(b ,yyscanner); + yy_flush_buffer( b , yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then cmFortran_yy_init_buffer was _probably_ - * called from cmFortran_yyrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1927,7 +2036,7 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -1948,7 +2057,7 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - cmFortran_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1957,15 +2066,15 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; - cmFortran_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from cmFortran_yy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1979,8 +2088,8 @@ void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscan yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from cmFortran_yy_switch_to_buffer. */ - cmFortran_yy_load_buffer_state(yyscanner ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } @@ -1988,19 +2097,19 @@ void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscan * The next element becomes the new top. * @param yyscanner The scanner object. */ -void cmFortran_yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; - cmFortran_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - cmFortran_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -2008,9 +2117,9 @@ void cmFortran_yypop_buffer_state (yyscan_t yyscanner) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -2020,11 +2129,11 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner) * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmFortran_yyalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -2039,12 +2148,12 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmFortran_yyrealloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2058,7 +2167,7 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -2068,11 +2177,11 @@ YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan /* They forgot to leave room for the EOB's. */ return NULL; - b = (YY_BUFFER_STATE) cmFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = NULL; @@ -2082,53 +2191,53 @@ YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - cmFortran_yy_switch_to_buffer(b ,yyscanner ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to cmFortran_yylex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * cmFortran_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return cmFortran_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to cmFortran_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) _yybytes_len + 2; - buf = (char *) cmFortran_yyalloc(n ,yyscanner ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < (size_t)_yybytes_len; ++i ) + for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = cmFortran_yy_scan_buffer(buf,n ,yyscanner); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in cmFortran_yy_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2142,11 +2251,11 @@ YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char * yybytes, int _yybytes_ #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2172,7 +2281,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; @@ -2181,7 +2290,7 @@ YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner) /** Get the current line number. * @param yyscanner The scanner object. */ -int cmFortran_yyget_lineno (yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2194,7 +2303,7 @@ int cmFortran_yyget_lineno (yyscan_t yyscanner) /** Get the current column number. * @param yyscanner The scanner object. */ -int cmFortran_yyget_column (yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2207,7 +2316,7 @@ int cmFortran_yyget_column (yyscan_t yyscanner) /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *cmFortran_yyget_in (yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; @@ -2216,7 +2325,7 @@ FILE *cmFortran_yyget_in (yyscan_t yyscanner) /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *cmFortran_yyget_out (yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; @@ -2225,7 +2334,7 @@ FILE *cmFortran_yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int cmFortran_yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -2235,7 +2344,7 @@ int cmFortran_yyget_leng (yyscan_t yyscanner) * @param yyscanner The scanner object. */ -char *cmFortran_yyget_text (yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; @@ -2245,7 +2354,7 @@ char *cmFortran_yyget_text (yyscan_t yyscanner) * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; @@ -2255,13 +2364,13 @@ void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) * @param _line_number line number * @param yyscanner The scanner object. */ -void cmFortran_yyset_lineno (int _line_number , yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmFortran_yyset_lineno called with no buffer" ); + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = _line_number; } @@ -2270,13 +2379,13 @@ void cmFortran_yyset_lineno (int _line_number , yyscan_t yyscanner) * @param _column_no column number * @param yyscanner The scanner object. */ -void cmFortran_yyset_column (int _column_no , yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmFortran_yyset_column called with no buffer" ); + YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = _column_no; } @@ -2285,27 +2394,27 @@ void cmFortran_yyset_column (int _column_no , yyscan_t yyscanner) * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see cmFortran_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void cmFortran_yyset_in (FILE * _in_str , yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } -void cmFortran_yyset_out (FILE * _out_str , yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } -int cmFortran_yyget_debug (yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } -void cmFortran_yyset_debug (int _bdebug , yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; @@ -2315,20 +2424,18 @@ void cmFortran_yyset_debug (int _bdebug , yyscan_t yyscanner) /* User-visible API */ -/* cmFortran_yylex_init is special because it creates the scanner itself, so it is +/* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ - -int cmFortran_yylex_init(yyscan_t* ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmFortran_yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2341,27 +2448,25 @@ int cmFortran_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } -/* cmFortran_yylex_init_extra has the same functionality as cmFortran_yylex_init, but follows the +/* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to cmFortran_yyalloc in + * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ - -int cmFortran_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; - cmFortran_yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmFortran_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2372,7 +2477,7 @@ int cmFortran_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_gl yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - cmFortran_yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } @@ -2381,7 +2486,7 @@ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. - * This function is called from cmFortran_yylex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = NULL; @@ -2405,37 +2510,37 @@ static int yy_init_globals (yyscan_t yyscanner) #endif /* For future reference: Set errno on error, since we are called by - * cmFortran_yylex_init() + * yylex_init() */ return 0; } -/* cmFortran_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int cmFortran_yylex_destroy (yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - cmFortran_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - cmFortran_yypop_buffer_state(yyscanner); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - cmFortran_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyfree(yyg->yy_buffer_stack , yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - cmFortran_yyfree(yyg->yy_start_stack ,yyscanner ); + yyfree( yyg->yy_start_stack , yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * cmFortran_yylex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ - cmFortran_yyfree ( yyscanner , yyscanner ); + yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } @@ -2445,7 +2550,7 @@ int cmFortran_yylex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2457,7 +2562,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -2467,14 +2572,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmFortran_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; return malloc(size); } -void *cmFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2489,19 +2594,15 @@ void *cmFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) return realloc(ptr, size); } -void cmFortran_yyfree (void * ptr , yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - free( (char *) ptr ); /* see cmFortran_yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 178 "cmFortranLexer.in.l" - - - /*--------------------------------------------------------------------------*/ YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner) { diff --git a/Source/LexerParser/cmFortranLexer.h b/Source/LexerParser/cmFortranLexer.h index ddda919..7bb9b44 100644 --- a/Source/LexerParser/cmFortranLexer.h +++ b/Source/LexerParser/cmFortranLexer.h @@ -2,10 +2,6 @@ #define cmFortran_yyHEADER_H 1 #define cmFortran_yyIN_HEADER 1 -#line 6 "cmFortranLexer.h" - -#line 8 "cmFortranLexer.h" - #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -14,11 +10,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmFortran_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmFortran_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmFortran_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmFortran_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmFortran_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmFortran_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmFortran_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmFortran_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmFortran_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmFortran_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmFortran_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmFortran_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmFortran_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmFortran_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmFortran_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmFortran_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmFortran_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmFortran_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmFortran_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmFortran_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmFortran_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmFortran_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmFortran_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmFortran_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmFortran_yylex_ALREADY_DEFINED +#else +#define yylex cmFortran_yylex +#endif + +#ifdef yyrestart +#define cmFortran_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmFortran_yyrestart +#endif + +#ifdef yylex_init +#define cmFortran_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmFortran_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmFortran_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmFortran_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmFortran_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmFortran_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmFortran_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmFortran_yyget_debug +#endif + +#ifdef yyset_debug +#define cmFortran_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmFortran_yyset_debug +#endif + +#ifdef yyget_extra +#define cmFortran_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmFortran_yyget_extra +#endif + +#ifdef yyset_extra +#define cmFortran_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmFortran_yyset_extra +#endif + +#ifdef yyget_in +#define cmFortran_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmFortran_yyget_in +#endif + +#ifdef yyset_in +#define cmFortran_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmFortran_yyset_in +#endif + +#ifdef yyget_out +#define cmFortran_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmFortran_yyget_out +#endif + +#ifdef yyset_out +#define cmFortran_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmFortran_yyset_out +#endif + +#ifdef yyget_leng +#define cmFortran_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmFortran_yyget_leng +#endif + +#ifdef yyget_text +#define cmFortran_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmFortran_yyget_text +#endif + +#ifdef yyget_lineno +#define cmFortran_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmFortran_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmFortran_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmFortran_yyset_lineno +#endif + +#ifdef yyget_column +#define cmFortran_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmFortran_yyget_column +#endif + +#ifdef yyset_column +#define cmFortran_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmFortran_yyset_column +#endif + +#ifdef yywrap +#define cmFortran_yywrap_ALREADY_DEFINED +#else +#define yywrap cmFortran_yywrap +#endif + +#ifdef yyalloc +#define cmFortran_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmFortran_yyalloc +#endif + +#ifdef yyrealloc +#define cmFortran_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmFortran_yyrealloc +#endif + +#ifdef yyfree +#define cmFortran_yyfree_ALREADY_DEFINED +#else +#define yyfree cmFortran_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -193,21 +405,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmFortran_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmFortran_yyfree (void * ,yyscan_t yyscanner ); +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); /* Begin user sect3 */ @@ -229,42 +441,42 @@ void cmFortran_yyfree (void * ,yyscan_t yyscanner ); #define YY_EXTRA_TYPE void * #endif -int cmFortran_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmFortran_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmFortran_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmFortran_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmFortran_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmFortran_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmFortran_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmFortran_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmFortran_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmFortran_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmFortran_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmFortran_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -272,18 +484,18 @@ void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmFortran_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmFortran_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT @@ -311,9 +523,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmFortran_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* yy_get_previous_state - get the state just before the EOB char was reached */ @@ -330,9 +542,150 @@ extern int cmFortran_yylex (yyscan_t yyscanner); #undef YY_DECL #endif -#line 178 "cmFortranLexer.in.l" - +#ifndef cmFortran_yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef cmFortran_yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef cmFortran_yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef cmFortran_yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef cmFortran_yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef cmFortran_yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef cmFortran_yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef cmFortran_yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef cmFortran_yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef cmFortran_yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef cmFortran_yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef cmFortran_yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef cmFortran_yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef cmFortran_yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef cmFortran_yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef cmFortran_yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef cmFortran_yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef cmFortran_yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef cmFortran_yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef cmFortran_yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef cmFortran_yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef cmFortran_yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef cmFortran_yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef cmFortran_yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef cmFortran_yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef cmFortran_yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef cmFortran_yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef cmFortran_yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef cmFortran_yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef cmFortran_yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef cmFortran_yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef cmFortran_yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef cmFortran_yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef cmFortran_yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef cmFortran_yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef cmFortran_yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef cmFortran_yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef cmFortran_yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef cmFortran_yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef cmFortran_yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef cmFortran_yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef cmFortran_yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef cmFortran_yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef cmFortran_yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef cmFortran_yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef cmFortran_yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef cmFortran_yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef cmFortran_yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif -#line 337 "cmFortranLexer.h" #undef cmFortran_yyIN_HEADER #endif /* cmFortran_yyHEADER_H */ diff --git a/Source/LexerParser/cmFortranLexer.in.l b/Source/LexerParser/cmFortranLexer.in.l index 1121210..9acba4c 100644 --- a/Source/LexerParser/cmFortranLexer.in.l +++ b/Source/LexerParser/cmFortranLexer.in.l @@ -17,14 +17,12 @@ This file must be translated to C++ and modified to build everywhere. Run flex >= 2.6 like this: - flex -i --nounistd -DFLEXINT_H --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l + flex -i --nounistd -DFLEXINT_H --noline --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l Modify cmFortranLexer.cxx: - - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t - + - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx + - remove blank lines at end of file: sed -i '${/^$/d;}' cmFortranLexer.h cmFortranLexer.cxx + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmFortranLexer.cxx */ /* IWYU pragma: no_forward_declare yyguts_t */ @@ -45,6 +43,7 @@ Modify cmFortranLexer.cxx: /*--------------------------------------------------------------------------*/ %} +%option prefix="cmFortran_yy" %option reentrant %option noyywrap diff --git a/Source/LexerParser/cmListFileLexer.c b/Source/LexerParser/cmListFileLexer.c index 3dd3b85..636a6fb 100644 --- a/Source/LexerParser/cmListFileLexer.c +++ b/Source/LexerParser/cmListFileLexer.c @@ -1,7 +1,4 @@ #include "cmStandardLexer.h" -#line 2 "cmListFileLexer.c" - -#line 4 "cmListFileLexer.c" #define FLEXINT_H 1 #define YY_INT_ALIGNED short int @@ -11,11 +8,221 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define cmListFileLexer_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer cmListFileLexer_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define cmListFileLexer_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer cmListFileLexer_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define cmListFileLexer_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer cmListFileLexer_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define cmListFileLexer_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string cmListFileLexer_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define cmListFileLexer_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes cmListFileLexer_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define cmListFileLexer_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer cmListFileLexer_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define cmListFileLexer_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer cmListFileLexer_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define cmListFileLexer_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state cmListFileLexer_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define cmListFileLexer_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer cmListFileLexer_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define cmListFileLexer_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state cmListFileLexer_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define cmListFileLexer_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state cmListFileLexer_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define cmListFileLexer_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack cmListFileLexer_yyensure_buffer_stack +#endif + +#ifdef yylex +#define cmListFileLexer_yylex_ALREADY_DEFINED +#else +#define yylex cmListFileLexer_yylex +#endif + +#ifdef yyrestart +#define cmListFileLexer_yyrestart_ALREADY_DEFINED +#else +#define yyrestart cmListFileLexer_yyrestart +#endif + +#ifdef yylex_init +#define cmListFileLexer_yylex_init_ALREADY_DEFINED +#else +#define yylex_init cmListFileLexer_yylex_init +#endif + +#ifdef yylex_init_extra +#define cmListFileLexer_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra cmListFileLexer_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define cmListFileLexer_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy cmListFileLexer_yylex_destroy +#endif + +#ifdef yyget_debug +#define cmListFileLexer_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug cmListFileLexer_yyget_debug +#endif + +#ifdef yyset_debug +#define cmListFileLexer_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug cmListFileLexer_yyset_debug +#endif + +#ifdef yyget_extra +#define cmListFileLexer_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra cmListFileLexer_yyget_extra +#endif + +#ifdef yyset_extra +#define cmListFileLexer_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra cmListFileLexer_yyset_extra +#endif + +#ifdef yyget_in +#define cmListFileLexer_yyget_in_ALREADY_DEFINED +#else +#define yyget_in cmListFileLexer_yyget_in +#endif + +#ifdef yyset_in +#define cmListFileLexer_yyset_in_ALREADY_DEFINED +#else +#define yyset_in cmListFileLexer_yyset_in +#endif + +#ifdef yyget_out +#define cmListFileLexer_yyget_out_ALREADY_DEFINED +#else +#define yyget_out cmListFileLexer_yyget_out +#endif + +#ifdef yyset_out +#define cmListFileLexer_yyset_out_ALREADY_DEFINED +#else +#define yyset_out cmListFileLexer_yyset_out +#endif + +#ifdef yyget_leng +#define cmListFileLexer_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng cmListFileLexer_yyget_leng +#endif + +#ifdef yyget_text +#define cmListFileLexer_yyget_text_ALREADY_DEFINED +#else +#define yyget_text cmListFileLexer_yyget_text +#endif + +#ifdef yyget_lineno +#define cmListFileLexer_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno cmListFileLexer_yyget_lineno +#endif + +#ifdef yyset_lineno +#define cmListFileLexer_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno cmListFileLexer_yyset_lineno +#endif + +#ifdef yyget_column +#define cmListFileLexer_yyget_column_ALREADY_DEFINED +#else +#define yyget_column cmListFileLexer_yyget_column +#endif + +#ifdef yyset_column +#define cmListFileLexer_yyset_column_ALREADY_DEFINED +#else +#define yyset_column cmListFileLexer_yyset_column +#endif + +#ifdef yywrap +#define cmListFileLexer_yywrap_ALREADY_DEFINED +#else +#define yywrap cmListFileLexer_yywrap +#endif + +#ifdef yyalloc +#define cmListFileLexer_yyalloc_ALREADY_DEFINED +#else +#define yyalloc cmListFileLexer_yyalloc +#endif + +#ifdef yyrealloc +#define cmListFileLexer_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc cmListFileLexer_yyrealloc +#endif + +#ifdef yyfree +#define cmListFileLexer_yyfree_ALREADY_DEFINED +#else +#define yyfree cmListFileLexer_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ +/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const @@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t; /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -131,20 +342,16 @@ typedef void* yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE cmListFileLexer_yyrestart(yyin ,yyscanner ) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -180,7 +387,7 @@ typedef size_t yy_size_t; /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE cmListFileLexer_yylex. + * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. @@ -213,7 +420,6 @@ typedef size_t yy_size_t; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -273,7 +479,7 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via cmListFileLexer_yyrestart()), so that the user can continue scanning by + * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -290,73 +496,67 @@ struct yy_buffer_state #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void cmListFileLexer_yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void cmListFileLexer_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmListFileLexer_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void cmListFileLexer_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmListFileLexer_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner ); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner ); -static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner ); -static void cmListFileLexer_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -#define YY_FLUSH_BUFFER cmListFileLexer_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *cmListFileLexer_yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *cmListFileLexer_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void cmListFileLexer_yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer cmListFileLexer_yy_create_buffer +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - cmListFileLexer_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - cmListFileLexer_yyensure_buffer_stack (yyscanner); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define cmListFileLexer_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -367,7 +567,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; - #define YY_NUM_RULES 24 #define YY_END_OF_BUFFER 25 /* This struct is not used in this scanner, @@ -377,7 +576,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[77] = +static const flex_int16_t yy_accept[77] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 25, 13, 22, 1, 16, 3, 13, 5, 6, 7, @@ -389,7 +588,7 @@ static yyconst flex_int16_t yy_accept[77] = 0, 0, 0, 0, 0, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -421,13 +620,13 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[16] = +static const YY_CHAR yy_meta[16] = { 0, 1, 1, 2, 3, 4, 3, 1, 3, 5, 6, 1, 6, 1, 1, 7 } ; -static yyconst flex_uint16_t yy_base[95] = +static const flex_int16_t yy_base[95] = { 0, 0, 0, 13, 25, 14, 16, 17, 18, 90, 88, 88, 39, 20, 237, 237, 74, 78, 237, 237, 13, @@ -442,7 +641,7 @@ static yyconst flex_uint16_t yy_base[95] = } ; -static yyconst flex_int16_t yy_def[95] = +static const flex_int16_t yy_def[95] = { 0, 76, 1, 77, 77, 78, 78, 79, 79, 80, 80, 76, 76, 76, 76, 76, 76, 12, 76, 76, 12, @@ -457,7 +656,7 @@ static yyconst flex_int16_t yy_def[95] = } ; -static yyconst flex_uint16_t yy_nxt[253] = +static const flex_int16_t yy_nxt[253] = { 0, 12, 13, 14, 13, 15, 16, 17, 18, 19, 12, 12, 20, 21, 22, 12, 24, 28, 25, 28, 28, @@ -489,7 +688,7 @@ static yyconst flex_uint16_t yy_nxt[253] = 76, 76 } ; -static yyconst flex_int16_t yy_chk[253] = +static const flex_int16_t yy_chk[253] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 3, 6, 7, @@ -522,7 +721,7 @@ static yyconst flex_int16_t yy_chk[253] = } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[25] = +static const flex_int32_t yy_rule_can_match_eol[25] = { 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, }; @@ -534,8 +733,6 @@ static yyconst flex_int32_t yy_rule_can_match_eol[25] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "cmListFileLexer.in.l" -#line 2 "cmListFileLexer.in.l" /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /* @@ -544,14 +741,12 @@ This file must be translated to C and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l + flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l Modify cmListFileLexer.c: - - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in cmListFileLexer_yy_scan_bytes for loop condition of _yybytes_len to size_t - - change type of variable yyl under yy_find_action from yy_size_t to int + - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c + - remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c */ @@ -600,11 +795,6 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer); /*--------------------------------------------------------------------------*/ - - - -#line 606 "cmListFileLexer.c" - #define INITIAL 0 #define STRING 1 #define BRACKET 2 @@ -649,44 +839,44 @@ struct yyguts_t }; /* end struct yyguts_t */ -static int yy_init_globals (yyscan_t yyscanner ); +static int yy_init_globals ( yyscan_t yyscanner ); -int cmListFileLexer_yylex_init (yyscan_t* scanner); +int yylex_init (yyscan_t* scanner); -int cmListFileLexer_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int cmListFileLexer_yylex_destroy (yyscan_t yyscanner ); +int yylex_destroy ( yyscan_t yyscanner ); -int cmListFileLexer_yyget_debug (yyscan_t yyscanner ); +int yyget_debug ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_debug (int debug_flag ,yyscan_t yyscanner ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner ); +FILE *yyget_in ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_in (FILE * _in_str ,yyscan_t yyscanner ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner ); +FILE *yyget_out ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_out (FILE * _out_str ,yyscan_t yyscanner ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int cmListFileLexer_yyget_leng (yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); -char *cmListFileLexer_yyget_text (yyscan_t yyscanner ); +char *yyget_text ( yyscan_t yyscanner ); -int cmListFileLexer_yyget_lineno (yyscan_t yyscanner ); +int yyget_lineno ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_lineno (int _line_number ,yyscan_t yyscanner ); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int cmListFileLexer_yyget_column (yyscan_t yyscanner ); +int yyget_column ( yyscan_t yyscanner ); -void cmListFileLexer_yyset_column (int _column_no ,yyscan_t yyscanner ); +void yyset_column ( int _column_no , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -694,32 +884,31 @@ void cmListFileLexer_yyset_column (int _column_no ,yyscan_t yyscanner ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int cmListFileLexer_yywrap (yyscan_t yyscanner ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int cmListFileLexer_yywrap (yyscan_t yyscanner ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (yyscan_t yyscanner ); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -750,7 +939,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -763,7 +952,7 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -804,9 +993,9 @@ static int input (yyscan_t yyscanner ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int cmListFileLexer_yylex (yyscan_t yyscanner); +extern int yylex (yyscan_t yyscanner); -#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner) +#define YY_DECL int yylex (yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -851,19 +1040,15 @@ YY_DECL yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - cmListFileLexer_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmListFileLexer_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } { -#line 80 "cmListFileLexer.in.l" - - -#line 866 "cmListFileLexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -891,9 +1076,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 77 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 237 ); @@ -935,7 +1120,6 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 82 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Newline; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -948,7 +1132,6 @@ YY_RULE_SETUP case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 91 "cmListFileLexer.in.l" { const char* bracket = yytext; lexer->comment = yytext[0] == '#'; @@ -971,7 +1154,6 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 111 "cmListFileLexer.in.l" { lexer->column += yyleng; BEGIN(COMMENT); @@ -979,14 +1161,12 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 116 "cmListFileLexer.in.l" { lexer->column += yyleng; } YY_BREAK case 5: YY_RULE_SETUP -#line 120 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenLeft; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -996,7 +1176,6 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 127 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenRight; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1006,7 +1185,6 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 134 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Identifier; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1016,7 +1194,6 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 141 "cmListFileLexer.in.l" { /* Handle ]]====]=======]*/ cmListFileLexerAppend(lexer, yytext, yyleng); @@ -1028,7 +1205,6 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 150 "cmListFileLexer.in.l" { lexer->column += yyleng; /* Erase the partial bracket from the token. */ @@ -1040,7 +1216,6 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 159 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1049,7 +1224,6 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 164 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); ++lexer->line; @@ -1059,7 +1233,6 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 171 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1068,7 +1241,6 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(BRACKET): case YY_STATE_EOF(BRACKETEND): -#line 177 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadBracket; BEGIN(INITIAL); @@ -1077,7 +1249,6 @@ case YY_STATE_EOF(BRACKETEND): YY_BREAK case 13: YY_RULE_SETUP -#line 183 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1087,7 +1258,6 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 190 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1097,7 +1267,6 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 197 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1107,7 +1276,6 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 204 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentQuoted; cmListFileLexerSetToken(lexer, "", 0); @@ -1117,7 +1285,6 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 211 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1126,7 +1293,6 @@ YY_RULE_SETUP case 18: /* rule 18 can match eol */ YY_RULE_SETUP -#line 216 "cmListFileLexer.in.l" { /* Continuation: text is not part of string */ ++lexer->line; @@ -1136,7 +1302,6 @@ YY_RULE_SETUP case 19: /* rule 19 can match eol */ YY_RULE_SETUP -#line 222 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); ++lexer->line; @@ -1145,7 +1310,6 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 228 "cmListFileLexer.in.l" { lexer->column += yyleng; BEGIN(INITIAL); @@ -1154,14 +1318,12 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 234 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; } YY_BREAK case YY_STATE_EOF(STRING): -#line 239 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadString; BEGIN(INITIAL); @@ -1170,7 +1332,6 @@ case YY_STATE_EOF(STRING): YY_BREAK case 22: YY_RULE_SETUP -#line 245 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Space; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1180,7 +1341,6 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 252 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadCharacter; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1190,7 +1350,6 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): -#line 259 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_None; cmListFileLexerSetToken(lexer, 0, 0); @@ -1199,10 +1358,8 @@ case YY_STATE_EOF(COMMENT): YY_BREAK case 24: YY_RULE_SETUP -#line 265 "cmListFileLexer.in.l" ECHO; YY_BREAK -#line 1205 "cmListFileLexer.c" case YY_END_OF_BUFFER: { @@ -1218,7 +1375,7 @@ ECHO; /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called - * cmListFileLexer_yylex(). If so, then we have to assure + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a @@ -1278,7 +1435,7 @@ ECHO; { yyg->yy_did_buffer_switch_on_eof = 0; - if ( cmListFileLexer_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1332,7 +1489,7 @@ ECHO; } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of cmListFileLexer_yylex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1346,7 +1503,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1375,7 +1532,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1411,7 +1568,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - cmListFileLexer_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1443,7 +1601,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - cmListFileLexer_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); } else @@ -1457,12 +1615,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmListFileLexer_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } yyg->yy_n_chars += number_to_move; @@ -1496,9 +1657,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 77 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1525,9 +1686,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 77 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 76); (void)yyg; @@ -1605,7 +1766,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1622,13 +1783,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ /* Reset buffer status. */ - cmListFileLexer_yyrestart(yyin ,yyscanner); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( cmListFileLexer_yywrap(yyscanner ) ) + if ( yywrap( yyscanner ) ) return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) @@ -1667,34 +1828,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void cmListFileLexer_yyrestart (FILE * input_file , yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - cmListFileLexer_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - cmListFileLexer_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - cmListFileLexer_yy_load_buffer_state(yyscanner ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void cmListFileLexer_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with - * cmListFileLexer_yypop_buffer_state(); - * cmListFileLexer_yypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - cmListFileLexer_yyensure_buffer_stack (yyscanner); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1707,17 +1868,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - cmListFileLexer_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (cmListFileLexer_yywrap()) processing, but the only time this flag - * is looked at is after cmListFileLexer_yywrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } -static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -1732,35 +1893,35 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE cmListFileLexer_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) cmListFileLexer_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - cmListFileLexer_yy_init_buffer(b,file ,yyscanner); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with cmListFileLexer_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ - void cmListFileLexer_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -1771,28 +1932,28 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - cmListFileLexer_yyfree((void *) b->yy_ch_buf ,yyscanner ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - cmListFileLexer_yyfree((void *) b ,yyscanner ); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a cmListFileLexer_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void cmListFileLexer_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - cmListFileLexer_yy_flush_buffer(b ,yyscanner); + yy_flush_buffer( b , yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then cmListFileLexer_yy_init_buffer was _probably_ - * called from cmListFileLexer_yyrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1809,7 +1970,7 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void cmListFileLexer_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -1830,7 +1991,7 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - cmListFileLexer_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1839,15 +2000,15 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; - cmListFileLexer_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from cmListFileLexer_yy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1861,8 +2022,8 @@ void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from cmListFileLexer_yy_switch_to_buffer. */ - cmListFileLexer_yy_load_buffer_state(yyscanner ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } @@ -1870,19 +2031,19 @@ void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t * The next element becomes the new top. * @param yyscanner The scanner object. */ -void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; - cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - cmListFileLexer_yy_load_buffer_state(yyscanner ); + yy_load_buffer_state( yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } @@ -1890,9 +2051,9 @@ void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1902,11 +2063,11 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner) * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); @@ -1921,12 +2082,12 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyrealloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -1940,7 +2101,7 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -1950,11 +2111,11 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size , /* They forgot to leave room for the EOB's. */ return NULL; - b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = NULL; @@ -1964,53 +2125,53 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size , b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - cmListFileLexer_yy_switch_to_buffer(b ,yyscanner ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to cmListFileLexer_yylex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * cmListFileLexer_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return cmListFileLexer_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to cmListFileLexer_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) _yybytes_len + 2; - buf = (char *) cmListFileLexer_yyalloc(n ,yyscanner ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < (size_t)_yybytes_len; ++i ) + for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = cmListFileLexer_yy_scan_buffer(buf,n ,yyscanner); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in cmListFileLexer_yy_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2024,11 +2185,11 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * yybytes, int _yy #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2054,7 +2215,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; @@ -2063,7 +2224,7 @@ YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner) /** Get the current line number. * @param yyscanner The scanner object. */ -int cmListFileLexer_yyget_lineno (yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2076,7 +2237,7 @@ int cmListFileLexer_yyget_lineno (yyscan_t yyscanner) /** Get the current column number. * @param yyscanner The scanner object. */ -int cmListFileLexer_yyget_column (yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2089,7 +2250,7 @@ int cmListFileLexer_yyget_column (yyscan_t yyscanner) /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; @@ -2098,7 +2259,7 @@ FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner) /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; @@ -2107,7 +2268,7 @@ FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int cmListFileLexer_yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -2117,7 +2278,7 @@ int cmListFileLexer_yyget_leng (yyscan_t yyscanner) * @param yyscanner The scanner object. */ -char *cmListFileLexer_yyget_text (yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; @@ -2127,7 +2288,7 @@ char *cmListFileLexer_yyget_text (yyscan_t yyscanner) * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; @@ -2137,13 +2298,13 @@ void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscann * @param _line_number line number * @param yyscanner The scanner object. */ -void cmListFileLexer_yyset_lineno (int _line_number , yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmListFileLexer_yyset_lineno called with no buffer" ); + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); yylineno = _line_number; } @@ -2152,13 +2313,13 @@ void cmListFileLexer_yyset_lineno (int _line_number , yyscan_t yyscanner) * @param _column_no column number * @param yyscanner The scanner object. */ -void cmListFileLexer_yyset_column (int _column_no , yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "cmListFileLexer_yyset_column called with no buffer" ); + YY_FATAL_ERROR( "yyset_column called with no buffer" ); yycolumn = _column_no; } @@ -2167,27 +2328,27 @@ void cmListFileLexer_yyset_column (int _column_no , yyscan_t yyscanner) * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see cmListFileLexer_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void cmListFileLexer_yyset_in (FILE * _in_str , yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = _in_str ; } -void cmListFileLexer_yyset_out (FILE * _out_str , yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = _out_str ; } -int cmListFileLexer_yyget_debug (yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } -void cmListFileLexer_yyset_debug (int _bdebug , yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = _bdebug ; @@ -2197,20 +2358,18 @@ void cmListFileLexer_yyset_debug (int _bdebug , yyscan_t yyscanner) /* User-visible API */ -/* cmListFileLexer_yylex_init is special because it creates the scanner itself, so it is +/* yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ - -int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2223,27 +2382,25 @@ int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } -/* cmListFileLexer_yylex_init_extra has the same functionality as cmListFileLexer_yylex_init, but follows the +/* yylex_init_extra has the same functionality as yylex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to cmListFileLexer_yyalloc in + * The user defined value in the first argument will be available to yyalloc in * the yyextra field. */ - -int cmListFileLexer_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; - cmListFileLexer_yyset_extra (yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } - *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; @@ -2254,7 +2411,7 @@ int cmListFileLexer_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - cmListFileLexer_yyset_extra (yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } @@ -2263,7 +2420,7 @@ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. - * This function is called from cmListFileLexer_yylex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = NULL; @@ -2287,37 +2444,37 @@ static int yy_init_globals (yyscan_t yyscanner) #endif /* For future reference: Set errno on error, since we are called by - * cmListFileLexer_yylex_init() + * yylex_init() */ return 0; } -/* cmListFileLexer_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int cmListFileLexer_yylex_destroy (yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - cmListFileLexer_yypop_buffer_state(yyscanner); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - cmListFileLexer_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyfree(yyg->yy_buffer_stack , yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ - cmListFileLexer_yyfree(yyg->yy_start_stack ,yyscanner ); + yyfree( yyg->yy_start_stack , yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * cmListFileLexer_yylex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* Destroy the main struct (reentrant only). */ - cmListFileLexer_yyfree ( yyscanner , yyscanner ); + yyfree ( yyscanner , yyscanner ); yyscanner = NULL; return 0; } @@ -2327,7 +2484,7 @@ int cmListFileLexer_yylex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2339,7 +2496,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -2349,14 +2506,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmListFileLexer_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; return malloc(size); } -void *cmListFileLexer_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; @@ -2371,19 +2528,15 @@ void *cmListFileLexer_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscann return realloc(ptr, size); } -void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void)yyg; - free( (char *) ptr ); /* see cmListFileLexer_yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 265 "cmListFileLexer.in.l" - - - /*--------------------------------------------------------------------------*/ static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text, int length) diff --git a/Source/LexerParser/cmListFileLexer.in.l b/Source/LexerParser/cmListFileLexer.in.l index 5152dbf..6ec8da4 100644 --- a/Source/LexerParser/cmListFileLexer.in.l +++ b/Source/LexerParser/cmListFileLexer.in.l @@ -7,14 +7,12 @@ This file must be translated to C and modified to build everywhere. Run flex >= 2.6 like this: - flex --nounistd -DFLEXINT_H --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l + flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l Modify cmListFileLexer.c: - - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c - - remove blank lines at end of file - - #include "cmStandardLexer.h" at the top - - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t - - change type of variable yyl under yy_find_action from yy_size_t to int + - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c + - remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c + - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c */ @@ -64,6 +62,8 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer); /*--------------------------------------------------------------------------*/ %} +%option prefix="cmListFileLexer_yy" + %option reentrant %option yylineno %option noyywrap @@ -439,11 +439,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f) if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) { return cmListFileLexer_BOM_UTF32LE; } - fsetpos(f, &p); + if (fsetpos(f, &p) != 0) { + return cmListFileLexer_BOM_Broken; + } return cmListFileLexer_BOM_UTF16LE; } } - rewind(f); + if (fseek(f, 0, SEEK_SET) != 0) { + return cmListFileLexer_BOM_Broken; + } return cmListFileLexer_BOM_None; } diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 7fa2ac6..9f881e2 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -22,19 +22,18 @@ #include "cmSystemTools.h" // IWYU pragma: keep -static const char* cmDocumentationName[][2] = { { CM_NULLPTR, +static const char* cmDocumentationName[][2] = { { nullptr, " cmake-gui - CMake GUI." }, - { CM_NULLPTR, CM_NULLPTR } }; + { nullptr, nullptr } }; static const char* cmDocumentationUsage[][2] = { - { CM_NULLPTR, " cmake-gui [options]\n" - " cmake-gui [options] <path-to-source>\n" - " cmake-gui [options] <path-to-existing-build>" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " cmake-gui [options]\n" + " cmake-gui [options] <path-to-source>\n" + " cmake-gui [options] <path-to-existing-build>" }, + { nullptr, nullptr } }; -static const char* cmDocumentationOptions[] - [2] = { { CM_NULLPTR, CM_NULLPTR } }; +static const char* cmDocumentationOptions[][2] = { { nullptr, nullptr } }; #if defined(Q_OS_MAC) static int cmOSXInstall(std::string dir); diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 57f8e10..bbb2395 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -32,7 +32,7 @@ QCMakeThread::QCMakeThread(QObject* p) : QThread(p) - , CMakeInstance(CM_NULLPTR) + , CMakeInstance(nullptr) { } @@ -48,7 +48,7 @@ void QCMakeThread::run() emit this->cmakeInitialized(); this->exec(); delete this->CMakeInstance; - this->CMakeInstance = CM_NULLPTR; + this->CMakeInstance = nullptr; } CMakeSetupDialog::CMakeSetupDialog() @@ -1195,7 +1195,7 @@ void CMakeSetupDialog::setSearchFilter(const QString& str) this->CacheValues->setSearchFilter(str); } -void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt) +void CMakeSetupDialog::doOutputContextMenu(QPoint pt) { QMenu* menu = this->Output->createStandardContextMenu(); diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 1abdb46..0da28d8 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -70,7 +70,7 @@ protected slots: bool doConfigureInternal(); bool doGenerateInternal(); void exitLoop(int); - void doOutputContextMenu(const QPoint&); + void doOutputContextMenu(QPoint pt); void doOutputFindDialog(); void doOutputFindNext(bool directionForward = true); void doOutputFindPrev(); diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h index 6c8c8f5..746266c 100644 --- a/Source/QtDialog/Compilers.h +++ b/Source/QtDialog/Compilers.h @@ -3,7 +3,7 @@ #ifndef COMPILERS_HPP #define COMPILERS_HPP -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <QWidget> @@ -13,7 +13,7 @@ class Compilers : public QWidget, public Ui::Compilers { Q_OBJECT public: - Compilers(QWidget* p = CM_NULLPTR) + Compilers(QWidget* p = nullptr) : QWidget(p) { this->setupUi(this); diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index b193a27..88ce7cb 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -301,7 +301,7 @@ QString CrossCompilerSetup::getFindRoot() const void CrossCompilerSetup::setFindRoot(const QString& t) { - return this->crossFindRoot->setText(t); + this->crossFindRoot->setText(t); } int CrossCompilerSetup::getProgramMode() const diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index e14cdf2..3b8cea7 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -3,7 +3,7 @@ #ifndef QCMake_h #define QCMake_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmake.h" @@ -63,7 +63,7 @@ class QCMake : public QObject { Q_OBJECT public: - QCMake(QObject* p = CM_NULLPTR); + QCMake(QObject* p = nullptr); ~QCMake(); public slots: /// load the cache file in a directory diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 08c2d58..c6b007d 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -539,7 +539,7 @@ QWidget* QCMakeCacheModelDelegate::createEditor( QModelIndex var = idx.sibling(idx.row(), 0); int type = var.data(QCMakeCacheModel::TypeRole).toInt(); if (type == QCMakeProperty::BOOL) { - return CM_NULLPTR; + return nullptr; } if (type == QCMakeProperty::PATH) { QCMakePathEditor* editor = @@ -642,7 +642,7 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, QStyleOptionButton opt; opt.QStyleOption::operator=(option); sz = sz.expandedTo( - style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, CM_NULLPTR) + style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, nullptr) .size()); return sz; diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 7f0cafa..b544b86 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -57,7 +57,7 @@ void QCMakeFilePathEditor::chooseFile() emit this->fileDialogExists(true); path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(), - CM_NULLPTR, QFileDialog::DontResolveSymlinks); + nullptr, QFileDialog::DontResolveSymlinks); emit this->fileDialogExists(false); if (!path.isEmpty()) { @@ -89,7 +89,7 @@ void QCMakePathEditor::chooseFile() // use same QDirModel for all completers static QDirModel* fileDirModel() { - static QDirModel* m = CM_NULLPTR; + static QDirModel* m = nullptr; if (!m) { m = new QDirModel(); } @@ -97,7 +97,7 @@ static QDirModel* fileDirModel() } static QDirModel* pathDirModel() { - static QDirModel* m = CM_NULLPTR; + static QDirModel* m = nullptr; if (!m) { m = new QDirModel(); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h index 1ec666f..e63c197 100644 --- a/Source/QtDialog/QCMakeWidgets.h +++ b/Source/QtDialog/QCMakeWidgets.h @@ -3,7 +3,7 @@ #ifndef QCMakeWidgets_h #define QCMakeWidgets_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <QComboBox> #include <QCompleter> @@ -35,7 +35,7 @@ class QCMakePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakePathEditor(QWidget* p = CM_NULLPTR, const QString& var = QString()); + QCMakePathEditor(QWidget* p = nullptr, const QString& var = QString()); void chooseFile(); }; @@ -44,8 +44,7 @@ class QCMakeFilePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakeFilePathEditor(QWidget* p = CM_NULLPTR, - const QString& var = QString()); + QCMakeFilePathEditor(QWidget* p = nullptr, const QString& var = QString()); void chooseFile(); }; diff --git a/Source/bindexplib.h b/Source/bindexplib.h index bc904e9..3e22ac7 100644 --- a/Source/bindexplib.h +++ b/Source/bindexplib.h @@ -3,7 +3,7 @@ #ifndef bindexplib_h #define bindexplib_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <stdio.h> diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index 297f901..7eac314 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddCompileOptionsCommand_h #define cmAddCompileOptionsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index b5e7c9e..bd054e8 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -31,7 +31,7 @@ bool cmAddCustomCommandCommand::InitialPass( std::string source, target, main_dependency, working, depfile; std::string comment_buffer; - const char* comment = CM_NULLPTR; + const char* comment = nullptr; std::vector<std::string> depends, outputs, output, byproducts; bool verbatim = false; bool append = false; diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index c3a91b2..95c58d9 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddCustomCommandCommand_h #define cmAddCustomCommandCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 87e1147..a8d5b2e 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -49,7 +49,7 @@ bool cmAddCustomTargetCommand::InitialPass( bool uses_terminal = false; bool command_expand_lists = false; std::string comment_buffer; - const char* comment = CM_NULLPTR; + const char* comment = nullptr; std::vector<std::string> sources; // Keep track of parser state. diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index 7229c27..8d9d09f 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddCustomTargetCommand_h #define cmAddCustomTargetCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index abf5a59..a58d430 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddDefinitionsCommand_h #define cmAddDefinitionsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index c7328d6..10f3c57 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -3,7 +3,7 @@ #ifndef cmDependenciessCommand_h #define cmDependenciessCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index 8100da1..570b35f 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -3,7 +3,7 @@ #ifndef cmExecutablesCommand_h #define cmExecutablesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index df49fae..1656312 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -3,7 +3,7 @@ #ifndef cmLibrarysCommand_h #define cmLibrarysCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index 0e71ffd..a6c92a8 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddSubDirectoryCommand_h #define cmAddSubDirectoryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index a098a03..a296904 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -3,7 +3,7 @@ #ifndef cmAddTestCommand_h #define cmAddTestCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 4adfe23..a4f66a9 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -9,6 +9,7 @@ #include <algorithm> #include <functional> #include <iterator> +#include <memory> #include <sstream> #include <string.h> #include <string> @@ -402,4 +403,22 @@ inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix) } } +namespace cm { + +#if defined(CMake_HAVE_CXX_MAKE_UNIQUE) + +using std::make_unique; + +#else + +template <typename T, typename... Args> +std::unique_ptr<T> make_unique(Args&&... args) +{ + return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); +} + +#endif + +} // namespace cm + #endif diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 0f13b11..02408a1 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -146,9 +146,9 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, } if (archive_write_open( - this->Archive, this, CM_NULLPTR, + this->Archive, this, nullptr, reinterpret_cast<archive_write_callback*>(&Callback::Write), - CM_NULLPTR) != ARCHIVE_OK) { + nullptr) != ARCHIVE_OK) { this->Error = "archive_write_open: "; this->Error += cm_archive_error_string(this->Archive); return; @@ -224,7 +224,7 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix) Entry e; cm_archive_entry_copy_sourcepath(e, file); cm_archive_entry_copy_pathname(e, dest); - if (archive_read_disk_entry_from_file(this->Disk, e, -1, CM_NULLPTR) != + if (archive_read_disk_entry_from_file(this->Disk, e, -1, nullptr) != ARCHIVE_OK) { this->Error = "archive_read_disk_entry_from_file '"; this->Error += file; diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 4c85c0d..56dce2a 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -67,13 +67,13 @@ public: * skip. The remaining part of the input path is appended to the * "prefix" value to construct the final name in the archive. */ - bool Add(std::string path, size_t skip = 0, const char* prefix = CM_NULLPTR, + bool Add(std::string path, size_t skip = 0, const char* prefix = nullptr, bool recursive = true); /** Returns true if there has been no error. */ operator safe_bool() const { - return this->Okay() ? &cmArchiveWrite::safe_bool_true : CM_NULLPTR; + return this->Okay() ? &cmArchiveWrite::safe_bool_true : nullptr; } /** Returns true if there has been an error. */ diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index e49e861..ea22855 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmAuxSourceDirectoryCommand_h #define cmAuxSourceDirectoryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h index fcca45c..c0a5e11 100644 --- a/Source/cmBreakCommand.h +++ b/Source/cmBreakCommand.h @@ -3,7 +3,7 @@ #ifndef cmBreakCommand_h #define cmBreakCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 1f357a9..17e9636 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -3,7 +3,7 @@ #ifndef cmBuildCommand_h #define cmBuildCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index ff26c55..e3d2f2a 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -3,7 +3,7 @@ #ifndef cmBuildNameCommand_h #define cmBuildNameCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCLocaleEnvironmentScope.h b/Source/cmCLocaleEnvironmentScope.h index e956cb2..ec81cb9 100644 --- a/Source/cmCLocaleEnvironmentScope.h +++ b/Source/cmCLocaleEnvironmentScope.h @@ -3,7 +3,7 @@ #ifndef cmCLocaleEnvironmentScope_h #define cmCLocaleEnvironmentScope_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 4475c5a..5106f52 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -76,6 +76,55 @@ bool cmCMakeHostSystemInformationCommand::GetValue( value = this->ValueToString(info.GetTotalPhysicalMemory()); } else if (key == "AVAILABLE_PHYSICAL_MEMORY") { value = this->ValueToString(info.GetAvailablePhysicalMemory()); + } else if (key == "IS_64BIT") { + value = this->ValueToString(info.Is64Bits()); + } else if (key == "HAS_FPU") { + value = this->ValueToString( + info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_FPU)); + } else if (key == "HAS_MMX") { + value = this->ValueToString( + info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_MMX)); + } else if (key == "HAS_MMX_PLUS") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_MMX_PLUS)); + } else if (key == "HAS_SSE") { + value = this->ValueToString( + info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_SSE)); + } else if (key == "HAS_SSE2") { + value = this->ValueToString( + info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_SSE2)); + } else if (key == "HAS_SSE_FP") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_SSE_FP)); + } else if (key == "HAS_SSE_MMX") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_SSE_MMX)); + } else if (key == "HAS_AMD_3DNOW") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_AMD_3DNOW)); + } else if (key == "HAS_AMD_3DNOW_PLUS") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_AMD_3DNOW_PLUS)); + } else if (key == "HAS_IA64") { + value = this->ValueToString( + info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_IA64)); + } else if (key == "HAS_SERIAL_NUMBER") { + value = this->ValueToString(info.DoesCPUSupportFeature( + cmsys::SystemInformation::CPU_FEATURE_SERIALNUMBER)); + } else if (key == "PROCESSOR_NAME") { + value = this->ValueToString(info.GetExtendedProcessorName()); + } else if (key == "PROCESSOR_DESCRIPTION") { + value = info.GetCPUDescription(); + } else if (key == "PROCESSOR_SERIAL_NUMBER") { + value = this->ValueToString(info.GetProcessorSerialNumber()); + } else if (key == "OS_NAME") { + value = this->ValueToString(info.GetOSName()); + } else if (key == "OS_RELEASE") { + value = this->ValueToString(info.GetOSRelease()); + } else if (key == "OS_VERSION") { + value = this->ValueToString(info.GetOSVersion()); + } else if (key == "OS_PLATFORM") { + value = this->ValueToString(info.GetOSPlatform()); #ifdef HAVE_VS_SETUP_HELPER } else if (key == "VS_15_DIR") { cmVSSetupAPIHelper vsSetupAPIHelper; diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h index ef6ca37..b3c05d4 100644 --- a/Source/cmCMakeHostSystemInformationCommand.h +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -3,7 +3,7 @@ #ifndef cmCMakeHostSystemInformationCommand_h #define cmCMakeHostSystemInformationCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 45b6b78..4a979de 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -3,7 +3,7 @@ #ifndef cmCMakeMinimumRequired_h #define cmCMakeMinimumRequired_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 0e88243..f9c51c3 100644 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -3,7 +3,7 @@ #ifndef cmCMakePolicyCommand_h #define cmCMakePolicyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h index 48f4c10..c5885f2 100644 --- a/Source/cmCPackPropertiesGenerator.h +++ b/Source/cmCPackPropertiesGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackPropertiesGenerator_h #define cmCPackPropertiesGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmScriptGenerator.h" diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index e78f5fe..e0b1711 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -218,8 +218,8 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName, } // Pass the call to the makefile instance. - mf->AddUtilityCommand(utilityName, (all ? false : true), CM_NULLPTR, - depends2, commandLines); + mf->AddUtilityCommand(utilityName, (all ? false : true), nullptr, depends2, + commandLines); } void CCONV cmAddCustomCommand(void* arg, const char* source, const char* command, int numArgs, @@ -257,7 +257,7 @@ void CCONV cmAddCustomCommand(void* arg, const char* source, } // Pass the call to the makefile instance. - const char* no_comment = CM_NULLPTR; + const char* no_comment = nullptr; mf->AddCustomCommandOldStyle(target, outputs2, depends2, source, commandLines, no_comment); } @@ -291,8 +291,8 @@ void CCONV cmAddCustomCommandToOutput(void* arg, const char* output, } // Pass the call to the makefile instance. - const char* no_comment = CM_NULLPTR; - const char* no_working_dir = CM_NULLPTR; + const char* no_comment = nullptr; + const char* no_working_dir = nullptr; mf->AddCustomCommandToOutput(output, depends2, main_dependency, commandLines, no_comment, no_working_dir); } @@ -333,8 +333,8 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target, // Pass the call to the makefile instance. std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; - const char* no_comment = CM_NULLPTR; - const char* no_working_dir = CM_NULLPTR; + const char* no_comment = nullptr; + const char* no_working_dir = nullptr; mf->AddCustomCommandToTarget(target, no_byproducts, no_depends, commandLines, cctype, no_comment, no_working_dir); } @@ -443,7 +443,7 @@ void CCONV cmExpandSourceListArguments(void* arg, int numArgs, result.push_back(args[i]); } int resargc = static_cast<int>(result.size()); - char** resargv = CM_NULLPTR; + char** resargv = nullptr; if (resargc) { resargv = (char**)malloc(resargc * sizeof(char*)); } @@ -482,7 +482,7 @@ int CCONV cmGetTotalArgumentSize(int argc, char** argv) struct cmCPluginAPISourceFile { cmCPluginAPISourceFile() - : RealSourceFile(CM_NULLPTR) + : RealSourceFile(nullptr) { } cmSourceFile* RealSourceFile; @@ -554,7 +554,7 @@ void CCONV* cmGetSource(void* arg, const char* name) } return (void*)i->second; } - return CM_NULLPTR; + return nullptr; } void* CCONV cmAddSource(void* arg, void* arg2) @@ -562,7 +562,7 @@ void* CCONV cmAddSource(void* arg, void* arg2) cmMakefile* mf = static_cast<cmMakefile*>(arg); cmCPluginAPISourceFile* osf = static_cast<cmCPluginAPISourceFile*>(arg2); if (osf->FullPath.empty()) { - return CM_NULLPTR; + return nullptr; } // Create the real cmSourceFile instance and copy over saved information. diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e260556..66b8f07 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -11,6 +11,7 @@ #include "cmsys/Process.h" #include "cmsys/String.hxx" #include "cmsys/SystemInformation.hxx" +#include <algorithm> #include <ctype.h> #include <iostream> #include <map> @@ -66,7 +67,7 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag) { struct tm* lctime; - time_t tctime = time(CM_NULLPTR); + time_t tctime = time(nullptr); lctime = gmtime(&tctime); char buf[1024]; // add todays year day and month to the time in str because @@ -84,7 +85,7 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag) // As such, this time may be in the past or in the future. time_t ntime = curl_getdate(buf, &tctime); cmCTestLog(this, DEBUG, " Get curl time: " << ntime << std::endl); - tctime = time(CM_NULLPTR); + tctime = time(nullptr); cmCTestLog(this, DEBUG, " Get the current time: " << tctime << std::endl); const int dayLength = 24 * 60 * 60; @@ -130,7 +131,7 @@ std::string cmCTest::CleanString(const std::string& str) std::string cmCTest::CurrentTime() { - time_t currenttime = time(CM_NULLPTR); + time_t currenttime = time(nullptr); struct tm* t = localtime(¤ttime); // return ::CleanString(ctime(¤ttime)); char current_time[1024]; @@ -156,7 +157,7 @@ std::string cmCTest::GetCostDataFile() static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb, void* data) { - int realsize = (int)(size * nmemb); + int realsize = static_cast<int>(size * nmemb); std::string* response = static_cast<std::string*>(data); const char* chPtr = static_cast<char*>(ptr); @@ -190,7 +191,8 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method, ::curl_easy_setopt(curl, CURLOPT_PUT, 1); file = cmsys::SystemTools::Fopen(putFile, "rb"); ::curl_easy_setopt(curl, CURLOPT_INFILE, file); - // fall through to append GET fields + // fall through to append GET fields + CM_FALLTHROUGH; case cmCTest::HTTP_GET: if (!fields.empty()) { url += "?" + fields; @@ -204,7 +206,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method, // set response options ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback); - ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&response); + ::curl_easy_setopt(curl, CURLOPT_FILE, &response); ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); CURLcode res = ::curl_easy_perform(curl); @@ -225,7 +227,7 @@ std::string cmCTest::MakeURLSafe(const std::string& str) if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' || ch == '=' || ch == '@') && ch != 9) { - sprintf(buffer, "%02x;", (unsigned int)ch); + sprintf(buffer, "%02x;", static_cast<unsigned int>(ch)); ost << buffer; } else { ost << ch; @@ -240,7 +242,7 @@ std::string cmCTest::DecodeURL(const std::string& in) for (const char* c = in.c_str(); *c; ++c) { if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) { char buf[3] = { *(c + 1), *(c + 2), 0 }; - out.append(1, char(strtoul(buf, CM_NULLPTR, 16))); + out.append(1, char(strtoul(buf, nullptr, 16))); c += 2; } else { out.append(1, *c); @@ -252,6 +254,7 @@ std::string cmCTest::DecodeURL(const std::string& in) cmCTest::cmCTest() { this->LabelSummary = true; + this->SubprojectSummary = true; this->ParallelLevel = 1; this->ParallelLevelSetInCli = false; this->TestLoad = 0; @@ -283,7 +286,7 @@ cmCTest::cmCTest() this->ScheduleType = ""; this->StopTime = ""; this->NextDayStopTime = false; - this->OutputLogFile = CM_NULLPTR; + this->OutputLogFile = nullptr; this->OutputLogFileLastTag = -1; this->SuppressUpdatingCTestConfiguration = false; this->DartVersion = 1; @@ -341,7 +344,7 @@ cmCTest::cmCTest() cmCTest::~cmCTest() { cmDeleteAll(this->TestingHandlers); - this->SetOutputLogFileName(CM_NULLPTR); + this->SetOutputLogFileName(nullptr); } void cmCTest::SetParallelLevel(int level) @@ -462,7 +465,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) std::string tag; if (createNewTag) { - time_t tctime = time(CM_NULLPTR); + time_t tctime = time(nullptr); if (this->TomorrowTag) { tctime += (24 * 60 * 60); } @@ -487,7 +490,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } tfin.close(); } - if (tag.empty() || (CM_NULLPTR != command) || this->Parts[PartStart]) { + if (tag.empty() || (nullptr != command) || this->Parts[PartStart]) { cmCTestOptionalLog( this, DEBUG, "TestModel: " << this->GetTestModelString() << std::endl, quiet); @@ -509,7 +512,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) ofs << this->GetTestModelString() << std::endl; } ofs.close(); - if (CM_NULLPTR == command) { + if (nullptr == command) { cmCTestOptionalLog(this, OUTPUT, "Create new tag: " << tag << " - " << this->GetTestModelString() << std::endl, @@ -805,7 +808,7 @@ cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler) cmCTest::t_TestingHandlers::iterator it = this->TestingHandlers.find(handler); if (it == this->TestingHandlers.end()) { - return CM_NULLPTR; + return nullptr; } it->second->Initialize(); return it->second; @@ -816,7 +819,7 @@ cmCTestGenericHandler* cmCTest::GetHandler(const char* handler) cmCTest::t_TestingHandlers::iterator it = this->TestingHandlers.find(handler); if (it == this->TestingHandlers.end()) { - return CM_NULLPTR; + return nullptr; } return it->second; } @@ -974,7 +977,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, a != args.end(); ++a) { argv.push_back(a->c_str()); } - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); output = ""; cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:"); @@ -1004,7 +1007,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents " << tick_len << " bytes of output" << std::endl << " " << std::flush); - while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { processOutput.DecodeText(data, length, strdata); for (size_t cc = 0; cc < strdata.size(); ++cc) { if (strdata[cc] == 0) { @@ -1040,7 +1043,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: " << int(double(output.size()) / 1024.0) << "K" << std::endl); - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); int result = cmsysProcess_GetState(cp); @@ -1169,7 +1172,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int length; cmProcessOutput processOutput(encoding); std::string strdata; - while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { processOutput.DecodeText(data, length, strdata); if (output) { tempOutput.insert(tempOutput.end(), data, data + length); @@ -1189,7 +1192,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, } } - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); processOutput.DecodeText(tempOutput, tempOutput); if (output && tempOutput.begin() != tempOutput.end()) { output->append(&*tempOutput.begin(), tempOutput.size()); @@ -1363,6 +1366,35 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml) } } +void cmCTest::GenerateSubprojectsOutput(cmXMLWriter& xml) +{ + std::vector<std::string> subprojects = this->GetLabelsForSubprojects(); + std::vector<std::string>::const_iterator i; + for (i = subprojects.begin(); i != subprojects.end(); ++i) { + xml.StartElement("Subproject"); + xml.Attribute("name", *i); + xml.Element("Label", *i); + xml.EndElement(); // Subproject + } +} + +std::vector<std::string> cmCTest::GetLabelsForSubprojects() +{ + std::string labelsForSubprojects = + this->GetCTestConfiguration("LabelsForSubprojects"); + std::vector<std::string> subprojects; + cmSystemTools::ExpandListArgument(labelsForSubprojects, subprojects); + + // sort the array + std::sort(subprojects.begin(), subprojects.end()); + // remove duplicates + std::vector<std::string>::iterator new_end = + std::unique(subprojects.begin(), subprojects.end()); + subprojects.erase(new_end, subprojects.end()); + + return subprojects; +} + void cmCTest::EndXML(cmXMLWriter& xml) { xml.EndElement(); // Site @@ -1735,7 +1767,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) { i++; - double timeout = (double)atof(args[i].c_str()); + double timeout = atof(args[i].c_str()); this->GlobalTimeout = timeout; } @@ -1764,6 +1796,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "--no-label-summary")) { this->LabelSummary = false; } + if (this->CheckArgument(arg, "--no-subproject-summary")) { + this->SubprojectSummary = false; + } if (this->CheckArgument(arg, "-Q", "--quiet")) { this->Quiet = true; } @@ -2194,7 +2229,7 @@ int cmCTest::ExecuteTests() it->second->SetSubmitIndex(this->SubmitIndex); } std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - if (!this->Initialize(cwd.c_str(), CM_NULLPTR)) { + if (!this->Initialize(cwd.c_str(), nullptr)) { res = 12; cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard." << std::endl); @@ -2352,7 +2387,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname) bool inBld = bldRelpath.find("..") == std::string::npos; // TODO: Handle files with .. in their name - std::string* res = CM_NULLPTR; + std::string* res = nullptr; if (inSrc && inBld) { // If both have relative path with no dots, pick the shorter one @@ -2402,7 +2437,7 @@ void cmCTest::EmptyCTestConfiguration() void cmCTest::DetermineNextDayStop() { struct tm* lctime; - time_t current_time = time(CM_NULLPTR); + time_t current_time = time(nullptr); lctime = gmtime(¤t_time); int gm_hour = lctime->tm_hour; time_t gm_time = mktime(lctime); @@ -2486,7 +2521,7 @@ bool cmCTest::GetProduceXML() const char* cmCTest::GetSpecificTrack() { if (this->SpecificTrack.empty()) { - return CM_NULLPTR; + return nullptr; } return this->SpecificTrack.c_str(); } @@ -2561,7 +2596,7 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, a != args.end(); ++a) { argv.push_back(a->c_str()); } - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); *stdOut = ""; *stdErr = ""; @@ -2584,7 +2619,7 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, int res; bool done = false; while (!done) { - res = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR); + res = cmsysProcess_WaitForData(cp, &data, &length, nullptr); switch (res) { case cmsysProcess_Pipe_STDOUT: tempOutput.insert(tempOutput.end(), data, data + length); @@ -2608,7 +2643,7 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, } } - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); if (!tempOutput.empty()) { processOutput.DecodeText(tempOutput, tempOutput); stdOut->append(&*tempOutput.begin(), tempOutput.size()); @@ -2652,7 +2687,7 @@ void cmCTest::SetOutputLogFileName(const char* name) { if (this->OutputLogFile) { delete this->OutputLogFile; - this->OutputLogFile = CM_NULLPTR; + this->OutputLogFile = nullptr; } if (name) { this->OutputLogFile = new cmGeneratedFileStream(name); @@ -2666,7 +2701,7 @@ static const char* cmCTestStringLogType[] = { "DEBUG", "HANDLER_VERBOSE_OUTPUT", "WARNING", "ERROR_MESSAGE", - CM_NULLPTR }; + nullptr }; #define cmCTestLogOutputFileLine(stream) \ if (this->ShowLineNumbers) { \ diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 60f3295..66e6a26 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -3,7 +3,7 @@ #ifndef cmCTest_h #define cmCTest_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmProcessOutput.h" #include "cmsys/String.hxx" @@ -95,7 +95,7 @@ public: typedef std::set<std::string> SetOfStrings; /** Process Command line arguments */ - int Run(std::vector<std::string>&, std::string* output = CM_NULLPTR); + int Run(std::vector<std::string>&, std::string* output = nullptr); /** * Initialize and finalize testing @@ -252,8 +252,8 @@ public: * escaped for this to with spaces. */ bool RunCommand(const char* command, std::string* stdOut, - std::string* stdErr, int* retVal = CM_NULLPTR, - const char* dir = CM_NULLPTR, double timeout = 0.0, + std::string* stdErr, int* retVal = nullptr, + const char* dir = nullptr, double timeout = 0.0, Encoding encoding = cmProcessOutput::Auto); /** @@ -438,7 +438,9 @@ public: this->StreamErr = err; } void AddSiteProperties(cmXMLWriter& xml); + bool GetLabelSummary() { return this->LabelSummary; } + bool GetSubprojectSummary() { return this->SubprojectSummary; } std::string GetCostDataFile(); @@ -453,6 +455,9 @@ public: /** Return true if test should run until fail */ bool GetRepeatUntilFail() { return this->RepeatUntilFail; } + void GenerateSubprojectsOutput(cmXMLWriter& xml); + std::vector<std::string> GetLabelsForSubprojects(); + private: int RepeatTests; bool RepeatUntilFail; @@ -464,6 +469,7 @@ private: bool ExtraVerbose; bool ProduceXML; bool LabelSummary; + bool SubprojectSummary; bool UseHTTP10; bool PrintLabels; bool Failover; @@ -571,7 +577,7 @@ private: /** Check if the argument is the one specified */ bool CheckArgument(const std::string& arg, const char* varg1, - const char* varg2 = CM_NULLPTR); + const char* varg2 = nullptr); /** Output errors from a test */ void OutputTestErrors(std::vector<char> const& process_output); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 0b025ab..d599275 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -173,7 +173,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, } const char* cmCacheManager::PersistentProperties[] = { "ADVANCED", "MODIFIED", - "STRINGS", CM_NULLPTR }; + "STRINGS", nullptr }; bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey, CacheEntry& e) @@ -440,7 +440,7 @@ cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry( if (i != this->Cache.end()) { return &i->second; } - return CM_NULLPTR; + return nullptr; } cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key) @@ -455,7 +455,7 @@ const char* cmCacheManager::GetInitializedCacheValue( if (i != this->Cache.end() && i->second.Initialized) { return i->second.Value.c_str(); } - return CM_NULLPTR; + return nullptr; } void cmCacheManager::PrintCache(std::ostream& out) const @@ -610,7 +610,7 @@ const char* cmCacheManager::CacheIterator::GetProperty( if (!this->IsAtEnd()) { return this->GetEntry().GetProperty(prop); } - return CM_NULLPTR; + return nullptr; } void cmCacheManager::CacheIterator::SetProperty(const std::string& p, @@ -647,5 +647,5 @@ void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v) bool cmCacheManager::CacheIterator::PropertyExists( const std::string& prop) const { - return this->GetProperty(prop) != CM_NULLPTR; + return this->GetProperty(prop) != nullptr; } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index c464311..e9e6570 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -117,7 +117,7 @@ public: void PrintCache(std::ostream&) const; ///! Get the iterator for an entry with a given key. - cmCacheManager::CacheIterator GetCacheIterator(const char* key = CM_NULLPTR); + cmCacheManager::CacheIterator GetCacheIterator(const char* key = nullptr); ///! Remove an entry from the cache void RemoveCacheEntry(const std::string& key); @@ -132,7 +132,7 @@ public: { cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str()); if (it.IsAtEnd()) { - return CM_NULLPTR; + return nullptr; } return it.GetValue(); } @@ -175,8 +175,7 @@ public: void RemoveCacheEntryProperty(std::string const& key, std::string const& propName) { - this->GetCacheIterator(key.c_str()) - .SetProperty(propName, (void*)CM_NULLPTR); + this->GetCacheIterator(key.c_str()).SetProperty(propName, nullptr); } void AppendCacheEntryProperty(std::string const& key, diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index ad35d30..fdc9e66 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -3,7 +3,7 @@ #ifndef cmCallVisualStudioMacro_h #define cmCallVisualStudioMacro_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmCommand.h b/Source/cmCommand.h index ad72fe2..2cc0b88 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -3,7 +3,7 @@ #ifndef cmCommand_h #define cmCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -31,7 +31,7 @@ public: * Construct the command. By default it has no makefile. */ cmCommand() - : Makefile(CM_NULLPTR) + : Makefile(nullptr) { } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 4eb4531..4764620 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -19,7 +19,7 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() this->WarnUninitialized = false; this->CheckSystemVars = false; this->FileLine = -1; - this->FileName = CM_NULLPTR; + this->FileName = nullptr; this->RemoveEmpty = true; this->EmptyVariable[0] = 0; strcpy(this->DCURLYVariable, "${"); @@ -88,13 +88,13 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, e << "Syntax $" << key << "{} is not supported. " << "Only ${}, $ENV{}, and $CACHE{} are allowed."; this->SetError(e.str()); - return CM_NULLPTR; + return nullptr; } char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { if (!var) { - return CM_NULLPTR; + return nullptr; } if (this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) { std::ostringstream ostr; @@ -117,7 +117,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); } } - return CM_NULLPTR; + return nullptr; } if (this->EscapeQuotes && value) { return this->AddString(cmSystemTools::EscapeQuotes(value)); @@ -169,7 +169,7 @@ char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2) void cmCommandArgumentParserHelper::AllocateParserType( cmCommandArgumentParserHelper::ParserType* pt, const char* str, int len) { - pt->str = CM_NULLPTR; + pt->str = nullptr; if (len == 0) { len = static_cast<int>(strlen(str)); } diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index 465ca9e..cb2a390 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -3,7 +3,7 @@ #ifndef cmCommandArgumentParserHelper_h #define cmCommandArgumentParserHelper_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx index babddbe..36d4da4 100644 --- a/Source/cmCommandArgumentsHelper.cxx +++ b/Source/cmCommandArgumentsHelper.cxx @@ -11,11 +11,11 @@ cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args, , ArgumentsBeforeEmpty(true) , CurrentIndex(0) { - if (args != CM_NULLPTR) { + if (args != nullptr) { args->AddArgument(this); } - if (this->Group != CM_NULLPTR) { + if (this->Group != nullptr) { this->Group->ContainedArguments.push_back(this); } } @@ -35,7 +35,7 @@ void cmCommandArgument::Follows(const cmCommandArgument* arg) void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group) { - if (group != CM_NULLPTR) { + if (group != nullptr) { this->ArgumentsBeforeEmpty = false; this->ArgumentsBefore.insert(group->ContainedArguments.begin(), group->ContainedArguments.end()); @@ -52,7 +52,7 @@ bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const bool cmCommandArgument::KeyMatches(const std::string& key) const { - if ((this->Key == CM_NULLPTR) || (this->Key[0] == '\0')) { + if ((this->Key == nullptr) || (this->Key[0] == '\0')) { return true; } return (key == this->Key); @@ -60,7 +60,7 @@ bool cmCommandArgument::KeyMatches(const std::string& key) const void cmCommandArgument::ApplyOwnGroup() { - if (this->Group != CM_NULLPTR) { + if (this->Group != nullptr) { for (std::vector<cmCommandArgument*>::const_iterator it = this->Group->ContainedArguments.begin(); it != this->Group->ContainedArguments.end(); ++it) { @@ -88,9 +88,9 @@ cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args, const char* key, cmCommandArgumentGroup* group) : cmCommandArgument(args, key, group) - , Ignore(CM_NULLPTR) + , Ignore(nullptr) { - if ((key == CM_NULLPTR) || (*key == 0)) { + if ((key == nullptr) || (*key == 0)) { this->DataStart = 0; } else { this->DataStart = 1; @@ -100,7 +100,7 @@ cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args, bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index) { if (index >= this->DataStart) { - if ((this->Ignore == CM_NULLPTR) || (arg != this->Ignore)) { + if ((this->Ignore == nullptr) || (arg != this->Ignore)) { this->Vector.push_back(arg); } } @@ -117,7 +117,7 @@ cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key, cmCommandArgumentGroup* group) : cmCommandArgument(args, key, group) { - if ((key == CM_NULLPTR) || (*key == 0)) { + if ((key == nullptr) || (*key == 0)) { this->DataStart = 0; } else { this->DataStart = 1; @@ -199,7 +199,7 @@ void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group) void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args, std::vector<std::string>* unconsumedArgs) { - if (args == CM_NULLPTR) { + if (args == nullptr) { return; } @@ -210,8 +210,8 @@ void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args, (*argIt)->Reset(); } - cmCommandArgument* activeArgument = CM_NULLPTR; - const cmCommandArgument* previousArgument = CM_NULLPTR; + cmCommandArgument* activeArgument = nullptr; + const cmCommandArgument* previousArgument = nullptr; for (std::vector<std::string>::const_iterator it = args->begin(); it != args->end(); ++it) { for (std::vector<cmCommandArgument*>::iterator argIt = @@ -229,10 +229,10 @@ void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args, bool argDone = activeArgument->Consume(*it); previousArgument = activeArgument; if (argDone) { - activeArgument = CM_NULLPTR; + activeArgument = nullptr; } } else { - if (unconsumedArgs != CM_NULLPTR) { + if (unconsumedArgs != nullptr) { unconsumedArgs->push_back(*it); } } diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h index 44db374..56d88e9 100644 --- a/Source/cmCommandArgumentsHelper.h +++ b/Source/cmCommandArgumentsHelper.h @@ -3,7 +3,7 @@ #ifndef cmCommandArgumentsHelper_h #define cmCommandArgumentsHelper_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> @@ -38,7 +38,7 @@ class cmCommandArgument { public: cmCommandArgument(cmCommandArgumentsHelper* args, const char* key, - cmCommandArgumentGroup* group = CM_NULLPTR); + cmCommandArgumentGroup* group = nullptr); virtual ~cmCommandArgument() {} /// this argument may follow after arg. 0 means it comes first. @@ -90,7 +90,7 @@ class cmCAStringVector : public cmCommandArgument { public: cmCAStringVector(cmCommandArgumentsHelper* args, const char* key, - cmCommandArgumentGroup* group = CM_NULLPTR); + cmCommandArgumentGroup* group = nullptr); /// Return the vector of strings const std::vector<std::string>& GetVector() const { return this->Vector; } @@ -113,7 +113,7 @@ class cmCAString : public cmCommandArgument { public: cmCAString(cmCommandArgumentsHelper* args, const char* key, - cmCommandArgumentGroup* group = CM_NULLPTR); + cmCommandArgumentGroup* group = nullptr); /// Return the string const std::string& GetString() const { return this->String; } @@ -132,7 +132,7 @@ class cmCAEnabler : public cmCommandArgument { public: cmCAEnabler(cmCommandArgumentsHelper* args, const char* key, - cmCommandArgumentGroup* group = CM_NULLPTR); + cmCommandArgumentGroup* group = nullptr); /// Has it been enabled ? bool IsEnabled() const { return this->Enabled; } @@ -149,7 +149,7 @@ class cmCADisabler : public cmCommandArgument { public: cmCADisabler(cmCommandArgumentsHelper* args, const char* key, - cmCommandArgumentGroup* group = CM_NULLPTR); + cmCommandArgumentGroup* group = nullptr); /// Is it still enabled ? bool IsEnabled() const { return this->Enabled; } diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index e1d8ef1..8a7d9bd 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -42,6 +42,7 @@ #include "cmIfCommand.h" #include "cmIncludeCommand.h" #include "cmIncludeDirectoryCommand.h" +#include "cmIncludeGuardCommand.h" #include "cmIncludeRegularExpressionCommand.h" #include "cmInstallCommand.h" #include "cmInstallFilesCommand.h" @@ -67,7 +68,12 @@ #include "cmSiteNameCommand.h" #include "cmStringCommand.h" #include "cmSubdirCommand.h" +#include "cmTargetCompileDefinitionsCommand.h" +#include "cmTargetCompileFeaturesCommand.h" +#include "cmTargetCompileOptionsCommand.h" +#include "cmTargetIncludeDirectoriesCommand.h" #include "cmTargetLinkLibrariesCommand.h" +#include "cmTargetSourcesCommand.h" #include "cmTryCompileCommand.h" #include "cmTryRunCommand.h" #include "cmUnsetCommand.h" @@ -93,11 +99,6 @@ #include "cmRemoveDefinitionsCommand.h" #include "cmSourceGroupCommand.h" #include "cmSubdirDependsCommand.h" -#include "cmTargetCompileDefinitionsCommand.h" -#include "cmTargetCompileFeaturesCommand.h" -#include "cmTargetCompileOptionsCommand.h" -#include "cmTargetIncludeDirectoriesCommand.h" -#include "cmTargetSourcesCommand.h" #include "cmUseMangledMesaCommand.h" #include "cmUtilitySourceCommand.h" #include "cmVariableRequiresCommand.h" @@ -132,6 +133,7 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("get_property", new cmGetPropertyCommand); state->AddBuiltinCommand("if", new cmIfCommand); state->AddBuiltinCommand("include", new cmIncludeCommand); + state->AddBuiltinCommand("include_guard", new cmIncludeGuardCommand); state->AddBuiltinCommand("list", new cmListCommand); state->AddBuiltinCommand("macro", new cmMacroCommand); state->AddBuiltinCommand("make_directory", new cmMakeDirectoryCommand); @@ -145,8 +147,6 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("separate_arguments", new cmSeparateArgumentsCommand); state->AddBuiltinCommand("set", new cmSetCommand); - state->AddBuiltinCommand("set_directory_properties", - new cmSetDirectoryPropertiesCommand); state->AddBuiltinCommand("set_property", new cmSetPropertyCommand); state->AddBuiltinCommand("site_name", new cmSiteNameCommand); state->AddBuiltinCommand("string", new cmStringCommand); @@ -229,6 +229,8 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install_targets", new cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", new cmLinkDirectoriesCommand); state->AddBuiltinCommand("project", new cmProjectCommand); + state->AddBuiltinCommand("set_directory_properties", + new cmSetDirectoryPropertiesCommand); state->AddBuiltinCommand("set_source_files_properties", new cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", @@ -236,8 +238,17 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("set_tests_properties", new cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", new cmSubdirCommand); + state->AddBuiltinCommand("target_compile_definitions", + new cmTargetCompileDefinitionsCommand); + state->AddBuiltinCommand("target_compile_features", + new cmTargetCompileFeaturesCommand); + state->AddBuiltinCommand("target_compile_options", + new cmTargetCompileOptionsCommand); + state->AddBuiltinCommand("target_include_directories", + new cmTargetIncludeDirectoriesCommand); state->AddBuiltinCommand("target_link_libraries", new cmTargetLinkLibrariesCommand); + state->AddBuiltinCommand("target_sources", new cmTargetSourcesCommand); state->AddBuiltinCommand("try_compile", new cmTryCompileCommand); state->AddBuiltinCommand("try_run", new cmTryRunCommand); @@ -258,15 +269,6 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("remove_definitions", new cmRemoveDefinitionsCommand); state->AddBuiltinCommand("source_group", new cmSourceGroupCommand); - state->AddBuiltinCommand("target_compile_definitions", - new cmTargetCompileDefinitionsCommand); - state->AddBuiltinCommand("target_compile_features", - new cmTargetCompileFeaturesCommand); - state->AddBuiltinCommand("target_compile_options", - new cmTargetCompileOptionsCommand); - state->AddBuiltinCommand("target_include_directories", - new cmTargetIncludeDirectoriesCommand); - state->AddBuiltinCommand("target_sources", new cmTargetSourcesCommand); state->AddDisallowedCommand( "export_library_dependencies", new cmExportLibraryDependenciesCommand, diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 391d65c..a70839e 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCommonTargetGenerator.h" -#include "cmConfigure.h" #include <set> #include <sstream> #include <utility> @@ -22,10 +21,11 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) : GeneratorTarget(gt) , Makefile(gt->Makefile) - , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator)) - , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>( + , LocalCommonGenerator( + static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator)) + , GlobalCommonGenerator(static_cast<cmGlobalCommonGenerator*>( gt->LocalGenerator->GetGlobalGenerator())) - , ConfigName(LocalGenerator->GetConfigName()) + , ConfigName(LocalCommonGenerator->GetConfigName()) { } @@ -62,10 +62,10 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag( // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; - flag += this->LocalGenerator->ConvertToOutputFormat( + flag += this->LocalCommonGenerator->ConvertToOutputFormat( linkLineComputer->ConvertToLinkReference(mdi->DefFile), cmOutputConverter::SHELL); - this->LocalGenerator->AppendFlags(flags, flag); + this->LocalCommonGenerator->AppendFlags(flags, flag); } void cmCommonTargetGenerator::AppendFortranFormatFlags( @@ -78,7 +78,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT"); format = cmOutputConverter::GetFortranFormat(tgtfmt); } - const char* var = CM_NULLPTR; + const char* var = nullptr; switch (format) { case cmOutputConverter::FortranFormatFixed: var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; @@ -90,8 +90,8 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( break; } if (var) { - this->LocalGenerator->AppendFlags(flags, - this->Makefile->GetDefinition(var)); + this->LocalCommonGenerator->AppendFlags( + flags, this->Makefile->GetDefinition(var)); } } @@ -101,8 +101,8 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l) if (i == this->FlagsByLanguage.end()) { std::string flags; - this->LocalGenerator->GetTargetCompileFlags(this->GeneratorTarget, - this->ConfigName, l, flags); + this->LocalCommonGenerator->GetTargetCompileFlags( + this->GeneratorTarget, this->ConfigName, l, flags); ByLanguageMap::value_type entry(l, flags); i = this->FlagsByLanguage.insert(entry).first; @@ -115,11 +115,11 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string& l) ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); if (i == this->DefinesByLanguage.end()) { std::set<std::string> defines; - this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, - this->ConfigName, l, defines); + this->LocalCommonGenerator->GetTargetDefines(this->GeneratorTarget, + this->ConfigName, l, defines); std::string definesString; - this->LocalGenerator->JoinDefines(defines, definesString, l); + this->LocalCommonGenerator->JoinDefines(defines, definesString, l); ByLanguageMap::value_type entry(l, definesString); i = this->DefinesByLanguage.insert(entry).first; @@ -198,9 +198,10 @@ std::string cmCommonTargetGenerator::GetManifests() std::vector<std::string> manifests; for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin(); mi != manifest_srcs.end(); ++mi) { - manifests.push_back(this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( - this->LocalGenerator->GetWorkingDirectory(), (*mi)->GetFullPath()), + manifests.push_back(this->LocalCommonGenerator->ConvertToOutputFormat( + this->LocalCommonGenerator->ConvertToRelativePath( + this->LocalCommonGenerator->GetWorkingDirectory(), + (*mi)->GetFullPath()), cmOutputConverter::SHELL)); } @@ -233,6 +234,6 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags, // Append the flag since a non-zero version is specified. std::ostringstream vflag; vflag << flag << major << "." << minor << "." << patch; - this->LocalGenerator->AppendFlags(flags, vflag.str()); + this->LocalCommonGenerator->AppendFlags(flags, vflag.str()); } } diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index c36145f..6b0f74e 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -37,8 +37,8 @@ protected: cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; - cmLocalCommonGenerator* LocalGenerator; - cmGlobalCommonGenerator* GlobalGenerator; + cmLocalCommonGenerator* LocalCommonGenerator; + cmGlobalCommonGenerator* GlobalCommonGenerator; std::string ConfigName; void AppendFortranFormatFlags(std::string& flags, diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 9c516ee..2277bbe 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -194,7 +194,7 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, this->OldLinkDirMode = false; // No computation has been done. - this->CCG = CM_NULLPTR; + this->CCG = nullptr; } cmComputeLinkDepends::~cmComputeLinkDepends() @@ -286,7 +286,7 @@ std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry( std::map<std::string, int>::iterator lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.push_back(LinkEntry()); - this->InferredDependSets.push_back(CM_NULLPTR); + this->InferredDependSets.push_back(nullptr); this->EntryConstraintGraph.push_back(EdgeList()); return lei; } @@ -314,7 +314,7 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item) // If the item has dependencies queue it to follow them. if (entry.Target) { // Target dependencies are always known. Follow them. - BFSEntry qe = { index, CM_NULLPTR }; + BFSEntry qe = { index, nullptr }; this->BFSQueue.push(qe); } else { // Look for an old-style <item>_LIB_DEPENDS variable. diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 84ee916..dd0e029 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -40,7 +40,7 @@ public: bool IsFlag; LinkEntry() : Item() - , Target(CM_NULLPTR) + , Target(nullptr) , IsSharedDep(false) , IsFlag(false) { diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b2deaaa..f348a7e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,7 +260,7 @@ cmComputeLinkInformation::cmComputeLinkInformation( this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = new cmOrderDirectories( this->GlobalGenerator, target, "runtime search path"); - this->OrderDependentRPath = CM_NULLPTR; + this->OrderDependentRPath = nullptr; // Get the language used for linking this target. this->LinkLanguage = this->Target->GetLinkerLanguage(config); @@ -281,7 +281,7 @@ cmComputeLinkInformation::cmComputeLinkInformation( // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. - this->LoaderFlag = CM_NULLPTR; + this->LoaderFlag = nullptr; if (!this->UseImportLibrary && this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; @@ -562,7 +562,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) for (std::vector<std::string>::const_iterator i = libsVec.begin(); i != libsVec.end(); ++i) { if (this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) { - this->AddItem(*i, CM_NULLPTR); + this->AddItem(*i, nullptr); } } } @@ -616,7 +616,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // Also add the item the interface specifies to be used in its place. std::string const& libName = tgt->GetImportedLibName(config); if (!libName.empty()) { - this->AddItem(libName, CM_NULLPTR); + this->AddItem(libName, nullptr); } } else { // Decide whether to use an import library. @@ -710,7 +710,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, // Check if we need to include the dependent shared library in other // path ordering. - cmOrderDirectories* order = CM_NULLPTR; + cmOrderDirectories* order = nullptr; if (this->SharedDependencyMode == SharedDepModeLibDir && !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */) { // Add the item to the linker search path. @@ -722,7 +722,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, if (order) { if (tgt) { std::string soName = tgt->GetSOName(this->Config); - const char* soname = soName.empty() ? CM_NULLPTR : soName.c_str(); + const char* soname = soName.empty() ? nullptr : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } else { order->AddRuntimeLibrary(lib); @@ -741,9 +741,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() this->LinkTypeEnabled = false; // Lookup link type selection flags. - const char* static_link_type_flag = CM_NULLPTR; - const char* shared_link_type_flag = CM_NULLPTR; - const char* target_type_str = CM_NULLPTR; + const char* static_link_type_flag = nullptr; + const char* shared_link_type_flag = nullptr; + const char* target_type_str = nullptr; switch (this->Target->GetType()) { case cmStateEnums::EXECUTABLE: target_type_str = "EXE"; @@ -1623,7 +1623,7 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo( // Try to get the soname of the library. Only files with this name // could possibly conflict. std::string soName = target->GetSOName(this->Config); - const char* soname = soName.empty() ? CM_NULLPTR : soName.c_str(); + const char* soname = soName.empty() ? nullptr : soName.c_str(); // Include this library in the runtime path ordering. this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname); diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 00e3ad2..f8c6214 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -33,11 +33,11 @@ public: Item() : Value() , IsPath(true) - , Target(CM_NULLPTR) + , Target(nullptr) { } Item(std::string const& v, bool p, - cmGeneratorTarget const* target = CM_NULLPTR) + cmGeneratorTarget const* target = nullptr) : Value(v) , IsPath(p) , Target(target) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ff19eac..ff0052b 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -161,7 +161,7 @@ void cmComputeTargetDepends::CollectTargets() std::vector<cmLocalGenerator*> const& lgens = this->GlobalGenerator->GetLocalGenerators(); for (unsigned int i = 0; i < lgens.size(); ++i) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = lgens[i]->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { @@ -290,7 +290,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( // within the project. if (dependee && dependee->GetType() == cmStateEnums::EXECUTABLE && !dependee->IsExecutableWithExports()) { - dependee = CM_NULLPTR; + dependee = nullptr; } if (dependee) { @@ -348,7 +348,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, // within the project. if (linking && dependee && dependee->GetType() == cmStateEnums::EXECUTABLE && !dependee->IsExecutableWithExports()) { - dependee = CM_NULLPTR; + dependee = nullptr; } if (dependee) { diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 2bacf73..f4d48d2 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmConditionEvaluator.h" -#include "cmConfigure.h" #include "cmsys/RegularExpression.hxx" #include <algorithm> #include <sstream> @@ -139,7 +138,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( if ((this->Policy54Status != cmPolicies::WARN && this->Policy54Status != cmPolicies::OLD) && argument.WasQuoted()) { - return CM_NULLPTR; + return nullptr; } const char* def = this->Makefile.GetDefinition(argument.GetValue()); @@ -455,7 +454,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) { cmCommand* command = this->Makefile.GetState()->GetCommand(argP1->c_str()); - this->HandlePredicate(command != CM_NULLPTR, reducible, arg, newArgs, + this->HandlePredicate(command != nullptr, reducible, arg, newArgs, argP1, argP2); } // does a policy exist @@ -467,7 +466,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, // does a target exist if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end()) { this->HandlePredicate( - this->Makefile.FindTargetToUse(argP1->GetValue()) != CM_NULLPTR, + this->Makefile.FindTargetToUse(argP1->GetValue()) != nullptr, reducible, arg, newArgs, argP1, argP2); } // does a test exist @@ -475,8 +474,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, this->Policy64Status != cmPolicies::WARN) { if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end()) { const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str()); - this->HandlePredicate(haveTest != CM_NULLPTR, reducible, arg, - newArgs, argP1, argP2); + this->HandlePredicate(haveTest != nullptr, reducible, arg, newArgs, + argP1, argP2); } } else if (this->Policy64Status == cmPolicies::WARN && this->IsKeyword(keyTEST, *arg)) { diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 524fdf8..e91471c 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -19,18 +19,14 @@ #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER -#cmakedefine CMAKE_USE_LIBUV #cmakedefine CMake_HAVE_CXX_AUTO_PTR #cmakedefine CMake_HAVE_CXX_EQ_DELETE #cmakedefine CMake_HAVE_CXX_FALLTHROUGH #cmakedefine CMake_HAVE_CXX_GNU_FALLTHROUGH #cmakedefine CMake_HAVE_CXX_ATTRIBUTE_FALLTHROUGH #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE -#cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE #cmakedefine CMake_HAVE_CXX_UNIQUE_PTR -#cmakedefine CMake_HAVE_CXX_UNORDERED_MAP -#cmakedefine CMake_HAVE_CXX_UNORDERED_SET #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" @@ -44,18 +40,12 @@ #define CM_FALLTHROUGH [[fallthrough]] #elif defined(CMake_HAVE_CXX_GNU_FALLTHROUGH) #define CM_FALLTHROUGH [[gnu::fallthrough]] -elif defined(CMake_HAVE_CXX_ATTRIBUTE_FALLTHROUGH) +#elif defined(CMake_HAVE_CXX_ATTRIBUTE_FALLTHROUGH) #define CM_FALLTHROUGH __attribute__((fallthrough)) #else #define CM_FALLTHROUGH #endif -#ifdef CMake_HAVE_CXX_NULLPTR -#define CM_NULLPTR nullptr -#else -#define CM_NULLPTR 0 -#endif - #ifdef CMake_HAVE_CXX_OVERRIDE #define CM_OVERRIDE override #else diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 6cebbd2..54ca0bf 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -3,7 +3,7 @@ #ifndef cmConfigureFileCommand_h #define cmConfigureFileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx new file mode 100644 index 0000000..f3fc1ef --- /dev/null +++ b/Source/cmConnection.cxx @@ -0,0 +1,158 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmConnection.h" + +#include "cmServer.h" +#include "cm_uv.h" + +#include <cassert> +#include <cstring> + +struct write_req_t +{ + uv_write_t req; + uv_buf_t buf; +}; + +void cmEventBasedConnection::on_alloc_buffer(uv_handle_t* handle, + size_t suggested_size, + uv_buf_t* buf) +{ + (void)(handle); + char* rawBuffer = new char[suggested_size]; + *buf = uv_buf_init(rawBuffer, static_cast<unsigned int>(suggested_size)); +} + +void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread, + const uv_buf_t* buf) +{ + auto conn = reinterpret_cast<cmEventBasedConnection*>(stream->data); + if (conn) { + if (nread >= 0) { + conn->ReadData(std::string(buf->base, buf->base + nread)); + } else { + conn->OnDisconnect(static_cast<int>(nread)); + } + } + + delete[](buf->base); +} + +void cmEventBasedConnection::on_close_delete(uv_handle_t* handle) +{ + delete handle; +} + +void cmEventBasedConnection::on_close(uv_handle_t* /*handle*/) +{ +} + +void cmEventBasedConnection::on_write(uv_write_t* req, int status) +{ + (void)(status); + + // Free req and buffer + write_req_t* wr = reinterpret_cast<write_req_t*>(req); + delete[](wr->buf.base); + delete wr; +} + +void cmEventBasedConnection::on_new_connection(uv_stream_t* stream, int status) +{ + (void)(status); + auto conn = reinterpret_cast<cmEventBasedConnection*>(stream->data); + + if (conn) { + conn->Connect(stream); + } +} + +bool cmEventBasedConnection::IsOpen() const +{ + return this->WriteStream != nullptr; +} + +void cmEventBasedConnection::WriteData(const std::string& data) +{ + assert(this->WriteStream); + + auto ds = data.size(); + + write_req_t* req = new write_req_t; + req->req.data = this; + req->buf = uv_buf_init(new char[ds], static_cast<unsigned int>(ds)); + memcpy(req->buf.base, data.c_str(), ds); + uv_write(reinterpret_cast<uv_write_t*>(req), + static_cast<uv_stream_t*>(this->WriteStream), &req->buf, 1, + on_write); +} + +void cmEventBasedConnection::ReadData(const std::string& data) +{ + this->RawReadBuffer += data; + if (BufferStrategy) { + std::string packet = BufferStrategy->BufferMessage(this->RawReadBuffer); + do { + ProcessRequest(packet); + packet = BufferStrategy->BufferMessage(this->RawReadBuffer); + } while (!packet.empty()); + + } else { + ProcessRequest(this->RawReadBuffer); + this->RawReadBuffer.clear(); + } +} + +cmEventBasedConnection::cmEventBasedConnection( + cmConnectionBufferStrategy* bufferStrategy) + : BufferStrategy(bufferStrategy) +{ +} + +void cmEventBasedConnection::Connect(uv_stream_t* server) +{ + (void)server; + Server->OnConnected(nullptr); +} + +void cmEventBasedConnection::OnDisconnect(int onerror) +{ + (void)onerror; + this->OnConnectionShuttingDown(); + this->Server->OnDisconnect(this); +} + +cmConnection::~cmConnection() +{ +} + +bool cmConnection::OnConnectionShuttingDown() +{ + return true; +} + +void cmConnection::SetServer(cmServerBase* s) +{ + Server = s; +} + +void cmConnection::ProcessRequest(const std::string& request) +{ + Server->ProcessRequest(this, request); +} + +bool cmConnection::OnServeStart(std::string* errString) +{ + (void)errString; + return true; +} + +bool cmEventBasedConnection::OnConnectionShuttingDown() +{ + this->WriteStream->data = nullptr; + this->ReadStream->data = nullptr; + + this->ReadStream = nullptr; + this->WriteStream = nullptr; + return true; +} diff --git a/Source/cmConnection.h b/Source/cmConnection.h new file mode 100644 index 0000000..f9d50de --- /dev/null +++ b/Source/cmConnection.h @@ -0,0 +1,118 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#pragma once + +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cm_uv.h" + +#include <cstddef> +#include <memory> +#include <string> + +class cmServerBase; + +/*** + * Given a sequence of bytes with any kind of buffering, instances of this + * class arrange logical chunks according to whatever the use case is for + * the connection. + */ +class cmConnectionBufferStrategy +{ +public: + virtual ~cmConnectionBufferStrategy(); + + /*** + * Called whenever with an active raw buffer. If a logical chunk + * becomes available, that chunk is returned and that portion is + * removed from the rawBuffer + * + * @param rawBuffer in/out parameter. Receive buffer; the buffer strategy is + * free to manipulate this buffer anyway it needs to. + * + * @return Next chunk from the stream. Returns the empty string if a chunk + * isn't ready yet. Users of this interface should repeatedly call this + * function until an empty string is returned since its entirely possible + * multiple chunks come in a single raw buffer. + */ + virtual std::string BufferMessage(std::string& rawBuffer) = 0; + + /*** + * Resets the internal state of the buffering + */ + virtual void clear(); + + // TODO: There should be a callback / flag set for errors +}; + +class cmConnection +{ + CM_DISABLE_COPY(cmConnection) + +public: + cmConnection() {} + + virtual void WriteData(const std::string& data) = 0; + + virtual ~cmConnection(); + + virtual bool OnConnectionShuttingDown(); + + virtual bool IsOpen() const = 0; + + virtual void SetServer(cmServerBase* s); + + virtual void ProcessRequest(const std::string& request); + + virtual bool OnServeStart(std::string* pString); + +protected: + cmServerBase* Server = nullptr; +}; + +/*** + * Abstraction of a connection; ties in event callbacks from libuv and notifies + * the server when appropriate + */ +class cmEventBasedConnection : public cmConnection +{ + +public: + /*** + * @param bufferStrategy If no strategy is given, it will process the raw + * chunks as they come in. The connection + * owns the pointer given. + */ + cmEventBasedConnection(cmConnectionBufferStrategy* bufferStrategy = nullptr); + + virtual void Connect(uv_stream_t* server); + + virtual void ReadData(const std::string& data); + + bool IsOpen() const override; + + void WriteData(const std::string& data) override; + bool OnConnectionShuttingDown() override; + + virtual void OnDisconnect(int errorCode); + uv_stream_t* ReadStream = nullptr; + uv_stream_t* WriteStream = nullptr; + + static void on_close(uv_handle_t* handle); + static void on_close_delete(uv_handle_t* handle); + +protected: + std::string RawReadBuffer; + + std::unique_ptr<cmConnectionBufferStrategy> BufferStrategy; + + static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); + + static void on_write(uv_write_t* req, int status); + + static void on_new_connection(uv_stream_t* stream, int status); + + static void on_alloc_buffer(uv_handle_t* handle, size_t suggested_size, + uv_buf_t* buf); +}; diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h index 92bc68e..51f991d 100644 --- a/Source/cmContinueCommand.h +++ b/Source/cmContinueCommand.h @@ -3,7 +3,7 @@ #ifndef cmContinueCommand_h #define cmContinueCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 9a4abf3..86f5282 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCoreTryCompile.h" -#include "cmConfigure.h" #include "cmsys/Directory.hxx" #include <set> #include <sstream> @@ -102,7 +101,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } const char* sourceDirectory = argv[2].c_str(); - const char* projectName = CM_NULLPTR; + const char* projectName = nullptr; std::string targetName; std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0] std::vector<std::string> compileDefs; diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index f1f1e4b..47fb610 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -3,7 +3,7 @@ #ifndef cmCreateTestSourceList_h #define cmCreateTestSourceList_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 7995b2c..623c5e0 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -75,7 +75,7 @@ CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo) if (strcmp(algo, "SHA3_512") == 0) { return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512)); } - return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR); + return CM_AUTO_PTR<cmCryptoHash>(nullptr); } bool cmCryptoHash::IntFromHexDigit(char input, char& output) diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index c380d85..9c13968 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -3,7 +3,7 @@ #ifndef cmCryptoHash_h #define cmCryptoHash_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmCurl.h b/Source/cmCurl.h index a2fa4b1..0688bb2 100644 --- a/Source/cmCurl.h +++ b/Source/cmCurl.h @@ -3,11 +3,11 @@ #ifndef cmCurl_h #define cmCurl_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_curl.h" #include <string> -std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = CM_NULLPTR); +std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = nullptr); #endif diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 5e377b5..cfd260c 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -4,8 +4,6 @@ #include "cmMakefile.h" -#include "cmConfigure.h" - cmCustomCommand::cmCustomCommand() : Backtrace() { @@ -30,7 +28,7 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf, , Backtrace() , Comment(comment ? comment : "") , WorkingDirectory(workingDirectory ? workingDirectory : "") - , HaveComment(comment != CM_NULLPTR) + , HaveComment(comment != nullptr) , EscapeAllowMakeVars(false) , EscapeOldStyle(true) , CommandExpandLists(false) @@ -62,7 +60,7 @@ const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const const char* cmCustomCommand::GetComment() const { - const char* no_comment = CM_NULLPTR; + const char* no_comment = nullptr; return this->HaveComment ? this->Comment.c_str() : no_comment; } diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 67213ec..fdc0a97 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -13,8 +13,6 @@ #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" -#include "cmConfigure.h" - cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, const std::string& config, cmLocalGenerator* lg) @@ -24,7 +22,6 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, , OldStyle(cc.GetEscapeOldStyle()) , MakeVars(cc.GetEscapeAllowMakeVars()) , GE(new cmGeneratorExpression(cc.GetBacktrace())) - , DependsDone(false) { const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines(); for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin(); @@ -44,6 +41,22 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, } this->CommandLines.push_back(argv); } + + std::vector<std::string> depends = this->CC.GetDepends(); + for (std::vector<std::string>::const_iterator i = depends.begin(); + i != depends.end(); ++i) { + CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i); + std::vector<std::string> result; + cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), + result); + for (std::vector<std::string>::iterator it = result.begin(); + it != result.end(); ++it) { + if (cmSystemTools::FileIsFullPath(it->c_str())) { + *it = cmSystemTools::CollapseFullPath(*it); + } + } + this->Depends.insert(this->Depends.end(), result.begin(), result.end()); + } } cmCustomCommandGenerator::~cmCustomCommandGenerator() @@ -60,7 +73,7 @@ const char* cmCustomCommandGenerator::GetCrossCompilingEmulator( unsigned int c) const { if (!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")) { - return CM_NULLPTR; + return nullptr; } std::string const& argv0 = this->CommandLines[c][0]; cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); @@ -68,7 +81,7 @@ const char* cmCustomCommandGenerator::GetCrossCompilingEmulator( !target->IsImported()) { return target->GetProperty("CROSSCOMPILING_EMULATOR"); } - return CM_NULLPTR; + return nullptr; } const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const @@ -81,7 +94,7 @@ const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { return target->GetLocation(this->Config); } - return CM_NULLPTR; + return nullptr; } std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const @@ -125,14 +138,13 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c, std::string& cmd) const { unsigned int offset = 1; - if (this->GetCrossCompilingEmulator(c) != CM_NULLPTR) { + if (this->GetCrossCompilingEmulator(c) != nullptr) { offset = 0; } cmCustomCommandLine const& commandLine = this->CommandLines[c]; for (unsigned int j = offset; j < commandLine.size(); ++j) { std::string arg; - if (const char* location = - j == 0 ? this->GetArgv0Location(c) : CM_NULLPTR) { + if (const char* location = j == 0 ? this->GetArgv0Location(c) : nullptr) { // GetCommand returned the emulator instead of the argv0 location, // so transform the latter now. arg = location; @@ -171,23 +183,5 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const { - if (!this->DependsDone) { - this->DependsDone = true; - std::vector<std::string> depends = this->CC.GetDepends(); - for (std::vector<std::string>::const_iterator i = depends.begin(); - i != depends.end(); ++i) { - CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i); - std::vector<std::string> result; - cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), - result); - for (std::vector<std::string>::iterator it = result.begin(); - it != result.end(); ++it) { - if (cmSystemTools::FileIsFullPath(it->c_str())) { - *it = cmSystemTools::CollapseFullPath(*it); - } - } - this->Depends.insert(this->Depends.end(), result.begin(), result.end()); - } - } return this->Depends; } diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 0a2adb5..ea33b51 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -21,9 +21,8 @@ class cmCustomCommandGenerator bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; - mutable bool DependsDone; - mutable std::vector<std::string> Depends; cmCustomCommandLines CommandLines; + std::vector<std::string> Depends; const char* GetCrossCompilingEmulator(unsigned int c) const; const char* GetArgv0Location(unsigned int c) const; diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index bc120c5..43f6c58 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmDefinesPropertyCommand_h #define cmDefinesPropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 7aa7641..021f2e8 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinitions.h" -#include "cmConfigure.h" #include <assert.h> #include <set> #include <utility> @@ -35,7 +34,7 @@ const char* cmDefinitions::Get(const std::string& key, StackIter begin, StackIter end) { Def const& def = cmDefinitions::GetInternal(key, begin, end, false); - return def.Exists ? def.c_str() : CM_NULLPTR; + return def.Exists ? def.c_str() : nullptr; } void cmDefinitions::Raise(const std::string& key, StackIter begin, diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index ddb8918..528b157 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -6,10 +6,10 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <unordered_map> #include <vector> #include "cmLinkedTree.h" -#include "cm_unordered_map.hxx" /** \class cmDefinitions * \brief Store a scope of variable definitions for CMake language. @@ -70,7 +70,7 @@ private: }; static Def NoDef; - typedef CM_UNORDERED_MAP<std::string, Def> MapType; + typedef std::unordered_map<std::string, Def> MapType; MapType Map; static Def const& GetInternal(const std::string& key, StackIter begin, diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index c898d12..a0775b3 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -18,7 +18,7 @@ cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir) : CompileDirectory() , LocalGenerator(lg) , Verbose(false) - , FileComparison(CM_NULLPTR) + , FileComparison(nullptr) , TargetDirectory(targetDir) , MaxPath(16384) , Dependee(new char[MaxPath]) @@ -125,7 +125,7 @@ bool cmDepends::CheckDependencies( // regenerated. bool okay = true; bool dependerExists = false; - DependencyVector* currentDependencies = CM_NULLPTR; + DependencyVector* currentDependencies = nullptr; while (internalDepends.getline(this->Dependee, this->MaxPath)) { if (this->Dependee[0] == 0 || this->Dependee[0] == '#' || @@ -167,7 +167,7 @@ bool cmDepends::CheckDependencies( bool regenerate = false; const char* dependee = this->Dependee + 1; const char* depender = this->Depender; - if (currentDependencies != CM_NULLPTR) { + if (currentDependencies != nullptr) { currentDependencies->push_back(dependee); } @@ -227,9 +227,9 @@ bool cmDepends::CheckDependencies( // Remove the information of this depender from the map, it needs // to be rescanned - if (currentDependencies != CM_NULLPTR) { + if (currentDependencies != nullptr) { validDeps.erase(this->Depender); - currentDependencies = CM_NULLPTR; + currentDependencies = nullptr; } // Remove the depender to be sure it is rebuilt. @@ -246,7 +246,7 @@ bool cmDepends::CheckDependencies( void cmDepends::SetIncludePathFromLanguage(const std::string& lang) { // Look for the new per "TARGET_" variant first: - const char* includePath = CM_NULLPTR; + const char* includePath = nullptr; std::string includePathVar = "CMAKE_"; includePathVar += lang; includePathVar += "_TARGET_INCLUDE_PATH"; diff --git a/Source/cmDepends.h b/Source/cmDepends.h index b33feb9..a4fee3c 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -3,7 +3,7 @@ #ifndef cmDepends_h #define cmDepends_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> @@ -29,7 +29,7 @@ class cmDepends public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDepends(cmLocalGenerator* lg = CM_NULLPTR, const char* targetDir = ""); + cmDepends(cmLocalGenerator* lg = nullptr, const char* targetDir = ""); /** at what level will the compile be done from */ void SetCompileDirectory(const char* dir) { this->CompileDirectory = dir; } diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 2c464cc..588a78c 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -20,7 +20,7 @@ #define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: " cmDependsC::cmDependsC() - : ValidDeps(CM_NULLPTR) + : ValidDeps(nullptr) { } @@ -96,7 +96,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, std::set<std::string> dependencies; bool haveDeps = false; - if (this->ValidDeps != CM_NULLPTR) { + if (this->ValidDeps != nullptr) { std::map<std::string, DependencyVector>::const_iterator tmpIt = this->ValidDeps->find(obj); if (tmpIt != this->ValidDeps->end()) { @@ -107,7 +107,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, if (!haveDeps) { // Walk the dependency graph starting with the source file. - int srcFiles = (int)sources.size(); + int srcFiles = static_cast<int>(sources.size()); this->Encountered.clear(); for (std::set<std::string>::const_iterator srcIt = sources.begin(); @@ -259,12 +259,12 @@ void cmDependsC::ReadCacheFile() } std::string line; - cmIncludeLines* cacheEntry = CM_NULLPTR; + cmIncludeLines* cacheEntry = nullptr; bool haveFileName = false; while (cmSystemTools::GetLineFromStream(fin, line)) { if (line.empty()) { - cacheEntry = CM_NULLPTR; + cacheEntry = nullptr; haveFileName = false; continue; } @@ -302,7 +302,7 @@ void cmDependsC::ReadCacheFile() } } } - } else if (cacheEntry != CM_NULLPTR) { + } else if (cacheEntry != nullptr) { UnscannedEntry entry; entry.FileName = line; if (cmSystemTools::GetLineFromStream(fin, line)) { diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 250d40f..7780ccf 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -3,7 +3,7 @@ #ifndef cmDependsC_h #define cmDependsC_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmDepends.h" diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 8b05fab..e149a19 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -52,7 +52,7 @@ public: }; cmDependsFortran::cmDependsFortran() - : Internal(CM_NULLPTR) + : Internal(nullptr) { } diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index ec208af..42879f1 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -3,7 +3,7 @@ #ifndef cmFortran_h #define cmFortran_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <set> diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index a07bf09..4fd5960 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -3,7 +3,7 @@ #ifndef cmDependsJava_h #define cmDependsJava_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmDepends.h" diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 7bc91bf..3a57a38 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDependsJavaParserHelper.h" -#include "cmConfigure.h" - #include "cmDependsJavaLexer.h" #include "cmSystemTools.h" @@ -57,7 +55,7 @@ void cmDependsJavaParserHelper::DeallocateParserType(char** pt) if (!*pt) { return; } - *pt = CM_NULLPTR; + *pt = nullptr; this->UnionsAvailable--; } @@ -96,9 +94,9 @@ void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line, for (cc = 0; cc < strlen(str); cc++) { unsigned char ch = str[cc]; if (ch >= 32 && ch <= 126) { - std::cout << (char)ch; + std::cout << static_cast<char>(ch); } else { - std::cout << "<" << (int)ch << ">"; + std::cout << "<" << static_cast<int>(ch) << ">"; break; } } @@ -158,15 +156,15 @@ void cmDependsJavaParserHelper::PrepareElement( cmDependsJavaParserHelper::ParserType* me) { // Inititalize self - me->str = CM_NULLPTR; + me->str = nullptr; } void cmDependsJavaParserHelper::AllocateParserType( cmDependsJavaParserHelper::ParserType* pt, const char* str, int len) { - pt->str = CM_NULLPTR; + pt->str = nullptr; if (len == 0) { - len = (int)strlen(str); + len = static_cast<int>(strlen(str)); } if (len == 0) { return; @@ -224,7 +222,7 @@ std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced() std::vector<CurrentClass>::const_iterator it; for (it = toplevel.NestedClasses.begin(); it != toplevel.NestedClasses.end(); ++it) { - it->AddFileNamesForPrinting(&files, CM_NULLPTR, "$"); + it->AddFileNamesForPrinting(&files, nullptr, "$"); } return files; } @@ -324,7 +322,7 @@ void cmDependsJavaParserHelper::Error(const char* str) void cmDependsJavaParserHelper::UpdateCombine(const char* str1, const char* str2) { - if (this->CurrentCombine == "" && str1 != CM_NULLPTR) { + if (this->CurrentCombine == "" && str1 != nullptr) { this->CurrentCombine = str1; } this->CurrentCombine += "."; diff --git a/Source/cmDisallowedCommand.h b/Source/cmDisallowedCommand.h index 0030116..d5bb79a 100644 --- a/Source/cmDisallowedCommand.h +++ b/Source/cmDisallowedCommand.h @@ -3,7 +3,7 @@ #ifndef cmDisallowedCommand_h #define cmDisallowedCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index c6286b3..4af44b4 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -41,12 +41,12 @@ static const char* cmDocumentationStandardOptions[][2] = { { "--help-variable-list [<f>]", "List variables with help available and exit." }, { "--help-variables [<f>]", "Print cmake-variables manual and exit." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; static const char* cmDocumentationGeneratorsHeader[][2] = { - { CM_NULLPTR, "The following generators are available on this platform:" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, "The following generators are available on this platform:" }, + { nullptr, nullptr } }; cmDocumentation::cmDocumentation() @@ -403,7 +403,7 @@ void cmDocumentation::SetSections( void cmDocumentation::PrependSection(const char* name, const char* docs[][2]) { - cmDocumentationSection* sec = CM_NULLPTR; + cmDocumentationSection* sec = nullptr; if (this->AllSections.find(name) == this->AllSections.end()) { sec = new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); @@ -417,7 +417,7 @@ void cmDocumentation::PrependSection(const char* name, const char* docs[][2]) void cmDocumentation::PrependSection(const char* name, std::vector<cmDocumentationEntry>& docs) { - cmDocumentationSection* sec = CM_NULLPTR; + cmDocumentationSection* sec = nullptr; if (this->AllSections.find(name) == this->AllSections.end()) { sec = new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); @@ -430,7 +430,7 @@ void cmDocumentation::PrependSection(const char* name, void cmDocumentation::AppendSection(const char* name, const char* docs[][2]) { - cmDocumentationSection* sec = CM_NULLPTR; + cmDocumentationSection* sec = nullptr; if (this->AllSections.find(name) == this->AllSections.end()) { sec = new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); @@ -444,7 +444,7 @@ void cmDocumentation::AppendSection(const char* name, const char* docs[][2]) void cmDocumentation::AppendSection(const char* name, std::vector<cmDocumentationEntry>& docs) { - cmDocumentationSection* sec = CM_NULLPTR; + cmDocumentationSection* sec = nullptr; if (this->AllSections.find(name) == this->AllSections.end()) { sec = new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 2866fef..c80bed1 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -3,7 +3,7 @@ #ifndef _cmDocumentation_h #define _cmDocumentation_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmDocumentationFormatter.h" @@ -32,7 +32,7 @@ public: * help arguments. */ bool CheckOptions(int argc, const char* const* argv, - const char* exitOpt = CM_NULLPTR); + const char* exitOpt = nullptr); /** * Print help requested on the command line. Call after diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 7fbe75c..2fe0360 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -22,7 +22,7 @@ private: static cmDynamicLoaderCache* Instance; }; -cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = CM_NULLPTR; +cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = nullptr; cmDynamicLoaderCache::~cmDynamicLoaderCache() { @@ -71,7 +71,7 @@ void cmDynamicLoaderCache::FlushCache() cmsys::DynamicLoader::CloseLibrary(it->second); } delete cmDynamicLoaderCache::Instance; - cmDynamicLoaderCache::Instance = CM_NULLPTR; + cmDynamicLoaderCache::Instance = nullptr; } cmDynamicLoaderCache* cmDynamicLoaderCache::GetInstance() diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h index 7c46dd5..61d3b46 100644 --- a/Source/cmDynamicLoader.h +++ b/Source/cmDynamicLoader.h @@ -8,7 +8,7 @@ #ifndef cmDynamicLoader_h #define cmDynamicLoader_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/DynamicLoader.hxx" // IWYU pragma: export diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index fc97bf3..e2655e7 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -594,7 +594,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( if (dssi->second.Position > 0) { return &dssi->second; } - return CM_NULLPTR; + return nullptr; } // Create an entry for this tag. Assume it is missing until found. @@ -605,14 +605,14 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( // Try reading the dynamic section. if (!this->LoadDynamicSection()) { - return CM_NULLPTR; + return nullptr; } // Get the string table referenced by the DYNAMIC section. ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; if (sec.sh_link >= this->SectionHeaders.size()) { this->SetErrorMessage("Section DYNAMIC has invalid string table index."); - return CM_NULLPTR; + return nullptr; } ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link]; @@ -627,7 +627,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( if (dyn.d_un.d_val >= strtab.sh_size) { this->SetErrorMessage("Section DYNAMIC references string beyond " "the end of its string section."); - return CM_NULLPTR; + return nullptr; } // Seek to the position reported by the entry. @@ -656,7 +656,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( if (!this->Stream) { this->SetErrorMessage("Dynamic section specifies unreadable RPATH."); se.Value = ""; - return CM_NULLPTR; + return nullptr; } // The value has been read successfully. Report it. @@ -667,7 +667,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( return &se; } } - return CM_NULLPTR; + return nullptr; } //============================================================================ @@ -683,7 +683,7 @@ const long cmELF::TagMipsRldMapRel = 0; #endif cmELF::cmELF(const char* fname) - : Internal(CM_NULLPTR) + : Internal(nullptr) { // Try to open the file. CM_AUTO_PTR<cmsys::ifstream> fin(new cmsys::ifstream(fname)); @@ -811,7 +811,7 @@ cmELF::StringEntry const* cmELF::GetSOName() this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) { return this->Internal->GetSOName(); } - return CM_NULLPTR; + return nullptr; } cmELF::StringEntry const* cmELF::GetRPath() @@ -821,7 +821,7 @@ cmELF::StringEntry const* cmELF::GetRPath() this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { return this->Internal->GetRPath(); } - return CM_NULLPTR; + return nullptr; } cmELF::StringEntry const* cmELF::GetRunPath() @@ -831,7 +831,7 @@ cmELF::StringEntry const* cmELF::GetRunPath() this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { return this->Internal->GetRunPath(); } - return CM_NULLPTR; + return nullptr; } void cmELF::PrintInfo(std::ostream& os) const diff --git a/Source/cmELF.h b/Source/cmELF.h index a6e407f..678a595 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -3,7 +3,7 @@ #ifndef cmELF_h #define cmELF_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index 33c1c22..2b8cc24 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -3,7 +3,7 @@ #ifndef cmEnableLanguageCommand_h #define cmEnableLanguageCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h index e249662..1743b25 100644 --- a/Source/cmEnableTestingCommand.h +++ b/Source/cmEnableTestingCommand.h @@ -3,7 +3,7 @@ #ifndef cmEnableTestingCommand_h #define cmEnableTestingCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index fcc3c45..3c39816 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -86,7 +86,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args, args[1].c_str(), verbose); } else { result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal, - CM_NULLPTR, verbose); + nullptr, verbose); } if (!result) { retVal = -1; @@ -205,7 +205,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, } fflush(stdout); fflush(stderr); - const char* cmd[] = { "/bin/sh", "-c", command, CM_NULLPTR }; + const char* cmd[] = { "/bin/sh", "-c", command, nullptr }; cmsysProcess_SetCommand(cp, cmd); #endif @@ -217,7 +217,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, int p; cmProcessOutput processOutput(encoding); std::string strdata; - while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { + while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) { if (verbose) { processOutput.DecodeText(data, length, strdata); @@ -235,7 +235,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, } // All output has been read. Wait for the process to exit. - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); processOutput.DecodeText(output, output); // Check the result of running the process. diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 6463c4d..e3d696e 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -3,7 +3,7 @@ #ifndef cmExecProgramCommand_h #define cmExecProgramCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -38,8 +38,7 @@ public: private: static bool RunCommand(const char* command, std::string& output, int& retVal, - const char* directory = CM_NULLPTR, - bool verbose = true, + const char* directory = nullptr, bool verbose = true, Encoding encoding = cmProcessOutput::Auto); }; diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 8c10dbe..408497b 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -7,6 +7,7 @@ #include <sstream> #include <stdio.h> +#include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmProcessOutput.h" #include "cmSystemTools.h" @@ -15,7 +16,7 @@ class cmExecutionStatus; static bool cmExecuteProcessCommandIsWhitespace(char c) { - return (isspace((int)c) || c == '\n' || c == '\r'); + return (isspace(static_cast<int>(c)) || c == '\n' || c == '\r'); } void cmExecuteProcessCommandFixText(std::vector<char>& output, @@ -46,6 +47,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, std::string output_variable; std::string error_variable; std::string result_variable; + std::string results_variable; std::string working_directory; cmProcessOutput::Encoding encoding = cmProcessOutput::None; for (size_t i = 0; i < args.size(); ++i) { @@ -77,6 +79,14 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, this->SetError(" called with no value for RESULT_VARIABLE."); return false; } + } else if (args[i] == "RESULTS_VARIABLE") { + doing_command = false; + if (++i < args.size()) { + results_variable = args[i]; + } else { + this->SetError(" called with no value for RESULTS_VARIABLE."); + return false; + } } else if (args[i] == "WORKING_DIRECTORY") { doing_command = false; if (++i < args.size()) { @@ -166,7 +176,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, return false; } // Add the null terminating pointer to the command argument list. - cmds[i].push_back(CM_NULLPTR); + cmds[i].push_back(nullptr); } // Parse the timeout string. @@ -234,7 +244,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, int p; cmProcessOutput processOutput(encoding); std::string strdata; - while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { + while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { // Put the output in the right place. if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) { if (output_variable.empty()) { @@ -266,7 +276,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, } // All output has been read. Wait for the process to exit. - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); processOutput.DecodeText(tempOutput, tempOutput); processOutput.DecodeText(tempError, tempError); @@ -287,7 +297,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, switch (cmsysProcess_GetState(cp)) { case cmsysProcess_State_Exited: { int v = cmsysProcess_GetExitValue(cp); - char buf[100]; + char buf[16]; sprintf(buf, "%d", v); this->Makefile->AddDefinition(result_variable, buf); } break; @@ -305,6 +315,47 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, break; } } + // Store the result of running the processes. + if (!results_variable.empty()) { + switch (cmsysProcess_GetState(cp)) { + case cmsysProcess_State_Exited: { + std::vector<std::string> res; + for (size_t i = 0; i < cmds.size(); ++i) { + switch (cmsysProcess_GetStateByIndex(cp, static_cast<int>(i))) { + case kwsysProcess_StateByIndex_Exited: { + int exitCode = + cmsysProcess_GetExitValueByIndex(cp, static_cast<int>(i)); + char buf[16]; + sprintf(buf, "%d", exitCode); + res.push_back(buf); + } break; + case kwsysProcess_StateByIndex_Exception: + res.push_back(cmsysProcess_GetExceptionStringByIndex( + cp, static_cast<int>(i))); + break; + case kwsysProcess_StateByIndex_Error: + default: + res.push_back("Error getting the child return code"); + break; + } + } + this->Makefile->AddDefinition(results_variable, + cmJoin(res, ";").c_str()); + } break; + case cmsysProcess_State_Exception: + this->Makefile->AddDefinition(results_variable, + cmsysProcess_GetExceptionString(cp)); + break; + case cmsysProcess_State_Error: + this->Makefile->AddDefinition(results_variable, + cmsysProcess_GetErrorString(cp)); + break; + case cmsysProcess_State_Expired: + this->Makefile->AddDefinition(results_variable, + "Process terminated due to timeout"); + break; + } + } // Delete the process instance. cmsysProcess_Delete(cp); diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h index 08fde0a..dcf7b1c 100644 --- a/Source/cmExecuteProcessCommand.h +++ b/Source/cmExecuteProcessCommand.h @@ -3,7 +3,7 @@ #ifndef cmExecuteProcessCommand_h #define cmExecuteProcessCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index b443fb0..8662e8a 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -21,8 +21,8 @@ cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator() { - this->LG = CM_NULLPTR; - this->ExportSet = CM_NULLPTR; + this->LG = nullptr; + this->ExportSet = nullptr; } void cmExportBuildAndroidMKGenerator::GenerateImportHeaderCode( diff --git a/Source/cmExportBuildAndroidMKGenerator.h b/Source/cmExportBuildAndroidMKGenerator.h index d028ef4..db386f0 100644 --- a/Source/cmExportBuildAndroidMKGenerator.h +++ b/Source/cmExportBuildAndroidMKGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportBuildAndroidMKGenerator_h #define cmExportBuildAndroidMKGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index a1c424a..6e182b7 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -26,8 +26,8 @@ class cmSourceFile; cmExportBuildFileGenerator::cmExportBuildFileGenerator() { - this->LG = CM_NULLPTR; - this->ExportSet = CM_NULLPTR; + this->LG = nullptr; + this->ExportSet = nullptr; } void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg) @@ -233,7 +233,7 @@ void cmExportBuildFileGenerator::HandleMissingTarget( dependee->GetLocalGenerator()->GetGlobalGenerator(); std::vector<std::string> namespaces = this->FindNamespaces(gg, name); - int targetOccurrences = (int)namespaces.size(); + int targetOccurrences = static_cast<int>(namespaces.size()); if (targetOccurrences == 1) { std::string missingTarget = namespaces[0]; diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 0556983..d509453 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportBuildFileGenerator_h #define cmExportBuildFileGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExportFileGenerator.h" diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 38cd511..64baa90 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -35,7 +35,7 @@ cmExportCommand::cmExportCommand() , ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup) , AndroidMKFile(&Helper, "ANDROID_MK") { - this->ExportSet = CM_NULLPTR; + this->ExportSet = nullptr; } // cmExportCommand @@ -51,10 +51,10 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, return this->HandlePackage(args); } if (args[0] == "EXPORT") { - this->ExportSetName.Follows(CM_NULLPTR); + this->ExportSetName.Follows(nullptr); this->ArgumentGroup.Follows(&this->ExportSetName); } else { - this->Targets.Follows(CM_NULLPTR); + this->Targets.Follows(nullptr); this->ArgumentGroup.Follows(&this->Targets); } @@ -186,7 +186,7 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, } // Setup export file generation. - cmExportBuildFileGenerator* ebfg = CM_NULLPTR; + cmExportBuildFileGenerator* ebfg = nullptr; if (android) { ebfg = new cmExportBuildAndroidMKGenerator; } else { diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index c47bc42..7b6ad11 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -3,7 +3,7 @@ #ifndef cmExportCommand_h #define cmExportCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h index ebef783..bb43513 100644 --- a/Source/cmExportInstallAndroidMKGenerator.h +++ b/Source/cmExportInstallAndroidMKGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportInstallAndroidMKGenerator_h #define cmExportInstallAndroidMKGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <set> diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 664a342..350dc19 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -445,7 +445,7 @@ void cmExportInstallFileGenerator::HandleMissingTarget( const std::string name = dependee->GetName(); cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator(); std::vector<std::string> namespaces = this->FindNamespaces(gg, name); - int targetOccurrences = (int)namespaces.size(); + int targetOccurrences = static_cast<int>(namespaces.size()); if (targetOccurrences == 1) { std::string missingTarget = namespaces[0]; diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 8fa9b7f..e535873 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportInstallFileGenerator_h #define cmExportInstallFileGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExportFileGenerator.h" diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 69150ae..a1fdeae 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -4,6 +4,7 @@ #include "cmsys/FStream.hxx" #include <map> +#include <unordered_map> #include <utility> #include "cmGeneratedFileStream.h" @@ -14,7 +15,6 @@ #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_map.hxx" #include "cmake.h" class cmExecutionStatus; diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h index 5559af9..286a3e0 100644 --- a/Source/cmExportLibraryDependenciesCommand.h +++ b/Source/cmExportLibraryDependenciesCommand.h @@ -3,7 +3,7 @@ #ifndef cmExportLibraryDependenciesCommand_h #define cmExportLibraryDependenciesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index cd0a7e6..54e0e71 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -62,8 +62,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, - CM_NULLPTR, CM_NULLPTR); + cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, nullptr, + nullptr); CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 9671fac..9f6ac03 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportTryCompileFileGenerator_h #define cmExportTryCompileFileGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExportFileGenerator.h" diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index c3f026a..fe7159a 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExprParserHelper.h" -#include "cmConfigure.h" - #include "cmExprLexer.h" #include <iostream> @@ -14,7 +12,7 @@ int cmExpr_yyparse(yyscan_t yyscanner); cmExprParserHelper::cmExprParserHelper() { this->FileLine = -1; - this->FileName = CM_NULLPTR; + this->FileName = nullptr; } cmExprParserHelper::~cmExprParserHelper() diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 5b7b827..547fc99 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -4,6 +4,7 @@ #include <map> #include <ostream> +#include <set> #include <string.h> #include <utility> @@ -95,7 +96,7 @@ struct Tree { std::string path; // only one component of the path std::vector<Tree> folders; - std::vector<std::string> files; + std::set<std::string> files; void InsertPath(const std::vector<std::string>& splitted, std::vector<std::string>::size_type start, const std::string& fileName); @@ -112,7 +113,7 @@ void Tree::InsertPath(const std::vector<std::string>& splitted, const std::string& fileName) { if (start == splitted.size()) { - files.push_back(fileName); + files.insert(fileName); return; } for (std::vector<Tree>::iterator it = folders.begin(); it != folders.end(); @@ -123,7 +124,7 @@ void Tree::InsertPath(const std::vector<std::string>& splitted, return; } // last part of splitted - it->files.push_back(fileName); + it->files.insert(fileName); return; } } @@ -136,7 +137,7 @@ void Tree::InsertPath(const std::vector<std::string>& splitted, return; } // last part of splitted - newFolder.files.push_back(fileName); + newFolder.files.insert(fileName); folders.push_back(newFolder); } @@ -164,7 +165,7 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders, void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const { - for (std::vector<std::string>::const_iterator it = files.begin(); + for (std::set<std::string>::const_iterator it = files.begin(); it != files.end(); ++it) { xml.StartElement("Unit"); xml.Attribute("filename", fsPath + *it); @@ -185,7 +186,7 @@ void Tree::BuildUnitImpl(cmXMLWriter& xml, const std::string& virtualFolderPath, const std::string& fsPath) const { - for (std::vector<std::string>::const_iterator it = files.begin(); + for (std::set<std::string>::const_iterator it = files.begin(); it != files.end(); ++it) { xml.StartElement("Unit"); xml.Attribute("filename", fsPath + path + "/" + *it); @@ -289,15 +290,16 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( xml.StartElement("Build"); - this->AppendTarget(xml, "all", CM_NULLPTR, make.c_str(), lgs[0], + this->AppendTarget(xml, "all", nullptr, make.c_str(), lgs[0], compiler.c_str(), makeArgs); // add all executable and library targets and some of the GLOBAL // and UTILITY targets for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { @@ -306,7 +308,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // not from the subdirs if (strcmp((*lg)->GetCurrentBinaryDirectory(), (*lg)->GetBinaryDirectory()) == 0) { - this->AppendTarget(xml, targetName, CM_NULLPTR, make.c_str(), *lg, + this->AppendTarget(xml, targetName, nullptr, make.c_str(), *lg, compiler.c_str(), makeArgs); } } break; @@ -322,7 +324,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( break; } - this->AppendTarget(xml, targetName, CM_NULLPTR, make.c_str(), *lg, + this->AppendTarget(xml, targetName, nullptr, make.c_str(), *lg, compiler.c_str(), makeArgs); break; case cmStateEnums::EXECUTABLE: @@ -359,8 +361,9 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { switch ((*ti)->GetType()) { case cmStateEnums::EXECUTABLE: @@ -515,7 +518,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget( xml.StartElement("Target"); xml.Attribute("title", targetName); - if (target != CM_NULLPTR) { + if (target != nullptr) { int cbTargetType = this->GetCBTargetType(target); std::string workingDir = lg->GetCurrentBinaryDirectory(); if (target->GetType() == cmStateEnums::EXECUTABLE) { @@ -523,12 +526,12 @@ void cmExtraCodeBlocksGenerator::AppendTarget( // set the working directory to this dir. const char* runtimeOutputDir = makefile->GetDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"); - if (runtimeOutputDir != CM_NULLPTR) { + if (runtimeOutputDir != nullptr) { workingDir = runtimeOutputDir; } else { const char* executableOutputDir = makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - if (executableOutputDir != CM_NULLPTR) { + if (executableOutputDir != nullptr) { workingDir = executableOutputDir; } } diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 450a9d0..9397733 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraCodeBlocksGenerator_h #define cmExtraCodeBlocksGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index b478f34..96502d5 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -292,8 +292,9 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { projectType = CollectSourceFiles(makefile, *ti, cFiles, otherFiles); } diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index de33098..549802e 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalCodeLiteGenerator_h #define cmGlobalCodeLiteGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 2a6ce98..684d1f5 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -222,17 +222,17 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, // now we have both, decide which one to use std::string valueToUse; - if (!envVarSet && cacheValue == CM_NULLPTR) { + if (!envVarSet && cacheValue == nullptr) { // nothing known, do nothing valueToUse = ""; - } else if (envVarSet && cacheValue == CM_NULLPTR) { + } else if (envVarSet && cacheValue == nullptr) { // The variable is in the env, but not in the cache. Use it and put it // in the cache valueToUse = envVarValue; mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmStateEnums::STRING, true); mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); - } else if (!envVarSet && cacheValue != CM_NULLPTR) { + } else if (!envVarSet && cacheValue != nullptr) { // It is already in the cache, but not in the env, so use it from the cache valueToUse = cacheValue; } else { @@ -475,7 +475,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) this->GlobalGenerator->GetLocalGenerators().begin(); lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) { cmMakefile* makefile = (*lgIt)->GetMakefile(); - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*lgIt)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); @@ -853,8 +853,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*it)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin(); l != targets.end(); ++l) { std::vector<std::string> includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -910,7 +911,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*it)->GetGeneratorTargets(); std::string subdir = (*it)->ConvertToRelativePath( this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory()); diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 1380d18..5d2ca10 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -3,7 +3,7 @@ #ifndef cmExtraEclipseCDT4Generator_h #define cmExtraEclipseCDT4Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" @@ -67,7 +67,7 @@ private: const std::string& make, const std::string& makeArguments, const std::string& path, const char* prefix = "", - const char* makeTarget = CM_NULLPTR); + const char* makeTarget = nullptr); static void AppendScannerProfile( cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled, const std::string& openActionFilePath, bool pParserEnabled, diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 3730433..a75a400 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -115,7 +115,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*it)->GetGeneratorTargets(); std::string currentDir = (*it)->GetCurrentBinaryDirectory(); bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); @@ -135,9 +135,9 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, if (targetName == "edit_cache") { const char* editCommand = (*it)->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND"); - if (editCommand == CM_NULLPTR) { + if (editCommand == nullptr) { insertTarget = false; - } else if (strstr(editCommand, "ccmake") != CM_NULLPTR) { + } else if (strstr(editCommand, "ccmake") != nullptr) { insertTarget = false; } } diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 6b9c7af..7e80314 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraKateGenerator_h #define cmExtraKateGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 1fd1418..5bb424b 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -174,9 +174,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler; if (!lgs.empty()) { - this->AppendTarget(fout, "all", lgs[0], CM_NULLPTR, make.c_str(), mf, + this->AppendTarget(fout, "all", lgs[0], nullptr, make.c_str(), mf, compiler.c_str(), sourceFileFlags, true); - this->AppendTarget(fout, "clean", lgs[0], CM_NULLPTR, make.c_str(), mf, + this->AppendTarget(fout, "clean", lgs[0], nullptr, make.c_str(), mf, compiler.c_str(), sourceFileFlags, false); } @@ -185,8 +185,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { @@ -195,7 +196,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( // not from the subdirs if (strcmp((*lg)->GetCurrentBinaryDirectory(), (*lg)->GetBinaryDirectory()) == 0) { - this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(), + this->AppendTarget(fout, targetName, *lg, nullptr, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -212,7 +213,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( break; } - this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(), + this->AppendTarget(fout, targetName, *lg, nullptr, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); break; @@ -244,7 +245,7 @@ void cmExtraSublimeTextGenerator::AppendTarget( MapSourceFileFlags& sourceFileFlags, bool firstTarget) { - if (target != CM_NULLPTR) { + if (target != nullptr) { std::vector<cmSourceFile*> sourceFiles; target->GetSourceFiles(sourceFiles, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 9022d37..bf6d23f 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraSublimeTextGenerator_h #define cmExtraSublimeTextGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index ff78f52..03d1ad1 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -72,8 +72,8 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args, // Add command for generating the .h and .cxx files std::string no_main_dependency; - const char* no_comment = CM_NULLPTR; - const char* no_working_dir = CM_NULLPTR; + const char* no_comment = nullptr; + const char* no_working_dir = nullptr; this->Makefile->AddCustomCommandToOutput( cxxres, depends, no_main_dependency, commandLines, no_comment, no_working_dir); diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index d8045ab..64c29f8 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -3,7 +3,7 @@ #ifndef cmFLTKWrapUICommand_h #define cmFLTKWrapUICommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 5777fb2..3af7484 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -55,14 +55,14 @@ class cmSystemToolsFileTime; static mode_t mode_owner_read = S_IREAD; static mode_t mode_owner_write = S_IWRITE; static mode_t mode_owner_execute = S_IEXEC; -static mode_t mode_group_read = 0; -static mode_t mode_group_write = 0; -static mode_t mode_group_execute = 0; -static mode_t mode_world_read = 0; -static mode_t mode_world_write = 0; -static mode_t mode_world_execute = 0; -static mode_t mode_setuid = 0; -static mode_t mode_setgid = 0; +static mode_t mode_group_read = 040; +static mode_t mode_group_write = 020; +static mode_t mode_group_execute = 010; +static mode_t mode_world_read = 04; +static mode_t mode_world_write = 02; +static mode_t mode_world_execute = 01; +static mode_t mode_setuid = 04000; +static mode_t mode_setgid = 02000; #else static mode_t mode_owner_read = S_IRUSR; static mode_t mode_owner_write = S_IWUSR; @@ -269,17 +269,17 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) cmCommandArgumentGroup group; cmCAString readArg(&argHelper, "READ"); - cmCAString fileNameArg(&argHelper, CM_NULLPTR); - cmCAString resultArg(&argHelper, CM_NULLPTR); + cmCAString fileNameArg(&argHelper, nullptr); + cmCAString resultArg(&argHelper, nullptr); cmCAString offsetArg(&argHelper, "OFFSET", &group); cmCAString limitArg(&argHelper, "LIMIT", &group); cmCAEnabler hexOutputArg(&argHelper, "HEX", &group); - readArg.Follows(CM_NULLPTR); + readArg.Follows(nullptr); fileNameArg.Follows(&readArg); resultArg.Follows(&fileNameArg); group.Follows(&resultArg); - argHelper.Parse(&args, CM_NULLPTR); + argHelper.Parse(&args, nullptr); std::string fileName = fileNameArg.GetString(); if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) { @@ -940,9 +940,9 @@ bool cmFileCommand::HandleDifferentCommand( */ // Evaluate arguments. - const char* file_lhs = CM_NULLPTR; - const char* file_rhs = CM_NULLPTR; - const char* var = CM_NULLPTR; + const char* file_lhs = nullptr; + const char* file_rhs = nullptr; + const char* var = nullptr; enum Doing { DoingNone, @@ -997,7 +997,7 @@ struct cmFileCopier , MatchlessFiles(true) , FilePermissions(0) , DirPermissions(0) - , CurrentMatchRule(CM_NULLPTR) + , CurrentMatchRule(nullptr) , UseGivenPermissionsFile(false) , UseGivenPermissionsDir(false) , UseSourcePermissions(true) @@ -1076,11 +1076,26 @@ protected: bool SetPermissions(const char* toFile, mode_t permissions) { - if (permissions && !cmSystemTools::SetPermissions(toFile, permissions)) { - std::ostringstream e; - e << this->Name << " cannot set permissions on \"" << toFile << "\""; - this->FileCommand->SetError(e.str()); - return false; + if (permissions) { +#ifdef WIN32 + if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) { + std::string mode_t_adt_filename = + std::string(toFile) + ":cmake_mode_t"; + + cmsys::ofstream permissionStream(mode_t_adt_filename.c_str()); + + if (permissionStream) { + permissionStream << std::oct << permissions << std::endl; + } + } +#endif + + if (!cmSystemTools::SetPermissions(toFile, permissions)) { + std::ostringstream e; + e << this->Name << " cannot set permissions on \"" << toFile << "\""; + this->FileCommand->SetError(e.str()); + return false; + } } return true; } @@ -2028,9 +2043,9 @@ bool cmFileCommand::HandleRPathChangeCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = CM_NULLPTR; - const char* oldRPath = CM_NULLPTR; - const char* newRPath = CM_NULLPTR; + const char* file = nullptr; + const char* oldRPath = nullptr; + const char* newRPath = nullptr; enum Doing { DoingNone, @@ -2118,7 +2133,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = CM_NULLPTR; + const char* file = nullptr; enum Doing { DoingNone, @@ -2182,8 +2197,8 @@ bool cmFileCommand::HandleRPathCheckCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = CM_NULLPTR; - const char* rpath = CM_NULLPTR; + const char* file = nullptr; + const char* rpath = nullptr; enum Doing { DoingNone, @@ -2241,16 +2256,16 @@ bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args) cmCommandArgumentGroup group; cmCAString readArg(&argHelper, "READ_ELF"); - cmCAString fileNameArg(&argHelper, CM_NULLPTR); + cmCAString fileNameArg(&argHelper, nullptr); cmCAString rpathArg(&argHelper, "RPATH", &group); cmCAString runpathArg(&argHelper, "RUNPATH", &group); cmCAString errorArg(&argHelper, "CAPTURE_ERROR", &group); - readArg.Follows(CM_NULLPTR); + readArg.Follows(nullptr); fileNameArg.Follows(&readArg); group.Follows(&fileNameArg); - argHelper.Parse(&args, CM_NULLPTR); + argHelper.Parse(&args, nullptr); if (!cmSystemTools::FileExists(fileNameArg.GetString(), true)) { std::ostringstream e; @@ -2439,7 +2454,7 @@ namespace { size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data) { - int realsize = (int)(size * nmemb); + int realsize = static_cast<int>(size * nmemb); cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data); const char* chPtr = static_cast<char*>(ptr); fout->write(chPtr, realsize); @@ -2449,7 +2464,7 @@ size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data) size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { - int realsize = (int)(size * nmemb); + int realsize = static_cast<int>(size * nmemb); cmFileCommandVectorOfChar* vec = static_cast<cmFileCommandVectorOfChar*>(data); const char* chPtr = static_cast<char*>(ptr); @@ -2581,7 +2596,7 @@ public: } } - void release() { this->Easy = CM_NULLPTR; } + void release() { this->Easy = nullptr; } private: ::CURL* Easy; @@ -2743,7 +2758,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) msg += "\""; if (!statusVar.empty()) { std::ostringstream result; - result << (int)0 << ";\"" << msg; + result << 0 << ";\"" << msg; this->Makefile->AddDefinition(statusVar, result.str().c_str()); } return true; @@ -2816,10 +2831,10 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) cmFileCommandVectorOfChar chunkDebug; - res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&fout); + res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fout); check_curl_result(res, "DOWNLOAD cannot set write data: "); - res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug); + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); check_curl_result(res, "DOWNLOAD cannot set debug data: "); res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); @@ -2866,7 +2881,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) check_curl_result(res, "DOWNLOAD cannot set user password: "); } - struct curl_slist* headers = CM_NULLPTR; + struct curl_slist* headers = nullptr; for (std::vector<std::string>::const_iterator h = curl_headers.begin(); h != curl_headers.end(); ++h) { headers = ::curl_slist_append(headers, h->c_str()); @@ -2883,7 +2898,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) if (!statusVar.empty()) { std::ostringstream result; - result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; + result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res) + << "\""; this->Makefile->AddDefinition(statusVar, result.str().c_str()); } @@ -2909,7 +2925,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " for file: [" << file << "]" << std::endl << " expected hash: [" << expectedHash << "]" << std::endl << " actual hash: [" << actualHash << "]" << std::endl - << " status: [" << (int)res << ";\"" + << " status: [" << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res) << "\"]" << std::endl; if (!statusVar.empty() && res == 0) { @@ -3065,10 +3081,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) cmFileCommandVectorOfChar chunkResponse; cmFileCommandVectorOfChar chunkDebug; - res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunkResponse); + res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunkResponse); check_curl_result(res, "UPLOAD cannot set write data: "); - res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug); + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); check_curl_result(res, "UPLOAD cannot set debug data: "); res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); @@ -3124,7 +3140,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) check_curl_result(res, "UPLOAD cannot set user password: "); } - struct curl_slist* headers = CM_NULLPTR; + struct curl_slist* headers = nullptr; for (std::vector<std::string>::const_iterator h = curl_headers.begin(); h != curl_headers.end(); ++h) { headers = ::curl_slist_append(headers, h->c_str()); @@ -3141,14 +3157,15 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) if (!statusVar.empty()) { std::ostringstream result; - result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; + result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res) + << "\""; this->Makefile->AddDefinition(statusVar, result.str().c_str()); } ::curl_global_cleanup(); fclose(fin); - fin = CM_NULLPTR; + fin = nullptr; if (!logVar.empty()) { std::string log; diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index d09ef42..1de8b59 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -3,7 +3,7 @@ #ifndef cmFileCommand_h #define cmFileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h index ccef508..c9ab0db 100644 --- a/Source/cmFileLock.h +++ b/Source/cmFileLock.h @@ -3,7 +3,7 @@ #ifndef cmFileLock_h #define cmFileLock_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h index c96a8c2..af98270 100644 --- a/Source/cmFileLockPool.h +++ b/Source/cmFileLockPool.h @@ -3,7 +3,7 @@ #ifndef cmFileLockPool_h #define cmFileLockPool_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx index a040705..9ca5d8a 100644 --- a/Source/cmFileLockResult.cxx +++ b/Source/cmFileLockResult.cxx @@ -5,6 +5,7 @@ #include <errno.h> #include <string.h> +#define WINMSG_BUF_LEN (1024) cmFileLockResult cmFileLockResult::MakeOk() { return cmFileLockResult(OK, 0); @@ -53,18 +54,12 @@ std::string cmFileLockResult::GetOutputMessage() const case SYSTEM: #if defined(_WIN32) { - char* errorText = NULL; - - // http://stackoverflow.com/a/455533/2288008 - DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; - ::FormatMessageA(flags, NULL, this->ErrorValue, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&errorText, 0, NULL); - - if (errorText != NULL) { - const std::string message = errorText; - ::LocalFree(errorText); + char winmsg[WINMSG_BUF_LEN]; + DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + if (FormatMessageA(flags, NULL, this->ErrorValue, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)winmsg, WINMSG_BUF_LEN, NULL)) { + const std::string message = winmsg; return message; } else { return "Internal error (FormatMessageA failed)"; diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 8027535..c0401d7 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -171,7 +171,9 @@ public: { if (this->Handle) { uv_fs_event_stop(this->Handle); - uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close); + if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(this->Handle))) { + uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close); + } this->Handle = nullptr; } cmVirtualDirectoryWatcher::StopWatching(); diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h index d7ec92a..632e751 100644 --- a/Source/cmFileMonitor.h +++ b/Source/cmFileMonitor.h @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <functional> #include <string> diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index f591a8d..61e419c 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -4,10 +4,9 @@ #include <string> #include <time.h> +#include <unordered_map> #include <utility> -#include "cm_unordered_map.hxx" - // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) #include "cm_sys_stat.h" @@ -27,7 +26,7 @@ public: bool FileTimesDiffer(const char* f1, const char* f2); private: - typedef CM_UNORDERED_MAP<std::string, cmFileTimeComparison_Type> + typedef std::unordered_map<std::string, cmFileTimeComparison_Type> FileStatsMap; FileStatsMap Files; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 10c6fe4..b195d27 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindBase.h" -#include "cmConfigure.h" #include <deque> #include <iostream> #include <iterator> @@ -335,7 +334,7 @@ bool cmFindBase::CheckForVariableInCache() cmState* state = this->Makefile->GetState(); const char* cacheEntry = state->GetCacheEntryValue(this->VariableName); bool found = !cmSystemTools::IsNOTFOUND(cacheValue); - bool cached = cacheEntry != CM_NULLPTR; + bool cached = cacheEntry != nullptr; if (found) { // If the user specifies the entry on the command line without a // type we should add the type and docstring but keep the diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 4ef0f3e..9ebe824 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -242,13 +242,13 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) { // null-terminated list of paths. static const char* paths[] = { "CMAKE_SYSTEM_IGNORE_PATH", - "CMAKE_IGNORE_PATH", CM_NULLPTR }; + "CMAKE_IGNORE_PATH", nullptr }; // Construct the list of path roots with no trailing slashes. for (const char** pathName = paths; *pathName; ++pathName) { // Get the list of paths to ignore from the variable. const char* ignorePath = this->Makefile->GetDefinition(*pathName); - if ((ignorePath == CM_NULLPTR) || (strlen(ignorePath) == 0)) { + if ((ignorePath == nullptr) || (strlen(ignorePath) == 0)) { continue; } diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 72dcd35..939a5bc 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -3,7 +3,7 @@ #ifndef cmFindCommon_h #define cmFindCommon_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <set> diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index bf57fec..88c2372 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -3,7 +3,7 @@ #ifndef cmFindFileCommand_h #define cmFindFileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmFindPathCommand.h" diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index 9d38eab..fb0a44f 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -3,7 +3,7 @@ #ifndef cmFindLibraryCommand_h #define cmFindLibraryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 7797700..d0cc6ce 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1319,7 +1319,7 @@ public: cmSystemTools::RemoveFile(this->File); } } - void Release() { this->File = CM_NULLPTR; } + void Release() { this->File = nullptr; } }; void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir, @@ -1642,7 +1642,7 @@ class cmFileList public: cmFileList() : First() - , Last(CM_NULLPTR) + , Last(nullptr) { } virtual ~cmFileList() {} diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 99b0059..69deb13 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -3,7 +3,7 @@ #ifndef cmFindPackageCommand_h #define cmFindPackageCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_kwiml.h" #include <map> diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 3761145..5b9ddf8 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -3,7 +3,7 @@ #ifndef cmFindPathCommand_h #define cmFindPathCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index b0cd420..f4d78b4 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -3,7 +3,7 @@ #ifndef cmFindProgramCommand_h #define cmFindProgramCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index 7c8a6d8..6787023 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -3,7 +3,7 @@ #ifndef cmForEachCommand_h #define cmForEachCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index d8b0023..3f5ad87 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -4,7 +4,7 @@ #define cmFortranParser_h #if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx) -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 4e23f36..333b6c1 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -3,7 +3,6 @@ #include "cmFortranParser.h" #include "cmSystemTools.h" -#include "cmConfigure.h" #include <assert.h> #include <set> #include <stack> @@ -61,7 +60,7 @@ cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes, // Create a dummy buffer that is never read but is the fallback // buffer when the last file is popped off the stack. YY_BUFFER_STATE buffer = - cmFortran_yy_create_buffer(CM_NULLPTR, 4, this->Scanner); + cmFortran_yy_create_buffer(nullptr, 4, this->Scanner); cmFortran_yy_switch_to_buffer(buffer, this->Scanner); } @@ -79,7 +78,7 @@ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname) std::string dir = cmSystemTools::GetParentDirectory(fname); cmFortranFile f(file, current, dir); YY_BUFFER_STATE buffer = - cmFortran_yy_create_buffer(CM_NULLPTR, 16384, parser->Scanner); + cmFortran_yy_create_buffer(nullptr, 16384, parser->Scanner); cmFortran_yy_switch_to_buffer(buffer, parser->Scanner); parser->FileStack.push(f); return true; @@ -121,7 +120,7 @@ int cmFortranParser_Input(cmFortranParser* parser, char* buffer, n = 1; ff.LastCharWasNewline = true; } - return (int)n; + return static_cast<int>(n); } return 0; } diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index f263126..48d6b36 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -3,7 +3,7 @@ #ifndef cmFunctionCommand_h #define cmFunctionCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 56f9988..5144772 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -3,7 +3,7 @@ #ifndef cmGeneratedFileStream_h #define cmGeneratedFileStream_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_codecvt.hxx" #include "cmsys/FStream.hxx" diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 34516f5..9d9ae4e 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpression_h #define cmGeneratorExpression_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmListFileCache.h" @@ -71,12 +71,12 @@ class cmCompiledGeneratorExpression CM_DISABLE_COPY(cmCompiledGeneratorExpression) public: - const char* Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet = false, - cmGeneratorTarget const* headTarget = CM_NULLPTR, - cmGeneratorTarget const* currentTarget = CM_NULLPTR, - cmGeneratorExpressionDAGChecker* dagChecker = CM_NULLPTR, - std::string const& language = std::string()) const; + const char* Evaluate(cmLocalGenerator* lg, const std::string& config, + bool quiet = false, + cmGeneratorTarget const* headTarget = nullptr, + cmGeneratorTarget const* currentTarget = nullptr, + cmGeneratorExpressionDAGChecker* dagChecker = nullptr, + std::string const& language = std::string()) const; const char* Evaluate(cmLocalGenerator* lg, const std::string& config, bool quiet, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 557a192..a3974ab 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionDAGChecker_h #define cmGeneratorExpressionDAGChecker_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmListFileCache.h" @@ -61,7 +61,7 @@ struct cmGeneratorExpressionDAGChecker void ReportError(cmGeneratorExpressionContext* context, const std::string& expr); - bool EvaluatingLinkLibraries(const char* tgt = CM_NULLPTR); + bool EvaluatingLinkLibraries(const char* tgt = nullptr); #define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 1526454..a2ff189 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpressionEvaluationFile.h" -#include "cmConfigure.h" #include "cmsys/FStream.hxx" #include <sstream> #include <utility> @@ -20,11 +19,13 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( const std::string& input, CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr, - CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent) + CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent, + cmPolicies::PolicyStatus policyStatusCMP0070) : Input(input) , OutputFileExpr(outputFileExpr) , Condition(condition) , InputIsContent(inputIsContent) + , PolicyStatusCMP0070(policyStatusCMP0070) { } @@ -36,7 +37,7 @@ void cmGeneratorExpressionEvaluationFile::Generate( std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { std::string condResult = this->Condition->Evaluate( - lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang); + lg, config, false, nullptr, nullptr, nullptr, lang); if (condResult == "0") { return; } @@ -51,10 +52,16 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - const std::string outputFileName = this->OutputFileExpr->Evaluate( - lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang); + std::string outputFileName = this->OutputFileExpr->Evaluate( + lg, config, false, nullptr, nullptr, nullptr, lang); const std::string outputContent = inputExpression->Evaluate( - lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang); + lg, config, false, nullptr, nullptr, nullptr, lang); + + if (cmSystemTools::FileIsFullPath(outputFileName)) { + outputFileName = cmSystemTools::CollapseFullPath(outputFileName); + } else { + outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); + } std::map<std::string, std::string>::iterator it = outputFiles.find(outputFileName); @@ -95,7 +102,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( for (std::vector<std::string>::const_iterator le = enabledLanguages.begin(); le != enabledLanguages.end(); ++le) { std::string name = this->OutputFileExpr->Evaluate( - lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, *le); + lg, config, false, nullptr, nullptr, nullptr, *le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); sf->SetProperty("GENERATED", "1"); @@ -111,12 +118,18 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) if (this->InputIsContent) { inputContent = this->Input; } else { - lg->GetMakefile()->AddCMakeDependFile(this->Input); - cmSystemTools::GetPermissions(this->Input.c_str(), perm); - cmsys::ifstream fin(this->Input.c_str()); + std::string inputFileName = this->Input; + if (cmSystemTools::FileIsFullPath(inputFileName)) { + inputFileName = cmSystemTools::CollapseFullPath(inputFileName); + } else { + inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg); + } + lg->GetMakefile()->AddCMakeDependFile(inputFileName); + cmSystemTools::GetPermissions(inputFileName.c_str(), perm); + cmsys::ifstream fin(inputFileName.c_str()); if (!fin) { std::ostringstream e; - e << "Evaluation file \"" << this->Input << "\" cannot be read."; + e << "Evaluation file \"" << inputFileName << "\" cannot be read."; lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -159,3 +172,57 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) } } } + +std::string cmGeneratorExpressionEvaluationFile::FixRelativePath( + std::string const& relativePath, PathRole role, cmLocalGenerator* lg) +{ + std::string resultPath; + switch (this->PolicyStatusCMP0070) { + case cmPolicies::WARN: { + std::string arg; + switch (role) { + case PathForInput: + arg = "INPUT"; + break; + case PathForOutput: + arg = "OUTPUT"; + break; + } + std::ostringstream w; + /* clang-format off */ + w << + cmPolicies::GetPolicyWarning(cmPolicies::CMP0070) << "\n" + "file(GENERATE) given relative " << arg << " path:\n" + " " << relativePath << "\n" + "This is not defined behavior unless CMP0070 is set to NEW. " + "For compatibility with older versions of CMake, the previous " + "undefined behavior will be used." + ; + /* clang-format on */ + lg->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + CM_FALLTHROUGH; + case cmPolicies::OLD: + // OLD behavior is to use the relative path unchanged, + // which ends up being used relative to the working dir. + resultPath = relativePath; + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // NEW behavior is to interpret the relative path with respect + // to the current source or binary directory. + switch (role) { + case PathForInput: + resultPath = cmSystemTools::CollapseFullPath( + relativePath, lg->GetCurrentSourceDirectory()); + break; + case PathForOutput: + resultPath = cmSystemTools::CollapseFullPath( + relativePath, lg->GetCurrentBinaryDirectory()); + break; + } + break; + } + return resultPath; +} diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 9872746..ecf919d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -10,6 +10,7 @@ #include <vector> #include "cmGeneratorExpression.h" +#include "cmPolicies.h" #include "cm_auto_ptr.hxx" #include "cm_sys_stat.h" @@ -21,7 +22,8 @@ public: cmGeneratorExpressionEvaluationFile( const std::string& input, CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr, - CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent); + CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent, + cmPolicies::PolicyStatus policyStatusCMP0070); void Generate(cmLocalGenerator* lg); @@ -35,12 +37,21 @@ private: cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string>& outputFiles, mode_t perm); + enum PathRole + { + PathForInput, + PathForOutput + }; + std::string FixRelativePath(std::string const& filePath, PathRole role, + cmLocalGenerator* lg); + private: const std::string Input; const CM_AUTO_PTR<cmCompiledGeneratorExpression> OutputFileExpr; const CM_AUTO_PTR<cmCompiledGeneratorExpression> Condition; std::vector<std::string> Files; const bool InputIsContent; + cmPolicies::PolicyStatus PolicyStatusCMP0070; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 6ce4a8e..f2dbc26 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -153,7 +153,7 @@ std::string GeneratorExpressionContent::EvaluateParameters( } if ((numExpected > cmGeneratorExpressionNode::DynamicParameters && - (unsigned int)numExpected != parameters.size())) { + static_cast<unsigned int>(numExpected) != parameters.size())) { if (numExpected == 0) { reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires no parameters."); diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index a0a826a..a7e5f6f 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionEvaluator_h #define cmGeneratorExpressionEvaluator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a57d2a0..7d34293 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -20,7 +20,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#include "cmConfigure.h" #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" #include <algorithm> @@ -730,8 +729,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode CM_OVERRIDE { if (parameters.empty()) { - return configurationNode.Evaluate(parameters, context, content, - CM_NULLPTR); + return configurationNode.Evaluate(parameters, context, content, nullptr); } static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$"); if (!configValidator.find(*parameters.begin())) { @@ -750,8 +748,8 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode } if (context->CurrentTarget && context->CurrentTarget->IsImported()) { - const char* loc = CM_NULLPTR; - const char* imp = CM_NULLPTR; + const char* loc = nullptr; + const char* imp = nullptr; std::string suffix; if (context->CurrentTarget->Target->GetMappedConfig( context->Config, &loc, &imp, suffix)) { @@ -813,7 +811,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode reportError( context, content->GetOriginalExpression(), "$<COMPILE_LANGUAGE:...> may only be used to specify include " - "directories compile definitions, compile options and to evaluate " + "directories, compile definitions, compile options, and to evaluate " "components of the file(GENERATE) command."); return std::string(); } @@ -864,7 +862,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode #define TRANSITIVE_PROPERTY_NAME(PROPERTY) , "INTERFACE_" #PROPERTY static const char* targetPropertyTransitiveWhitelist[] = { - CM_NULLPTR CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME) + nullptr CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME) }; #undef TRANSITIVE_PROPERTY_NAME @@ -1260,8 +1258,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode std::vector<std::string> objects; if (gt->IsImported()) { - const char* loc = CM_NULLPTR; - const char* imp = CM_NULLPTR; + const char* loc = nullptr; + const char* imp = nullptr; std::string suffix; if (gt->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) { cmSystemTools::ExpandListArgument(loc, objects); @@ -1389,7 +1387,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode } compileFeaturesNode; static const char* targetPolicyWhitelist[] = { - CM_NULLPTR + nullptr #define TARGET_POLICY_STRING(POLICY) , #POLICY CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING) @@ -1873,7 +1871,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( } NodeMap::const_iterator i = nodeMap.find(identifier); if (i == nodeMap.end()) { - return CM_NULLPTR; + return nullptr; } return i->second; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 329c7a9..a0a3f4f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -12,6 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unordered_set> #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" @@ -32,7 +33,6 @@ #include "cmTargetLinkLibraryType.h" #include "cmTargetPropertyComputer.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_set.hxx" #include "cmake.h" class cmMessenger; @@ -204,14 +204,14 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const if (!cmTargetPropertyComputer::PassesWhitelist( this->GetType(), prop, this->Makefile->GetMessenger(), this->GetBacktrace())) { - return CM_NULLPTR; + return nullptr; } if (const char* result = cmTargetPropertyComputer::GetProperty( this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) { return result; } if (cmSystemTools::GetFatalErrorOccured()) { - return CM_NULLPTR; + return nullptr; } return this->Target->GetProperty(prop); } @@ -326,6 +326,13 @@ std::string cmGeneratorTarget::GetOutputName( return i->second; } +void cmGeneratorTarget::ClearSourcesCache() +{ + this->KindedSourcesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + this->Objects.clear(); +} + void cmGeneratorTarget::AddSourceCommon(const std::string& src) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -333,8 +340,7 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src) CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); this->SourceEntries.push_back(new TargetPropertyEntry(cge)); - this->KindedSourcesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; + this->ClearSourcesCache(); } void cmGeneratorTarget::AddSource(const std::string& src) @@ -373,7 +379,7 @@ std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends( if (i != this->SourceDepends.end()) { return &i->second.Depends; } - return CM_NULLPTR; + return nullptr; } static void handleSystemIncludesDep( @@ -511,7 +517,7 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang, } // Note: check consistency with messages from CheckIPOSupported - const char* message = CM_NULLPTR; + const char* message = nullptr; if (!this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_SUPPORTED_BY_CMAKE")) { message = "CMake doesn't support IPO for current compiler"; } else if (!this->Makefile->IsOn("_CMAKE_" + lang + @@ -553,7 +559,7 @@ const char* cmGeneratorTarget::GetCustomObjectExtension() const extension = ".ptx"; return extension.c_str(); } - return CM_NULLPTR; + return nullptr; } void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) @@ -749,7 +755,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( if (iter == this->SystemIncludesCache.end()) { cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr); bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); @@ -817,7 +823,7 @@ static void AddInterfaceEntries( static bool processSources( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, - std::vector<std::string>& srcs, CM_UNORDERED_SET<std::string>& uniqueSrcs, + std::vector<std::string>& srcs, std::unordered_set<std::string>& uniqueSrcs, cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config, bool debugSources) { @@ -942,9 +948,9 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files, } cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES", - CM_NULLPTR, CM_NULLPTR); + nullptr, nullptr); - CM_UNORDERED_SET<std::string> uniqueSrcs; + std::unordered_set<std::string> uniqueSrcs; bool contextDependentDirectSources = processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker, config, debugSources); @@ -1714,7 +1720,7 @@ const char* cmGeneratorTarget::GetExportMacro() const } return this->ExportMacro.c_str(); } - return CM_NULLPTR; + return nullptr; } class cmTargetCollectLinkLanguages @@ -1722,7 +1728,7 @@ class cmTargetCollectLinkLanguages public: cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, const std::string& config, - CM_UNORDERED_SET<std::string>& languages, + std::unordered_set<std::string>& languages, cmGeneratorTarget const* head) : Config(config) , Languages(languages) @@ -1789,7 +1795,7 @@ public: private: std::string Config; - CM_UNORDERED_SET<std::string>& Languages; + std::unordered_set<std::string>& Languages; cmGeneratorTarget const* HeadTarget; const cmGeneratorTarget* Target; std::set<cmGeneratorTarget const*> Visited; @@ -1861,7 +1867,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc) const { // Get languages built in this target. - CM_UNORDERED_SET<std::string> languages; + std::unordered_set<std::string> languages; cmLinkImplementation const* impl = this->GetLinkImplementation(config); assert(impl); for (std::vector<std::string>::const_iterator li = impl->Languages.begin(); @@ -1878,7 +1884,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } // Store the transitive closure of languages. - for (CM_UNORDERED_SET<std::string>::const_iterator li = languages.begin(); + for (std::unordered_set<std::string>::const_iterator li = languages.begin(); li != languages.end(); ++li) { lc.Languages.push_back(*li); } @@ -1899,7 +1905,8 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } // Now consider languages that propagate from linked targets. - for (CM_UNORDERED_SET<std::string>::const_iterator sit = languages.begin(); + for (std::unordered_set<std::string>::const_iterator sit = + languages.begin(); sit != languages.end(); ++sit) { std::string propagates = "CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES"; @@ -1973,7 +1980,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( { // There is no compile information for imported targets. if (this->IsImported()) { - return CM_NULLPTR; + return nullptr; } if (this->GetType() > cmStateEnums::OBJECT_LIBRARY) { @@ -1982,7 +1989,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( msg += " which has type "; msg += cmState::GetTargetTypeName(this->GetType()); this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); - return CM_NULLPTR; + return nullptr; } // Lookup/compute/cache the compile information for this configuration. @@ -2008,7 +2015,7 @@ cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const if (this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && !this->IsExecutableWithExports()) { - return CM_NULLPTR; + return nullptr; } // Lookup/compute/cache the compile information for this configuration. @@ -2059,7 +2066,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result, cmGeneratorExpression ge; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "AUTOUIC_OPTIONS", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "AUTOUIC_OPTIONS", nullptr, nullptr); cmSystemTools::ExpandListArgument( ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, this, &dagChecker), @@ -2144,7 +2151,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) this->Makefile = target->Target->GetMakefile(); this->LocalGenerator = target->GetLocalGenerator(); this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); - this->CurrentEntry = CM_NULLPTR; + this->CurrentEntry = nullptr; // Queue all the source files already specified for the target. if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { @@ -2219,7 +2226,7 @@ void cmTargetTraceDependencies::Trace() this->CheckCustomCommand(*cc); } } - this->CurrentEntry = CM_NULLPTR; + this->CurrentEntry = nullptr; this->GeneratorTarget->AddTracedSources(this->NewSources); } @@ -2418,7 +2425,7 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const { - const char* archs = CM_NULLPTR; + const char* archs = nullptr; if (!config.empty()) { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); @@ -2471,7 +2478,7 @@ static void processIncludeDirectories( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& includes, - CM_UNORDERED_SET<std::string>& uniqueIncludes, + std::unordered_set<std::string>& uniqueIncludes, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugIncludes, const std::string& language) { @@ -2585,10 +2592,10 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( const std::string& config, const std::string& lang) const { std::vector<std::string> includes; - CM_UNORDERED_SET<std::string> uniqueIncludes; + std::unordered_set<std::string> uniqueIncludes; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "INCLUDE_DIRECTORIES", nullptr, nullptr); std::vector<std::string> debugProperties; const char* debugProp = @@ -2651,7 +2658,7 @@ static void processCompileOptionsInternal( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, const char* logName, std::string const& language) { @@ -2689,7 +2696,7 @@ static void processCompileOptions( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, std::string const& language) { @@ -2702,10 +2709,10 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result, const std::string& config, const std::string& language) const { - CM_UNORDERED_SET<std::string> uniqueOptions; + std::unordered_set<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "COMPILE_OPTIONS", nullptr, nullptr); std::vector<std::string> debugProperties; const char* debugProp = @@ -2743,7 +2750,7 @@ static void processCompileFeatures( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions) { @@ -2755,10 +2762,10 @@ static void processCompileFeatures( void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result, const std::string& config) const { - CM_UNORDERED_SET<std::string> uniqueFeatures; + std::unordered_set<std::string> uniqueFeatures; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "COMPILE_FEATURES", nullptr, nullptr); std::vector<std::string> debugProperties; const char* debugProp = @@ -2793,7 +2800,7 @@ static void processCompileDefinitions( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, std::string const& language) { @@ -2806,10 +2813,10 @@ void cmGeneratorTarget::GetCompileDefinitions( std::vector<std::string>& list, const std::string& config, const std::string& language) const { - CM_UNORDERED_SET<std::string> uniqueOptions; + std::unordered_set<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "COMPILE_DEFINITIONS", nullptr, nullptr); std::vector<std::string> debugProperties; const char* debugProp = @@ -3045,8 +3052,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, this->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. - version = CM_NULLPTR; - soversion = CM_NULLPTR; + version = nullptr; + soversion = nullptr; } if (version && !soversion) { // The soversion must be set if the library version is set. Use @@ -3122,7 +3129,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, const char* version = this->GetProperty("VERSION"); if (this->GetType() != cmStateEnums::EXECUTABLE || this->Makefile->IsOn("XCODE")) { - version = CM_NULLPTR; + version = nullptr; } #endif @@ -3228,7 +3235,7 @@ void cmGeneratorTarget::GetFullNameInternal( const char* targetSuffix = (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX") : this->GetProperty("SUFFIX")); - const char* configPostfix = CM_NULLPTR; + const char* configPostfix = nullptr; if (!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); configProp += "_POSTFIX"; @@ -3236,7 +3243,7 @@ void cmGeneratorTarget::GetFullNameInternal( // Mac application bundles and frameworks have no postfix. if (configPostfix && (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) { - configPostfix = CM_NULLPTR; + configPostfix = nullptr; } } const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); @@ -3270,14 +3277,14 @@ void cmGeneratorTarget::GetFullNameInternal( fw_prefix = this->GetFrameworkDirectory(config, ContentLevel); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); - targetSuffix = CM_NULLPTR; + targetSuffix = nullptr; } if (this->IsCFBundleOnApple()) { fw_prefix = this->GetCFBundleDirectory(config, FullLevel); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); - targetSuffix = CM_NULLPTR; + targetSuffix = nullptr; } // Begin the final name with the prefix. @@ -3581,7 +3588,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, case BoolType: assert(false && "String compatibility check function called for boolean"); - return CM_NULLPTR; + return nullptr; case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case NumberMinType: @@ -3590,7 +3597,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(false && "Unreachable!"); - return CM_NULLPTR; + return nullptr; } template <typename PropertyType> @@ -3628,7 +3635,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, } if (emitted.insert(*pi).second) { getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, t, - CM_NULLPTR); + nullptr); if (cmSystemTools::GetErrorOccuredFlag()) { return; } @@ -3706,25 +3713,25 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } checkPropertyConsistency<bool>(this, li->Target, strBool, emittedBools, - config, BoolType, CM_NULLPTR); + config, BoolType, nullptr); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char*>(this, li->Target, strString, emittedStrings, config, StringType, - CM_NULLPTR); + nullptr); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char*>(this, li->Target, strNumMin, emittedMinNumbers, config, - NumberMinType, CM_NULLPTR); + NumberMinType, nullptr); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char*>(this, li->Target, strNumMax, emittedMaxNumbers, config, - NumberMaxType, CM_NULLPTR); + NumberMaxType, nullptr); if (cmSystemTools::GetErrorOccuredFlag()) { return; } @@ -3858,7 +3865,7 @@ std::pair<bool, const char*> consistentStringProperty(const char* lhs, const char* rhs) { const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : CM_NULLPTR); + return std::make_pair(b, b ? lhs : nullptr); } std::pair<bool, const char*> consistentNumberProperty(const char* lhs, @@ -3867,7 +3874,7 @@ std::pair<bool, const char*> consistentNumberProperty(const char* lhs, { char* pEnd; - const char* const null_ptr = CM_NULLPTR; + const char* const null_ptr = nullptr; long lnum = strtol(lhs, &pEnd, 0); if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) { @@ -3900,7 +3907,7 @@ std::pair<bool, const char*> consistentProperty(const char* lhs, return std::make_pair(true, lhs); } - const char* const null_ptr = CM_NULLPTR; + const char* const null_ptr = nullptr; switch (t) { case BoolType: @@ -4063,28 +4070,28 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string& p, const std::string& config) const { return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE", - BoolType, CM_NULLPTR); + BoolType, nullptr); } const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string& p, const std::string& config) const { return checkInterfacePropertyCompatibility<const char*>( - this, p, config, "empty", StringType, CM_NULLPTR); + this, p, config, "empty", StringType, nullptr); } const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string& p, const std::string& config) const { return checkInterfacePropertyCompatibility<const char*>( - this, p, config, "empty", NumberMinType, CM_NULLPTR); + this, p, config, "empty", NumberMinType, nullptr); } const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string& p, const std::string& config) const { return checkInterfacePropertyCompatibility<const char*>( - this, p, config, "empty", NumberMaxType, CM_NULLPTR); + this, p, config, "empty", NumberMaxType, nullptr); } cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation( @@ -4099,7 +4106,7 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation( new cmComputeLinkInformation(this, config); if (!info || !info->Compute()) { delete info; - info = CM_NULLPTR; + info = nullptr; } // Store the information for this configuration. @@ -4291,8 +4298,8 @@ void cmGeneratorTarget::ExpandLinkItems( std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const { cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, CM_NULLPTR, - CM_NULLPTR); + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, nullptr, + nullptr); // The $<LINK_ONLY> expression may be in a link interface to specify private // link dependencies that are otherwise excluded from usage requirements. if (usage_requirements_only) { @@ -4320,7 +4327,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface( // export symbols. if (this->GetType() == cmStateEnums::EXECUTABLE && !this->IsExecutableWithExports()) { - return CM_NULLPTR; + return nullptr; } // Lookup any existing link interface for this configuration. @@ -4344,7 +4351,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface( } } - return iface.Exists ? &iface : CM_NULLPTR; + return iface.Exists ? &iface : nullptr; } void cmGeneratorTarget::ComputeLinkInterface( @@ -4357,7 +4364,7 @@ void cmGeneratorTarget::ComputeLinkInterface( this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. - CM_UNORDERED_SET<std::string> emitted; + std::unordered_set<std::string> emitted; for (std::vector<cmLinkItem>::const_iterator li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) { @@ -4436,7 +4443,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( // export symbols. if (this->GetType() == cmStateEnums::EXECUTABLE && !this->IsExecutableWithExports()) { - return CM_NULLPTR; + return nullptr; } // Lookup any existing link interface for this configuration. @@ -4459,7 +4466,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( usage_requirements_only); } - return iface.Exists ? &iface : CM_NULLPTR; + return iface.Exists ? &iface : nullptr; } std::string cmGeneratorTarget::GetDirectory( @@ -4494,7 +4501,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( { // There is no output information for imported targets. if (this->IsImported()) { - return CM_NULLPTR; + return nullptr; } // Only libraries and executables have well-defined output files. @@ -4504,7 +4511,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( msg += " which has type "; msg += cmState::GetTargetTypeName(this->GetType()); this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); - return CM_NULLPTR; + return nullptr; } // Lookup/compute/cache the output information for this configuration. @@ -4537,7 +4544,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( cmake::FATAL_ERROR, "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", this->GetBacktrace()); - return CM_NULLPTR; + return nullptr; } return &i->second; } @@ -4552,7 +4559,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // Look for a target property defining the target output directory // based on the target type. std::string targetTypeName = this->GetOutputTargetType(artifact); - const char* propertyName = CM_NULLPTR; + const char* propertyName = nullptr; std::string propertyNameStr = targetTypeName; if (!propertyNameStr.empty()) { propertyNameStr += "_OUTPUT_DIRECTORY"; @@ -4561,7 +4568,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(conf); - const char* configProp = CM_NULLPTR; + const char* configProp = nullptr; std::string configPropStr = targetTypeName; if (!configPropStr.empty()) { configPropStr += "_OUTPUT_DIRECTORY_"; @@ -4629,7 +4636,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, { // Look for a target property defining the target output directory // based on the target type. - const char* propertyName = CM_NULLPTR; + const char* propertyName = nullptr; std::string propertyNameStr = kind; if (!propertyNameStr.empty()) { propertyNameStr += "_OUTPUT_DIRECTORY"; @@ -4639,7 +4646,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(conf); - const char* configProp = CM_NULLPTR; + const char* configProp = nullptr; std::string configPropStr = kind; if (!configPropStr.empty()) { configPropStr += "_OUTPUT_DIRECTORY_"; @@ -4697,7 +4704,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( // An explicit list of interface libraries may be set for shared // libraries and executables that export symbols. - const char* explicitLibraries = CM_NULLPTR; + const char* explicitLibraries = nullptr; std::string linkIfaceProp; if (this->GetPolicyStatusCMP0022() != cmPolicies::OLD && this->GetPolicyStatusCMP0022() != cmPolicies::WARN) { @@ -4824,7 +4831,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface( { cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config); if (!info) { - return CM_NULLPTR; + return nullptr; } std::string CONFIG = cmSystemTools::UpperCase(config); @@ -4860,7 +4867,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo( { // There is no imported information for non-imported targets. if (!this->IsImported()) { - return CM_NULLPTR; + return nullptr; } // Lookup/compute/cache the import information for this @@ -4886,7 +4893,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo( // If the location is empty then the target is not available for // this configuration. if (i->second.Location.empty() && i->second.ImportLibrary.empty()) { - return CM_NULLPTR; + return nullptr; } // Return the import information. @@ -4903,8 +4910,8 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, // Initialize members. info.NoSOName = false; - const char* loc = CM_NULLPTR; - const char* imp = CM_NULLPTR; + const char* loc = nullptr; + const char* imp = nullptr; std::string suffix; if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) { return; @@ -5049,7 +5056,7 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( { // There is no link implementation for imported targets. if (this->IsImported()) { - return CM_NULLPTR; + return nullptr; } std::string CONFIG = cmSystemTools::UpperCase(config); @@ -5281,7 +5288,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal( { // There is no link implementation for imported targets. if (this->IsImported()) { - return CM_NULLPTR; + return nullptr; } // Populate the link implementation libraries for this configuration. @@ -5322,7 +5329,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( le != end; ++le, ++btIt) { std::vector<std::string> llibs; cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), "LINK_LIBRARIES", CM_NULLPTR, CM_NULLPTR); + this->GetName(), "LINK_LIBRARIES", nullptr, nullptr); cmGeneratorExpression ge(*btIt); CM_AUTO_PTR<cmCompiledGeneratorExpression> const cge = ge.Parse(*le); std::string const evaluated = @@ -5415,7 +5422,7 @@ cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink( // within the project. if (tgt && tgt->GetType() == cmStateEnums::EXECUTABLE && !tgt->IsExecutableWithExports()) { - tgt = CM_NULLPTR; + tgt = nullptr; } if (tgt && tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { @@ -5429,7 +5436,7 @@ cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink( "with the ENABLE_EXPORTS property set."; cmake* cm = this->LocalGenerator->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - tgt = CM_NULLPTR; + tgt = nullptr; } return tgt; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52147e3..85311a7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorTarget_h #define cmGeneratorTarget_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmLinkItem.h" #include "cmListFileCache.h" @@ -491,6 +491,11 @@ public: std::string GetOutputName(const std::string& config, cmStateEnums::ArtifactType artifact) const; + /** Clears cached meta data for local and external source files. + * The meta data will be recomputed on demand. + */ + void ClearSourcesCache(); + void AddSource(const std::string& src); void AddTracedSources(std::vector<std::string> const& srcs); @@ -519,7 +524,7 @@ public: { SourceFileFlags() : Type(SourceFileTypeNormal) - , MacFolder(CM_NULLPTR) + , MacFolder(nullptr) { } SourceFileType Type; @@ -565,7 +570,7 @@ public: /** Convert the given GNU import library name (.dll.a) to a name with a new extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = CM_NULLPTR) const; + const char* newExt = nullptr) const; bool IsExecutableWithExports() const; diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 5ba3326..fc82fee 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -37,7 +37,7 @@ bool cmGetCMakePropertyCommand::InitialPass( this->Makefile->GetGlobalGenerator()->GetInstallComponents(); output = cmJoin(*components, ";"); } else { - const char* prop = CM_NULLPTR; + const char* prop = nullptr; if (!args[1].empty()) { prop = this->Makefile->GetState()->GetGlobalProperty(args[1]); } diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index 9dfc40f..803f051 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetCMakePropertyCommand_h #define cmGetCMakePropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 1005b15..a8cf6ab 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -70,7 +70,7 @@ bool cmGetDirectoryPropertyCommand::InitialPass( return true; } - const char* prop = CM_NULLPTR; + const char* prop = nullptr; if (!i->empty()) { if (*i == "DEFINITIONS") { switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0059)) { diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index 7d97950..f373bc2 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetDirectoryPropertyCommand_h #define cmGetDirectoryPropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h index c8a23c7..b7141b2 100644 --- a/Source/cmGetFilenameComponentCommand.h +++ b/Source/cmGetFilenameComponentCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetFilenameComponentCommand_h #define cmGetFilenameComponentCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index ddecdf6..4494c3e 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -258,9 +258,9 @@ bool cmGetPropertyCommand::HandleTargetMode() if (this->Makefile->IsAlias(this->Name)) { return this->StoreResult(target->GetName().c_str()); } - return this->StoreResult(CM_NULLPTR); + return this->StoreResult(nullptr); } - const char* prop_cstr = CM_NULLPTR; + const char* prop_cstr = nullptr; cmListFileBacktrace bt = this->Makefile->GetBacktrace(); cmMessenger* messenger = this->Makefile->GetMessenger(); if (cmTargetPropertyComputer::PassesWhitelist( @@ -333,7 +333,7 @@ bool cmGetPropertyCommand::HandleCacheMode() return false; } - const char* value = CM_NULLPTR; + const char* value = nullptr; if (this->Makefile->GetState()->GetCacheEntryValue(this->Name)) { value = this->Makefile->GetState()->GetCacheEntryProperty( this->Name, this->PropertyName); @@ -357,7 +357,7 @@ bool cmGetPropertyCommand::HandleInstallMode() std::string value; bool isSet = file->GetProperty(this->PropertyName, value); - return this->StoreResult(isSet ? value.c_str() : CM_NULLPTR); + return this->StoreResult(isSet ? value.c_str() : nullptr); } std::ostringstream e; e << "given INSTALL name that could not be found or created: " << this->Name; diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index 6497801..44a3852 100644 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetPropertyCommand_h #define cmGetPropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 1a5f08e..75879a5 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -28,7 +28,7 @@ bool cmGetSourceFilePropertyCommand::InitialPass( this->Makefile->AddDefinition(var, sf->GetLanguage().c_str()); return true; } - const char* prop = CM_NULLPTR; + const char* prop = nullptr; if (!args[2].empty()) { prop = sf->GetPropertyForUser(args[2]); } diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index e96bb29..d4fef01 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetSourceFilePropertyCommand_h #define cmGetSourceFilePropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 0910a53..ec485aa 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -34,7 +34,7 @@ bool cmGetTargetPropertyCommand::InitialPass( prop_exists = true; } } else if (!args[2].empty()) { - const char* prop_cstr = CM_NULLPTR; + const char* prop_cstr = nullptr; cmListFileBacktrace bt = this->Makefile->GetBacktrace(); cmMessenger* messenger = this->Makefile->GetMessenger(); if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2], diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index 5de3225..e74b7e1 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetTargetPropertyCommand_h #define cmGetTargetPropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index 6424515..0b0d6eb 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -20,7 +20,7 @@ bool cmGetTestPropertyCommand::InitialPass( std::string const& var = args[2]; cmTest* test = this->Makefile->GetTest(testName); if (test) { - const char* prop = CM_NULLPTR; + const char* prop = nullptr; if (!args[1].empty()) { prop = test->GetProperty(args[1]); } diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index b17e7a1..5a3ef40 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmGetTestPropertyCommand_h #define cmGetTestPropertyCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h index 7bc7bfc..b1eead1 100644 --- a/Source/cmGhsMultiGpj.h +++ b/Source/cmGhsMultiGpj.h @@ -3,7 +3,7 @@ #ifndef cmGhsMultiGpj_h #define cmGhsMultiGpj_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep class cmGeneratedFileStream; diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h index f2ad059..842a7c4 100644 --- a/Source/cmGlobalCommonGenerator.h +++ b/Source/cmGlobalCommonGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalCommonGenerator_h #define cmGlobalCommonGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGlobalGenerator.h" diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 099f705..ab35593 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -89,9 +89,9 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) // how long to let try compiles run this->TryCompileTimeout = 0; - this->ExtraGenerator = CM_NULLPTR; - this->CurrentMakefile = CM_NULLPTR; - this->TryCompileOuterMakefile = CM_NULLPTR; + this->ExtraGenerator = nullptr; + this->CurrentConfigureMakefile = nullptr; + this->TryCompileOuterMakefile = nullptr; this->ConfigureDoneCMP0026AndCMP0024 = false; this->FirstTimeProgress = 0.0f; @@ -252,7 +252,7 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string& file) } delete it->second; - it->second = CM_NULLPTR; + it->second = nullptr; this->BuildExportSets.erase(it); return result; } @@ -490,7 +490,6 @@ void cmGlobalGenerator::EnableLanguage( windowsVersionString << osviex.dwMajorVersion << "." << osviex.dwMinorVersion << "." << osviex.dwBuildNumber; - windowsVersionString.str(); mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str().c_str()); #endif @@ -1075,7 +1074,7 @@ bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const void cmGlobalGenerator::ClearEnabledLanguages() { - return this->CMakeInstance->GetState()->ClearEnabledLanguages(); + this->CMakeInstance->GetState()->ClearEnabledLanguages(); } void cmGlobalGenerator::CreateLocalGenerators() @@ -1145,7 +1144,7 @@ void cmGlobalGenerator::Configure() std::ostringstream msg; if (cmSystemTools::GetErrorOccuredFlag()) { msg << "Configuring incomplete, errors occurred!"; - const char* logs[] = { "CMakeOutput.log", "CMakeError.log", CM_NULLPTR }; + const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr }; for (const char** log = logs; *log; ++log) { std::string f = this->CMakeInstance->GetHomeOutputDirectory(); f += this->CMakeInstance->GetCMakeFilesDirectory(); @@ -1192,7 +1191,7 @@ cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile( { std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it = this->BuildExportSets.find(filename); - return it == this->BuildExportSets.end() ? CM_NULLPTR : it->second; + return it == this->BuildExportSets.end() ? nullptr : it->second; } void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) @@ -1352,7 +1351,7 @@ void cmGlobalGenerator::Generate() "Generating", (static_cast<float>(i) + 1.0f) / static_cast<float>(this->LocalGenerators.size())); } - this->SetCurrentMakefile(CM_NULLPTR); + this->SetCurrentMakefile(nullptr); if (!this->GenerateCPackPropertiesFile()) { this->GetCMakeInstance()->IssueMessage( @@ -1375,7 +1374,7 @@ void cmGlobalGenerator::Generate() this->WriteSummary(); - if (this->ExtraGenerator != CM_NULLPTR) { + if (this->ExtraGenerator != nullptr) { this->ExtraGenerator->Generate(); } @@ -1434,31 +1433,36 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() std::vector<const cmGeneratorTarget*> autogenTargets; #ifdef CMAKE_BUILD_WITH_CMAKE - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> targets = - this->LocalGenerators[i]->GetGeneratorTargets(); + for (std::vector<cmLocalGenerator*>::const_iterator lgit = + this->LocalGenerators.begin(); + lgit != this->LocalGenerators.end(); ++lgit) { + cmLocalGenerator* localGen = *lgit; + const std::vector<cmGeneratorTarget*>& targets = + localGen->GetGeneratorTargets(); + // Find targets that require AUTOGEN processing std::vector<cmGeneratorTarget*> filteredTargets; filteredTargets.reserve(targets.size()); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { - if ((*ti)->GetType() == cmStateEnums::GLOBAL_TARGET) { + cmGeneratorTarget* target = *ti; + if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } - if ((*ti)->GetType() != cmStateEnums::EXECUTABLE && - (*ti)->GetType() != cmStateEnums::STATIC_LIBRARY && - (*ti)->GetType() != cmStateEnums::SHARED_LIBRARY && - (*ti)->GetType() != cmStateEnums::MODULE_LIBRARY && - (*ti)->GetType() != cmStateEnums::OBJECT_LIBRARY) { + if (target->GetType() != cmStateEnums::EXECUTABLE && + target->GetType() != cmStateEnums::STATIC_LIBRARY && + target->GetType() != cmStateEnums::SHARED_LIBRARY && + target->GetType() != cmStateEnums::MODULE_LIBRARY && + target->GetType() != cmStateEnums::OBJECT_LIBRARY) { continue; } - if ((!(*ti)->GetPropertyAsBool("AUTOMOC") && - !(*ti)->GetPropertyAsBool("AUTOUIC") && - !(*ti)->GetPropertyAsBool("AUTORCC")) || - (*ti)->IsImported()) { + if ((!target->GetPropertyAsBool("AUTOMOC") && + !target->GetPropertyAsBool("AUTOUIC") && + !target->GetPropertyAsBool("AUTORCC")) || + target->IsImported()) { continue; } - // don't do anything if there is no Qt4 or Qt5Core (which contains moc): - cmMakefile* mf = (*ti)->Target->GetMakefile(); + // don't do anything if there is no Qt4 or Qt5Core (which contains moc) + cmMakefile* mf = target->Target->GetMakefile(); std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); @@ -1466,17 +1470,13 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() if (qtMajorVersion != "4" && qtMajorVersion != "5") { continue; } - - cmGeneratorTarget* gt = *ti; - - cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt); - filteredTargets.push_back(gt); + filteredTargets.push_back(target); } + // Initialize AUTOGEN targets for (std::vector<cmGeneratorTarget*>::iterator ti = filteredTargets.begin(); ti != filteredTargets.end(); ++ti) { - cmQtAutoGeneratorInitializer::InitializeAutogenTarget( - this->LocalGenerators[i], *ti); + cmQtAutoGeneratorInitializer::InitializeAutogenTarget(localGen, *ti); autogenTargets.push_back(*ti); } } @@ -1815,7 +1815,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, output += "\n"; if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr, - &retVal, CM_NULLPTR, outputflag, + &retVal, nullptr, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error("Generator: execution of make clean failed."); @@ -1834,7 +1834,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, output += "\n"; if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr, - &retVal, CM_NULLPTR, outputflag, + &retVal, nullptr, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error( @@ -2057,7 +2057,7 @@ cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const if (i != this->MakefileSearchIndex.end()) { return i->second; } - return CM_NULLPTR; + return nullptr; } ///! Find a local generator by its startdirectory @@ -2072,7 +2072,7 @@ cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator( return *it; } } - return CM_NULLPTR; + return nullptr; } void cmGlobalGenerator::AddAlias(const std::string& name, @@ -2117,7 +2117,7 @@ cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const if (i != this->TargetSearchIndex.end()) { return i->second; } - return CM_NULLPTR; + return nullptr; } cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl( @@ -2128,7 +2128,7 @@ cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl( if (i != this->GeneratorTargetSearchIndex.end()) { return i->second; } - return CM_NULLPTR; + return nullptr; } cmTarget* cmGlobalGenerator::FindTarget(const std::string& name, @@ -2413,7 +2413,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( // install_strip const char* install_strip = this->GetInstallStripTargetName(); - if ((install_strip != CM_NULLPTR) && (mf->IsSet("CMAKE_STRIP"))) { + if ((install_strip != nullptr) && (mf->IsSet("CMAKE_STRIP"))) { gti.Name = install_strip; gti.Message = "Installing the project stripped..."; gti.UsesTerminal = true; @@ -2470,8 +2470,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; // Store the custom command in the target. - cmCustomCommand cc(CM_NULLPTR, no_outputs, no_byproducts, no_depends, - gti.CommandLines, CM_NULLPTR, gti.WorkingDir.c_str()); + cmCustomCommand cc(nullptr, no_outputs, no_byproducts, no_depends, + gti.CommandLines, nullptr, gti.WorkingDir.c_str()); cc.SetUsesTerminal(gti.UsesTerminal); target.AddPostBuildCommand(cc); if (!gti.Message.empty()) { @@ -2556,7 +2556,7 @@ void cmGlobalGenerator::SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator* extraGenerator) { this->ExtraGenerator = extraGenerator; - if (this->ExtraGenerator != CM_NULLPTR) { + if (this->ExtraGenerator != nullptr) { this->ExtraGenerator->SetGlobalGenerator(this); } } @@ -2594,9 +2594,9 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, continue; } // Get the targets in the makefile - std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets(); // loop over all the targets - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { cmGeneratorTarget* target = *l; if (this->IsRootOnlyTarget(target) && @@ -2789,9 +2789,9 @@ void cmGlobalGenerator::WriteSummary() cmGeneratedFileStream fout(fname.c_str()); for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin(); it != tgts.end(); ++it) { if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -2812,7 +2812,12 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) #ifdef CMAKE_BUILD_WITH_CMAKE // Check whether labels are enabled for this target. - if (const char* value = target->GetProperty("LABELS")) { + const char* targetLabels = target->GetProperty("LABELS"); + const char* directoryLabels = + target->Target->GetMakefile()->GetProperty("LABELS"); + const char* cmakeDirectoryLabels = + target->Target->GetMakefile()->GetDefinition("CMAKE_DIRECTORY_LABELS"); + if (targetLabels || directoryLabels || cmakeDirectoryLabels) { Json::Value lj_root(Json::objectValue); Json::Value& lj_target = lj_root["target"] = Json::objectValue; lj_target["name"] = target->GetName(); @@ -2822,19 +2827,53 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) cmSystemTools::MakeDirectory(dir.c_str()); cmGeneratedFileStream fout(file.c_str()); + std::vector<std::string> labels; + // List the target-wide labels. All sources in the target get // these labels. - std::vector<std::string> labels; - cmSystemTools::ExpandListArgument(value, labels); - if (!labels.empty()) { - fout << "# Target labels\n"; - for (std::vector<std::string>::const_iterator li = labels.begin(); - li != labels.end(); ++li) { - fout << " " << *li << "\n"; - lj_target_labels.append(*li); + if (targetLabels) { + cmSystemTools::ExpandListArgument(targetLabels, labels); + if (!labels.empty()) { + fout << "# Target labels\n"; + for (std::vector<std::string>::const_iterator li = labels.begin(); + li != labels.end(); ++li) { + fout << " " << *li << "\n"; + lj_target_labels.append(*li); + } } } + // List directory labels + std::vector<std::string> directoryLabelsList; + std::vector<std::string> cmakeDirectoryLabelsList; + + if (directoryLabels) { + cmSystemTools::ExpandListArgument(directoryLabels, directoryLabelsList); + } + + if (cmakeDirectoryLabels) { + cmSystemTools::ExpandListArgument(cmakeDirectoryLabels, + cmakeDirectoryLabelsList); + } + + if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) { + fout << "# Directory labels\n"; + } + + for (std::vector<std::string>::const_iterator li = + directoryLabelsList.begin(); + li != directoryLabelsList.end(); ++li) { + fout << " " << *li << "\n"; + lj_target_labels.append(*li); + } + + for (std::vector<std::string>::const_iterator li = + cmakeDirectoryLabelsList.begin(); + li != cmakeDirectoryLabelsList.end(); ++li) { + fout << " " << *li << "\n"; + lj_target_labels.append(*li); + } + // List the source files with any per-source labels. fout << "# Source files and their labels\n"; std::vector<cmSourceFile*> sources; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 871178b..7ff141d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -3,12 +3,13 @@ #ifndef cmGlobalGenerator_h #define cmGlobalGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> #include <set> #include <string> +#include <unordered_map> #include <utility> #include <vector> @@ -19,7 +20,6 @@ #include "cmTarget.h" #include "cmTargetDepend.h" #include "cm_codecvt.hxx" -#include "cm_unordered_map.hxx" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmFileLockPool.h" @@ -187,9 +187,15 @@ public: return this->LocalGenerators; } - cmMakefile* GetCurrentMakefile() const { return this->CurrentMakefile; } + cmMakefile* GetCurrentMakefile() const + { + return this->CurrentConfigureMakefile; + } - void SetCurrentMakefile(cmMakefile* mf) { this->CurrentMakefile = mf; } + void SetCurrentMakefile(cmMakefile* mf) + { + this->CurrentConfigureMakefile = mf; + } void AddMakefile(cmMakefile* mf); @@ -289,15 +295,15 @@ public: virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } - virtual const char* GetInstallLocalTargetName() const { return CM_NULLPTR; } - virtual const char* GetInstallStripTargetName() const { return CM_NULLPTR; } - virtual const char* GetPreinstallTargetName() const { return CM_NULLPTR; } + virtual const char* GetInstallLocalTargetName() const { return nullptr; } + virtual const char* GetInstallStripTargetName() const { return nullptr; } + virtual const char* GetPreinstallTargetName() const { return nullptr; } virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } virtual const char* GetPackageTargetName() const { return "PACKAGE"; } - virtual const char* GetPackageSourceTargetName() const { return CM_NULLPTR; } - virtual const char* GetEditCacheTargetName() const { return CM_NULLPTR; } - virtual const char* GetRebuildCacheTargetName() const { return CM_NULLPTR; } - virtual const char* GetCleanTargetName() const { return CM_NULLPTR; } + virtual const char* GetPackageSourceTargetName() const { return nullptr; } + virtual const char* GetEditCacheTargetName() const { return nullptr; } + virtual const char* GetRebuildCacheTargetName() const { return nullptr; } + virtual const char* GetCleanTargetName() const { return nullptr; } // Lookup edit_cache target command preferred by this generator. virtual std::string GetEditCacheCommand() const { return ""; } @@ -460,7 +466,7 @@ protected: cmake* CMakeInstance; std::vector<cmMakefile*> Makefiles; std::vector<cmLocalGenerator*> LocalGenerators; - cmMakefile* CurrentMakefile; + cmMakefile* CurrentConfigureMakefile; // map from project name to vector of local generators in that project std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap; @@ -482,9 +488,10 @@ protected: const char* GetPredefinedTargetsFolder(); private: - typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap; - typedef CM_UNORDERED_MAP<std::string, cmGeneratorTarget*> GeneratorTargetMap; - typedef CM_UNORDERED_MAP<std::string, cmMakefile*> MakefileMap; + typedef std::unordered_map<std::string, cmTarget*> TargetMap; + typedef std::unordered_map<std::string, cmGeneratorTarget*> + GeneratorTargetMap; + typedef std::unordered_map<std::string, cmMakefile*> MakefileMap; // Map efficiently from target name to cmTarget instance. // Do not use this structure for looping over all targets. // It contains both normal and globally visible imported targets. @@ -550,7 +557,7 @@ private: void IndexMakefile(cmMakefile* mf); - virtual const char* GetBuildIgnoreErrorsFlag() const { return CM_NULLPTR; } + virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; } // Cache directory content and target files to be built. struct DirectoryContent diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index d5a6db0..125a9e2 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -3,7 +3,7 @@ #ifndef cmGlobalGeneratorFactory_h #define cmGlobalGeneratorFactory_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -48,7 +48,7 @@ public: cmake* cm) const CM_OVERRIDE { if (name != T::GetActualName()) { - return CM_NULLPTR; + return nullptr; } return new T(cm); } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 42ab4d9..788a179 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -260,7 +260,7 @@ void cmGlobalGhsMultiGenerator::Generate() for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { cmLocalGhsMultiGenerator* lg = static_cast<cmLocalGhsMultiGenerator*>(this->LocalGenerators[i]); - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); this->UpdateBuildFiles(tgts); } } @@ -436,9 +436,9 @@ std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath( } void cmGlobalGhsMultiGenerator::UpdateBuildFiles( - std::vector<cmGeneratorTarget*> tgts) + const std::vector<cmGeneratorTarget*>& tgts) { - for (std::vector<cmGeneratorTarget*>::iterator tgtsI = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator tgtsI = tgts.begin(); tgtsI != tgts.end(); ++tgtsI) { const cmGeneratorTarget* tgt = *tgtsI; if (IsTgtForBuild(tgt)) { diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 7b3eebb..05a3a3c 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -116,7 +116,7 @@ private: std::vector<cmsys::String>::const_iterator end, GhsMultiGpj::Types projType); static std::string GetFileNameFromPath(std::string const& path); - void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts); + void UpdateBuildFiles(const std::vector<cmGeneratorTarget*>& tgts); bool IsTgtForBuild(const cmGeneratorTarget* tgt); std::vector<cmGeneratedFileStream*> TargetSubProjects; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index e72c6e3..39ac73a 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -115,21 +115,22 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( // make sure the file is part of this source tree if ((tmp[0] != '/') && (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) == - CM_NULLPTR)) { + nullptr)) { files.insert(tmp); tmp = cmSystemTools::GetFilenameName(tmp); // add all files which dont match the default // */CMakeLists.txt;*cmake; to the file pattern if ((tmp != "CMakeLists.txt") && - (strstr(tmp.c_str(), ".cmake") == CM_NULLPTR)) { + (strstr(tmp.c_str(), ".cmake") == nullptr)) { cmakeFilePattern += tmp + ";"; } } } // get all sources - std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*it)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::vector<cmSourceFile*> sources; cmGeneratorTarget* gt = *ti; @@ -146,7 +147,7 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( if ((tmp[0] != '/') && (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) == - CM_NULLPTR) && + nullptr) && (cmSystemTools::GetFilenameExtension(tmp) != ".moc")) { files.insert(tmp); @@ -170,7 +171,7 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( cmSystemTools::ReplaceString(tmp, projectDir.c_str(), ""); if ((tmp[0] != '/') && (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) == - CM_NULLPTR)) { + nullptr)) { files.insert(tmp); } } @@ -300,12 +301,12 @@ void cmGlobalKdevelopGenerator::MergeProjectFiles( it != lines.end(); it++) { const char* line = (*it).c_str(); // skip these tags as they are always replaced - if ((strstr(line, "<projectdirectory>") != CM_NULLPTR) || - (strstr(line, "<projectmanagement>") != CM_NULLPTR) || - (strstr(line, "<absoluteprojectpath>") != CM_NULLPTR) || - (strstr(line, "<filelistdirectory>") != CM_NULLPTR) || - (strstr(line, "<buildtool>") != CM_NULLPTR) || - (strstr(line, "<builddir>") != CM_NULLPTR)) { + if ((strstr(line, "<projectdirectory>") != nullptr) || + (strstr(line, "<projectmanagement>") != nullptr) || + (strstr(line, "<absoluteprojectpath>") != nullptr) || + (strstr(line, "<filelistdirectory>") != nullptr) || + (strstr(line, "<buildtool>") != nullptr) || + (strstr(line, "<builddir>") != nullptr)) { continue; } diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index bdcf8a1..fd57782 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalKdevelopGenerator_h #define cmGlobalKdevelopGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2eef9e4..de3546b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -474,9 +474,9 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os, cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) : cmGlobalCommonGenerator(cm) - , BuildFileStream(CM_NULLPTR) - , RulesFileStream(CM_NULLPTR) - , CompileCommandsStream(CM_NULLPTR) + , BuildFileStream(nullptr) + , RulesFileStream(nullptr) + , CompileCommandsStream(nullptr) , Rules() , AllDependencies() , UsingGCCOnWindows(false) @@ -582,8 +582,8 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) command.push_back("--version"); std::string version; std::string error; - if (!cmSystemTools::RunSingleCommand(command, &version, &error, CM_NULLPTR, - CM_NULLPTR, + if (!cmSystemTools::RunSingleCommand(command, &version, &error, nullptr, + nullptr, cmSystemTools::OUTPUT_NONE)) { mf->IssueMessage(cmake::FATAL_ERROR, "Running\n '" + cmJoin(command, "' '") + "'\n" @@ -741,7 +741,7 @@ void cmGlobalNinjaGenerator::AddRule( description, comment, depfile, deptype, rspfile, rspcontent, restat, generator); - this->RuleCmdLength[name] = (int)command.size(); + this->RuleCmdLength[name] = static_cast<int>(command.size()); } bool cmGlobalNinjaGenerator::HasRule(const std::string& name) @@ -805,7 +805,7 @@ void cmGlobalNinjaGenerator::CloseBuildFileStream() { if (this->BuildFileStream) { delete this->BuildFileStream; - this->BuildFileStream = CM_NULLPTR; + this->BuildFileStream = nullptr; } else { cmSystemTools::Error("Build file stream was not open."); } @@ -847,7 +847,7 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream() { if (this->RulesFileStream) { delete this->RulesFileStream; - this->RulesFileStream = CM_NULLPTR; + this->RulesFileStream = nullptr; } else { cmSystemTools::Error("Rules file stream was not open."); } @@ -928,7 +928,7 @@ void cmGlobalNinjaGenerator::CloseCompileCommandsStream() if (this->CompileCommandsStream) { *this->CompileCommandsStream << "\n]"; delete this->CompileCommandsStream; - this->CompileCommandsStream = CM_NULLPTR; + this->CompileCommandsStream = nullptr; } } @@ -1092,7 +1092,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, // Mark the target's outputs as ambiguous to ensure that no other target uses // the output as an alias. for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) { - TargetAliases[*i] = CM_NULLPTR; + TargetAliases[*i] = nullptr; } // Insert the alias into the map. If the alias was already present in the @@ -1100,7 +1100,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, std::pair<TargetAliasMap::iterator, bool> newAlias = TargetAliases.insert(std::make_pair(buildAlias, target)); if (newAlias.second && newAlias.first->second != target) { - newAlias.first->second = CM_NULLPTR; + newAlias.first->second = nullptr; } } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index b0008f7..87affdc 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalNinjaGenerator_h #define cmGlobalNinjaGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> @@ -114,7 +114,7 @@ public: const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables, const std::string& rspfile = std::string(), - int cmdLineLimit = 0, bool* usedResponseFile = CM_NULLPTR); + int cmdLineLimit = 0, bool* usedResponseFile = nullptr); /** * Helper to write a build statement with the special 'phony' rule. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 23b3718..05c9ce0 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -38,7 +38,7 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm) #else this->UseLinkScript = true; #endif - this->CommandDatabase = CM_NULLPTR; + this->CommandDatabase = nullptr; this->IncludeDirective = "include"; this->DefineWindowsNULL = false; @@ -161,10 +161,10 @@ void cmGlobalUnixMakefileGenerator3::Generate() this->WriteMainMakefile2(); this->WriteMainCMakefile(); - if (this->CommandDatabase != CM_NULLPTR) { + if (this->CommandDatabase != nullptr) { *this->CommandDatabase << std::endl << "]"; delete this->CommandDatabase; - this->CommandDatabase = CM_NULLPTR; + this->CommandDatabase = nullptr; } } @@ -172,7 +172,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( const std::string& sourceFile, const std::string& workingDirectory, const std::string& compileCommand) { - if (this->CommandDatabase == CM_NULLPTR) { + if (this->CommandDatabase == nullptr) { std::string commandDatabaseName = std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) + "/compile_commands.json"; @@ -382,8 +382,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules( for (unsigned int i = 0; i < lGenerators.size(); ++i) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]); // for all of out targets - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if (((*l)->GetType() == cmStateEnums::EXECUTABLE) || ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -414,8 +414,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector<std::string> depends; - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin(); l != targets.end(); ++l) { cmGeneratorTarget* gtarget = *l; int type = gtarget->GetType(); @@ -547,8 +547,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( for (i = 0; i < this->LocalGenerators.size(); ++i) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]); // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; // Don't emit the same rule twice (e.g. two targets with the same @@ -629,8 +629,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; int type = gtarget->GetType(); @@ -807,7 +807,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() this->LocalGenerators.begin(); lgi != this->LocalGenerators.end(); ++lgi) { cmLocalGenerator* lg = *lgi; - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gt = *t; @@ -952,8 +952,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( // the targets if (lg2 == lg || lg->IsRootMakefile()) { // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + lg2->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; cmStateEnums::TargetType type = target->GetType(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index a656102..bc03c44 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -3,7 +3,7 @@ #ifndef cmGlobalUnixMakefileGenerator3_h #define cmGlobalUnixMakefileGenerator3_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 4fff11a..1c0953a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -495,7 +495,7 @@ const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const { std::string const& toolset = this->GetPlatformToolsetString(); if (toolset.empty()) { - return CM_NULLPTR; + return nullptr; } return toolset.c_str(); } @@ -519,7 +519,7 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const if (!this->GeneratorToolsetHostArchitecture.empty()) { return this->GeneratorToolsetHostArchitecture.c_str(); } - return CM_NULLPTR; + return nullptr; } const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const @@ -527,7 +527,7 @@ const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const if (!this->GeneratorToolsetCuda.empty()) { return this->GeneratorToolsetCuda.c_str(); } - return CM_NULLPTR; + return nullptr; } std::string const& @@ -971,7 +971,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const cmIDEFlagTable const* table = this->ToolsetOptions.GetClFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultClFlagTable; + return (table != nullptr) ? table : this->DefaultClFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() @@ -980,7 +980,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() cmIDEFlagTable const* table = this->ToolsetOptions.GetCSharpFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultCSharpFlagTable; + return (table != nullptr) ? table : this->DefaultCSharpFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const @@ -988,7 +988,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const cmIDEFlagTable const* table = this->ToolsetOptions.GetRcFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultRcFlagTable; + return (table != nullptr) ? table : this->DefaultRcFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const @@ -996,7 +996,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const cmIDEFlagTable const* table = this->ToolsetOptions.GetLibFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultLibFlagTable; + return (table != nullptr) ? table : this->DefaultLibFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const @@ -1004,7 +1004,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const cmIDEFlagTable const* table = this->ToolsetOptions.GetLinkFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultLinkFlagTable; + return (table != nullptr) ? table : this->DefaultLinkFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const @@ -1023,7 +1023,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const cmIDEFlagTable const* table = this->ToolsetOptions.GetMasmFlagTable( this->GetPlatformName(), this->GetPlatformToolsetString()); - return (table != CM_NULLPTR) ? table : this->DefaultMasmFlagTable; + return (table != nullptr) ? table : this->DefaultMasmFlagTable; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index b4b327d..8b75aad 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio11Generator_h #define cmGlobalVisualStudio11Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <set> diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index ebc95bb..d032782 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio12Generator_h #define cmGlobalVisualStudio12Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index c8cf02c..e2120b8 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -151,6 +151,13 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } + if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion, + this->SystemVersion)) { + std::ostringstream e; + e << "Selecting Windows SDK version " << this->WindowsTargetPlatformVersion + << " to target Windows " << this->SystemVersion << "."; + mf->DisplayStatus(e.str().c_str(), -1); + } mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", this->WindowsTargetPlatformVersion.c_str()); return true; diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 0ce9a56..425fb22 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio14Generator_h #define cmGlobalVisualStudio14Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h index 4be88f4..730784b 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudio15Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio15Generator_h #define cmGlobalVisualStudio15Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index aeceb8d..624f9e5 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -202,7 +202,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( i != configs.end(); ++i) { const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(*i)); - if (dstConfig == CM_NULLPTR) { + if (dstConfig == nullptr) { dstConfig = i->c_str(); } fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 7a42b72..728ad2d 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -320,10 +320,10 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets() cmGlobalVisualStudio7Generator::AddExtraIDETargets(); if (this->AddCheckTarget()) { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. - for (std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin(); ti != tgts.end(); ++ti) { if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); @@ -356,7 +356,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( i != configs.end(); ++i) { const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(*i)); - if (dstConfig == CM_NULLPTR) { + if (dstConfig == nullptr) { dstConfig = i->c_str(); } fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 87a22d1..f85e409 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -82,8 +82,10 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() // Now make all targets depend on the ALL_BUILD target for (std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = + targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* tgt = *t; if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET || @@ -298,8 +300,10 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() std::vector<cmLocalGenerator*>& gen = it->second; for (std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = + targets.begin(); ti != targets.end(); ++ti) { this->ComputeVSTargetDepends(*ti); } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index c12a933..04d97c5 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudioGenerator_h #define cmGlobalVisualStudioGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index b2d6d5d..bd09715 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalWatcomWMakeGenerator_h #define cmGlobalWatcomWMakeGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGlobalGeneratorFactory.h" #include "cmGlobalUnixMakefileGenerator3.h" diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3cd14e1..9dbb173 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -193,7 +193,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( if (version_number < 30) { cm->IssueMessage(cmake::FATAL_ERROR, "Xcode " + version_string + " not supported."); - return CM_NULLPTR; + return nullptr; } CM_AUTO_PTR<cmGlobalXCodeGenerator> gg( @@ -440,8 +440,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( continue; } - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* target = *l; @@ -925,12 +925,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets) { this->SetCurrentLocalGenerator(gen); - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->CurrentLocalGenerator->GetGeneratorTargets(); typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets> cmSortedTargets; cmSortedTargets sortedTargets; - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { sortedTargets[(*l)->GetName()] = *l; } @@ -1210,7 +1210,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( void cmGlobalXCodeGenerator::ForceLinkerLanguages() { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin(); @@ -1517,17 +1517,6 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase( makecmd += " all"; buildphase->AddAttribute("shellScript", this->CreateString(makecmd)); buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0")); - - cmXCodeObject* outputFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); - for (std::vector<cmCustomCommand>::const_iterator i = commands.begin(); - i != commands.end(); ++i) { - std::vector<std::string> const& outputs = i->GetOutputs(); - for (std::vector<std::string>::const_iterator j = outputs.begin(); - j != outputs.end(); ++j) { - outputFiles->AddObject(this->CreateString(*j)); - } - } - buildphase->AddAttribute("outputPaths", outputFiles); } void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( @@ -2706,8 +2695,8 @@ bool cmGlobalXCodeGenerator::CreateGroups( i != generators.end(); ++i) { cmMakefile* mf = (*i)->GetMakefile(); std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups(); - std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* gtgt = *l; @@ -3309,6 +3298,31 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( const std::string& xcProjDir) { + // collect all tests for the targets + std::map<std::string, cmXCodeScheme::TestObjects> testables; + + for (std::vector<cmXCodeObject*>::const_iterator i = + this->XCodeObjects.begin(); + i != this->XCodeObjects.end(); ++i) { + cmXCodeObject* obj = *i; + if (obj->GetType() != cmXCodeObject::OBJECT || + obj->GetIsA() != cmXCodeObject::PBXNativeTarget) { + continue; + } + + if (!obj->GetTarget()->IsXCTestOnApple()) { + continue; + } + + const char* testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE"); + if (!testee) { + continue; + } + + testables[testee].push_back(obj); + } + + // generate scheme for (std::vector<cmXCodeObject*>::const_iterator i = this->XCodeObjects.begin(); i != this->XCodeObjects.end(); ++i) { @@ -3316,8 +3330,9 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( if (obj->GetType() == cmXCodeObject::OBJECT && (obj->GetIsA() == cmXCodeObject::PBXNativeTarget || obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) { - cmXCodeScheme schm(obj, this->CurrentConfigurationTypes, - this->XcodeVersion); + const std::string& targetName = obj->GetTarget()->GetName(); + cmXCodeScheme schm(obj, testables[targetName], + this->CurrentConfigurationTypes, this->XcodeVersion); schm.WriteXCodeSharedScheme(xcProjDir, this->RelativeToSource(xcProjDir.c_str())); } @@ -3583,7 +3598,7 @@ bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation( std::string* reason) const { if (this->ObjectDirArch.find('$') != std::string::npos) { - if (reason != CM_NULLPTR) { + if (reason != nullptr) { *reason = " under Xcode with multiple architectures"; } return false; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e69793b..7f57335 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalXCodeGenerator_h #define cmGlobalXCodeGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7e953ce..b334f41 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGraphVizWriter.h" -#include "cmConfigure.h" #include <iostream> #include <sstream> #include <utility> @@ -150,7 +149,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) { - if (ptrIt->second == CM_NULLPTR) { + if (ptrIt->second == nullptr) { continue; } @@ -194,7 +193,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) { - if (ptrIt->second == CM_NULLPTR) { + if (ptrIt->second == nullptr) { continue; } @@ -240,7 +239,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) { - if (ptrIt->second == CM_NULLPTR) { + if (ptrIt->second == nullptr) { continue; } @@ -279,7 +278,7 @@ void cmGraphVizWriter::WriteConnections( this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str); - if (targetPtrIt->second == CM_NULLPTR) // it's an external library + if (targetPtrIt->second == nullptr) // it's an external library { return; } @@ -330,7 +329,7 @@ void cmGraphVizWriter::WriteDependerConnections( this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str); - if (targetPtrIt->second == CM_NULLPTR) // it's an external library + if (targetPtrIt->second == nullptr) // it's an external library { return; } @@ -341,7 +340,7 @@ void cmGraphVizWriter::WriteDependerConnections( for (std::map<std::string, const cmGeneratorTarget*>::const_iterator dependerIt = this->TargetPtrs.begin(); dependerIt != this->TargetPtrs.end(); ++dependerIt) { - if (dependerIt->second == CM_NULLPTR) { + if (dependerIt->second == nullptr) { continue; } @@ -420,7 +419,8 @@ int cmGraphVizWriter::CollectAllTargets() for (std::vector<cmLocalGenerator*>::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = + (*lit)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); @@ -445,7 +445,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) for (std::vector<cmLocalGenerator*>::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = + (*lit)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); @@ -469,7 +470,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) std::ostringstream ostr; ostr << this->GraphNodePrefix << cnt++; this->TargetNamesNodes[libName] = ostr.str(); - this->TargetPtrs[libName] = CM_NULLPTR; + this->TargetPtrs[libName] = nullptr; // str << " \"" << ostr << "\" [ label=\"" << libName // << "\" shape=\"ellipse\"];" << std::endl; } diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index 78dceb7..8deb8c1 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmHexFileConverter.h" -#include "cmConfigure.h" #include <stdio.h> #include <string.h> @@ -22,7 +21,7 @@ static bool cm_IsHexChar(char c) static unsigned int ChompStrlen(const char* line) { - if (line == CM_NULLPTR) { + if (line == nullptr) { return 0; } unsigned int length = static_cast<unsigned int>(strlen(line)); @@ -139,7 +138,7 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType( { char buf[1024]; FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb"); - if (inFile == CM_NULLPTR) { + if (inFile == nullptr) { return Binary; } @@ -188,11 +187,11 @@ bool cmHexFileConverter::TryConvert(const char* inFileName, // try to open the file FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb"); FILE* outFile = cmsys::SystemTools::Fopen(outFileName, "wb"); - if ((inFile == CM_NULLPTR) || (outFile == CM_NULLPTR)) { - if (inFile != CM_NULLPTR) { + if ((inFile == nullptr) || (outFile == nullptr)) { + if (inFile != nullptr) { fclose(inFile); } - if (outFile != CM_NULLPTR) { + if (outFile != nullptr) { fclose(outFile); } return false; @@ -201,7 +200,7 @@ bool cmHexFileConverter::TryConvert(const char* inFileName, // convert them line by line bool success = false; char buf[1024]; - while (fgets(buf, 1024, inFile) != CM_NULLPTR) { + while (fgets(buf, 1024, inFile) != nullptr) { if (type == MotorolaSrec) { success = ConvertMotorolaSrecLine(buf, outFile); } else if (type == IntelHex) { diff --git a/Source/cmHexFileConverter.h b/Source/cmHexFileConverter.h index 1050bc1..25278e4 100644 --- a/Source/cmHexFileConverter.h +++ b/Source/cmHexFileConverter.h @@ -3,6 +3,8 @@ #ifndef cmHexFileConverter_h #define cmHexFileConverter_h +#include "cmConfigure.h" // IWYU pragma: keep + /** \class cmHexFileConverter * \brief Can detects Intel Hex and Motorola S-record files and convert them * to binary files. diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 19e96bd..af03128 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -3,7 +3,7 @@ #ifndef cmIDEOptions_h #define cmIDEOptions_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 5877a7d..da2fce9 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -3,7 +3,7 @@ #ifndef cmIfCommand_h #define cmIfCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 12e0c9a..cd4d850 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -78,7 +78,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args, cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); if (gg->IsExportedTargetsFile(fname_abs)) { - const char* modal = CM_NULLPTR; + const char* modal = nullptr; std::ostringstream e; cmake::MessageType messageType = cmake::AUTHOR_WARNING; diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 16dda0e..ceda931 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -3,7 +3,7 @@ #ifndef cmIncludeCommand_h #define cmIncludeCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 12de698..a7b3685 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmIncludeDirectoryCommand_h #define cmIncludeDirectoryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 375646f..88ee2f8 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -3,7 +3,7 @@ #ifndef cmIncludeExternalMSProjectCommand_h #define cmIncludeExternalMSProjectCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx new file mode 100644 index 0000000..505b07c --- /dev/null +++ b/Source/cmIncludeGuardCommand.cxx @@ -0,0 +1,108 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmIncludeGuardCommand.h" + +#include "cmExecutionStatus.h" +#include "cmMakefile.h" +#include "cmStateDirectory.h" +#include "cmStateSnapshot.h" +#include "cmSystemTools.h" +#include "cmake.h" + +namespace { + +enum IncludeGuardScope +{ + VARIABLE, + DIRECTORY, + GLOBAL +}; + +std::string GetIncludeGuardVariableName(std::string const& filePath) +{ + std::string result = "__INCGUARD_"; +#ifdef CMAKE_BUILD_WITH_CMAKE + result += cmSystemTools::ComputeStringMD5(filePath); +#else + result += cmSystemTools::MakeCidentifier(filePath); +#endif + result += "__"; + return result; +} + +bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar) +{ + if (mf->GetProperty(includeGuardVar)) { + return true; + } + cmStateSnapshot dirSnapshot = + mf->GetStateSnapshot().GetBuildsystemDirectoryParent(); + while (dirSnapshot.GetState()) { + cmStateDirectory stateDir = dirSnapshot.GetDirectory(); + if (stateDir.GetProperty(includeGuardVar)) { + return true; + } + dirSnapshot = dirSnapshot.GetBuildsystemDirectoryParent(); + } + return false; +} + +} // anonymous namespace + +// cmIncludeGuardCommand +bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args, + cmExecutionStatus& status) +{ + if (args.size() > 1) { + this->SetError( + "given an invalid number of arguments. The command takes at " + "most 1 argument."); + return false; + } + + IncludeGuardScope scope = VARIABLE; + + if (!args.empty()) { + std::string const& arg = args[0]; + if (arg == "DIRECTORY") { + scope = DIRECTORY; + } else if (arg == "GLOBAL") { + scope = GLOBAL; + } else { + this->SetError("given an invalid scope: " + arg); + return false; + } + } + + std::string includeGuardVar = GetIncludeGuardVariableName( + this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")); + + cmMakefile* const mf = this->Makefile; + + switch (scope) { + case VARIABLE: + if (mf->IsDefinitionSet(includeGuardVar)) { + status.SetReturnInvoked(); + return true; + } + mf->AddDefinition(includeGuardVar, true); + break; + case DIRECTORY: + if (CheckIncludeGuardIsSet(mf, includeGuardVar)) { + status.SetReturnInvoked(); + return true; + } + mf->SetProperty(includeGuardVar, "TRUE"); + break; + case GLOBAL: + cmake* const cm = mf->GetCMakeInstance(); + if (cm->GetProperty(includeGuardVar)) { + status.SetReturnInvoked(); + return true; + } + cm->SetProperty(includeGuardVar, "TRUE"); + break; + } + + return true; +} diff --git a/Source/cmIncludeGuardCommand.h b/Source/cmIncludeGuardCommand.h new file mode 100644 index 0000000..4dc3d90 --- /dev/null +++ b/Source/cmIncludeGuardCommand.h @@ -0,0 +1,37 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmIncludeGuardCommand_h +#define cmIncludeGuardCommand_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string> +#include <vector> + +#include "cmCommand.h" + +class cmExecutionStatus; + +/** \class cmIncludeGuardCommand + * \brief cmIncludeGuardCommand identical to C++ #pragma_once command + * Can work in 3 modes: GLOBAL (works on global properties), + * DIRECTORY(use directory property), VARIABLE(unnamed overload without + * arguments) define an ordinary variable to be used as include guard checker + */ +class cmIncludeGuardCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + cmCommand* Clone() CM_OVERRIDE { return new cmIncludeGuardCommand; } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + bool InitialPass(std::vector<std::string> const& args, + cmExecutionStatus& status) CM_OVERRIDE; +}; + +#endif diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index bac4b8f..3ea0443 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -3,7 +3,7 @@ #ifndef cmIncludeRegularExpressionCommand_h #define cmIncludeRegularExpressionCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 294fb17..7402105 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -204,7 +204,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCommandArgumentsHelper argHelper; cmCommandArgumentGroup group; - cmCAStringVector genericArgVector(&argHelper, CM_NULLPTR); + cmCAStringVector genericArgVector(&argHelper, nullptr); cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group); cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group); cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group); @@ -216,10 +216,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) &group); cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group); cmCAStringVector resourceArgVector(&argHelper, "RESOURCE", &group); - genericArgVector.Follows(CM_NULLPTR); + genericArgVector.Follows(nullptr); group.Follows(&genericArgVector); - argHelper.Parse(&args, CM_NULLPTR); + argHelper.Parse(&args, nullptr); // now parse the generic args (i.e. the ones not specialized on LIBRARY/ // ARCHIVE, RUNTIME etc. (see above) @@ -229,7 +229,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCAStringVector targetList(&genericArgs.Parser, "TARGETS"); cmCAString exports(&genericArgs.Parser, "EXPORT", &genericArgs.ArgumentGroup); - targetList.Follows(CM_NULLPTR); + targetList.Follows(nullptr); genericArgs.ArgumentGroup.Follows(&targetList); genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs); bool success = genericArgs.Finalize(); @@ -402,15 +402,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) ti != targets.end(); ++ti) { // Handle each target type. cmTarget& target = *(*ti); - cmInstallTargetGenerator* archiveGenerator = CM_NULLPTR; - cmInstallTargetGenerator* libraryGenerator = CM_NULLPTR; - cmInstallTargetGenerator* runtimeGenerator = CM_NULLPTR; - cmInstallTargetGenerator* objectGenerator = CM_NULLPTR; - cmInstallTargetGenerator* frameworkGenerator = CM_NULLPTR; - cmInstallTargetGenerator* bundleGenerator = CM_NULLPTR; - cmInstallFilesGenerator* privateHeaderGenerator = CM_NULLPTR; - cmInstallFilesGenerator* publicHeaderGenerator = CM_NULLPTR; - cmInstallFilesGenerator* resourceGenerator = CM_NULLPTR; + cmInstallTargetGenerator* archiveGenerator = nullptr; + cmInstallTargetGenerator* libraryGenerator = nullptr; + cmInstallTargetGenerator* runtimeGenerator = nullptr; + cmInstallTargetGenerator* objectGenerator = nullptr; + cmInstallTargetGenerator* frameworkGenerator = nullptr; + cmInstallTargetGenerator* bundleGenerator = nullptr; + cmInstallFilesGenerator* privateHeaderGenerator = nullptr; + cmInstallFilesGenerator* publicHeaderGenerator = nullptr; + cmInstallFilesGenerator* resourceGenerator = nullptr; // Track whether this is a namelink-only rule. bool namelinkOnly = false; @@ -437,8 +437,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) runtimeGenerator = CreateInstallTargetGenerator(target, runtimeArgs, false); } - if ((archiveGenerator == CM_NULLPTR) && - (runtimeGenerator == CM_NULLPTR)) { + if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) { this->SetError("Library TARGETS given no DESTINATION!"); return false; } @@ -688,16 +687,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } // Keep track of whether we're installing anything in each category - installsArchive = installsArchive || archiveGenerator != CM_NULLPTR; - installsLibrary = installsLibrary || libraryGenerator != CM_NULLPTR; - installsRuntime = installsRuntime || runtimeGenerator != CM_NULLPTR; - installsObject = installsObject || objectGenerator != CM_NULLPTR; - installsFramework = installsFramework || frameworkGenerator != CM_NULLPTR; - installsBundle = installsBundle || bundleGenerator != CM_NULLPTR; + installsArchive = installsArchive || archiveGenerator != nullptr; + installsLibrary = installsLibrary || libraryGenerator != nullptr; + installsRuntime = installsRuntime || runtimeGenerator != nullptr; + installsObject = installsObject || objectGenerator != nullptr; + installsFramework = installsFramework || frameworkGenerator != nullptr; + installsBundle = installsBundle || bundleGenerator != nullptr; installsPrivateHeader = - installsPrivateHeader || privateHeaderGenerator != CM_NULLPTR; + installsPrivateHeader || privateHeaderGenerator != nullptr; installsPublicHeader = - installsPublicHeader || publicHeaderGenerator != CM_NULLPTR; + installsPublicHeader || publicHeaderGenerator != nullptr; installsResource = installsResource || resourceGenerator; this->Makefile->AddInstallGenerator(archiveGenerator); @@ -779,7 +778,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) bool programs = (args[0] == "PROGRAMS"); cmInstallCommandArguments ica(this->DefaultComponentName); cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES"); - files.Follows(CM_NULLPTR); + files.Follows(nullptr); ica.ArgumentGroup.Follows(&files); std::vector<std::string> unknownArgs; ica.Parse(&args, &unknownArgs); @@ -819,7 +818,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) for (std::vector<std::string>::const_iterator fileIt = filesVector.begin(); fileIt != filesVector.end(); ++fileIt) { if (gg->IsExportedTargetsFile(*fileIt)) { - const char* modal = CM_NULLPTR; + const char* modal = nullptr; std::ostringstream e; cmake::MessageType messageType = cmake::AUTHOR_WARNING; @@ -895,7 +894,7 @@ bool cmInstallCommand::HandleDirectoryMode( bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; - const char* destination = CM_NULLPTR; + const char* destination = nullptr; std::string permissions_file; std::string permissions_dir; std::vector<std::string> configurations; @@ -1181,7 +1180,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode( cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES", &ica.ArgumentGroup); cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup); - exp.Follows(CM_NULLPTR); + exp.Follows(nullptr); ica.ArgumentGroup.Follows(&exp); std::vector<std::string> unknownArgs; @@ -1273,7 +1272,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES", &ica.ArgumentGroup); cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup); - exp.Follows(CM_NULLPTR); + exp.Follows(nullptr); ica.ArgumentGroup.Follows(&exp); std::vector<std::string> unknownArgs; diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index f5d1f92..b34f560 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -3,7 +3,7 @@ #ifndef cmInstallCommand_h #define cmInstallCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index b73414d..072d2a5 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -2,15 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallCommandArguments.h" -#include "cmConfigure.h" - #include "cmSystemTools.h" // Table of valid permissions. const char* cmInstallCommandArguments::PermissionsTable[] = { "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE", "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE", "WORLD_READ", "WORLD_WRITE", - "WORLD_EXECUTE", "SETUID", "SETGID", CM_NULLPTR + "WORLD_EXECUTE", "SETUID", "SETGID", nullptr }; const std::string cmInstallCommandArguments::EmptyString; @@ -28,7 +26,7 @@ cmInstallCommandArguments::cmInstallCommandArguments( , Optional(&Parser, "OPTIONAL", &ArgumentGroup) , NamelinkOnly(&Parser, "NAMELINK_ONLY", &ArgumentGroup) , NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup) - , GenericArguments(CM_NULLPTR) + , GenericArguments(nullptr) , DefaultComponentName(defaultComponent) { } @@ -38,7 +36,7 @@ const std::string& cmInstallCommandArguments::GetDestination() const if (!this->DestinationString.empty()) { return this->DestinationString; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetDestination(); } return this->EmptyString; @@ -49,7 +47,7 @@ const std::string& cmInstallCommandArguments::GetComponent() const if (!this->Component.GetString().empty()) { return this->Component.GetString(); } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetComponent(); } if (!this->DefaultComponentName.empty()) { @@ -64,7 +62,7 @@ const std::string& cmInstallCommandArguments::GetRename() const if (!this->Rename.GetString().empty()) { return this->Rename.GetString(); } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetRename(); } return this->EmptyString; @@ -75,7 +73,7 @@ const std::string& cmInstallCommandArguments::GetPermissions() const if (!this->PermissionsString.empty()) { return this->PermissionsString; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetPermissions(); } return this->EmptyString; @@ -86,7 +84,7 @@ bool cmInstallCommandArguments::GetOptional() const if (this->Optional.IsEnabled()) { return true; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetOptional(); } return false; @@ -97,7 +95,7 @@ bool cmInstallCommandArguments::GetExcludeFromAll() const if (this->ExcludeFromAll.IsEnabled()) { return true; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetExcludeFromAll(); } return false; @@ -108,7 +106,7 @@ bool cmInstallCommandArguments::GetNamelinkOnly() const if (this->NamelinkOnly.IsEnabled()) { return true; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetNamelinkOnly(); } return false; @@ -119,7 +117,7 @@ bool cmInstallCommandArguments::GetNamelinkSkip() const if (this->NamelinkSkip.IsEnabled()) { return true; } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetNamelinkSkip(); } return false; @@ -131,7 +129,7 @@ const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations() if (!this->Configurations.GetVector().empty()) { return this->Configurations.GetVector(); } - if (this->GenericArguments != CM_NULLPTR) { + if (this->GenericArguments != nullptr) { return this->GenericArguments->GetConfigurations(); } return this->Configurations.GetVector(); diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 54ad85c..1ca9893 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -17,7 +17,7 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( bool optional) : cmInstallGenerator(dest, configurations, component, message, exclude_from_all) - , LocalGenerator(CM_NULLPTR) + , LocalGenerator(nullptr) , Directories(dirs) , FilePermissions(file_permissions) , DirPermissions(dir_permissions) @@ -86,7 +86,7 @@ void cmInstallDirectoryGenerator::AddDirectoryInstallRule( std::vector<std::string> const& dirs) { // Write code to install the directories. - const char* no_rename = CM_NULLPTR; + const char* no_rename = nullptr; this->AddInstallRule(os, this->GetDestination(config), cmInstallType_DIRECTORY, dirs, this->Optional, this->FilePermissions.c_str(), diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index aa2cbc6..d699599 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -6,7 +6,7 @@ #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmInstallExportAndroidMKGenerator.cxx b/Source/cmInstallExportAndroidMKGenerator.cxx index 8eeaa9c..dd85b88 100644 --- a/Source/cmInstallExportAndroidMKGenerator.cxx +++ b/Source/cmInstallExportAndroidMKGenerator.cxx @@ -95,8 +95,8 @@ void cmInstallExportAndroidMKGenerator::GenerateScriptConfigs( std::string config_test = this->CreateConfigTest(i->first); os << indent << "if(" << config_test << ")\n"; this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), CM_NULLPTR, - CM_NULLPTR, CM_NULLPTR, indent.Next()); + false, this->FilePermissions.c_str(), nullptr, + nullptr, nullptr, indent.Next()); os << indent << "endif()\n"; files.clear(); } @@ -135,6 +135,6 @@ void cmInstallExportAndroidMKGenerator::GenerateScriptActions( std::vector<std::string> files; files.push_back(this->MainImportFile); this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), CM_NULLPTR, - CM_NULLPTR, CM_NULLPTR, indent); + false, this->FilePermissions.c_str(), nullptr, nullptr, + nullptr, indent); } diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index b176e85..ec1b210 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -29,7 +29,7 @@ cmInstallExportGenerator::cmInstallExportGenerator( , FileName(filename) , Namespace(name_space) , ExportOld(exportOld) - , LocalGenerator(CM_NULLPTR) + , LocalGenerator(nullptr) { if (android) { #ifdef CMAKE_BUILD_WITH_CMAKE @@ -181,8 +181,8 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, std::string config_test = this->CreateConfigTest(i->first); os << indent << "if(" << config_test << ")\n"; this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), CM_NULLPTR, - CM_NULLPTR, CM_NULLPTR, indent.Next()); + false, this->FilePermissions.c_str(), nullptr, + nullptr, nullptr, indent.Next()); os << indent << "endif()\n"; files.clear(); } @@ -221,6 +221,6 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os, std::vector<std::string> files; files.push_back(this->MainImportFile); this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), CM_NULLPTR, - CM_NULLPTR, CM_NULLPTR, indent); + false, this->FilePermissions.c_str(), nullptr, nullptr, + nullptr, indent); } diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 047e6b3..35c7743 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallExportGenerator_h #define cmInstallExportGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index b3c27b8..702b332 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -3,7 +3,7 @@ #ifndef cmInstallFilesCommand_h #define cmInstallFilesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 6323a91..4fcff4f 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -16,7 +16,7 @@ cmInstallFilesGenerator::cmInstallFilesGenerator( const char* rename, bool optional) : cmInstallGenerator(dest, configurations, component, message, exclude_from_all) - , LocalGenerator(CM_NULLPTR) + , LocalGenerator(nullptr) , Files(files) , FilePermissions(file_permissions) , Rename(rename) @@ -58,12 +58,12 @@ void cmInstallFilesGenerator::AddFilesInstallRule( std::vector<std::string> const& files) { // Write code to install the files. - const char* no_dir_permissions = CM_NULLPTR; + const char* no_dir_permissions = nullptr; this->AddInstallRule( os, this->GetDestination(config), (this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files, this->Optional, this->FilePermissions.c_str(), no_dir_permissions, - this->Rename.c_str(), CM_NULLPTR, indent); + this->Rename.c_str(), nullptr, indent); } void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 62b57f9..b2c7c4b 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallFilesGenerator_h #define cmInstallFilesGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 13b588e..3fbb3af 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -131,9 +131,9 @@ void cmInstallGenerator::AddInstallRule( std::string cmInstallGenerator::CreateComponentTest(const char* component, bool exclude_from_all) { - std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \""; + std::string result = "\"x${CMAKE_INSTALL_COMPONENT}x\" STREQUAL \"x"; result += component; - result += "\""; + result += "x\""; if (!exclude_from_all) { result += " OR NOT CMAKE_INSTALL_COMPONENT"; } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index 8f8701f..813cbe8 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallGenerator_h #define cmInstallGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmInstallType.h" #include "cmScriptGenerator.h" @@ -41,9 +41,9 @@ public: void AddInstallRule( std::ostream& os, std::string const& dest, cmInstallType type, std::vector<std::string> const& files, bool optional = false, - const char* permissions_file = CM_NULLPTR, - const char* permissions_dir = CM_NULLPTR, const char* rename = CM_NULLPTR, - const char* literal_args = CM_NULLPTR, Indent indent = Indent()); + const char* permissions_file = nullptr, + const char* permissions_dir = nullptr, const char* rename = nullptr, + const char* literal_args = nullptr, Indent indent = Indent()); /** Get the install destination as it should appear in the installation script. */ diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index 242fb95..e0ecbda 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -3,7 +3,7 @@ #ifndef cmInstallProgramsCommand_h #define cmInstallProgramsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index b39a622..f7e6e44 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -11,7 +11,7 @@ cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script, bool code, const char* component, bool exclude_from_all) - : cmInstallGenerator(CM_NULLPTR, std::vector<std::string>(), component, + : cmInstallGenerator(nullptr, std::vector<std::string>(), component, MessageDefault, exclude_from_all) , Script(script) , Code(code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index e183999..7e19aa6 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallScriptGenerator_h #define cmInstallScriptGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmInstallGenerator.h" diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 84d6f7a..2b15aeb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -28,7 +28,7 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( : cmInstallGenerator(dest, configurations, component, message, exclude_from_all) , TargetName(targetName) - , Target(CM_NULLPTR) + , Target(nullptr) , FilePermissions(file_permissions) , ImportLibrary(implib) , Optional(optional) @@ -312,8 +312,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( &cmInstallTargetGenerator::PreReplacementTweaks); // Write code to install the target file. - const char* no_dir_permissions = CM_NULLPTR; - const char* no_rename = CM_NULLPTR; + const char* no_dir_permissions = nullptr; + const char* no_rename = nullptr; bool optional = this->Optional || this->ImportLibrary; this->AddInstallRule(os, this->GetDestination(config), type, filesFrom, optional, this->FilePermissions.c_str(), @@ -351,8 +351,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfigObjectLibrary( std::string const obj_dir = this->Target->GetObjectDirectory(config); std::string const literal_args = " FILES_FROM_DIR \"" + obj_dir + "\""; - const char* no_dir_permissions = CM_NULLPTR; - const char* no_rename = CM_NULLPTR; + const char* no_dir_permissions = nullptr; + const char* no_rename = nullptr; this->AddInstallRule(os, dest, cmInstallType_FILES, objects, this->Optional, this->FilePermissions.c_str(), no_dir_permissions, no_rename, literal_args.c_str(), indent); diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index cf2de58..385d995 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallTargetGenerator_h #define cmInstallTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index e00eba0..d721ca0 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallTargetsCommand.h" +#include <unordered_map> #include <utility> #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" -#include "cm_unordered_map.hxx" class cmExecutionStatus; diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index cc84843..17622fb 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -3,7 +3,7 @@ #ifndef cmInstallTargetsCommand_h #define cmInstallTargetsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index d51fd8d..035c900 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -7,11 +7,10 @@ #include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmConfigure.h" #include <utility> cmInstalledFile::cmInstalledFile() - : NameExpression(CM_NULLPTR) + : NameExpression(nullptr) { } diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index b64e48d..6297073 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -3,7 +3,7 @@ #ifndef cmLinkDirectoriesCommand_h #define cmLinkDirectoriesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index f0fded2..e8c9487 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -3,7 +3,7 @@ #ifndef cmLinkItem_h #define cmLinkItem_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <algorithm> #include <map> @@ -24,7 +24,7 @@ class cmLinkItem : public std::string public: cmLinkItem() : std_string() - , Target(CM_NULLPTR) + , Target(nullptr) { } cmLinkItem(const std_string& n, cmGeneratorTarget const* t) @@ -105,7 +105,7 @@ struct cmOptionalLinkInterface : public cmLinkInterface , AllDone(false) , Exists(false) , HadHeadSensitiveCondition(false) - , ExplicitLibraries(CM_NULLPTR) + , ExplicitLibraries(nullptr) { } bool LibrariesDone; diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index f1b3a68..54121dd 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -3,7 +3,7 @@ #ifndef cmLinkLibrariesCommand_h #define cmLinkLibrariesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index d33e8d1..a016358 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmLinkLineComputer_h #define cmLinkLineComputer_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h index c3fac61..66941d3 100644 --- a/Source/cmLinkLineDeviceComputer.h +++ b/Source/cmLinkLineDeviceComputer.h @@ -4,7 +4,7 @@ #ifndef cmLinkLineDeviceComputer_h #define cmLinkLineDeviceComputer_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 55592cb..8865e23 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -3,7 +3,7 @@ #ifndef cmLinkedTree_h #define cmLinkedTree_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <assert.h> #include <iterator> @@ -49,7 +49,7 @@ public: public: iterator() - : Tree(CM_NULLPTR) + : Tree(nullptr) , Position(0) { } diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 0542c4f..ae4f0a8 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -182,9 +182,9 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) value += sep; sep = ";"; if (item < 0) { - item = (int)nitem + item; + item = static_cast<int>(nitem) + item; } - if (item < 0 || nitem <= (size_t)item) { + if (item < 0 || nitem <= static_cast<size_t>(item)) { std::ostringstream str; str << "index: " << item << " out of range (-" << nitem << ", " << nitem - 1 << ")"; @@ -273,9 +273,9 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) if (!varArgsExpanded.empty()) { size_t nitem = varArgsExpanded.size(); if (item < 0) { - item = (int)nitem + item; + item = static_cast<int>(nitem) + item; } - if (item < 0 || nitem <= (size_t)item) { + if (item < 0 || nitem <= static_cast<size_t>(item)) { std::ostringstream str; str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " @@ -423,9 +423,9 @@ bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args) for (cc = 2; cc < args.size(); ++cc) { int item = atoi(args[cc].c_str()); if (item < 0) { - item = (int)nitem + item; + item = static_cast<int>(nitem) + item; } - if (item < 0 || nitem <= (size_t)item) { + if (item < 0 || nitem <= static_cast<size_t>(item)) { std::ostringstream str; str << "index: " << item << " out of range (-" << nitem << ", " << nitem - 1 << ")"; diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index 7789f7d..7d3800a 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -3,7 +3,7 @@ #ifndef cmListCommand_h #define cmListCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 0c73cd7..8e8a54d 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -9,7 +9,6 @@ #include "cmSystemTools.h" #include "cmake.h" -#include "cmConfigure.h" #include <algorithm> #include <assert.h> #include <sstream> @@ -82,7 +81,7 @@ bool cmListFileParser::ParseFile() } if (bom == cmListFileLexer_BOM_Broken) { - cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR); + cmListFileLexer_SetFileName(this->Lexer, nullptr, nullptr); this->IssueFileOpenError("Error while reading Byte-Order-Mark. " "File not seekable?"); return false; @@ -90,7 +89,7 @@ bool cmListFileParser::ParseFile() // Verify the Byte-Order-Mark, if any. if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) { - cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR); + cmListFileLexer_SetFileName(this->Lexer, nullptr, nullptr); this->IssueFileOpenError( "File starts with a Byte-Order-Mark that is not UTF-8."); return false; @@ -330,13 +329,13 @@ cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& bottom, cmListFileBacktrace::cmListFileBacktrace() : Bottom() - , Cur(CM_NULLPTR) + , Cur(nullptr) { } cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot) : Bottom(snapshot.GetCallStackBottom()) - , Cur(CM_NULLPTR) + , Cur(nullptr) { } diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index 1a8a0fc..e46144d 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -3,7 +3,7 @@ #ifndef cmLoadCacheCommand_h #define cmLoadCacheCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 92a32a1..5ce48e3 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -63,7 +63,7 @@ public: void FinalPass() CM_OVERRIDE; bool HasFinalPass() const CM_OVERRIDE { - return this->info.FinalPass != CM_NULLPTR; + return this->info.FinalPass != nullptr; } static const char* LastName; @@ -86,11 +86,11 @@ public: #endif signal(SIGILL, TrapsForSignalsCFunction); } else { - signal(SIGSEGV, CM_NULLPTR); + signal(SIGSEGV, nullptr); #ifdef SIGBUS - signal(SIGBUS, CM_NULLPTR); + signal(SIGBUS, nullptr); #endif - signal(SIGILL, CM_NULLPTR); + signal(SIGILL, nullptr); } } @@ -102,7 +102,7 @@ extern "C" void TrapsForSignalsCFunction(int sig) cmLoadedCommand::TrapsForSignals(sig); } -const char* cmLoadedCommand::LastName = CM_NULLPTR; +const char* cmLoadedCommand::LastName = nullptr; bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) @@ -118,17 +118,16 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args, // create argc and argv and then invoke the command int argc = static_cast<int>(args.size()); - char** argv = CM_NULLPTR; + char** argv = nullptr; if (argc) { - argv = (char**)malloc(argc * sizeof(char*)); + argv = reinterpret_cast<char**>(malloc(argc * sizeof(char*))); } int i; for (i = 0; i < argc; ++i) { argv[i] = strdup(args[i].c_str()); } cmLoadedCommand::InstallSignalHandlers(info.Name); - int result = - info.InitialPass((void*)&info, (void*)this->Makefile, argc, argv); + int result = info.InitialPass(&info, this->Makefile, argc, argv); cmLoadedCommand::InstallSignalHandlers(info.Name, 1); cmFreeArguments(argc, argv); @@ -147,7 +146,7 @@ void cmLoadedCommand::FinalPass() { if (this->info.FinalPass) { cmLoadedCommand::InstallSignalHandlers(info.Name); - this->info.FinalPass((void*)&this->info, (void*)this->Makefile); + this->info.FinalPass(&this->info, this->Makefile); cmLoadedCommand::InstallSignalHandlers(info.Name, 1); } } @@ -156,7 +155,7 @@ cmLoadedCommand::~cmLoadedCommand() { if (this->info.Destructor) { cmLoadedCommand::InstallSignalHandlers(info.Name); - this->info.Destructor((void*)&this->info); + this->info.Destructor(&this->info); cmLoadedCommand::InstallSignalHandlers(info.Name, 1); } if (this->info.Error) { @@ -225,14 +224,13 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args, // find the init function std::string initFuncName = args[0] + "Init"; - CM_INIT_FUNCTION initFunction = - (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(lib, - initFuncName); + CM_INIT_FUNCTION initFunction = reinterpret_cast<CM_INIT_FUNCTION>( + cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName)); if (!initFunction) { initFuncName = "_"; initFuncName += args[0]; initFuncName += "Init"; - initFunction = (CM_INIT_FUNCTION)( + initFunction = reinterpret_cast<CM_INIT_FUNCTION>( cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName)); } // if the symbol is found call it to set the name on the diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index 030786e..30bb7da 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -3,7 +3,7 @@ #ifndef cmLoadCommandCommand_h #define cmLoadCommandCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index a5afcd8..999085e 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalCommonGenerator_h #define cmLocalCommonGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6ce31c5..6e0e28c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -214,8 +214,8 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -259,6 +259,17 @@ void cmLocalGenerator::GenerateTestFiles() fout << "include(\"" << testIncludeFile << "\")" << std::endl; } + const char* testIncludeFiles = + this->Makefile->GetProperty("TEST_INCLUDE_FILES"); + if (testIncludeFiles) { + std::vector<std::string> includesList; + cmSystemTools::ExpandListArgument(testIncludeFiles, includesList); + for (std::vector<std::string>::const_iterator i = includesList.begin(); + i != includesList.end(); ++i) { + fout << "include(\"" << *i << "\")" << std::endl; + } + } + // Ask each test generator to write its code. std::vector<cmTestGenerator*> const& testers = this->Makefile->GetTestGenerators(); @@ -277,6 +288,25 @@ void cmLocalGenerator::GenerateTestFiles() outP = cmOutputConverter::EscapeForCMake(outP); fout << "subdirs(" << outP << ")" << std::endl; } + + // Add directory labels property + const char* directoryLabels = + this->Makefile->GetDefinition("CMAKE_DIRECTORY_LABELS"); + const char* labels = this->Makefile->GetProperty("LABELS"); + + if (labels || directoryLabels) { + fout << "set_directory_properties(PROPERTIES LABELS "; + if (labels) { + fout << cmOutputConverter::EscapeForCMake(labels); + } + if (labels && directoryLabels) { + fout << ";"; + } + if (directoryLabels) { + fout << cmOutputConverter::EscapeForCMake(directoryLabels); + } + fout << ")" << std::endl; + } } void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) @@ -327,6 +357,7 @@ void cmLocalGenerator::GenerateInstallRules() { // Compute the install prefix. const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX"); + #if defined(_WIN32) && !defined(__CYGWIN__) std::string prefix_win32; if (!prefix) { @@ -370,7 +401,7 @@ void cmLocalGenerator::GenerateInstallRules() // Choose a default install configuration. std::string default_config = config; const char* default_order[] = { "RELEASE", "MINSIZEREL", "RELWITHDEBINFO", - "DEBUG", CM_NULLPTR }; + "DEBUG", nullptr }; for (const char** c = default_order; *c && default_config.empty(); ++c) { for (std::vector<std::string>::iterator i = configurationTypes.begin(); i != configurationTypes.end(); ++i) { @@ -451,6 +482,19 @@ void cmLocalGenerator::GenerateInstallRules() /* clang-format on */ } + // Copy cmake cross compile state to install code. + if (const char* crosscompiling = + this->Makefile->GetDefinition("CMAKE_CROSSCOMPILING")) { + /* clang-format off */ + fout << + "# Is this installation the result of a crosscompile?\n" + "if(NOT DEFINED CMAKE_CROSSCOMPILING)\n" + " set(CMAKE_CROSSCOMPILING \"" << crosscompiling << "\")\n" + "endif()\n" + "\n"; + /* clang-format on */ + } + // Ask each install generator to write its code. std::vector<cmInstallGenerator*> const& installers = this->Makefile->GetInstallGenerators(); @@ -504,6 +548,8 @@ void cmLocalGenerator::GenerateInstallRules() void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) { this->GeneratorTargets.push_back(gt); + this->GeneratorTargetSearchIndex.insert( + std::pair<std::string, cmGeneratorTarget*>(gt->GetName(), gt)); this->GlobalGenerator->IndexGeneratorTarget(gt); } @@ -537,13 +583,12 @@ private: cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( const std::string& name) const { - std::vector<cmGeneratorTarget*>::const_iterator ti = - std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(), - NamedGeneratorTargetFinder(name)); - if (ti != this->GeneratorTargets.end()) { - return *ti; + GeneratorTargetMap::const_iterator ti = + this->GeneratorTargetSearchIndex.find(name); + if (ti != this->GeneratorTargetSearchIndex.end()) { + return ti->second; } - return CM_NULLPTR; + return nullptr; } void cmLocalGenerator::ComputeTargetManifest() @@ -556,8 +601,8 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -581,8 +626,8 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() } // Process compile features of all targets. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; for (std::vector<std::string>::iterator ci = configNames.begin(); @@ -663,7 +708,7 @@ std::string cmLocalGenerator::GetIncludeFlags( // normal flag is repeated for each directory. std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_"; sysFlagVar += lang; - const char* sysIncludeFlag = CM_NULLPTR; + const char* sysIncludeFlag = nullptr; if (repeatFlag) { sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar); } @@ -1301,7 +1346,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, target->GetAppleArchs(config, archs); const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); if (sysroot && sysroot[0] == '/' && !sysroot[1]) { - sysroot = CM_NULLPTR; + sysroot = nullptr; } std::string sysrootFlagVar = std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; @@ -1502,20 +1547,34 @@ void cmLocalGenerator::AddCompilerRequirementFlag( // This compiler has no notion of language standard levels. return; } - std::string stdProp = lang + "_STANDARD"; - const char* standardProp = target->GetProperty(stdProp); - if (!standardProp) { - return; - } std::string extProp = lang + "_EXTENSIONS"; - std::string type = "EXTENSION"; bool ext = true; if (const char* extPropValue = target->GetProperty(extProp)) { if (cmSystemTools::IsOff(extPropValue)) { ext = false; - type = "STANDARD"; } } + std::string stdProp = lang + "_STANDARD"; + const char* standardProp = target->GetProperty(stdProp); + if (!standardProp) { + if (ext) { + // No language standard is specified and extensions are not disabled. + // Check if this compiler needs a flag to enable extensions. + std::string const option_flag = + "CMAKE_" + lang + "_EXTENSION_COMPILE_OPTION"; + if (const char* opt = + target->Target->GetMakefile()->GetDefinition(option_flag)) { + std::vector<std::string> optVec; + cmSystemTools::ExpandListArgument(opt, optVec); + for (size_t i = 0; i < optVec.size(); ++i) { + this->AppendFlagEscape(flags, optVec[i]); + } + } + } + return; + } + + std::string const type = ext ? "EXTENSION" : "STANDARD"; if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) { std::string option_flag = @@ -1583,8 +1642,10 @@ void cmLocalGenerator::AddCompilerRequirementFlag( return; } - // Greater or equal because the standards are stored in - // backward chronological order. + // If the standard requested is older than the compiler's default + // then we need to use a flag to change it. The comparison is + // greater-or-equal because the standards are stored in backward + // chronological order. if (stdIt >= defaultStdIt) { std::string option_flag = "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; @@ -1599,6 +1660,9 @@ void cmLocalGenerator::AddCompilerRequirementFlag( return; } + // The standard requested is at least as new as the compiler's default, + // and the standard request is not required. Decay to the newest standard + // for which a flag is defined. for (; stdIt < defaultStdIt; ++stdIt) { std::string option_flag = "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; @@ -1679,7 +1743,7 @@ void cmLocalGenerator::AddVisibilityPresetFlags( } std::string warnCMP0063; - std::string* pWarnCMP0063 = CM_NULLPTR; + std::string* pWarnCMP0063 = nullptr; if (target->GetType() != cmStateEnums::SHARED_LIBRARY && target->GetType() != cmStateEnums::MODULE_LIBRARY && !target->IsExecutableWithExports()) { @@ -1790,7 +1854,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, std::string const& lang, int targetType) { - const char* picFlags = CM_NULLPTR; + const char* picFlags = nullptr; if (targetType == cmStateEnums::EXECUTABLE) { std::string flagsVar = "CMAKE_"; @@ -1873,7 +1937,7 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags, const std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_IPO"; const char* rawFlagsList = this->Makefile->GetDefinition(name); - if (rawFlagsList == CM_NULLPTR) { + if (rawFlagsList == nullptr) { return; } @@ -2003,7 +2067,7 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, } snp = snp.GetBuildsystemDirectoryParent(); } - return CM_NULLPTR; + return nullptr; } std::string cmLocalGenerator::GetProjectName() const @@ -2058,8 +2122,8 @@ void cmLocalGenerator::GenerateTargetInstallRules( { // Convert the old-style install specification from each target to // an install generator and run it. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -2067,7 +2131,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( // Include the user-specified pre-install script for this target. if (const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, CM_NULLPTR, false); + cmInstallScriptGenerator g(preinstall, false, nullptr, false); g.Generate(os, config, configurationTypes); } @@ -2120,7 +2184,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( // Include the user-specified post-install script for this target. if (const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, CM_NULLPTR, false); + cmInstallScriptGenerator g(postinstall, false, nullptr, false); g.Generate(os, config, configurationTypes); } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9f78be4..4a7d2ca 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -3,13 +3,14 @@ #ifndef cmLocalGenerator_h #define cmLocalGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_kwiml.h" #include <iosfwd> #include <map> #include <set> #include <string> +#include <unordered_map> #include <vector> #include "cmListFileCache.h" @@ -282,8 +283,8 @@ public: // Compute object file names. std::string GetObjectFileNameWithoutTarget( const cmSourceFile& source, std::string const& dir_max, - bool* hasSourceExtension = CM_NULLPTR, - char const* customOutputExtension = CM_NULLPTR); + bool* hasSourceExtension = nullptr, + char const* customOutputExtension = nullptr); /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, @@ -311,7 +312,7 @@ public: virtual void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, - cmGeneratorTarget const* gt = CM_NULLPTR); + cmGeneratorTarget const* gt = nullptr); bool IsWindowsShell() const; bool IsWatcomWMake() const; @@ -353,8 +354,12 @@ protected: std::string::size_type ObjectPathMax; std::set<std::string> ObjectMaxPathViolations; - std::set<cmGeneratorTarget const*> WarnCMP0063; + typedef std::unordered_map<std::string, cmGeneratorTarget*> + GeneratorTargetMap; + GeneratorTargetMap GeneratorTargetSearchIndex; std::vector<cmGeneratorTarget*> GeneratorTargets; + + std::set<cmGeneratorTarget const*> WarnCMP0063; std::vector<cmGeneratorTarget*> ImportedGeneratorTargets; std::vector<cmGeneratorTarget*> OwnedImportedGeneratorTargets; std::map<std::string, std::string> AliasTargets; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 5f37af5..ab6774e 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -20,9 +20,9 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() void cmLocalGhsMultiGenerator::Generate() { - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 266710c..9fa3ca5 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -79,8 +79,8 @@ void cmLocalNinjaGenerator::Generate() } } - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index a45e018..83bc9d3 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalNinjaGenerator_h #define cmLocalNinjaGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> @@ -76,7 +76,7 @@ public: void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, - cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE; + cmGeneratorTarget const* gt = nullptr) CM_OVERRIDE; protected: std::string ConvertToIncludeReference( diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9b9d22c..cde2621 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -116,10 +116,10 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -172,8 +172,8 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( std::map<std::string, LocalObjectInfo>& localObjectFiles) { - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmGeneratorTarget* gt = *ti; if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -348,7 +348,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( std::vector<std::string> depends; depends.push_back(output); std::vector<std::string> no_commands; - this->WriteMakeRule(ruleFileStream, CM_NULLPTR, outNoExt, depends, + this->WriteMakeRule(ruleFileStream, nullptr, outNoExt, depends, no_commands, true, true); inHelp = false; } @@ -382,9 +382,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( // for each target we just provide a rule to cd up to the top and do a make // on the target - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); std::string localName; - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if (((*t)->GetType() == cmStateEnums::EXECUTABLE) || ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -718,7 +718,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop( // Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make. std::vector<std::string> depends; depends.push_back(".hpux_make_needs_suffix_list"); - this->WriteMakeRule(makefileStream, CM_NULLPTR, ".SUFFIXES", depends, + this->WriteMakeRule(makefileStream, nullptr, ".SUFFIXES", depends, no_commands, false); if (this->IsWatcomWMake()) { // Switch on WMake feature, if an error or interrupt occurs during @@ -1186,7 +1186,7 @@ void cmLocalUnixMakefileGenerator3::AppendEcho( line = ""; // Progress appears only on first line. - progress = CM_NULLPTR; + progress = nullptr; // Terminate on end-of-string. if (*c == '\0') { @@ -1460,7 +1460,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string lang = *li; // Create the scanner for this language - cmDepends* scanner = CM_NULLPTR; + cmDepends* scanner = nullptr; if (lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM" || lang == "CUDA") { // TODO: Handle RC (resource files) dependencies correctly. @@ -1562,8 +1562,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( this->WriteDivider(ruleFileStream); ruleFileStream << "# Targets provided globally by CMake.\n" << "\n"; - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - std::vector<cmGeneratorTarget*>::iterator glIt; + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + std::vector<cmGeneratorTarget*>::const_iterator glIt; for (glIt = targets.begin(); glIt != targets.end(); ++glIt) { if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::string targetString = diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index f64409c..16c305a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -3,7 +3,7 @@ #ifndef cmLocalUnixMakefileGenerator3_h #define cmLocalUnixMakefileGenerator3_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmDepends.h" #include "cmLocalCommonGenerator.h" @@ -108,8 +108,7 @@ public: std::string Arg; }; void AppendEcho(std::vector<std::string>& commands, std::string const& text, - EchoColor color = EchoNormal, - EchoProgress const* = CM_NULLPTR); + EchoColor color = EchoNormal, EchoProgress const* = nullptr); /** Get whether the makefile is to have color. */ bool GetColorMakefile() const { return this->ColorMakefile; } @@ -238,11 +237,11 @@ protected: cmGeneratorTarget* target, std::string const& relative, bool echo_comment = false, - std::ostream* content = CM_NULLPTR); + std::ostream* content = nullptr); void AppendCleanCommand(std::vector<std::string>& commands, const std::vector<std::string>& files, cmGeneratorTarget* target, - const char* filename = CM_NULLPTR); + const char* filename = nullptr); // Helper methods for dependeny updates. bool ScanDependencies( @@ -255,7 +254,7 @@ private: void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, - cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE; + cmGeneratorTarget const* gt = nullptr) CM_OVERRIDE; friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; @@ -272,7 +271,7 @@ private: cmGeneratorTarget* Target; std::string Language; LocalObjectEntry() - : Target(CM_NULLPTR) + : Target(nullptr) , Language() { } diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 85d4a73..db1776a 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -60,8 +60,8 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::Generate() { - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index e57dd8f..4cd56dd 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudio10Generator_h #define cmLocalVisualStudio10Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd08e5b..857ce46 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -62,8 +62,8 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { // Now create GUIDs for targets - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -91,8 +91,9 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() // specification source changes. if (cmSourceFile* sf = this->CreateVCProjBuildRule()) { // Add the rule to targets that need it. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = + this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; @@ -110,8 +111,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() // Visual Studio .NET 2003 Service Pack 1 will not run post-build // commands for targets in which no sources are built. Add dummy // rules to force these targets to build. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector<std::string> no_depends; @@ -150,10 +151,10 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() } // Get the set of targets in this directory. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); // Create the project file for each target. - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 89a3ee3..7a77574 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudio7Generator_h #define cmLocalVisualStudio7Generator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 85fb8a5..c47db4f 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudioGenerator_h #define cmLocalVisualStudioGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <memory> diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 739ef43..355c394 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -42,8 +42,8 @@ void cmLocalXCodeGenerator::Generate() { cmLocalGenerator::Generate(); - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } @@ -53,8 +53,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules() { cmLocalGenerator::GenerateInstallRules(); - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } diff --git a/Source/cmLocale.h b/Source/cmLocale.h index 9f90a3a..174f0f0 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -3,7 +3,7 @@ #ifndef cmLocale_h #define cmLocale_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <locale.h> #include <string> @@ -14,7 +14,7 @@ class cmLocaleRAII public: cmLocaleRAII() - : OldLocale(setlocale(LC_CTYPE, CM_NULLPTR)) + : OldLocale(setlocale(LC_CTYPE, nullptr)) { setlocale(LC_CTYPE, ""); } diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h index f2892d5..19e2c16 100644 --- a/Source/cmMSVC60LinkLineComputer.h +++ b/Source/cmMSVC60LinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmMSVC60LinkLineComputer_h #define cmMSVC60LinkLineComputer_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmMachO.h b/Source/cmMachO.h index 42745cf..aa17c6a 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -3,7 +3,7 @@ #ifndef cmMachO_h #define cmMachO_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 0d35fe0..cbfb60f 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -3,7 +3,7 @@ #ifndef cmMacroCommand_h #define cmMacroCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index af72eab..214cf92 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmMakeDirectoryCommand_h #define cmMakeDirectoryCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 608b18a..230c210 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -66,8 +66,8 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->DefineFlags = " "; - this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)"); - this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)"); + this->cmDefineRegex.compile("#([ \t]*)cmakedefine[ \t]+([A-Za-z_0-9]*)"); + this->cmDefine01Regex.compile("#([ \t]*)cmakedefine01[ \t]+([A-Za-z_0-9]*)"); this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); @@ -87,12 +87,10 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, #if defined(CMAKE_BUILD_WITH_CMAKE) this->AddSourceGroup("", "^.*$"); - this->AddSourceGroup("Source Files", - "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp" - "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$"); + this->AddSourceGroup("Source Files", CM_SOURCE_REGEX); this->AddSourceGroup("Header Files", CM_HEADER_REGEX); this->AddSourceGroup("CMake Rules", "\\.rule$"); - this->AddSourceGroup("Resources", "\\.plist$"); + this->AddSourceGroup("Resources", CM_RESOURCE_REGEX); this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); this->ObjectLibrariesSourceGroupIndex = this->SourceGroups.size(); @@ -592,7 +590,8 @@ void cmMakefile::AddEvaluationFile( CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent) { this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile( - inputFile, outputName, condition, inputIsContent)); + inputFile, outputName, condition, inputIsContent, + this->GetPolicyStatus(cmPolicies::CMP0070))); } std::vector<cmGeneratorExpressionEvaluationFile*> @@ -780,7 +779,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( // Make sure there is at least one output. if (outputs.empty()) { cmSystemTools::Error("Attempt to add a custom rule with no output!"); - return CM_NULLPTR; + return nullptr; } // Validate custom commands. TODO: More strict? @@ -791,12 +790,12 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( std::ostringstream e; e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n"; this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return CM_NULLPTR; + return nullptr; } } // Choose a source file on which to store the custom command. - cmSourceFile* file = CM_NULLPTR; + cmSourceFile* file = nullptr; if (!commandLines.empty() && !main_dependency.empty()) { // The main dependency was specified. Use it unless a different // custom command already used it. @@ -810,7 +809,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( } // The existing custom command is different. We need to // generate a rule file for this new command. - file = CM_NULLPTR; + file = nullptr; } else if (!file) { file = this->CreateSource(main_dependency); } @@ -934,7 +933,7 @@ void cmMakefile::AddCustomCommandOldStyle( std::vector<std::string> no_byproducts; this->AddCustomCommandToTarget(target, no_byproducts, depends, commandLines, cmTarget::POST_BUILD, comment, - CM_NULLPTR); + nullptr); return; } @@ -952,14 +951,14 @@ void cmMakefile::AddCustomCommandOldStyle( if (sourceFiles.find(source)) { // The source looks like a real file. Use it as the main dependency. sf = this->AddCustomCommandToOutput(output, depends, source, - commandLines, comment, CM_NULLPTR); + commandLines, comment, nullptr); } else { // The source may not be a real file. Do not use a main dependency. std::string no_main_dependency; std::vector<std::string> depends2 = depends; depends2.push_back(source); sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency, - commandLines, comment, CM_NULLPTR); + commandLines, comment, nullptr); } // If the rule was added to the source (and not a .rule file), @@ -1236,6 +1235,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) } } + // labels + this->SetProperty("LABELS", parent->GetProperty("LABELS")); + // link libraries this->SetProperty("LINK_LIBRARIES", parent->GetProperty("LINK_LIBRARIES")); @@ -1757,7 +1759,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) cmVariableWatch* vv = this->GetVariableWatch(); if (vv) { vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS, - CM_NULLPTR, this); + nullptr, this); } #endif } @@ -1908,7 +1910,7 @@ cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( } // otherwise return NULL - return CM_NULLPTR; + return nullptr; } cmSourceFile* cmMakefile::GetSourceFileWithOutput( @@ -1924,14 +1926,14 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput( if (o != this->OutputToSource.end()) { return (*o).second; } - return CM_NULLPTR; + return nullptr; } #if defined(CMAKE_BUILD_WITH_CMAKE) cmSourceGroup* cmMakefile::GetSourceGroup( const std::vector<std::string>& name) const { - cmSourceGroup* sg = CM_NULLPTR; + cmSourceGroup* sg = nullptr; // first look for source group starting with the same as the one we want for (std::vector<cmSourceGroup>::const_iterator sgIt = @@ -1944,11 +1946,11 @@ cmSourceGroup* cmMakefile::GetSourceGroup( } } - if (sg != CM_NULLPTR) { + if (sg != nullptr) { // iterate through its children to find match source group for (unsigned int i = 1; i < name.size(); ++i) { sg = sg->LookupChild(name[i].c_str()); - if (sg == CM_NULLPTR) { + if (sg == nullptr) { break; } } @@ -1966,14 +1968,14 @@ void cmMakefile::AddSourceGroup(const std::string& name, const char* regex) void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, const char* regex) { - cmSourceGroup* sg = CM_NULLPTR; + cmSourceGroup* sg = nullptr; std::vector<std::string> currentName; int i = 0; const int lastElement = static_cast<int>(name.size() - 1); for (i = lastElement; i >= 0; --i) { currentName.assign(name.begin(), name.begin() + i + 1); sg = this->GetSourceGroup(currentName); - if (sg != CM_NULLPTR) { + if (sg != nullptr) { break; } } @@ -2001,8 +2003,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, } // build the whole source group path for (++i; i <= lastElement; ++i) { - sg->AddChild( - cmSourceGroup(name[i].c_str(), CM_NULLPTR, sg->GetFullName())); + sg->AddChild(cmSourceGroup(name[i].c_str(), nullptr, sg->GetFullName())); sg = sg->LookupChild(name[i].c_str()); } @@ -2252,7 +2253,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const } } #endif - return def != CM_NULLPTR; + return def != nullptr; } const char* cmMakefile::GetDefinition(const std::string& name) const @@ -2561,7 +2562,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( openstack.pop_back(); result.append(last, in - last); std::string const& lookup = result.substr(var.loc); - const char* value = CM_NULLPTR; + const char* value = nullptr; std::string varresult; std::string svalue; static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE"; @@ -2617,7 +2618,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( if (!atOnly) { t_lookup lookup; const char* next = in + 1; - const char* start = CM_NULLPTR; + const char* start = nullptr; char nextc = *next; if (nextc == '{') { // Looking for a variable. @@ -3101,7 +3102,7 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const return sf; } } - return CM_NULLPTR; + return nullptr; } cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName, @@ -3302,7 +3303,7 @@ cmVariableWatch* cmMakefile::GetVariableWatch() const this->GetCMakeInstance()->GetVariableWatch()) { return this->GetCMakeInstance()->GetVariableWatch(); } - return CM_NULLPTR; + return nullptr; } #endif @@ -3432,18 +3433,22 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, // Replace #cmakedefine instances. if (this->cmDefineRegex.find(line)) { - const char* def = this->GetDefinition(this->cmDefineRegex.match(1)); + const char* def = this->GetDefinition(this->cmDefineRegex.match(2)); if (!cmSystemTools::IsOff(def)) { - cmSystemTools::ReplaceString(line, "#cmakedefine", "#define"); + const std::string indentation = this->cmDefineRegex.match(1); + cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine", + "#" + indentation + "define"); output += line; } else { output += "/* #undef "; - output += this->cmDefineRegex.match(1); + output += this->cmDefineRegex.match(2); output += " */"; } } else if (this->cmDefine01Regex.find(line)) { - const char* def = this->GetDefinition(this->cmDefine01Regex.match(1)); - cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define"); + const std::string indentation = this->cmDefine01Regex.match(1); + const char* def = this->GetDefinition(this->cmDefine01Regex.match(2)); + cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine01", + "#" + indentation + "define"); output += line; if (!cmSystemTools::IsOff(def)) { output += " 1"; @@ -3463,7 +3468,7 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, } // Perform variable replacements. - this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, CM_NULLPTR, + this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, nullptr, -1, true, true); } @@ -3603,7 +3608,7 @@ cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const if (i != this->Targets.end()) { return &i->second; } - return CM_NULLPTR; + return nullptr; } cmTest* cmMakefile::CreateTest(const std::string& testName) @@ -3625,7 +3630,7 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const if (mi != this->Tests.end()) { return mi->second; } - return CM_NULLPTR; + return nullptr; } void cmMakefile::AddCMakeDependFilesFromUser() @@ -3896,16 +3901,6 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath, return false; } -void cmMakefile::AddQtUiFileWithOptions(cmSourceFile* sf) -{ - this->QtUiFilesWithOptions.push_back(sf); -} - -std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const -{ - return this->QtUiFilesWithOptions; -} - static std::string const matchVariables[] = { "CMAKE_MATCH_0", "CMAKE_MATCH_1", "CMAKE_MATCH_2", "CMAKE_MATCH_3", "CMAKE_MATCH_4", "CMAKE_MATCH_5", "CMAKE_MATCH_6", "CMAKE_MATCH_7", @@ -4093,10 +4088,10 @@ bool cmMakefile::IgnoreErrorsCMP0061() const } #define FEATURE_STRING(F) , #F -static const char* const C_FEATURES[] = { CM_NULLPTR FOR_EACH_C_FEATURE( +static const char* const C_FEATURES[] = { nullptr FOR_EACH_C_FEATURE( FEATURE_STRING) }; -static const char* const CXX_FEATURES[] = { CM_NULLPTR FOR_EACH_CXX_FEATURE( +static const char* const CXX_FEATURES[] = { nullptr FOR_EACH_CXX_FEATURE( FEATURE_STRING) }; #undef FEATURE_STRING @@ -4204,7 +4199,7 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang, this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); } - return CM_NULLPTR; + return nullptr; } const char* featuresKnown = @@ -4227,7 +4222,7 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang, this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); } - return CM_NULLPTR; + return nullptr; } return featuresKnown; } @@ -4375,6 +4370,18 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, cmStrCmp(existingCxxStandard)) : cmArrayEnd(CXX_STANDARDS); + if (needCxx17 && + existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), + cmArrayEnd(CXX_STANDARDS), + cmStrCmp("17"))) { + return false; + } + if (needCxx14 && + existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), + cmArrayEnd(CXX_STANDARDS), + cmStrCmp("14"))) { + return false; + } if (needCxx11 && existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e65ba46..938b61b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -3,7 +3,7 @@ #ifndef cmMakefile_h #define cmMakefile_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/RegularExpression.hxx" #include <deque> @@ -12,6 +12,7 @@ #include <stack> #include <stddef.h> #include <string> +#include <unordered_map> #include <vector> #include "cmAlgorithms.h" @@ -22,7 +23,6 @@ #include "cmStateTypes.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_map.hxx" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -187,24 +187,26 @@ public: * Add a utility to the build. A utiltity target is a command that * is run every time the target is built. */ - cmTarget* AddUtilityCommand( - const std::string& utilityName, bool excludeFromAll, - const std::vector<std::string>& depends, const char* workingDirectory, - const char* command, const char* arg1 = CM_NULLPTR, - const char* arg2 = CM_NULLPTR, const char* arg3 = CM_NULLPTR, - const char* arg4 = CM_NULLPTR); + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + const std::vector<std::string>& depends, + const char* workingDirectory, + const char* command, const char* arg1 = nullptr, + const char* arg2 = nullptr, + const char* arg3 = nullptr, + const char* arg4 = nullptr); cmTarget* AddUtilityCommand( const std::string& utilityName, bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, - const char* comment = CM_NULLPTR, bool uses_terminal = false, + const char* comment = nullptr, bool uses_terminal = false, bool command_expand_lists = false); cmTarget* AddUtilityCommand( const std::string& utilityName, bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, - const char* comment = CM_NULLPTR, bool uses_terminal = false, + const char* comment = nullptr, bool uses_terminal = false, bool command_expand_lists = false); /** @@ -272,14 +274,14 @@ public: /** * Add a root source group for consideration when adding a new source. */ - void AddSourceGroup(const std::string& name, const char* regex = CM_NULLPTR); + void AddSourceGroup(const std::string& name, const char* regex = nullptr); /** * Add a source group for consideration when adding a new source. * name is tokenized. */ void AddSourceGroup(const std::vector<std::string>& name, - const char* regex = CM_NULLPTR); + const char* regex = nullptr); #endif @@ -521,7 +523,7 @@ public: const char* ExpandVariablesInString(std::string& source) const; const char* ExpandVariablesInString(std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly = false, - const char* filename = CM_NULLPTR, + const char* filename = nullptr, long line = -1, bool removeEmpty = false, bool replaceAt = false) const; @@ -594,11 +596,11 @@ public: */ bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, std::vector<std::string>& outArgs, - const char* filename = CM_NULLPTR) const; + const char* filename = nullptr) const; bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, std::vector<cmExpandedCommandArgument>& outArgs, - const char* filename = CM_NULLPTR) const; + const char* filename = nullptr) const; /** * Get the instance @@ -736,9 +738,6 @@ public: cmStringRange GetCompileDefinitionsEntries() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const; - void AddQtUiFileWithOptions(cmSourceFile* sf); - std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; - std::set<std::string> const& GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; @@ -747,7 +746,7 @@ public: bool PolicyOptionalWarningEnabled(std::string const& var); bool AddRequiredTargetFeature(cmTarget* target, const std::string& feature, - std::string* error = CM_NULLPTR) const; + std::string* error = nullptr) const; bool CompileFeatureKnown(cmTarget const* target, const std::string& feature, std::string& lang, std::string* error) const; @@ -871,7 +870,7 @@ private: friend class cmParseFileScope; std::vector<cmTarget*> ImportedTargetsOwned; - typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap; + typedef std::unordered_map<std::string, cmTarget*> TargetMap; TargetMap ImportedTargets; // Internal policy stack management. @@ -909,7 +908,7 @@ private: cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. - typedef CM_UNORDERED_MAP<std::string, cmSourceFile*> OutputToSourceMap; + typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap; OutputToSourceMap OutputToSource; void UpdateOutputToSourceMap(std::vector<std::string> const& outputs, @@ -917,14 +916,12 @@ private: void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source); - std::vector<cmSourceFile*> QtUiFilesWithOptions; - bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, - std::string* error = CM_NULLPTR) const; + std::string* error = nullptr) const; bool AddRequiredTargetCxxFeature(cmTarget* target, const std::string& feature, - std::string* error = CM_NULLPTR) const; + std::string* error = nullptr) const; void CheckNeededCLanguage(const std::string& feature, bool& needC90, bool& needC99, bool& needC11) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 359b9fd..b9b3c2f 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -284,7 +284,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( commands1.clear(); // Write the build rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, targetOutputReal, depends, commands, false); @@ -687,7 +687,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } // Write the build rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, targetFullPathReal, depends, commands, false); @@ -698,7 +698,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) depends.clear(); commands.clear(); depends.push_back(targetFullPathReal); - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, targetFullPath, depends, commands, false); } diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h index 01aa627..122e817 100644 --- a/Source/cmMakefileExecutableTargetGenerator.h +++ b/Source/cmMakefileExecutableTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileExecutableTargetGenerator_h #define cmMakefileExecutableTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 3d1594b..2faef67 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -117,7 +117,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() this->AppendObjectDepends(depends); // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, this->GeneratorTarget->GetName(), depends, commands, true); @@ -454,7 +454,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( std::vector<std::string> outputs(1, targetOutputReal); // Write the build rule. - this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends, + this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends, commands, false); // Write the main driver rule to build everything in this target. @@ -1008,7 +1008,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Write the build rule. - this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends, + this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends, commands, false); // Write the main driver rule to build everything in this target. diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index da1d8b6..307cd15 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileLibraryTargetGenerator_h #define cmMakefileLibraryTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmMakefileTargetGenerator.h" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a4511b6..b9bcdef 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -32,12 +32,12 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) - , OSXBundleGenerator(CM_NULLPTR) - , MacOSXContentGenerator(CM_NULLPTR) + , OSXBundleGenerator(nullptr) + , MacOSXContentGenerator(nullptr) { - this->BuildFileStream = CM_NULLPTR; - this->InfoFileStream = CM_NULLPTR; - this->FlagFileStream = CM_NULLPTR; + this->BuildFileStream = nullptr; + this->InfoFileStream = nullptr; + this->FlagFileStream = nullptr; this->CustomCommandDriver = OnBuild; this->LocalGenerator = static_cast<cmLocalUnixMakefileGenerator3*>(target->GetLocalGenerator()); @@ -60,7 +60,7 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator() cmMakefileTargetGenerator* cmMakefileTargetGenerator::New( cmGeneratorTarget* tgt) { - cmMakefileTargetGenerator* result = CM_NULLPTR; + cmMakefileTargetGenerator* result = nullptr; switch (tgt->GetType()) { case cmStateEnums::EXECUTABLE: @@ -139,7 +139,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() cmSystemTools::ExpandListArgument( cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget, - CM_NULLPTR, CM_NULLPTR), + nullptr, nullptr), this->CleanFiles); } @@ -337,7 +337,7 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()( output, cmOutputConverter::SHELL); commands.push_back(copyCommand); this->Generator->LocalGenerator->WriteMakeRule( - *this->Generator->BuildFileStream, CM_NULLPTR, output, depends, commands, + *this->Generator->BuildFileStream, nullptr, output, depends, commands, false); this->Generator->ExtraFiles.insert(output); } @@ -657,7 +657,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } // Maybe insert a compiler launcher like ccache or distcc - if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { + if (!compileCommands.empty() && + (lang == "C" || lang == "CXX" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); @@ -710,7 +711,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } // Write the rule. - this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends, + this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends, commands); bool do_preprocess_rules = lang_has_preprocessor && @@ -769,7 +770,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( commands.push_back(cmd); } - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, relativeObjI, force_depends, commands, false); } @@ -817,7 +818,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( commands.push_back(cmd); } - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, relativeObjS, force_depends, commands, false); } @@ -829,7 +830,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( objectRequires += ".requires"; std::vector<std::string> p_depends; // always provide an empty requires target - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, objectRequires, p_depends, no_commands, true); @@ -847,14 +848,14 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( p_depends.clear(); p_depends.push_back(objectRequires); - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, objectProvides, p_depends, r_commands, true); // write the provides.build rule dependency on the obj file p_depends.clear(); p_depends.push_back(relativeObj); - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, temp, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, temp, p_depends, no_commands, false); } @@ -880,7 +881,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules() } // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, depTarget, depends, no_commands, true); } @@ -902,7 +903,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() this->LocalGenerator->GetBinaryDirectory()); // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, cleanTarget, depends, commands, true); } @@ -959,7 +960,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule( if (!o_symbolic) { output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out); } - this->LocalGenerator->WriteMakeRule(os, CM_NULLPTR, *o, output_depends, + this->LocalGenerator->WriteMakeRule(os, nullptr, *o, output_depends, output_commands, o_symbolic, in_help); if (!o_symbolic) { @@ -1106,7 +1107,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() } // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, depTarget, depends, commands, true); } @@ -1169,8 +1170,8 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( // Write the rule. const std::vector<std::string>& outputs = ccg.GetOutputs(); - bool symbolic = this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, - outputs, depends, commands); + bool symbolic = this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, + depends, commands); // If the rule has changed make sure the output is rebuilt. if (!symbolic) { @@ -1341,7 +1342,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( std::vector<std::string> depends; depends.push_back(main_output); - const char* comment = CM_NULLPTR; + const char* comment = nullptr; if (relink) { // Setup the comment for the preinstall driver. comment = "Rule to relink during preinstall."; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 92c9f60..e0e9580 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileTargetGenerator_h #define cmMakefileTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index a7c5d27..46df0d8 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -95,7 +95,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() } // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, this->GeneratorTarget->GetName(), depends, commands, true); diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h index 8df5dd4..2826392 100644 --- a/Source/cmMakefileUtilityTargetGenerator.h +++ b/Source/cmMakefileUtilityTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileUtilityTargetGenerator_h #define cmMakefileUtilityTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmMakefileTargetGenerator.h" diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 14fd96f..45c59b9 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -34,7 +34,7 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args, cmState* state = this->Makefile->GetState(); if (!state->GetCacheEntryValue(variable)) { this->Makefile->GetCMakeInstance()->AddCacheEntry( - variable, CM_NULLPTR, CM_NULLPTR, cmStateEnums::UNINITIALIZED); + variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED); overwrite = true; } if (!state->GetCacheEntryValue(variable)) { diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index a7791a9..6c22d4c 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -3,7 +3,7 @@ #ifndef cmMarkAsAdvancedCommand_h #define cmMarkAsAdvancedCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index 67dbdda..bc97402 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -3,7 +3,7 @@ #ifndef cmMathCommand_h #define cmMathCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index 96939e5..59ee458 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -3,7 +3,7 @@ #ifndef cmMessageCommand_h #define cmMessageCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h index 13f05a8..a75de05 100644 --- a/Source/cmNinjaLinkLineComputer.h +++ b/Source/cmNinjaLinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmNinjaLinkLineComputer_h #define cmNinjaLinkLineComputer_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 14a4ef8..ddac20e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -142,7 +142,7 @@ const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const case cmStateEnums::EXECUTABLE: return "executable"; default: - return CM_NULLPTR; + return nullptr; } } @@ -409,10 +409,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); if (targetType == cmStateEnums::EXECUTABLE) { + std::vector<std::string> commandLines; + commandLines.push_back(cmakeCommand + + " -E cmake_symlink_executable $in $out"); + commandLines.push_back("$POST_BUILD"); + this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_EXECUTABLE", - cmakeCommand + " -E cmake_symlink_executable" - " $in $out && $POST_BUILD", + this->GetLocalGenerator()->BuildCommandLine(commandLines), "Creating executable symlink $out", "Rule for creating " "executable symlink.", /*depfile*/ "", @@ -422,10 +426,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) /*restat*/ "", /*generator*/ false); } else { + std::vector<std::string> commandLines; + commandLines.push_back(cmakeCommand + + " -E cmake_symlink_library $in $SONAME $out"); + commandLines.push_back("$POST_BUILD"); + this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_LIBRARY", - cmakeCommand + " -E cmake_symlink_library" - " $in $SONAME $out && $POST_BUILD", + this->GetLocalGenerator()->BuildCommandLine(commandLines), "Creating library symlink $out", "Rule for creating " "library symlink.", /*depfile*/ "", @@ -477,7 +485,16 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() this->TargetLinkLanguage, this->GetConfigName()); const char* linkCmd = mf->GetDefinition(linkCmdVar); if (linkCmd) { - cmSystemTools::ExpandListArgument(linkCmd, linkCmds); + std::string linkCmdStr = linkCmd; + if (this->GetGeneratorTarget()->HasImplibGNUtoMS()) { + std::string ruleVar = "CMAKE_"; + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); + ruleVar += "_GNUtoMS_RULE"; + if (const char* rule = this->Makefile->GetDefinition(ruleVar)) { + linkCmdStr += rule; + } + } + cmSystemTools::ExpandListArgument(linkCmdStr, linkCmds); if (this->GetGeneratorTarget()->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 677b1c6..d8baa67 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaNormalTargetGenerator_h #define cmNinjaNormalTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmNinjaTargetGenerator.h" diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d38dbcb..4a4e5b2 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -47,14 +47,14 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target) return new cmNinjaUtilityTargetGenerator(target); default: - return CM_NULLPTR; + return nullptr; } } cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) - , MacOSXContentGenerator(CM_NULLPTR) - , OSXBundleGenerator(CM_NULLPTR) + , MacOSXContentGenerator(nullptr) + , OSXBundleGenerator(nullptr) , MacContentFolders() , LocalGenerator( static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator())) @@ -557,17 +557,11 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // Write the rule for ninja dyndep file generation. std::vector<std::string> ddCmds; -#ifdef _WIN32 - // Windows command line length is limited -> use response file for dyndep - // rules + // Command line length is almost always limited -> use response file for + // dyndep rules std::string ddRspFile = "$out.rsp"; std::string ddRspContent = "$in"; std::string ddInput = "@" + ddRspFile; -#else - std::string ddRspFile; - std::string ddRspContent; - std::string ddInput = "$in"; -#endif // Run CMake dependency scanner on preprocessed output. std::string const cmake = this->GetLocalGenerator()->ConvertToOutputFormat( @@ -648,7 +642,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } // Maybe insert a compiler launcher like ccache or distcc - if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { + if (!compileCmds.empty() && + (lang == "C" || lang == "CXX" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { @@ -896,9 +891,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( // The actual compilation will now use the preprocessed source. explicitDeps.push_back(ppFileName); - // Preprocessing and compilation use the same flags. + // Preprocessing and compilation generally use the same flags. ppVars["FLAGS"] = vars["FLAGS"]; + // In case compilation requires flags that are incompatible with + // preprocessing, include them here. + std::string const postFlag = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_POSTPROCESS_FLAG"); + this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag); + // Move preprocessor definitions to the preprocessor build statement. std::swap(ppVars["DEFINES"], vars["DEFINES"]); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 5eb7a9a..e15ba25 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaTargetGenerator_h #define cmNinjaTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCommonTargetGenerator.h" #include "cmGlobalNinjaGenerator.h" diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h index 9256e36..361befe 100644 --- a/Source/cmNinjaUtilityTargetGenerator.h +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaUtilityTargetGenerator_h #define cmNinjaUtilityTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmNinjaTargetGenerator.h" diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index beddc6e..847e3f2 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmOSXBundleGenerator.h" -#include "cmConfigure.h" - #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -21,7 +19,7 @@ cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target, , Makefile(target->Target->GetMakefile()) , LocalGenerator(target->GetLocalGenerator()) , ConfigName(configName) - , MacContentFolders(CM_NULLPTR) + , MacContentFolders(nullptr) { if (this->MustSkip()) { return; diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 634e3a8..d6e51a5 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -3,7 +3,7 @@ #ifndef cmOptionCommand_h #define cmOptionCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 3a0637a..5916f7a 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -3,7 +3,7 @@ #ifndef cmOrderDirectories_h #define cmOrderDirectories_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/RegularExpression.hxx" #include <map> @@ -26,7 +26,7 @@ public: const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, - const char* soname = CM_NULLPTR); + const char* soname = nullptr); void AddLinkLibrary(std::string const& fullPath); void AddUserDirectories(std::vector<std::string> const& extra); void AddLanguageDirectories(std::vector<std::string> const& dirs); diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 14c986d..f56d212 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -389,7 +389,7 @@ int cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags) int cmOutputConverter::Shell__CharIsMakeVariableName(char c) { - return c && (c == '_' || isalpha(((int)c))); + return c && (c == '_' || isalpha((static_cast<int>(c)))); } const char* cmOutputConverter::Shell__SkipMakeVariables(const char* c) diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2339d68..2fd266a 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -5,6 +5,7 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include <map> +#include <unordered_map> #include <utility> #include "cmAlgorithms.h" @@ -13,7 +14,6 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cm_unordered_map.hxx" class cmExecutionStatus; @@ -31,7 +31,7 @@ public: */ cmDependInformation() : DependDone(false) - , SourceFile(CM_NULLPTR) + , SourceFile(nullptr) { } @@ -157,7 +157,7 @@ public: */ const cmDependInformation* FindDependencies(const char* file) { - cmDependInformation* info = this->GetDependInformation(file, CM_NULLPTR); + cmDependInformation* info = this->GetDependInformation(file, nullptr); this->GenerateDependInformation(info); return info; } @@ -202,7 +202,7 @@ protected: message += includeFile; message += " for file "; message += info->FullPath; - cmSystemTools::Error(message.c_str(), CM_NULLPTR); + cmSystemTools::Error(message.c_str(), nullptr); } continue; } @@ -328,7 +328,7 @@ protected: // See if the cmSourceFile for it has any files specified as // dependency hints. - if (info->SourceFile != CM_NULLPTR) { + if (info->SourceFile != nullptr) { // Get the cmSourceFile corresponding to this. const cmSourceFile& cFile = *(info->SourceFile); diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index d20bfbd..6dcb888 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -3,7 +3,7 @@ #ifndef cmOutputRequiredFilesCommand_h #define cmOutputRequiredFilesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <stdio.h> diff --git a/Source/cmParseArgumentsCommand.h b/Source/cmParseArgumentsCommand.h index 359fb85..469a76a 100644 --- a/Source/cmParseArgumentsCommand.h +++ b/Source/cmParseArgumentsCommand.h @@ -3,7 +3,7 @@ #ifndef cmParseArgumentsCommand_h #define cmParseArgumentsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmPipeConnection.cxx b/Source/cmPipeConnection.cxx new file mode 100644 index 0000000..b18a1d6 --- /dev/null +++ b/Source/cmPipeConnection.cxx @@ -0,0 +1,79 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmPipeConnection.h" + +#include "cmServer.h" + +cmPipeConnection::cmPipeConnection(const std::string& name, + cmConnectionBufferStrategy* bufferStrategy) + : cmEventBasedConnection(bufferStrategy) + , PipeName(name) +{ +} + +void cmPipeConnection::Connect(uv_stream_t* server) +{ + if (this->ClientPipe) { + // Accept and close all pipes but the first: + uv_pipe_t* rejectPipe = new uv_pipe_t(); + + uv_pipe_init(this->Server->GetLoop(), rejectPipe, 0); + uv_accept(server, reinterpret_cast<uv_stream_t*>(rejectPipe)); + uv_close(reinterpret_cast<uv_handle_t*>(rejectPipe), &on_close_delete); + return; + } + + this->ClientPipe = new uv_pipe_t(); + uv_pipe_init(this->Server->GetLoop(), this->ClientPipe, 0); + this->ClientPipe->data = static_cast<cmEventBasedConnection*>(this); + auto client = reinterpret_cast<uv_stream_t*>(this->ClientPipe); + if (uv_accept(server, client) != 0) { + uv_close(reinterpret_cast<uv_handle_t*>(client), &on_close_delete); + this->ClientPipe = nullptr; + return; + } + this->ReadStream = client; + this->WriteStream = client; + + uv_read_start(this->ReadStream, on_alloc_buffer, on_read); + Server->OnConnected(this); +} + +bool cmPipeConnection::OnServeStart(std::string* errorMessage) +{ + this->ServerPipe = new uv_pipe_t(); + uv_pipe_init(this->Server->GetLoop(), this->ServerPipe, 0); + this->ServerPipe->data = static_cast<cmEventBasedConnection*>(this); + + int r; + if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) { + *errorMessage = std::string("Internal Error with ") + this->PipeName + + ": " + uv_err_name(r); + return false; + } + auto serverStream = reinterpret_cast<uv_stream_t*>(this->ServerPipe); + if ((r = uv_listen(serverStream, 1, on_new_connection)) != 0) { + *errorMessage = std::string("Internal Error listening on ") + + this->PipeName + ": " + uv_err_name(r); + return false; + } + + return cmConnection::OnServeStart(errorMessage); +} + +bool cmPipeConnection::OnConnectionShuttingDown() +{ + if (this->ClientPipe) { + uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe), + &on_close_delete); + this->WriteStream->data = nullptr; + } + uv_close(reinterpret_cast<uv_handle_t*>(this->ServerPipe), &on_close_delete); + + this->ClientPipe = nullptr; + this->ServerPipe = nullptr; + this->WriteStream = nullptr; + this->ReadStream = nullptr; + + return cmConnection::OnConnectionShuttingDown(); +} diff --git a/Source/cmPipeConnection.h b/Source/cmPipeConnection.h new file mode 100644 index 0000000..7b89842 --- /dev/null +++ b/Source/cmPipeConnection.h @@ -0,0 +1,28 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string> + +#include "cmConnection.h" +#include "cm_uv.h" + +class cmPipeConnection : public cmEventBasedConnection +{ +public: + cmPipeConnection(const std::string& name, + cmConnectionBufferStrategy* bufferStrategy = nullptr); + + bool OnServeStart(std::string* pString) override; + + bool OnConnectionShuttingDown() override; + + void Connect(uv_stream_t* server) override; + +private: + const std::string PipeName; + uv_pipe_t* ServerPipe = nullptr; + uv_pipe_t* ClientPipe = nullptr; +}; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index da3edd4..910f6fb 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -8,7 +8,6 @@ #include "cmVersion.h" #include "cmake.h" -#include "cmConfigure.h" #include <assert.h> #include <ctype.h> #include <sstream> @@ -62,9 +61,9 @@ static const char* idToString(cmPolicies::PolicyID id) CM_FOR_EACH_POLICY_ID(POLICY_CASE) #undef POLICY_CASE case cmPolicies::CMPCOUNT: - return CM_NULLPTR; + return nullptr; } - return CM_NULLPTR; + return nullptr; } static const char* idToVersion(cmPolicies::PolicyID id) @@ -76,9 +75,9 @@ static const char* idToVersion(cmPolicies::PolicyID id) CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE) #undef POLICY_CASE case cmPolicies::CMPCOUNT: - return CM_NULLPTR; + return nullptr; } - return CM_NULLPTR; + return nullptr; } static bool isPolicyNewerThan(cmPolicies::PolicyID id, unsigned int majorV, @@ -108,9 +107,9 @@ const char* idToShortDescription(cmPolicies::PolicyID id) CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE) #undef POLICY_CASE case cmPolicies::CMPCOUNT: - return CM_NULLPTR; + return nullptr; } - return CM_NULLPTR; + return nullptr; } static void DiagnoseAncientPolicies( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 69cbc18..354011a 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -206,7 +206,12 @@ class cmMakefile; cmPolicies::WARN) \ SELECT(POLICY, CMP0069, \ "INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.", 3, 9, 0, \ - cmPolicies::WARN) + cmPolicies::WARN) \ + SELECT(POLICY, CMP0070, \ + "Define file(GENERATE) behavior for relative paths.", 3, 10, 0, \ + cmPolicies::WARN) \ + SELECT(POLICY, CMP0071, "Let AUTOMOC and AUTOUIC process GENERATED files.", \ + 3, 10, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index de7b061..67b4a97 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -10,22 +10,22 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, OutputParser* err, Encoding encoding) { cmsysProcess_Execute(cp); - char* data = CM_NULLPTR; + char* data = nullptr; int length = 0; int p; cmProcessOutput processOutput(encoding); std::string strdata; while ((out || err) && - (p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { + (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { if (out && p == cmsysProcess_Pipe_STDOUT) { processOutput.DecodeText(data, length, strdata, 1); if (!out->Process(strdata.c_str(), int(strdata.size()))) { - out = CM_NULLPTR; + out = nullptr; } } else if (err && p == cmsysProcess_Pipe_STDERR) { processOutput.DecodeText(data, length, strdata, 2); if (!err->Process(strdata.c_str(), int(strdata.size()))) { - err = CM_NULLPTR; + err = nullptr; } } } @@ -41,12 +41,12 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, out->Process(strdata.c_str(), int(strdata.size())); } } - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); } cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR) - : Log(CM_NULLPTR) - , Prefix(CM_NULLPTR) + : Log(nullptr) + , Prefix(nullptr) , Separator(sep) , LineEnd('\0') , IgnoreCR(ignoreCR) diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index e7d9a10..5b357cd 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -3,7 +3,7 @@ #ifndef cmProcessTools_h #define cmProcessTools_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmProcessOutput.h" #include <iosfwd> @@ -70,7 +70,7 @@ public: class OutputLogger : public LineParser { public: - OutputLogger(std::ostream& log, const char* prefix = CM_NULLPTR) + OutputLogger(std::ostream& log, const char* prefix = nullptr) { this->SetLog(&log, prefix); } @@ -81,7 +81,7 @@ public: /** Run a process and send output to given parsers. */ static void RunProcess(struct cmsysProcess_s* cp, OutputParser* out, - OutputParser* err = CM_NULLPTR, + OutputParser* err = nullptr, Encoding encoding = cmProcessOutput::Auto); }; diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index 3c579ac..afe489a 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -3,7 +3,7 @@ #ifndef cmProjectCommand_h #define cmProjectCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 222afb4..27f0ecd 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProperty.h" -#include "cmConfigure.h" - void cmProperty::Set(const char* value) { this->Value = value; @@ -24,5 +22,5 @@ const char* cmProperty::GetValue() const if (this->ValueHasBeenSet) { return this->Value.c_str(); } - return CM_NULLPTR; + return nullptr; } diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 1e089d1..4905c24 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" -#include "cmConfigure.h" #include <algorithm> #include <assert.h> #include <utility> @@ -59,7 +58,7 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const cmPropertyMap::const_iterator it = this->find(name); if (it == this->end()) { - return CM_NULLPTR; + return nullptr; } return it->second.GetValue(); } diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index de9e545..ae1fdfa 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -78,7 +78,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args, depends.push_back(hname); std::string no_main_dependency; - const char* no_working_dir = CM_NULLPTR; + const char* no_working_dir = nullptr; this->Makefile->AddCustomCommandToOutput( newName, depends, no_main_dependency, commandLines, "Qt Wrapped File", no_working_dir); diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index ad1ccf3..014a4ab 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -3,7 +3,7 @@ #ifndef cmQTWrapCPPCommand_h #define cmQTWrapCPPCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index d3c6631..3d586d6 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -109,8 +109,8 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string> depends; depends.push_back(uiName); std::string no_main_dependency; - const char* no_comment = CM_NULLPTR; - const char* no_working_dir = CM_NULLPTR; + const char* no_comment = nullptr; + const char* no_working_dir = nullptr; this->Makefile->AddCustomCommandToOutput( hName, depends, no_main_dependency, hCommandLines, no_comment, no_working_dir); diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index ac7ab01..f7e6bdd 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -3,7 +3,7 @@ #ifndef cmQTWrapUICommand_h #define cmQTWrapUICommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx index 3e1b58c..a8e6b96 100644 --- a/Source/cmQtAutoGeneratorCommon.cxx +++ b/Source/cmQtAutoGeneratorCommon.cxx @@ -38,7 +38,7 @@ static bool RccListInputsQt4(const std::string& fileName, osst << ifs.rdbuf(); qrcContents = osst.str(); } else { - if (errorMessage != CM_NULLPTR) { + if (errorMessage != nullptr) { std::ostringstream ost; ost << "AutoRcc: Error: Rcc file not readable:\n" << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n"; @@ -98,7 +98,7 @@ static bool RccListInputsQt5(const std::string& rccCommand, int retVal = 0; bool result = cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, - CM_NULLPTR, cmSystemTools::OUTPUT_NONE); + nullptr, cmSystemTools::OUTPUT_NONE); if (result && retVal == 0 && rccStdOut.find("--list") != std::string::npos) { hasDashDashList = true; @@ -117,10 +117,10 @@ static bool RccListInputsQt5(const std::string& rccCommand, command.push_back(fileName); result = cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, - CM_NULLPTR, cmSystemTools::OUTPUT_NONE); + nullptr, cmSystemTools::OUTPUT_NONE); } if (!result || retVal) { - if (errorMessage != CM_NULLPTR) { + if (errorMessage != nullptr) { std::ostringstream ost; ost << "AutoRcc: Error: Rcc list process for " << fileName << " failed:\n" @@ -153,7 +153,7 @@ static bool RccListInputsQt5(const std::string& rccCommand, std::string::size_type pos = eline.find(searchString); if (pos == std::string::npos) { - if (errorMessage != CM_NULLPTR) { + if (errorMessage != nullptr) { std::ostringstream ost; ost << "AutoRcc: Error: Rcc lists unparsable output:\n" << cmQtAutoGeneratorCommon::Quoted(eline) << "\n"; @@ -205,7 +205,7 @@ bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion, allGood = RccListInputsQt5(rccCommand, fileName, files, errorMessage); } } else { - if (errorMessage != CM_NULLPTR) { + if (errorMessage != nullptr) { std::ostringstream ost; ost << "AutoRcc: Error: Rcc file does not exist:\n" << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n"; diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h index a131baf..23a882a 100644 --- a/Source/cmQtAutoGeneratorCommon.h +++ b/Source/cmQtAutoGeneratorCommon.h @@ -3,7 +3,7 @@ #ifndef cmQtAutoGeneratorCommon_h #define cmQtAutoGeneratorCommon_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -33,7 +33,7 @@ public: const std::string& rccCommand, const std::string& fileName, std::vector<std::string>& files, - std::string* errorMessage = CM_NULLPTR); + std::string* errorMessage = nullptr); }; #endif diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index cecf165..07fb528 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -4,6 +4,7 @@ #include "cmQtAutoGeneratorCommon.h" #include "cmAlgorithms.h" +#include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmFilePathChecksum.h" #include "cmGeneratorTarget.h" @@ -11,6 +12,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" +#include "cmPolicies.h" #include "cmSourceFile.h" #include "cmSourceGroup.h" #include "cmState.h" @@ -18,40 +20,30 @@ #include "cmTarget.h" #include "cm_sys_stat.h" #include "cmake.h" - -#if defined(_WIN32) && !defined(__CYGWIN__) -#include "cmGlobalVisualStudioGenerator.h" -#endif - -#include "cmConfigure.h" #include "cmsys/FStream.hxx" + #include <algorithm> #include <map> #include <set> +#include <sstream> #include <string> #include <utility> #include <vector> -static void utilCopyTargetProperty(cmTarget* destinationTarget, - cmTarget* sourceTarget, - const std::string& propertyName) +inline static const char* SafeString(const char* value) { - const char* propertyValue = sourceTarget->GetProperty(propertyName); - if (propertyValue) { - destinationTarget->SetProperty(propertyName, propertyValue); - } + return (value != nullptr) ? value : ""; } -inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key) +static std::string GetSafeProperty(cmGeneratorTarget const* target, + const char* key) { - return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key)); + return std::string(SafeString(target->GetProperty(key))); } -static std::string GetSafeProperty(cmGeneratorTarget const* target, - const char* key) +inline static bool AutogenMultiConfig(cmGlobalGenerator* globalGen) { - const char* tmp = target->GetProperty(key); - return std::string((tmp != CM_NULLPTR) ? tmp : ""); + return globalGen->IsMultiConfig(); } static std::string GetAutogenTargetName(cmGeneratorTarget const* target) @@ -93,7 +85,7 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) } const char* targetQtVersion = target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""); - if (targetQtVersion != CM_NULLPTR) { + if (targetQtVersion != nullptr) { qtMajorVersion = targetQtVersion; } return qtMajorVersion; @@ -113,7 +105,7 @@ static std::string GetQtMinorVersion(cmGeneratorTarget const* target, const char* targetQtVersion = target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", ""); - if (targetQtVersion != CM_NULLPTR) { + if (targetQtVersion != nullptr) { qtMinorVersion = targetQtVersion; } return qtMinorVersion; @@ -154,28 +146,13 @@ static void GetCompileDefinitionsAndDirectories( } } -static bool IsMultiConfig(cmGlobalGenerator* globalGen) -{ - // FIXME: Xcode does not support per-config sources, yet. - // (EXCLUDED_SOURCE_FILE_NAMES) - // Treat it as a single configuration generator meanwhile. - if (globalGen->GetName().find("Xcode") != std::string::npos) { - return false; - } - // FIXME: Visual Studio does not fully support per-config sources yet. - if (globalGen->GetName().find("Visual Studio") != std::string::npos) { - return false; - } - return globalGen->IsMultiConfig(); -} - static std::vector<std::string> GetConfigurations( - cmMakefile* makefile, std::string* config = CM_NULLPTR) + cmMakefile* makefile, std::string* config = nullptr) { std::vector<std::string> configs; { std::string cfg = makefile->GetConfigurations(configs); - if (config != CM_NULLPTR) { + if (config != nullptr) { *config = cfg; } } @@ -189,7 +166,7 @@ static std::vector<std::string> GetConfigurations( static std::vector<std::string> GetConfigurationSuffixes(cmMakefile* makefile) { std::vector<std::string> suffixes; - if (IsMultiConfig(makefile->GetGlobalGenerator())) { + if (AutogenMultiConfig(makefile->GetGlobalGenerator())) { makefile->GetConfigurations(suffixes); for (std::vector<std::string>::iterator it = suffixes.begin(); it != suffixes.end(); ++it) { @@ -216,13 +193,20 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); } +static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, + const std::set<std::string>& values) +{ + makefile->AddDefinition( + key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); +} + static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, cmQtAutoGeneratorCommon::GeneratorType genType) { - cmSourceGroup* sourceGroup = CM_NULLPTR; + cmSourceGroup* sourceGroup = nullptr; // Acquire source group { - const char* groupName = CM_NULLPTR; + const char* groupName = nullptr; // Use generator specific group name switch (genType) { case cmQtAutoGeneratorCommon::MOC: @@ -237,27 +221,27 @@ static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, break; } // Use default group name on demand - if ((groupName == CM_NULLPTR) || (*groupName == 0)) { + if ((groupName == nullptr) || (*groupName == 0)) { groupName = makefile->GetState()->GetGlobalProperty("AUTOGEN_SOURCE_GROUP"); } // Generate a source group on demand - if ((groupName != CM_NULLPTR) && (*groupName != 0)) { + if ((groupName != nullptr) && (*groupName != 0)) { { const char* delimiter = makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); - if (delimiter == CM_NULLPTR) { + if (delimiter == nullptr) { delimiter = "\\"; } std::vector<std::string> folders = cmSystemTools::tokenize(groupName, delimiter); sourceGroup = makefile->GetSourceGroup(folders); - if (sourceGroup == CM_NULLPTR) { + if (sourceGroup == nullptr) { makefile->AddSourceGroup(folders); sourceGroup = makefile->GetSourceGroup(folders); } } - if (sourceGroup == CM_NULLPTR) { + if (sourceGroup == nullptr) { cmSystemTools::Error( "Autogen: Could not create or find source group: ", cmQtAutoGeneratorCommon::Quoted(groupName).c_str()); @@ -265,101 +249,164 @@ static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, } } } - if (sourceGroup != CM_NULLPTR) { + if (sourceGroup != nullptr) { sourceGroup->AddGroupFile(fileName); } return true; } -static void AddGeneratedSource(cmMakefile* makefile, +static void AddCleanFile(cmMakefile* makefile, const std::string& fileName) +{ + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fileName.c_str(), + false); +} + +static void AddGeneratedSource(cmGeneratorTarget* target, const std::string& filename, cmQtAutoGeneratorCommon::GeneratorType genType) { - cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true); - gFile->SetProperty("GENERATED", "1"); - gFile->SetProperty("SKIP_AUTOGEN", "On"); + cmMakefile* makefile = target->Target->GetMakefile(); + { + cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true); + gFile->SetProperty("GENERATED", "1"); + gFile->SetProperty("SKIP_AUTOGEN", "On"); + } + target->AddSource(filename); AddToSourceGroup(makefile, filename, genType); } -static void AcquireScanFiles(cmGeneratorTarget const* target, - std::vector<std::string>& mocUicSources, - std::vector<std::string>& mocUicHeaders, - std::vector<std::string>& mocSkipList, - std::vector<std::string>& uicSkipList) +struct AutogenSetup { - const bool mocTarget = target->GetPropertyAsBool("AUTOMOC"); - const bool uicTarget = target->GetPropertyAsBool("AUTOUIC"); + std::vector<std::string> sources; + std::vector<std::string> headers; - std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + std::set<std::string> mocSkip; + std::set<std::string> uicSkip; + + std::map<std::string, std::string> configSuffix; + std::map<std::string, std::string> configMocIncludes; + std::map<std::string, std::string> configMocDefines; + std::map<std::string, std::string> configUicOptions; +}; + +static void SetupAcquireScanFiles(cmGeneratorTarget const* target, + bool mocEnabled, bool uicEnabled, + const std::vector<cmSourceFile*>& srcFiles, + AutogenSetup& setup) +{ + // Read skip files from makefile sources + { + const std::vector<cmSourceFile*>& allSources = + target->Makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator fit = allSources.begin(); + fit != allSources.end(); ++fit) { + cmSourceFile* sf = *fit; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); + if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && + !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + continue; + } + const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN"); + const bool mocSkip = + mocEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC")); + const bool uicSkip = + uicEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC")); + if (mocSkip || uicSkip) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + if (mocSkip) { + setup.mocSkip.insert(absFile); + } + if (uicSkip) { + setup.uicSkip.insert(absFile); + } + } + } + } + + const cmPolicies::PolicyStatus CMP0071_status = + target->Makefile->GetPolicyStatus(cmPolicies::CMP0071); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); const cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); - if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { continue; } - if (PropertyEnabled(sf, "GENERATED") && - !target->GetPropertyAsBool("__UNDOCUMENTED_AUTOGEN_GENERATED_FILES")) { - // FIXME: Add a policy whose NEW behavior allows generated files. - // The implementation already works. We disable it here to avoid - // changing behavior for existing projects that do not expect it. + // Real file path + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + // Skip test + const bool mocSkip = !mocEnabled || (setup.mocSkip.count(absFile) != 0); + const bool uicSkip = !uicEnabled || (setup.uicSkip.count(absFile) != 0); + if (mocSkip && uicSkip) { continue; } - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - // Skip flags - const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN"); - const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC"); - const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC"); - // Add file name to skip lists. - // Do this even when the file is not added to the sources/headers lists - // because the file name may be extracted from an other file when - // processing - if (mocSkip) { - mocSkipList.push_back(absFile); - } - if (uicSkip) { - uicSkipList.push_back(absFile); - } - if ((mocTarget && !mocSkip) || (uicTarget && !uicSkip)) { - // Add file name to sources or headers list - switch (fileType) { - case cmSystemTools::CXX_FILE_FORMAT: - mocUicSources.push_back(absFile); - break; - case cmSystemTools::HEADER_FILE_FORMAT: - mocUicHeaders.push_back(absFile); + // For GENERATED files check status of policy CMP0071 + if (sf->GetPropertyAsBool("GENERATED")) { + bool policyAccept = false; + switch (CMP0071_status) { + case cmPolicies::WARN: { + std::ostringstream ost; + ost << cmPolicies::GetPolicyWarning(cmPolicies::CMP0071) << "\n"; + ost << "AUTOMOC/AUTOUIC: Ignoring GENERATED source file:\n"; + ost << " " << cmQtAutoGeneratorCommon::Quoted(absFile) << "\n"; + target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, ost.str()); + } + CM_FALLTHROUGH; + case cmPolicies::OLD: + // Ignore GENERATED file break; - default: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Process GENERATED file + policyAccept = true; break; } + if (!policyAccept) { + continue; + } + } + + // Add file name to sources or headers list + switch (fileType) { + case cmSystemTools::CXX_FILE_FORMAT: + setup.sources.push_back(absFile); + break; + case cmSystemTools::HEADER_FILE_FORMAT: + setup.headers.push_back(absFile); + break; + default: + break; } } } -static void MocSetupAutoTarget( - cmGeneratorTarget const* target, const std::string& autogenTargetName, - std::string const& qtMajorVersion, std::string const& config, - std::vector<std::string> const& configs, - std::vector<std::string> const& mocSkipList, - std::map<std::string, std::string>& configMocIncludes, - std::map<std::string, std::string>& configMocDefines) +static void SetupAutoTargetMoc(cmGeneratorTarget const* target, + std::string const& qtMajorVersion, + std::string const& config, + std::vector<std::string> const& configs, + AutogenSetup& setup) { - cmLocalGenerator* lg = target->GetLocalGenerator(); + cmLocalGenerator* localGen = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); + AddDefinitionEscaped(makefile, "_moc_skip", setup.mocSkip); AddDefinitionEscaped(makefile, "_moc_options", GetSafeProperty(target, "AUTOMOC_MOC_OPTIONS")); - AddDefinitionEscaped(makefile, "_moc_skip", mocSkipList); AddDefinitionEscaped(makefile, "_moc_relaxed_mode", makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE" : "FALSE"); + AddDefinitionEscaped(makefile, "_moc_macro_names", + GetSafeProperty(target, "AUTOMOC_MACRO_NAMES")); AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); @@ -386,42 +433,41 @@ static void MocSetupAutoTarget( GetCompileDefinitionsAndDirectories(target, *li, configIncs, configCompileDefs); if (configIncs != incs) { - configMocIncludes[*li] = cmOutputConverter::EscapeForCMake(configIncs); + setup.configMocIncludes[*li] = configIncs; } if (configCompileDefs != compileDefs) { - configMocDefines[*li] = - cmOutputConverter::EscapeForCMake(configCompileDefs); + setup.configMocDefines[*li] = configCompileDefs; } } } // Moc executable { + std::string mocExec; std::string err; - const char* mocExec = CM_NULLPTR; + if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc"); - if (qt5Moc != CM_NULLPTR) { - mocExec = qt5Moc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::moc"); + if (tgt != nullptr) { + mocExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt5::moc target not found " + autogenTargetName; + err = "AUTOMOC: Qt5::moc target not found"; } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc"); - if (qt4Moc != CM_NULLPTR) { - mocExec = qt4Moc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::moc"); + if (tgt != nullptr) { + mocExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt4::moc target not found " + autogenTargetName; + err = "AUTOMOC: Qt4::moc target not found"; } } else { - err = "The CMAKE_AUTOMOC feature supports only Qt 4 and Qt 5 "; - err += autogenTargetName; + err = "The AUTOMOC feature supports only Qt 4 and Qt 5"; } - // Add definition or error + if (err.empty()) { - AddDefinitionEscaped(makefile, "_qt_moc_executable", - mocExec ? mocExec : ""); + AddDefinitionEscaped(makefile, "_qt_moc_executable", mocExec); } else { + err += " (" + target->GetName() + ")"; cmSystemTools::Error(err.c_str()); } } @@ -435,26 +481,30 @@ static void UicGetOpts(cmGeneratorTarget const* target, optString = cmJoin(opts, ";"); } -static void UicSetupAutoTarget( - cmGeneratorTarget const* target, std::string const& qtMajorVersion, - std::string const& config, std::vector<std::string> const& configs, - std::vector<std::string> const& uicSkipList, - std::map<std::string, std::string>& configUicOptions) +static void SetupAutoTargetUic(cmGeneratorTarget const* target, + std::string const& qtMajorVersion, + std::string const& config, + std::vector<std::string> const& configs, + AutogenSetup& setup) { - cmLocalGenerator* lg = target->GetLocalGenerator(); + cmLocalGenerator* localGen = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); - AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList); + AddDefinitionEscaped(makefile, "_uic_skip", setup.uicSkip); // Uic search paths { std::vector<std::string> uicSearchPaths; - cmSystemTools::ExpandListArgument( - GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths); - const std::string srcDir = makefile->GetCurrentSourceDirectory(); - for (std::vector<std::string>::iterator it = uicSearchPaths.begin(); - it != uicSearchPaths.end(); ++it) { - *it = cmSystemTools::CollapseFullPath(*it, srcDir); + { + const std::string usp = GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"); + if (!usp.empty()) { + cmSystemTools::ExpandListArgument(usp, uicSearchPaths); + const std::string srcDir = makefile->GetCurrentSourceDirectory(); + for (std::vector<std::string>::iterator it = uicSearchPaths.begin(); + it != uicSearchPaths.end(); ++it) { + *it = cmSystemTools::CollapseFullPath(*it, srcDir); + } + } } AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths); } @@ -471,8 +521,7 @@ static void UicSetupAutoTarget( std::string configUicOpts; UicGetOpts(target, *li, configUicOpts); if (configUicOpts != uicOpts) { - configUicOptions[*li] = - cmOutputConverter::EscapeForCMake(configUicOpts); + setup.configUicOptions[*li] = configUicOpts; } } } @@ -481,25 +530,25 @@ static void UicSetupAutoTarget( std::vector<std::string> uiFileFiles; std::vector<std::string> uiFileOptions; { - std::set<std::string> skipped; - skipped.insert(uicSkipList.begin(), uicSkipList.end()); - - const std::vector<cmSourceFile*> uiFilesWithOptions = - makefile->GetQtUiFilesWithOptions(); - for (std::vector<cmSourceFile*>::const_iterator fileIt = - uiFilesWithOptions.begin(); - fileIt != uiFilesWithOptions.end(); ++fileIt) { - cmSourceFile* sf = *fileIt; - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - if (skipped.insert(absFile).second) { - // The file wasn't skipped - uiFileFiles.push_back(absFile); - { - std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); - cmSystemTools::ReplaceString(opts, ";", - cmQtAutoGeneratorCommon::listSep); - uiFileOptions.push_back(opts); + const std::string uiExt = "ui"; + const std::vector<cmSourceFile*>& srcFiles = makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator fit = srcFiles.begin(); + fit != srcFiles.end(); ++fit) { + cmSourceFile* sf = *fit; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + if (sf->GetExtension() == uiExt) { + // Check if the files has uic options + std::string uicOpts = sf->GetProperty("AUTOUIC_OPTIONS"); + if (!uicOpts.empty()) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + // Check if file isn't skipped + if (setup.uicSkip.count(absFile) == 0) { + uiFileFiles.push_back(absFile); + cmSystemTools::ReplaceString(uicOpts, ";", + cmQtAutoGeneratorCommon::listSep); + uiFileOptions.push_back(uicOpts); + } } } } @@ -511,30 +560,30 @@ static void UicSetupAutoTarget( // Uic executable { std::string err; - const char* uicExec = CM_NULLPTR; + std::string uicExec; + if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic"); - if (qt5Uic != CM_NULLPTR) { - uicExec = qt5Uic->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::uic"); + if (tgt != nullptr) { + uicExec = SafeString(tgt->ImportedGetLocation("")); } else { // Project does not use Qt5Widgets, but has AUTOUIC ON anyway } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic"); - if (qt4Uic != CM_NULLPTR) { - uicExec = qt4Uic->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::uic"); + if (tgt != nullptr) { + uicExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt4::uic target not found " + target->GetName(); + err = "AUTOUIC: Qt4::uic target not found"; } } else { - err = "The CMAKE_AUTOUIC feature supports only Qt 4 and Qt 5 "; - err += target->GetName(); + err = "The AUTOUIC feature supports only Qt 4 and Qt 5"; } - // Add definition or error + if (err.empty()) { - AddDefinitionEscaped(makefile, "_qt_uic_executable", - uicExec ? uicExec : ""); + AddDefinitionEscaped(makefile, "_qt_uic_executable", uicExec); } else { + err += " (" + target->GetName() + ")"; cmSystemTools::Error(err.c_str()); } } @@ -544,27 +593,30 @@ static std::string RccGetExecutable(cmGeneratorTarget const* target, const std::string& qtMajorVersion) { std::string rccExec; - cmLocalGenerator* lg = target->GetLocalGenerator(); + std::string err; + + cmLocalGenerator* localGen = target->GetLocalGenerator(); if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc"); - if (qt5Rcc != CM_NULLPTR) { - rccExec = qt5Rcc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::rcc"); + if (tgt != nullptr) { + rccExec = SafeString(tgt->ImportedGetLocation("")); } else { - cmSystemTools::Error("Qt5::rcc target not found ", - target->GetName().c_str()); + err = "AUTORCC: Qt5::rcc target not found"; } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc"); - if (qt4Rcc != CM_NULLPTR) { - rccExec = qt4Rcc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::rcc"); + if (tgt != nullptr) { + rccExec = SafeString(tgt->ImportedGetLocation("")); } else { - cmSystemTools::Error("Qt4::rcc target not found ", - target->GetName().c_str()); + err = "AUTORCC: Qt4::rcc target not found"; } } else { - cmSystemTools::Error( - "The CMAKE_AUTORCC feature supports only Qt 4 and Qt 5 ", - target->GetName().c_str()); + err = "The AUTORCC feature supports only Qt 4 and Qt 5"; + } + + if (!err.empty()) { + err += " (" + target->GetName() + ")"; + cmSystemTools::Error(err.c_str()); } return rccExec; } @@ -606,38 +658,38 @@ static void RccMergeOptions(std::vector<std::string>& opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void RccSetupAutoTarget(cmGeneratorTarget const* target, - const std::string& qtMajorVersion) +static void SetupAutoTargetRcc(cmGeneratorTarget const* target, + const std::string& qtMajorVersion, + const std::vector<cmSourceFile*>& srcFiles) { cmMakefile* makefile = target->Target->GetMakefile(); const bool qtMajorVersion5 = (qtMajorVersion == "5"); const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); - std::vector<std::string> _rcc_files; - std::vector<std::string> _rcc_inputs; + std::vector<std::string> rccFiles; + std::vector<std::string> rccInputs; std::vector<std::string> rccFileFiles; std::vector<std::string> rccFileOptions; std::vector<std::string> rccOptionsTarget; - if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) { - cmSystemTools::ExpandListArgument(opts, rccOptionsTarget); - } - std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmSystemTools::ExpandListArgument(GetSafeProperty(target, "AUTORCC_OPTIONS"), + rccOptionsTarget); + for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); if ((sf->GetExtension() == "qrc") && - !PropertyEnabled(sf, "SKIP_AUTOGEN") && - !PropertyEnabled(sf, "SKIP_AUTORCC")) { - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); + !sf->GetPropertyAsBool("SKIP_AUTOGEN") && + !sf->GetPropertyAsBool("SKIP_AUTORCC")) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); // qrc file - _rcc_files.push_back(absFile); + rccFiles.push_back(absFile); // qrc file entries { std::string entriesList = "{"; // Read input file list only for non generated .qrc files. - if (!PropertyEnabled(sf, "GENERATED")) { + if (!sf->GetPropertyAsBool("GENERATED")) { std::string error; std::vector<std::string> files; if (cmQtAutoGeneratorCommon::RccListInputs( @@ -648,7 +700,7 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target, } } entriesList += "}"; - _rcc_inputs.push_back(entriesList); + rccInputs.push_back(entriesList); } // rcc options for this qrc file { @@ -670,70 +722,50 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target, } AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand); - AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files); - AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs); + AddDefinitionEscaped(makefile, "_rcc_files", rccFiles); + AddDefinitionEscaped(makefile, "_rcc_inputs", rccInputs); AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles); AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions); } -void cmQtAutoGeneratorInitializer::InitializeAutogenSources( - cmGeneratorTarget* target) -{ - if (target->GetPropertyAsBool("AUTOMOC")) { - cmMakefile* makefile = target->Target->GetMakefile(); - const std::vector<std::string> suffixes = - GetConfigurationSuffixes(makefile); - // Get build directory - const std::string autogenBuildDir = GetAutogenTargetBuildDir(target); - // Register all compilation files as generated - for (std::vector<std::string>::const_iterator it = suffixes.begin(); - it != suffixes.end(); ++it) { - std::string mcFile = autogenBuildDir + "/mocs_compilation"; - mcFile += *it; - mcFile += ".cpp"; - AddGeneratedSource(makefile, mcFile, cmQtAutoGeneratorCommon::MOC); - } - // Mocs compilation file - if (IsMultiConfig(target->GetGlobalGenerator())) { - target->AddSource(autogenBuildDir + "/mocs_compilation_$<CONFIG>.cpp"); - } else { - target->AddSource(autogenBuildDir + "/mocs_compilation.cpp"); - } - } -} - void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( - cmLocalGenerator* lg, cmGeneratorTarget* target) + cmLocalGenerator* localGen, cmGeneratorTarget* target) { cmMakefile* makefile = target->Target->GetMakefile(); + cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator(); // Create a custom target for running generators at buildtime const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); - const bool multiConfig = IsMultiConfig(target->GetGlobalGenerator()); + const bool multiConfig = AutogenMultiConfig(globalGen); const std::string autogenTargetName = GetAutogenTargetName(target); const std::string autogenBuildDir = GetAutogenTargetBuildDir(target); const std::string workingDirectory = cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory()); - const std::string qtMajorVersion = GetQtMajorVersion(target); - const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile); - std::vector<std::string> autogenDepends; + std::set<std::string> autogenDependsSet; std::vector<std::string> autogenProvides; + bool usePRE_BUILD = false; + if (globalGen->GetName().find("Visual Studio") != std::string::npos) { + // Under VS use a PRE_BUILD event instead of a separate target to + // reduce the number of targets loaded into the IDE. + // This also works around a VS 11 bug that may skip updating the target: + // https://connect.microsoft.com/VisualStudio/feedback/details/769495 + usePRE_BUILD = true; + } + // Remove build directories on cleanup - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - autogenBuildDir.c_str(), false); + AddCleanFile(makefile, autogenBuildDir); // Remove old settings on cleanup { std::string base = GetAutogenTargetFilesDir(target); + base += "/AutogenOldSettings"; for (std::vector<std::string>::const_iterator it = suffixes.begin(); it != suffixes.end(); ++it) { - std::string fname = base + "/AutogenOldSettings" + *it + ".cmake"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fname.c_str(), - false); + AddCleanFile(makefile, base + *it + ".cmake"); } } @@ -777,151 +809,173 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( // Add moc compilation to generated files list if (mocEnabled) { - for (std::vector<std::string>::const_iterator it = suffixes.begin(); - it != suffixes.end(); ++it) { - std::string mcFile = autogenBuildDir + "/mocs_compilation"; - mcFile += *it; - mcFile += ".cpp"; - autogenProvides.push_back(mcFile); - } + const std::string mocsComp = autogenBuildDir + "/mocs_compilation.cpp"; + AddGeneratedSource(target, mocsComp, cmQtAutoGeneratorCommon::MOC); + autogenProvides.push_back(mocsComp); } // Add autogen includes directory to the origin target INCLUDE_DIRECTORIES if (mocEnabled || uicEnabled) { + std::string includeDir = autogenBuildDir + "/include"; if (multiConfig) { - target->AddIncludeDirectory(autogenBuildDir + "/include_$<CONFIG>", - true); - - } else { - target->AddIncludeDirectory(autogenBuildDir + "/include", true); + includeDir += "_$<CONFIG>"; } + target->AddIncludeDirectory(includeDir, true); } -#if defined(_WIN32) && !defined(__CYGWIN__) - bool usePRE_BUILD = false; - cmGlobalGenerator* gg = lg->GetGlobalGenerator(); - if (gg->GetName().find("Visual Studio") != std::string::npos) { - // Under VS use a PRE_BUILD event instead of a separate target to - // reduce the number of targets loaded into the IDE. - // This also works around a VS 11 bug that may skip updating the target: - // https://connect.microsoft.com/VisualStudio/feedback/details/769495 - usePRE_BUILD = true; + // Add user defined autogen target dependencies + { + const std::string deps = GetSafeProperty(target, "AUTOGEN_TARGET_DEPENDS"); + if (!deps.empty()) { + std::vector<std::string> extraDepends; + cmSystemTools::ExpandListArgument(deps, extraDepends); + autogenDependsSet.insert(extraDepends.begin(), extraDepends.end()); + } } -#endif - - // Initialize autogen target dependencies - if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) { - cmSystemTools::ExpandListArgument(deps, autogenDepends); + // Add utility target dependencies to the autogen dependencies + { + const std::set<std::string>& utils = target->Target->GetUtilities(); + for (std::set<std::string>::const_iterator it = utils.begin(); + it != utils.end(); ++it) { + const std::string& targetName = *it; + if (makefile->FindTargetToUse(targetName) != nullptr) { + autogenDependsSet.insert(targetName); + } + } } - // Add link library targets to the autogen dependencies + // Add link library target dependencies to the autogen dependencies { const cmTarget::LinkLibraryVectorType& libVec = target->Target->GetOriginalLinkLibraries(); for (cmTarget::LinkLibraryVectorType::const_iterator it = libVec.begin(); it != libVec.end(); ++it) { const std::string& libName = it->first; - if (makefile->FindTargetToUse(libName) != CM_NULLPTR) { - autogenDepends.push_back(libName); + if (makefile->FindTargetToUse(libName) != nullptr) { + autogenDependsSet.insert(libName); } } } + + // Extract relevant source files + std::vector<std::string> generatedSources; + std::vector<std::pair<std::string, bool> > qrcSources; { - cmFilePathChecksum fpathCheckSum(makefile); - // Iterate over all source files + const std::string qrcExt = "qrc"; std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; - if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) { - std::string const& ext = sf->GetExtension(); - // Add generated file that will be scanned by moc or uic to - // the dependencies - if (mocEnabled || uicEnabled) { - const cmSystemTools::FileFormat fileType = - cmSystemTools::GetFileFormat(ext.c_str()); - if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || - (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { - if (PropertyEnabled(sf, "GENERATED")) { - if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) || - (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) { - autogenDepends.push_back( - cmsys::SystemTools::GetRealPath(sf->GetFullPath())); -#if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD with generated files - usePRE_BUILD = false; -#endif - } + if (sf->GetPropertyAsBool("SKIP_AUTOGEN")) { + continue; + } + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + const std::string& ext = sf->GetExtension(); + // Register generated files that will be scanned by moc or uic + if (mocEnabled || uicEnabled) { + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(ext.c_str()); + if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || + (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + if (sf->GetPropertyAsBool("GENERATED")) { + if ((mocEnabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) || + (uicEnabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) { + generatedSources.push_back( + cmsys::SystemTools::GetRealPath(fPath)); } } } - // Process rcc enabled files - if (rccEnabled && (ext == "qrc") && - !PropertyEnabled(sf, "SKIP_AUTORCC")) { - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - - // Compose rcc output file name - { - std::string rccOutBase = autogenBuildDir + "/"; - rccOutBase += fpathCheckSum.getPart(absFile); - rccOutBase += "/qrc_"; - rccOutBase += - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); - - // Register rcc ouput file as generated - for (std::vector<std::string>::const_iterator it = - suffixes.begin(); - it != suffixes.end(); ++it) { - std::string rccOutCfg = rccOutBase; - rccOutCfg += *it; - rccOutCfg += ".cpp"; - AddGeneratedSource(makefile, rccOutCfg, - cmQtAutoGeneratorCommon::RCC); - autogenProvides.push_back(rccOutCfg); - } - // Add rcc output file to origin target sources - if (multiConfig) { - target->AddSource(rccOutBase + "_$<CONFIG>.cpp"); - } else { - target->AddSource(rccOutBase + ".cpp"); - } - } + } + // Register rcc enabled files + if (rccEnabled && (ext == qrcExt) && + !sf->GetPropertyAsBool("SKIP_AUTORCC")) { + qrcSources.push_back( + std::pair<std::string, bool>(cmsys::SystemTools::GetRealPath(fPath), + sf->GetPropertyAsBool("GENERATED"))); + } + } + // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's + // sources meta data cache. Clear it so that OBJECT library targets that + // are AUTOGEN initialized after this target get their added + // mocs_compilation.cpp source acknowledged by this target. + target->ClearSourcesCache(); + } + + if (!generatedSources.empty()) { + for (std::vector<std::string>::const_iterator it = + generatedSources.begin(); + it != generatedSources.end(); ++it) { + autogenDependsSet.insert(*it); + } + } + + if (!qrcSources.empty()) { + const std::string qtMajorVersion = GetQtMajorVersion(target); + const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); + const cmFilePathChecksum fpathCheckSum(makefile); + for (std::vector<std::pair<std::string, bool> >::const_iterator it = + qrcSources.begin(); + it != qrcSources.end(); ++it) { + const std::string& absFile = it->first; + + // Compose rcc output file name + { + std::string rccBuildFile = autogenBuildDir + "/"; + rccBuildFile += fpathCheckSum.getPart(absFile); + rccBuildFile += "/qrc_"; + rccBuildFile += + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); + rccBuildFile += ".cpp"; + + // Register rcc ouput file as generated + AddGeneratedSource(target, rccBuildFile, cmQtAutoGeneratorCommon::RCC); + // Register rcc ouput file as generated by the _autogen target + autogenProvides.push_back(rccBuildFile); + } - if (PropertyEnabled(sf, "GENERATED")) { - // Add generated qrc file to the dependencies - autogenDepends.push_back(absFile); + if (it->second) { + // Add generated qrc file to the dependencies + autogenDependsSet.insert(absFile); + } else { + // Run cmake again when .qrc file changes + makefile->AddCMakeDependFile(absFile); + // Add the qrc input files to the dependencies + { + std::string error; + std::vector<std::string> extraDepends; + if (cmQtAutoGeneratorCommon::RccListInputs( + qtMajorVersion, rccCommand, absFile, extraDepends, &error)) { + autogenDependsSet.insert(extraDepends.begin(), extraDepends.end()); } else { - // Run cmake again when .qrc file changes - makefile->AddCMakeDependFile(absFile); - - // Add the qrc input files to the dependencies - std::string error; - if (!cmQtAutoGeneratorCommon::RccListInputs( - qtMajorVersion, rccCommand, absFile, autogenDepends, - &error)) { - cmSystemTools::Error(error.c_str()); - } + cmSystemTools::Error(error.c_str()); } -#if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD because the resource files themselves - // may not be sources within the target so VS may not know the - // target needs to re-build at all. - usePRE_BUILD = false; -#endif } } } } -#if defined(_WIN32) && !defined(__CYGWIN__) + // Convert std::set to std::vector + const std::vector<std::string> autogenDepends(autogenDependsSet.begin(), + autogenDependsSet.end()); + // Disable PRE_BUILD on demand if (usePRE_BUILD) { - // If the autogen target depends on an other target don't use PRE_BUILD - for (std::vector<std::string>::iterator it = autogenDepends.begin(); - it != autogenDepends.end(); ++it) { - if (makefile->FindTargetToUse(*it) != CM_NULLPTR) { - usePRE_BUILD = false; - break; + if (!generatedSources.empty() || !qrcSources.empty()) { + // - Cannot use PRE_BUILD with generated files + // - Cannot use PRE_BUILD because the resource files themselves + // may not be sources within the target so VS may not know the + // target needs to re-build at all. + usePRE_BUILD = false; + } + if (usePRE_BUILD) { + // If the autogen target depends on an other target don't use PRE_BUILD + for (std::vector<std::string>::const_iterator it = + autogenDepends.begin(); + it != autogenDepends.end(); ++it) { + if (makefile->FindTargetToUse(*it) != nullptr) { + usePRE_BUILD = false; + break; + } } } } @@ -936,31 +990,33 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); target->Target->AddPreBuildCommand(cc); - } else -#endif - { + } else { cmTarget* autogenTarget = makefile->AddUtilityCommand( autogenTargetName, true, workingDirectory.c_str(), /*byproducts=*/autogenProvides, autogenDepends, commandLines, false, autogenComment.c_str()); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - lg->AddGeneratorTarget(gt); + localGen->AddGeneratorTarget( + new cmGeneratorTarget(autogenTarget, localGen)); - // Set target folder - const char* autogenFolder = - makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); - if (!autogenFolder) { - autogenFolder = - makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); - } - if (autogenFolder && *autogenFolder) { - autogenTarget->SetProperty("FOLDER", autogenFolder); - } else { - // inherit FOLDER property from target (#13688) - utilCopyTargetProperty(gt->Target, target->Target, "FOLDER"); + // Set autogen target FOLDER + { + const char* autogenFolder = + makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); + if (autogenFolder == nullptr) { + autogenFolder = + makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); + } + // Inherit FOLDER property from target (#13688) + if (autogenFolder == nullptr) { + autogenFolder = target->Target->GetProperty("FOLDER"); + } + if ((autogenFolder != nullptr) && (*autogenFolder != '\0')) { + autogenTarget->SetProperty("FOLDER", autogenFolder); + } } + // Add autogen target to the origin target dependencies target->Target->AddUtility(autogenTargetName); } } @@ -978,54 +1034,46 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( std::string config; const std::vector<std::string> configs(GetConfigurations(makefile, &config)); - // Configurations settings buffers + // Configuration suffixes std::map<std::string, std::string> configSuffix; - std::map<std::string, std::string> configMocIncludes; - std::map<std::string, std::string> configMocDefines; - std::map<std::string, std::string> configUicOptions; - - // Configuration suffix - if (IsMultiConfig(target->GetGlobalGenerator())) { + if (AutogenMultiConfig(target->GetGlobalGenerator())) { for (std::vector<std::string>::const_iterator it = configs.begin(); it != configs.end(); ++it) { configSuffix[*it] = "_" + *it; } } + // Configurations settings buffers + AutogenSetup setup; + // Basic setup { const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); - const std::string autogenTargetName = GetAutogenTargetName(target); const std::string qtMajorVersion = GetQtMajorVersion(target); - - std::vector<std::string> sources; - std::vector<std::string> headers; - - if (mocEnabled || uicEnabled || rccEnabled) { - std::vector<std::string> mocSkipList; - std::vector<std::string> uicSkipList; - AcquireScanFiles(target, sources, headers, mocSkipList, uicSkipList); - if (mocEnabled) { - MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion, config, - configs, mocSkipList, configMocIncludes, - configMocDefines); - } - if (uicEnabled) { - UicSetupAutoTarget(target, qtMajorVersion, config, configs, - uicSkipList, configUicOptions); + { + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + if (mocEnabled || uicEnabled) { + SetupAcquireScanFiles(target, mocEnabled, uicEnabled, srcFiles, setup); + if (mocEnabled) { + SetupAutoTargetMoc(target, qtMajorVersion, config, configs, setup); + } + if (uicEnabled) { + SetupAutoTargetUic(target, qtMajorVersion, config, configs, setup); + } } if (rccEnabled) { - RccSetupAutoTarget(target, qtMajorVersion); + SetupAutoTargetRcc(target, qtMajorVersion, srcFiles); } } - AddDefinitionEscaped(makefile, "_autogen_build_dir", + AddDefinitionEscaped(makefile, "_build_dir", GetAutogenTargetBuildDir(target)); AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion); - AddDefinitionEscaped(makefile, "_sources", sources); - AddDefinitionEscaped(makefile, "_headers", headers); + AddDefinitionEscaped(makefile, "_sources", setup.sources); + AddDefinitionEscaped(makefile, "_headers", setup.headers); } // Generate info file @@ -1038,8 +1086,8 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( } // Append custom definitions to info file on demand - if (!configSuffix.empty() || !configMocDefines.empty() || - !configMocIncludes.empty() || !configUicOptions.empty()) { + if (!configSuffix.empty() || !setup.configMocDefines.empty() || + !setup.configMocIncludes.empty() || !setup.configUicOptions.empty()) { // Ensure we have write permission in case .in was read-only. mode_t perm = 0; @@ -1061,29 +1109,29 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( it = configSuffix.begin(), end = configSuffix.end(); it != end; ++it) { - ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configMocDefines.begin(), - end = configMocDefines.end(); + it = setup.configMocDefines.begin(), + end = setup.configMocDefines.end(); it != end; ++it) { - ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configMocIncludes.begin(), - end = configMocIncludes.end(); + it = setup.configMocIncludes.begin(), + end = setup.configMocIncludes.end(); it != end; ++it) { - ofs << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_MOC_INCLUDES_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configUicOptions.begin(), - end = configUicOptions.end(); + it = setup.configUicOptions.begin(), + end = setup.configUicOptions.end(); it != end; ++it) { - ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } } else { // File open error diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h index ca806f5..48ae70e 100644 --- a/Source/cmQtAutoGeneratorInitializer.h +++ b/Source/cmQtAutoGeneratorInitializer.h @@ -11,8 +11,7 @@ class cmLocalGenerator; class cmQtAutoGeneratorInitializer { public: - static void InitializeAutogenSources(cmGeneratorTarget* target); - static void InitializeAutogenTarget(cmLocalGenerator* lg, + static void InitializeAutogenTarget(cmLocalGenerator* localGen, cmGeneratorTarget* target); static void SetupAutoGenerateTarget(cmGeneratorTarget const* target); }; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c79f66d..e51033a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -3,7 +3,6 @@ #include "cmQtAutoGenerators.h" #include "cmQtAutoGeneratorCommon.h" -#include "cmConfigure.h" #include "cmsys/FStream.hxx" #include "cmsys/Terminal.h" #include <algorithm> @@ -81,7 +80,7 @@ static void InfoGet(cmMakefile* makefile, const char* key, static void InfoGetConfig(cmMakefile* makefile, const char* key, const std::string& config, std::string& value) { - const char* valueConf = CM_NULLPTR; + const char* valueConf = nullptr; { std::string keyConf = key; if (!config.empty()) { @@ -90,7 +89,7 @@ static void InfoGetConfig(cmMakefile* makefile, const char* key, } valueConf = makefile->GetDefinition(keyConf); } - if (valueConf == CM_NULLPTR) { + if (valueConf == nullptr) { valueConf = makefile->GetSafeDefinition(key); } value = valueConf; @@ -280,10 +279,10 @@ cmQtAutoGenerators::cmQtAutoGenerators() } // Moc macro filters - this->MocMacroFilters[0].first = "Q_OBJECT"; - this->MocMacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - this->MocMacroFilters[1].first = "Q_GADGET"; - this->MocMacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_OBJECT", "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]")); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_GADGET", "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]")); // Precompile regular expressions this->MocRegExpInclude.compile( @@ -364,6 +363,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return false; } + // -- Meta + InfoGetConfig(makefile, "AM_CONFIG_SUFFIX", config, this->ConfigSuffix); + // - Old settings file { this->SettingsFile = cmSystemTools::CollapseFullPath(targetDirectory); @@ -373,9 +375,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( this->SettingsFile += ".cmake"; } - // -- Meta - InfoGetConfig(makefile, "AM_CONFIG_SUFFIX", config, this->ConfigSuffix); - // - Files and directories InfoGet(makefile, "AM_CMAKE_SOURCE_DIR", this->ProjectSourceDir); InfoGet(makefile, "AM_CMAKE_BINARY_DIR", this->ProjectBinaryDir); @@ -400,7 +399,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); - InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); // Check Qt version if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { this->LogError("AutoGen: Error: Unsupported Qt version: " + @@ -425,6 +423,16 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions); InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode); { + std::vector<std::string> MocMacroNames; + InfoGet(makefile, "AM_MOC_MACRO_NAMES", MocMacroNames); + for (std::vector<std::string>::const_iterator dit = + MocMacroNames.begin(); + dit != MocMacroNames.end(); ++dit) { + this->MocMacroFilters.push_back( + MocMacroFilter(*dit, "[^a-zA-Z0-9_]" + *dit + "[^a-zA-Z0-9_]")); + } + } + { std::vector<std::string> mocDependFilters; InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters); // Insert Q_PLUGIN_METADATA dependency filter @@ -450,6 +458,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return false; } } + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); } // - Uic @@ -634,9 +643,7 @@ bool cmQtAutoGenerators::SettingsFileWrite() void cmQtAutoGenerators::Init(cmMakefile* makefile) { // Mocs compilation file - this->MocCompFileRel = "mocs_compilation"; - this->MocCompFileRel += this->ConfigSuffix; - this->MocCompFileRel += ".cpp"; + this->MocCompFileRel = "mocs_compilation.cpp"; this->MocCompFileAbs = cmSystemTools::CollapseCombinedPath( this->AutogenBuildDir, this->MocCompFileRel); @@ -647,7 +654,9 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) // Moc predefs file if (!this->MocPredefsCmd.empty()) { - this->MocPredefsFileRel = "moc_predefs.h"; + this->MocPredefsFileRel = "moc_predefs"; + this->MocPredefsFileRel += this->ConfigSuffix; + this->MocPredefsFileRel += ".h"; this->MocPredefsFileAbs = cmSystemTools::CollapseCombinedPath( this->AutogenBuildDir, this->MocPredefsFileRel); } @@ -722,10 +731,10 @@ bool cmQtAutoGenerators::RunAutogen() // the program goes through all .cpp files to see which moc files are // included. It is not really interesting how the moc file is named, but // what file the moc is created from. Once a moc is included the same moc - // may not be included in the mocs_compilation_$<CONFIG>.cpp file anymore. + // may not be included in the mocs_compilation.cpp file anymore. // OTOH if there's a header containing Q_OBJECT where no corresponding // moc file is included anywhere a moc_<filename>.cpp file is created and - // included in the mocs_compilation_$<CONFIG>.cpp file. + // included in the mocs_compilation.cpp file. // Create AUTOGEN include directory { @@ -798,14 +807,16 @@ bool cmQtAutoGenerators::RunAutogen() bool cmQtAutoGenerators::MocRequired(const std::string& contentText, std::string* macroName) { - for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) { - MocMacroFilter& filter = this->MocMacroFilters[ii]; + for (std::vector<MocMacroFilter>::iterator fit = + this->MocMacroFilters.begin(); + fit != this->MocMacroFilters.end(); ++fit) { + MocMacroFilter& filter = *fit; // Run a simple find string operation before the expensive // regular expression check if (contentText.find(filter.first) != std::string::npos) { if (filter.second.find(contentText)) { // Return macro name on demand - if (macroName != CM_NULLPTR) { + if (macroName != nullptr) { *macroName = filter.first; } return true; @@ -927,7 +938,7 @@ void cmQtAutoGenerators::UicParseContent( } const char* contentChars = contentText.c_str(); - if (strstr(contentChars, "ui_") != CM_NULLPTR) { + if (strstr(contentChars, "ui_") != nullptr) { while (this->UicRegExpInclude.find(contentChars)) { uisIncluded[absFilename].push_back(this->UicRegExpInclude.match(1)); contentChars += this->UicRegExpInclude.end(); @@ -961,7 +972,7 @@ bool cmQtAutoGenerators::MocParseSourceContent( // and if the string search already fails, we don't have to try the // expensive regexp const char* contentChars = contentText.c_str(); - if (strstr(contentChars, "moc") != CM_NULLPTR) { + if (strstr(contentChars, "moc") != nullptr) { // Iterate over all included moc files while (this->MocRegExpInclude.find(contentChars)) { const std::string incString = this->MocRegExpInclude.match(1); @@ -1253,7 +1264,9 @@ bool cmQtAutoGenerators::MocGenerateAll( if (!this->MocPredefsCmd.empty()) { if (this->MocSettingsChanged || FileAbsentOrOlder(this->MocPredefsFileAbs, this->SettingsFile)) { - this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel); + if (this->Verbose) { + this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel); + } std::string output; { @@ -1340,7 +1353,9 @@ bool cmQtAutoGenerators::MocGenerateAll( if (this->FileDiffers(this->MocCompFileAbs, automocSource)) { // Actually write mocs compilation file - this->LogBold("Generating MOC compilation " + this->MocCompFileRel); + if (this->Verbose) { + this->LogBold("Generating MOC compilation " + this->MocCompFileRel); + } if (!this->FileWrite("AutoMoc", this->MocCompFileAbs, automocSource)) { return false; } @@ -1391,7 +1406,9 @@ bool cmQtAutoGenerators::MocGenerateFile( } if (generateMoc) { // Log - this->LogBold("Generating MOC source " + mocFileRel); + if (this->Verbose) { + this->LogBold("Generating MOC source " + mocFileRel); + } // Make sure the parent directory exists if (this->MakeParentDirectory("AutoMoc", mocFileAbs)) { @@ -1446,31 +1463,62 @@ bool cmQtAutoGenerators::MocGenerateFile( bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile, const std::string& sourceFile, - const std::string& includeString) + const std::string& searchPath, + const std::string& searchFile) { bool success = false; - // Search in vicinity of the source + std::vector<std::string> testFiles; + // Collect search paths list { - std::string testPath = SubDirPrefix(sourceFile); - testPath += includeString; - if (cmsys::SystemTools::FileExists(testPath.c_str())) { - absFile = cmsys::SystemTools::GetRealPath(testPath); + const std::string searchFileFull = searchPath + searchFile; + // Vicinity of the source + { + const std::string sourcePath = SubDirPrefix(sourceFile); + testFiles.push_back(sourcePath + searchFile); + if (!searchPath.empty()) { + testFiles.push_back(sourcePath + searchFileFull); + } + } + // AUTOUIC search paths + if (!this->UicSearchPaths.empty()) { + for (std::vector<std::string>::const_iterator iit = + this->UicSearchPaths.begin(); + iit != this->UicSearchPaths.end(); ++iit) { + testFiles.push_back(*iit + "/" + searchFile); + } + if (!searchPath.empty()) { + for (std::vector<std::string>::const_iterator iit = + this->UicSearchPaths.begin(); + iit != this->UicSearchPaths.end(); ++iit) { + testFiles.push_back(*iit + "/" + searchFileFull); + } + } + } + } + + // Search for the .ui file! + for (std::vector<std::string>::const_iterator iit = testFiles.begin(); + iit != testFiles.end(); ++iit) { + const std::string& testFile = *iit; + if (cmsys::SystemTools::FileExists(testFile.c_str())) { + absFile = cmsys::SystemTools::GetRealPath(testFile); success = true; + break; } } - // Search in include directories + + // Log error if (!success) { - for (std::vector<std::string>::const_iterator iit = - this->UicSearchPaths.begin(); - iit != this->UicSearchPaths.end(); ++iit) { - const std::string fullPath = ((*iit) + '/' + includeString); - if (cmsys::SystemTools::FileExists(fullPath.c_str())) { - absFile = cmsys::SystemTools::GetRealPath(fullPath); - success = true; - break; - } + std::ostringstream ost; + ost << "AutoUic: Error: " << Quoted(sourceFile) << "\n"; + ost << "Could not find " << Quoted(searchFile) << " in\n"; + for (std::vector<std::string>::const_iterator iit = testFiles.begin(); + iit != testFiles.end(); ++iit) { + ost << " " << Quoted(*iit) << "\n"; } + this->LogError(ost.str()); } + return success; } @@ -1500,16 +1548,14 @@ bool cmQtAutoGenerators::UicGenerateAll( const std::string uiBasePath = SubDirPrefix(*uit); const std::string uiBaseName = cmsys::SystemTools::GetFilenameWithoutLastExtension(*uit).substr(3); - const std::string searchFileName = uiBasePath + uiBaseName + ".ui"; + const std::string uiFileName = uiBaseName + ".ui"; std::string uiInputFile; - if (UicFindIncludedFile(uiInputFile, source, searchFileName)) { + if (UicFindIncludedFile(uiInputFile, source, uiBasePath, uiFileName)) { std::string uiOutputFile = uiBasePath + "ui_" + uiBaseName + ".h"; cmSystemTools::ReplaceString(uiOutputFile, "..", "__"); uiGenMap[uiInputFile] = uiOutputFile; testMap[uiInputFile] = uiOutputFile; } else { - this->LogError("AutoUic: Error: " + Quoted(sit->first) + - "\nCould not find " + Quoted(searchFileName)); return false; } } @@ -1567,7 +1613,9 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName, } if (generateUic) { // Log - this->LogBold("Generating UIC header " + uicFileRel); + if (this->Verbose) { + this->LogBold("Generating UIC header " + uicFileRel); + } // Make sure the parent directory exists if (this->MakeParentDirectory("AutoUic", uicFileAbs)) { @@ -1673,10 +1721,10 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, { bool rccGenerated = false; bool generateRcc = this->RccSettingsChanged; - const std::string rccBuildFile = cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, rccOutputFile); + // Check if regeneration is required if (!generateRcc) { // Test if the resources list file is newer than build file generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile); @@ -1692,13 +1740,13 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, readFiles, &error)) { files = &readFiles; } else { - files = CM_NULLPTR; + files = nullptr; this->LogError(error); this->RccRunFailed = true; } } // Test if any input file is newer than the build file - if (files != CM_NULLPTR) { + if (files != nullptr) { for (std::vector<std::string>::const_iterator it = files->begin(); it != files->end(); ++it) { if (FileAbsentOrOlder(rccBuildFile, *it)) { @@ -1709,9 +1757,12 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, } } } + // Regenerate on demand if (generateRcc) { // Log - this->LogBold("Generating RCC source " + rccOutputFile); + if (this->Verbose) { + this->LogBold("Generating RCC source " + rccOutputFile); + } // Make sure the parent directory exists if (this->MakeParentDirectory("AutoRcc", rccBuildFile)) { @@ -1764,6 +1815,41 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, this->RccRunFailed = true; } } + // For a multi configuration generator generate a wrapper file + if (!this->ConfigSuffix.empty() && !this->RccRunFailed) { + // Wrapper file name + const std::string cppSuffix = ".cpp"; + const size_t suffixLength = this->ConfigSuffix.size() + cppSuffix.size(); + const std::string wrapperFileRel = + rccOutputFile.substr(0, rccOutputFile.size() - suffixLength) + cppSuffix; + const std::string wrapperFileAbs = cmSystemTools::CollapseCombinedPath( + this->AutogenBuildDir, wrapperFileRel); + // Wrapper file content + std::string content = + "// This is an autogenerated configuration wrapper file. Do not edit.\n" + "#include \""; + content += cmsys::SystemTools::GetFilenameName(rccBuildFile); + content += "\"\n"; + // Write content to file + if (this->FileDiffers(wrapperFileAbs, content)) { + // Write new wrapper file if the content differs + if (this->Verbose) { + this->LogBold("Generating RCC wrapper " + wrapperFileRel); + } + if (!this->FileWrite("AutoRcc", wrapperFileAbs, content)) { + // Error + rccGenerated = false; + this->RccRunFailed = true; + } + } else if (rccGenerated) { + // Only touch wrapper file if the content matches + if (this->Verbose) { + this->LogInfo("Touching RCC wrapper " + wrapperFileRel); + } + cmSystemTools::Touch(wrapperFileAbs, false); + } + } + return rccGenerated; } @@ -1956,7 +2042,7 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, // Execute command int retVal = 0; bool res = cmSystemTools::RunSingleCommand( - command, &output, &output, &retVal, CM_NULLPTR, + command, &output, &output, &retVal, nullptr, verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE); return (res && (retVal == 0)); } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index b525364..a8eb961 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -59,7 +59,7 @@ private: // -- Content analysis bool MocRequired(const std::string& contentText, - std::string* macroName = CM_NULLPTR); + std::string* macroName = nullptr); void MocFindDepends( const std::string& absFilename, const std::string& contentText, std::map<std::string, std::set<std::string> >& mocDepends); @@ -112,7 +112,8 @@ private: // -- Uic file generation bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile, - const std::string& includeString); + const std::string& searchPath, + const std::string& searchFile); bool UicGenerateAll( const std::map<std::string, std::vector<std::string> >& includedUis); bool UicGenerateFile(const std::string& realName, @@ -200,7 +201,7 @@ private: std::vector<std::string> MocOptions; std::vector<std::string> MocPredefsCmd; std::vector<MocDependFilter> MocDependFilters; - MocMacroFilter MocMacroFilters[2]; + std::vector<MocMacroFilter> MocMacroFilters; cmsys::RegularExpression MocRegExpInclude; // -- Uic bool UicSettingsChanged; diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index f2e89f6..9e035d7 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -3,7 +3,7 @@ #ifndef cmRemoveCommand_h #define cmRemoveCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 9a9a5d5..c2c6b0e 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -3,7 +3,7 @@ #ifndef cmRemoveDefinitionsCommand_h #define cmRemoveDefinitionsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index 87900e7..53c91cd 100644 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -3,7 +3,7 @@ #ifndef cmReturnCommand_h #define cmReturnCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 753a1ba..768e15a 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -10,7 +10,7 @@ cmScriptGenerator::cmScriptGenerator( : RuntimeConfigVariable(config_var) , Configurations(configurations) , ConfigurationName("") - , ConfigurationTypes(CM_NULLPTR) + , ConfigurationTypes(nullptr) , ActionsPerConfig(false) { } @@ -27,7 +27,7 @@ void cmScriptGenerator::Generate( this->ConfigurationTypes = &configurationTypes; this->GenerateScript(os); this->ConfigurationName = ""; - this->ConfigurationTypes = CM_NULLPTR; + this->ConfigurationTypes = nullptr; } static void cmScriptGeneratorEncodeConfig(const std::string& config, diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index d0879c6..c8fed19 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -3,7 +3,7 @@ #ifndef cmScriptGenerator_h #define cmScriptGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <ostream> #include <string> diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 0df6e0c..0f2ef6e 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -42,7 +42,7 @@ void cmSearchPath::AddPath(const std::string& path) void cmSearchPath::AddUserPath(const std::string& path) { - assert(this->FC != CM_NULLPTR); + assert(this->FC != nullptr); std::vector<std::string> outPaths; @@ -77,7 +77,7 @@ void cmSearchPath::AddUserPath(const std::string& path) void cmSearchPath::AddCMakePath(const std::string& variable) { - assert(this->FC != CM_NULLPTR); + assert(this->FC != nullptr); // Get a path from a CMake variable. if (const char* value = this->FC->Makefile->GetDefinition(variable)) { @@ -104,7 +104,7 @@ void cmSearchPath::AddEnvPath(const std::string& variable) void cmSearchPath::AddCMakePrefixPath(const std::string& variable) { - assert(this->FC != CM_NULLPTR); + assert(this->FC != nullptr); // Get a path from a CMake variable. if (const char* value = this->FC->Makefile->GetDefinition(variable)) { @@ -168,7 +168,7 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes) void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, const char* base) { - assert(this->FC != CM_NULLPTR); + assert(this->FC != nullptr); // default for programs std::string subdir = "bin"; @@ -209,7 +209,7 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, void cmSearchPath::AddPathInternal(const std::string& path, const char* base) { - assert(this->FC != CM_NULLPTR); + assert(this->FC != nullptr); std::string collapsed = cmSystemTools::CollapseFullPath(path, base); diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h index 932022a..fd0c7c5 100644 --- a/Source/cmSearchPath.h +++ b/Source/cmSearchPath.h @@ -3,7 +3,7 @@ #ifndef cmSearchPath_h #define cmSearchPath_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> @@ -23,7 +23,7 @@ public: // cmSearchPath must be initialized from a valid pointer. The only reason // for the default is to allow it to be easily used in stl containers. // Attempting to initialize with a NULL value will fail an assertion - cmSearchPath(cmFindCommon* findCmd = CM_NULLPTR); + cmSearchPath(cmFindCommon* findCmd = nullptr); ~cmSearchPath(); const std::vector<std::string>& GetPaths() const { return this->Paths; } @@ -42,8 +42,8 @@ public: protected: void AddPrefixPaths(const std::vector<std::string>& paths, - const char* base = CM_NULLPTR); - void AddPathInternal(const std::string& path, const char* base = CM_NULLPTR); + const char* base = nullptr); + void AddPathInternal(const std::string& path, const char* base = nullptr); cmFindCommon* FC; std::vector<std::string> Paths; diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 6bf8549..2d4c7cd 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -3,7 +3,7 @@ #ifndef cmSeparateArgumentsCommand_h #define cmSeparateArgumentsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 7fc6ed7..c3e6811 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -2,7 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmServer.h" -#include "cmServerConnection.h" +#include "cmAlgorithms.h" +#include "cmConnection.h" +#include "cmFileMonitor.h" #include "cmServerDictionary.h" #include "cmServerProtocol.h" #include "cmSystemTools.h" @@ -14,8 +16,23 @@ #include <algorithm> #include <cassert> #include <cstdint> +#include <memory> #include <utility> +void on_signal(uv_signal_t* signal, int signum) +{ + auto conn = reinterpret_cast<cmServerBase*>(signal->data); + conn->OnSignal(signum); +} + +static void on_walk_to_shutdown(uv_handle_t* handle, void* arg) +{ + (void)arg; + if (!uv_is_closing(handle)) { + uv_close(handle, &cmEventBasedConnection::on_close); + } +} + class cmServer::DebugInfo { public: @@ -30,13 +47,12 @@ public: uint64_t StartTime; }; -cmServer::cmServer(cmServerConnection* conn, bool supportExperimental) - : Connection(conn) +cmServer::cmServer(cmConnection* conn, bool supportExperimental) + : cmServerBase(conn) , SupportExperimental(supportExperimental) { - this->Connection->SetServer(this); // Register supported protocols: - this->RegisterProtocol(new cmServerProtocol1_0); + this->RegisterProtocol(new cmServerProtocol1); } cmServer::~cmServer() @@ -48,41 +64,33 @@ cmServer::~cmServer() for (cmServerProtocol* p : this->SupportedProtocols) { delete p; } - - delete this->Connection; } -void cmServer::PopOne() +void cmServer::ProcessRequest(cmConnection* connection, + const std::string& input) { - if (this->Queue.empty()) { - return; - } - Json::Reader reader; Json::Value value; - const std::string input = this->Queue.front(); - this->Queue.erase(this->Queue.begin()); - if (!reader.parse(input, value)) { - this->WriteParseError("Failed to parse JSON input."); + this->WriteParseError(connection, "Failed to parse JSON input."); return; } std::unique_ptr<DebugInfo> debug; Json::Value debugValue = value["debug"]; if (!debugValue.isNull()) { - debug = std::make_unique<DebugInfo>(); + debug = cm::make_unique<DebugInfo>(); debug->OutputFile = debugValue["dumpToFile"].asString(); debug->PrintStatistics = debugValue["showStats"].asBool(); } - const cmServerRequest request(this, value[kTYPE_KEY].asString(), + const cmServerRequest request(this, connection, value[kTYPE_KEY].asString(), value[kCOOKIE_KEY].asString(), value); if (request.Type == "") { cmServerResponse response(request); response.SetError("No type given in request."); - this->WriteResponse(response, nullptr); + this->WriteResponse(connection, response, nullptr); return; } @@ -91,9 +99,11 @@ void cmServer::PopOne() if (this->Protocol) { this->Protocol->CMakeInstance()->SetProgressCallback( reportProgress, const_cast<cmServerRequest*>(&request)); - this->WriteResponse(this->Protocol->Process(request), debug.get()); + this->WriteResponse(connection, this->Protocol->Process(request), + debug.get()); } else { - this->WriteResponse(this->SetProtocolVersion(request), debug.get()); + this->WriteResponse(connection, this->SetProtocolVersion(request), + debug.get()); } } @@ -115,7 +125,7 @@ void cmServer::RegisterProtocol(cmServerProtocol* protocol) } } -void cmServer::PrintHello() const +void cmServer::PrintHello(cmConnection* connection) const { Json::Value hello = Json::objectValue; hello[kTYPE_KEY] = "hello"; @@ -134,13 +144,7 @@ void cmServer::PrintHello() const protocolVersions.append(tmp); } - this->WriteJsonObject(hello, nullptr); -} - -void cmServer::QueueRequest(const std::string& request) -{ - this->Queue.push_back(request); - this->PopOne(); + this->WriteJsonObject(connection, hello, nullptr); } void cmServer::reportProgress(const char* msg, float progress, void* data) @@ -216,7 +220,7 @@ cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) std::string errorMessage; if (!this->Protocol->Activate(this, request, &errorMessage)) { - this->Protocol = CM_NULLPTR; + this->Protocol = nullptr; return request.ReportError("Failed to activate protocol version: " + errorMessage); } @@ -232,17 +236,26 @@ bool cmServer::Serve(std::string* errorMessage) } assert(!this->Protocol); - return Connection->ProcessEvents(errorMessage); + return cmServerBase::Serve(errorMessage); } cmFileMonitor* cmServer::FileMonitor() const { - return Connection->FileMonitor(); + return fileMonitor.get(); } void cmServer::WriteJsonObject(const Json::Value& jsonValue, const DebugInfo* debug) const { + for (auto& connection : this->Connections) { + WriteJsonObject(connection.get(), jsonValue, debug); + } +} + +void cmServer::WriteJsonObject(cmConnection* connection, + const Json::Value& jsonValue, + const DebugInfo* debug) const +{ Json::FastWriter writer; auto beforeJson = uv_hrtime(); @@ -272,7 +285,7 @@ void cmServer::WriteJsonObject(const Json::Value& jsonValue, } } - Connection->WriteData(std::string("\n") + kSTART_MAGIC + std::string("\n") + + connection->WriteData(std::string("\n") + kSTART_MAGIC + std::string("\n") + result + kEND_MAGIC + std::string("\n")); } @@ -311,7 +324,7 @@ void cmServer::WriteProgress(const cmServerRequest& request, int min, obj[kPROGRESS_MAXIMUM_KEY] = max; obj[kPROGRESS_CURRENT_KEY] = current; - this->WriteJsonObject(obj, nullptr); + this->WriteJsonObject(request.Connection, obj, nullptr); } void cmServer::WriteMessage(const cmServerRequest& request, @@ -331,10 +344,11 @@ void cmServer::WriteMessage(const cmServerRequest& request, obj[kTITLE_KEY] = title; } - WriteJsonObject(obj, nullptr); + WriteJsonObject(request.Connection, obj, nullptr); } -void cmServer::WriteParseError(const std::string& message) const +void cmServer::WriteParseError(cmConnection* connection, + const std::string& message) const { Json::Value obj = Json::objectValue; obj[kTYPE_KEY] = kERROR_TYPE; @@ -342,7 +356,7 @@ void cmServer::WriteParseError(const std::string& message) const obj[kREPLY_TO_KEY] = ""; obj[kCOOKIE_KEY] = ""; - this->WriteJsonObject(obj, nullptr); + this->WriteJsonObject(connection, obj, nullptr); } void cmServer::WriteSignal(const std::string& name, @@ -358,7 +372,8 @@ void cmServer::WriteSignal(const std::string& name, WriteJsonObject(obj, nullptr); } -void cmServer::WriteResponse(const cmServerResponse& response, +void cmServer::WriteResponse(cmConnection* connection, + const cmServerResponse& response, const DebugInfo* debug) const { assert(response.IsComplete()); @@ -371,5 +386,163 @@ void cmServer::WriteResponse(const cmServerResponse& response, obj[kERROR_MESSAGE_KEY] = response.ErrorMessage(); } - this->WriteJsonObject(obj, debug); + this->WriteJsonObject(connection, obj, debug); +} + +void cmServer::OnConnected(cmConnection* connection) +{ + PrintHello(connection); +} + +void cmServer::OnServeStart() +{ + cmServerBase::OnServeStart(); + fileMonitor = std::make_shared<cmFileMonitor>(GetLoop()); +} + +void cmServer::StartShutDown() +{ + if (fileMonitor) { + fileMonitor->StopMonitoring(); + fileMonitor.reset(); + } + cmServerBase::StartShutDown(); +} + +static void __start_thread(void* arg) +{ + auto server = reinterpret_cast<cmServerBase*>(arg); + std::string error; + server->Serve(&error); +} + +bool cmServerBase::StartServeThread() +{ + ServeThreadRunning = true; + uv_thread_create(&ServeThread, __start_thread, this); + return true; +} + +bool cmServerBase::Serve(std::string* errorMessage) +{ + errorMessage->clear(); + + uv_signal_init(&Loop, &this->SIGINTHandler); + uv_signal_init(&Loop, &this->SIGHUPHandler); + + this->SIGINTHandler.data = this; + this->SIGHUPHandler.data = this; + + uv_signal_start(&this->SIGINTHandler, &on_signal, SIGINT); + uv_signal_start(&this->SIGHUPHandler, &on_signal, SIGHUP); + + OnServeStart(); + + for (auto& connection : Connections) { + if (!connection->OnServeStart(errorMessage)) { + return false; + } + } + + if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + *errorMessage = "Internal Error: Event loop stopped in unclean state."; + StartShutDown(); + return false; + } + + ServeThreadRunning = false; + return true; +} + +void cmServerBase::OnConnected(cmConnection*) +{ +} + +void cmServerBase::OnDisconnect() +{ +} + +void cmServerBase::OnServeStart() +{ + uv_signal_start(&this->SIGINTHandler, &on_signal, SIGINT); + uv_signal_start(&this->SIGHUPHandler, &on_signal, SIGHUP); +} + +void cmServerBase::StartShutDown() +{ + if (!uv_is_closing( + reinterpret_cast<const uv_handle_t*>(&this->SIGINTHandler))) { + uv_signal_stop(&this->SIGINTHandler); + } + + if (!uv_is_closing( + reinterpret_cast<const uv_handle_t*>(&this->SIGHUPHandler))) { + uv_signal_stop(&this->SIGHUPHandler); + } + + for (auto& connection : Connections) { + connection->OnConnectionShuttingDown(); + } + Connections.clear(); + + uv_stop(&Loop); + + uv_walk(&Loop, on_walk_to_shutdown, nullptr); + + uv_run(&Loop, UV_RUN_DEFAULT); +} + +bool cmServerBase::OnSignal(int signum) +{ + (void)signum; + StartShutDown(); + return true; +} + +cmServerBase::cmServerBase(cmConnection* connection) +{ + uv_loop_init(&Loop); + + uv_signal_init(&Loop, &this->SIGINTHandler); + uv_signal_init(&Loop, &this->SIGHUPHandler); + + this->SIGINTHandler.data = this; + this->SIGHUPHandler.data = this; + + AddNewConnection(connection); +} + +cmServerBase::~cmServerBase() +{ + + if (ServeThreadRunning) { + StartShutDown(); + uv_thread_join(&ServeThread); + } + + uv_loop_close(&Loop); +} + +void cmServerBase::AddNewConnection(cmConnection* ownedConnection) +{ + Connections.emplace_back(ownedConnection); + ownedConnection->SetServer(this); +} + +uv_loop_t* cmServerBase::GetLoop() +{ + return &Loop; +} + +void cmServerBase::OnDisconnect(cmConnection* pConnection) +{ + auto pred = [pConnection](const std::unique_ptr<cmConnection>& m) { + return m.get() == pConnection; + }; + Connections.erase( + std::remove_if(Connections.begin(), Connections.end(), pred), + Connections.end()); + if (Connections.empty()) { + StartShutDown(); + } } diff --git a/Source/cmServer.h b/Source/cmServer.h index b814050..eafd860 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -2,31 +2,88 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_jsoncpp_value.h" #include "cm_uv.h" +#include <memory> // IWYU pragma: keep #include <string> #include <vector> +class cmConnection; class cmFileMonitor; -class cmServerConnection; class cmServerProtocol; class cmServerRequest; class cmServerResponse; -class cmServer +/*** + * This essentially hold and manages a libuv event queue and responds to + * messages + * on any of its connections. + */ +class cmServerBase +{ +public: + cmServerBase(cmConnection* connection); + virtual ~cmServerBase(); + + virtual void AddNewConnection(cmConnection* ownedConnection); + + /*** + * The main override responsible for tailoring behavior towards + * whatever the given server is supposed to do + * + * This should almost always be called by the given connections + * directly. + * + * @param connection The connectiont the request was received on + * @param request The actual request + */ + virtual void ProcessRequest(cmConnection* connection, + const std::string& request) = 0; + virtual void OnConnected(cmConnection* connection); + virtual void OnDisconnect(); + + /*** + * Start a dedicated thread. If this is used to start the server, it will + * join on the + * servers dtor. + */ + virtual bool StartServeThread(); + virtual bool Serve(std::string* errorMessage); + + virtual void OnServeStart(); + virtual void StartShutDown(); + + virtual bool OnSignal(int signum); + uv_loop_t* GetLoop(); + + void OnDisconnect(cmConnection* pConnection); + +protected: + std::vector<std::unique_ptr<cmConnection> > Connections; + + bool ServeThreadRunning = false; + uv_thread_t ServeThread; + + uv_loop_t Loop; + + uv_signal_t SIGINTHandler; + uv_signal_t SIGHUPHandler; +}; + +class cmServer : public cmServerBase { CM_DISABLE_COPY(cmServer) public: class DebugInfo; - cmServer(cmServerConnection* conn, bool supportExperimental); - ~cmServer(); + cmServer(cmConnection* conn, bool supportExperimental); + ~cmServer() override; - bool Serve(std::string* errorMessage); + bool Serve(std::string* errorMessage) override; cmFileMonitor* FileMonitor() const; @@ -34,9 +91,20 @@ private: void RegisterProtocol(cmServerProtocol* protocol); // Callbacks from cmServerConnection: - void PopOne(); - void QueueRequest(const std::string& request); + void ProcessRequest(cmConnection* connection, + const std::string& request) override; + std::shared_ptr<cmFileMonitor> fileMonitor; + +public: + void OnServeStart() override; + + void StartShutDown() override; + +public: + void OnConnected(cmConnection* connection) override; + +private: static void reportProgress(const char* msg, float progress, void* data); static void reportMessage(const char* msg, const char* title, bool& cancel, void* data); @@ -44,36 +112,37 @@ private: // Handle requests: cmServerResponse SetProtocolVersion(const cmServerRequest& request); - void PrintHello() const; + void PrintHello(cmConnection* connection) const; // Write responses: void WriteProgress(const cmServerRequest& request, int min, int current, int max, const std::string& message) const; void WriteMessage(const cmServerRequest& request, const std::string& message, const std::string& title) const; - void WriteResponse(const cmServerResponse& response, + void WriteResponse(cmConnection* connection, + const cmServerResponse& response, const DebugInfo* debug) const; - void WriteParseError(const std::string& message) const; + void WriteParseError(cmConnection* connection, + const std::string& message) const; void WriteSignal(const std::string& name, const Json::Value& obj) const; void WriteJsonObject(Json::Value const& jsonValue, const DebugInfo* debug) const; + void WriteJsonObject(cmConnection* connection, Json::Value const& jsonValue, + const DebugInfo* debug) const; + static cmServerProtocol* FindMatchingProtocol( const std::vector<cmServerProtocol*>& protocols, int major, int minor); - cmServerConnection* Connection = nullptr; const bool SupportExperimental; cmServerProtocol* Protocol = nullptr; std::vector<cmServerProtocol*> SupportedProtocols; - std::vector<std::string> Queue; std::string DataBuffer; std::string JsonData; - uv_loop_t* Loop = nullptr; - typedef union { uv_tty_t tty; @@ -87,7 +156,6 @@ private: mutable bool Writing = false; - friend class cmServerConnection; friend class cmServerProtocol; friend class cmServerRequest; }; diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index 36312ed..4891131 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -2,376 +2,123 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmServerConnection.h" -#include "cmFileMonitor.h" #include "cmServer.h" #include "cmServerDictionary.h" -#include <assert.h> -#include <string.h> - -namespace { - -struct write_req_t +cmStdIoConnection::cmStdIoConnection( + cmConnectionBufferStrategy* bufferStrategy) + : cmEventBasedConnection(bufferStrategy) + , Input() + , Output() { - uv_write_t req; - uv_buf_t buf; -}; - -void on_alloc_buffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) -{ - (void)(handle); - char* rawBuffer = new char[suggested_size]; - *buf = uv_buf_init(rawBuffer, static_cast<unsigned int>(suggested_size)); -} - -void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) -{ - auto conn = reinterpret_cast<cmServerConnection*>(stream->data); - if (nread >= 0) { - conn->ReadData(std::string(buf->base, buf->base + nread)); - } else { - conn->TriggerShutdown(); - } - - delete[](buf->base); } -void on_write(uv_write_t* req, int status) +void cmStdIoConnection::SetServer(cmServerBase* s) { - (void)(status); - auto conn = reinterpret_cast<cmServerConnection*>(req->data); - - // Free req and buffer - write_req_t* wr = reinterpret_cast<write_req_t*>(req); - delete[](wr->buf.base); - delete wr; + cmConnection::SetServer(s); - conn->ProcessNextRequest(); -} + if (uv_guess_handle(1) == UV_TTY) { + usesTty = true; -void on_new_connection(uv_stream_t* stream, int status) -{ - (void)(status); - auto conn = reinterpret_cast<cmServerConnection*>(stream->data); - conn->Connect(stream); -} + this->Input.tty = new uv_tty_t(); + uv_tty_init(this->Server->GetLoop(), this->Input.tty, 0, 1); + uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL); + this->Input.tty->data = static_cast<cmEventBasedConnection*>(this); + this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty); -void on_signal(uv_signal_t* signal, int signum) -{ - auto conn = reinterpret_cast<cmServerConnection*>(signal->data); - (void)(signum); - conn->TriggerShutdown(); -} + this->Output.tty = new uv_tty_t(); + uv_tty_init(this->Server->GetLoop(), this->Output.tty, 1, 0); + uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL); + this->Output.tty->data = static_cast<cmEventBasedConnection*>(this); + this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty); + } else { + usesTty = false; -void on_signal_close(uv_handle_t* handle) -{ - delete reinterpret_cast<uv_signal_t*>(handle); -} + this->Input.pipe = new uv_pipe_t(); + uv_pipe_init(this->Server->GetLoop(), this->Input.pipe, 0); + uv_pipe_open(this->Input.pipe, 0); + this->Input.pipe->data = static_cast<cmEventBasedConnection*>(this); + this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe); -void on_pipe_close(uv_handle_t* handle) -{ - delete reinterpret_cast<uv_pipe_t*>(handle); + this->Output.pipe = new uv_pipe_t(); + uv_pipe_init(this->Server->GetLoop(), this->Output.pipe, 0); + uv_pipe_open(this->Output.pipe, 1); + this->Output.pipe->data = static_cast<cmEventBasedConnection*>(this); + this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe); + } } -void on_tty_close(uv_handle_t* handle) +bool cmStdIoConnection::OnServeStart(std::string* pString) { - delete reinterpret_cast<uv_tty_t*>(handle); + uv_read_start(this->ReadStream, on_alloc_buffer, on_read); + Server->OnConnected(this); + return cmConnection::OnServeStart(pString); } -} // namespace - -class LoopGuard +bool cmStdIoConnection::OnConnectionShuttingDown() { -public: - LoopGuard(cmServerConnection* connection) - : Connection(connection) - { - this->Connection->mLoop = uv_default_loop(); - if (!this->Connection->mLoop) { - return; - } - this->Connection->mFileMonitor = - new cmFileMonitor(this->Connection->mLoop); - } - - ~LoopGuard() - { - if (!this->Connection->mLoop) { - return; - } + cmEventBasedConnection::OnConnectionShuttingDown(); - if (this->Connection->mFileMonitor) { - delete this->Connection->mFileMonitor; - } - uv_loop_close(this->Connection->mLoop); - this->Connection->mLoop = nullptr; + if (usesTty) { + uv_read_stop(reinterpret_cast<uv_stream_t*>(this->Input.tty)); + uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty), + &on_close_delete); + uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty), + &on_close_delete); + } else { + uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe), + &on_close_delete); + uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe), + &on_close_delete); } -private: - cmServerConnection* Connection; -}; + return true; +} -cmServerConnection::cmServerConnection() +cmServerPipeConnection::cmServerPipeConnection(const std::string& name) + : cmPipeConnection(name, new cmServerBufferStrategy) { } -cmServerConnection::~cmServerConnection() +cmServerStdIoConnection::cmServerStdIoConnection() + : cmStdIoConnection(new cmServerBufferStrategy) { } -void cmServerConnection::SetServer(cmServer* s) +cmConnectionBufferStrategy::~cmConnectionBufferStrategy() { - this->Server = s; } -bool cmServerConnection::ProcessEvents(std::string* errorMessage) +void cmConnectionBufferStrategy::clear() { - assert(this->Server); - errorMessage->clear(); - - this->RawReadBuffer.clear(); - this->RequestBuffer.clear(); - - LoopGuard guard(this); - (void)(guard); - if (!this->mLoop) { - *errorMessage = "Internal Error: Failed to create event loop."; - return false; - } - - this->SIGINTHandler = new uv_signal_t; - uv_signal_init(this->mLoop, this->SIGINTHandler); - this->SIGINTHandler->data = static_cast<void*>(this); - uv_signal_start(this->SIGINTHandler, &on_signal, SIGINT); - - this->SIGHUPHandler = new uv_signal_t; - uv_signal_init(this->mLoop, this->SIGHUPHandler); - this->SIGHUPHandler->data = static_cast<void*>(this); - uv_signal_start(this->SIGHUPHandler, &on_signal, SIGHUP); - - if (!DoSetup(errorMessage)) { - return false; - } - - if (uv_run(this->mLoop, UV_RUN_DEFAULT) != 0) { - *errorMessage = "Internal Error: Event loop stopped in unclean state."; - return false; - } - - // These need to be cleaned up by now: - assert(!this->ReadStream); - assert(!this->WriteStream); - - this->RawReadBuffer.clear(); - this->RequestBuffer.clear(); - - return true; } -void cmServerConnection::ReadData(const std::string& data) +std::string cmServerBufferStrategy::BufferMessage(std::string& RawReadBuffer) { - this->RawReadBuffer += data; - for (;;) { - auto needle = this->RawReadBuffer.find('\n'); + auto needle = RawReadBuffer.find('\n'); if (needle == std::string::npos) { - return; + return ""; } - std::string line = this->RawReadBuffer.substr(0, needle); + std::string line = RawReadBuffer.substr(0, needle); const auto ls = line.size(); if (ls > 1 && line.at(ls - 1) == '\r') { line.erase(ls - 1, 1); } - this->RawReadBuffer.erase(this->RawReadBuffer.begin(), - this->RawReadBuffer.begin() + - static_cast<long>(needle) + 1); + RawReadBuffer.erase(RawReadBuffer.begin(), + RawReadBuffer.begin() + static_cast<long>(needle) + 1); if (line == kSTART_MAGIC) { - this->RequestBuffer.clear(); + RequestBuffer.clear(); continue; } if (line == kEND_MAGIC) { - this->Server->QueueRequest(this->RequestBuffer); - this->RequestBuffer.clear(); - } else { - this->RequestBuffer += line; - this->RequestBuffer += "\n"; + std::string rtn; + rtn.swap(this->RequestBuffer); + return rtn; } - } -} -void cmServerConnection::TriggerShutdown() -{ - this->FileMonitor()->StopMonitoring(); - - uv_signal_stop(this->SIGINTHandler); - uv_signal_stop(this->SIGHUPHandler); - - uv_close(reinterpret_cast<uv_handle_t*>(this->SIGINTHandler), - &on_signal_close); // delete handle - uv_close(reinterpret_cast<uv_handle_t*>(this->SIGHUPHandler), - &on_signal_close); // delete handle - - this->SIGINTHandler = nullptr; - this->SIGHUPHandler = nullptr; - - this->TearDown(); -} - -void cmServerConnection::WriteData(const std::string& data) -{ - assert(this->WriteStream); - - auto ds = data.size(); - - write_req_t* req = new write_req_t; - req->req.data = this; - req->buf = uv_buf_init(new char[ds], static_cast<unsigned int>(ds)); - memcpy(req->buf.base, data.c_str(), ds); - - uv_write(reinterpret_cast<uv_write_t*>(req), - static_cast<uv_stream_t*>(this->WriteStream), &req->buf, 1, - on_write); -} - -void cmServerConnection::ProcessNextRequest() -{ - Server->PopOne(); -} - -void cmServerConnection::SendGreetings() -{ - Server->PrintHello(); -} - -cmServerStdIoConnection::cmServerStdIoConnection() -{ - this->Input.tty = nullptr; - this->Output.tty = nullptr; -} - -bool cmServerStdIoConnection::DoSetup(std::string* errorMessage) -{ - (void)(errorMessage); - - if (uv_guess_handle(1) == UV_TTY) { - usesTty = true; - this->Input.tty = new uv_tty_t; - uv_tty_init(this->Loop(), this->Input.tty, 0, 1); - uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL); - Input.tty->data = this; - this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty); - - this->Output.tty = new uv_tty_t; - uv_tty_init(this->Loop(), this->Output.tty, 1, 0); - uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL); - Output.tty->data = this; - this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty); - } else { - usesTty = false; - this->Input.pipe = new uv_pipe_t; - uv_pipe_init(this->Loop(), this->Input.pipe, 0); - uv_pipe_open(this->Input.pipe, 0); - Input.pipe->data = this; - this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe); - - this->Output.pipe = new uv_pipe_t; - uv_pipe_init(this->Loop(), this->Output.pipe, 0); - uv_pipe_open(this->Output.pipe, 1); - Output.pipe->data = this; - this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe); + this->RequestBuffer += line; + this->RequestBuffer += "\n"; } - - SendGreetings(); - uv_read_start(this->ReadStream, on_alloc_buffer, on_read); - - return true; -} - -void cmServerStdIoConnection::TearDown() -{ - if (usesTty) { - uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty), &on_tty_close); - uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty), &on_tty_close); - this->Input.tty = nullptr; - this->Output.tty = nullptr; - } else { - uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe), &on_pipe_close); - uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe), - &on_pipe_close); - this->Input.pipe = nullptr; - this->Input.pipe = nullptr; - } - this->ReadStream = nullptr; - this->WriteStream = nullptr; -} - -cmServerPipeConnection::cmServerPipeConnection(const std::string& name) - : PipeName(name) -{ -} - -bool cmServerPipeConnection::DoSetup(std::string* errorMessage) -{ - this->ServerPipe = new uv_pipe_t; - uv_pipe_init(this->Loop(), this->ServerPipe, 0); - this->ServerPipe->data = this; - - int r; - if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) { - *errorMessage = std::string("Internal Error with ") + this->PipeName + - ": " + uv_err_name(r); - return false; - } - auto serverStream = reinterpret_cast<uv_stream_t*>(this->ServerPipe); - if ((r = uv_listen(serverStream, 1, on_new_connection)) != 0) { - *errorMessage = std::string("Internal Error listening on ") + - this->PipeName + ": " + uv_err_name(r); - return false; - } - - return true; -} - -void cmServerPipeConnection::TearDown() -{ - if (this->ClientPipe) { - uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe), &on_pipe_close); - this->WriteStream->data = nullptr; - } - uv_close(reinterpret_cast<uv_handle_t*>(this->ServerPipe), &on_pipe_close); - - this->ClientPipe = nullptr; - this->ServerPipe = nullptr; - this->WriteStream = nullptr; - this->ReadStream = nullptr; -} - -void cmServerPipeConnection::Connect(uv_stream_t* server) -{ - if (this->ClientPipe) { - // Accept and close all pipes but the first: - uv_pipe_t* rejectPipe = new uv_pipe_t; - - uv_pipe_init(this->Loop(), rejectPipe, 0); - auto rejecter = reinterpret_cast<uv_stream_t*>(rejectPipe); - uv_accept(server, rejecter); - uv_close(reinterpret_cast<uv_handle_t*>(rejecter), &on_pipe_close); - return; - } - - this->ClientPipe = new uv_pipe_t; - uv_pipe_init(this->Loop(), this->ClientPipe, 0); - this->ClientPipe->data = this; - auto client = reinterpret_cast<uv_stream_t*>(this->ClientPipe); - if (uv_accept(server, client) != 0) { - uv_close(reinterpret_cast<uv_handle_t*>(client), nullptr); - return; - } - this->ReadStream = client; - this->WriteStream = client; - - uv_read_start(this->ReadStream, on_alloc_buffer, on_read); - - this->SendGreetings(); } diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h index b96bf3c..df404ce 100644 --- a/Source/cmServerConnection.h +++ b/Source/cmServerConnection.h @@ -2,68 +2,47 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once -#include "cmConfigure.h" - -#include "cm_uv.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> -class cmFileMonitor; -class cmServer; +#include "cmConnection.h" +#include "cmPipeConnection.h" +#include "cm_uv.h" -class cmServerConnection -{ - CM_DISABLE_COPY(cmServerConnection) +class cmServerBase; +/*** + * This connection buffer strategy accepts messages in the form of + * [== "CMake Server" ==[ +{ + ... some JSON message ... +} +]== "CMake Server" ==] + * and only passes on the core json; it discards the envelope. + */ +class cmServerBufferStrategy : public cmConnectionBufferStrategy +{ public: - cmServerConnection(); - virtual ~cmServerConnection(); - - void SetServer(cmServer* s); - - bool ProcessEvents(std::string* errorMessage); - - void ReadData(const std::string& data); - void TriggerShutdown(); - void WriteData(const std::string& data); - void ProcessNextRequest(); - - virtual void Connect(uv_stream_t* server) { (void)(server); } - - cmFileMonitor* FileMonitor() const { return this->mFileMonitor; } - -protected: - virtual bool DoSetup(std::string* errorMessage) = 0; - virtual void TearDown() = 0; - - void SendGreetings(); - - uv_loop_t* Loop() const { return mLoop; } - -protected: - std::string RawReadBuffer; - std::string RequestBuffer; - - uv_stream_t* ReadStream = nullptr; - uv_stream_t* WriteStream = nullptr; + std::string BufferMessage(std::string& rawBuffer) override; private: - uv_loop_t* mLoop = nullptr; - cmFileMonitor* mFileMonitor = nullptr; - cmServer* Server = nullptr; - uv_signal_t* SIGINTHandler = nullptr; - uv_signal_t* SIGHUPHandler = nullptr; - - friend class LoopGuard; + std::string RequestBuffer; }; -class cmServerStdIoConnection : public cmServerConnection +/*** + * Generic connection over std io interfaces -- tty + */ +class cmStdIoConnection : public cmEventBasedConnection { public: - cmServerStdIoConnection(); - bool DoSetup(std::string* errorMessage) override; + cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy); - void TearDown() override; + void SetServer(cmServerBase* s) override; + + bool OnConnectionShuttingDown() override; + + bool OnServeStart(std::string* pString) override; private: typedef union @@ -78,18 +57,18 @@ private: InOutUnion Output; }; -class cmServerPipeConnection : public cmServerConnection +/*** + * These specific connections use the cmake server + * buffering strategy. + */ +class cmServerStdIoConnection : public cmStdIoConnection { public: - cmServerPipeConnection(const std::string& name); - bool DoSetup(std::string* errorMessage) override; - - void TearDown() override; - - void Connect(uv_stream_t* server) override; + cmServerStdIoConnection(); +}; -private: - const std::string PipeName; - uv_pipe_t* ServerPipe = nullptr; - uv_pipe_t* ClientPipe = nullptr; +class cmServerPipeConnection : public cmPipeConnection +{ +public: + cmServerPipeConnection(const std::string& name); }; diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h index e6a7ae6..405ff6b 100644 --- a/Source/cmServerDictionary.h +++ b/Source/cmServerDictionary.h @@ -89,6 +89,11 @@ static const std::string kWARN_UNUSED_KEY = "warnUnused"; static const std::string kWATCHED_DIRECTORIES_KEY = "watchedDirectories"; static const std::string kWATCHED_FILES_KEY = "watchedFiles"; +static const std::string kTARGET_CROSS_REFERENCES_KEY = "crossReferences"; +static const std::string kLINE_NUMBER_KEY = "line"; +static const std::string kBACKTRACE_KEY = "backtrace"; +static const std::string kRELATED_STATEMENTS_KEY = "relatedStatements"; + static const std::string kSTART_MAGIC = "[== \"CMake Server\" ==["; static const std::string kEND_MAGIC = "]== \"CMake Server\" ==]"; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index c5b7f60..2bcfefd 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -2,12 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmServerProtocol.h" +#include "cmAlgorithms.h" #include "cmExternalMakefileProjectGenerator.h" #include "cmFileMonitor.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLinkLineComputer.h" +#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmServer.h" @@ -18,6 +20,7 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" +#include "cmTarget.h" #include "cm_uv.h" #include "cmake.h" @@ -125,11 +128,13 @@ void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir, } // namespace -cmServerRequest::cmServerRequest(cmServer* server, const std::string& t, - const std::string& c, const Json::Value& d) +cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection, + const std::string& t, const std::string& c, + const Json::Value& d) : Type(t) , Cookie(c) , Data(d) + , Connection(connection) , m_Server(server) { } @@ -215,10 +220,10 @@ bool cmServerProtocol::Activate(cmServer* server, { assert(server); this->m_Server = server; - this->m_CMakeInstance = std::make_unique<cmake>(cmake::RoleProject); + this->m_CMakeInstance = cm::make_unique<cmake>(cmake::RoleProject); const bool result = this->DoActivate(request, errorMessage); if (!result) { - this->m_CMakeInstance = CM_NULLPTR; + this->m_CMakeInstance = nullptr; } return result; } @@ -247,9 +252,9 @@ bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/, return true; } -std::pair<int, int> cmServerProtocol1_0::ProtocolVersion() const +std::pair<int, int> cmServerProtocol1::ProtocolVersion() const { - return std::make_pair(1, 0); + return std::make_pair(1, 1); } static void setErrorMessage(std::string* errorMessage, const std::string& text) @@ -264,6 +269,10 @@ static bool testHomeDirectory(cmState* state, std::string& value, { const std::string cachedValue = std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY")); + if (value.empty()) { + value = cachedValue; + return true; + } const std::string suffix = "/CMakeLists.txt"; const std::string cachedValueCML = cachedValue + suffix; const std::string valueCML = value + suffix; @@ -274,9 +283,6 @@ static bool testHomeDirectory(cmState* state, std::string& value, "source directory value.")); return false; } - if (value.empty()) { - value = cachedValue; - } return true; } @@ -287,20 +293,20 @@ static bool testValue(cmState* state, const std::string& key, const char* entry = state->GetCacheEntryValue(key); const std::string cachedValue = entry == nullptr ? std::string() : std::string(entry); - if (!cachedValue.empty() && !value.empty() && cachedValue != value) { + if (value.empty()) { + value = cachedValue; + } + if (!cachedValue.empty() && cachedValue != value) { setErrorMessage(errorMessage, std::string("\"") + key + "\" is set but incompatible with configured " + keyDescription + " value."); return false; } - if (value.empty()) { - value = cachedValue; - } return true; } -bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, - std::string* errorMessage) +bool cmServerProtocol1::DoActivate(const cmServerRequest& request, + std::string* errorMessage) { std::string sourceDirectory = request.Data[kSOURCE_DIRECTORY_KEY].asString(); const std::string buildDirectory = @@ -419,8 +425,8 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, return true; } -void cmServerProtocol1_0::HandleCMakeFileChanges(const std::string& path, - int event, int status) +void cmServerProtocol1::HandleCMakeFileChanges(const std::string& path, + int event, int status) { assert(status == 0); static_cast<void>(status); @@ -443,7 +449,7 @@ void cmServerProtocol1_0::HandleCMakeFileChanges(const std::string& path, SendSignal(kFILE_CHANGE_SIGNAL, obj); } -const cmServerResponse cmServerProtocol1_0::Process( +const cmServerResponse cmServerProtocol1::Process( const cmServerRequest& request) { assert(this->m_State >= STATE_ACTIVE); @@ -476,18 +482,14 @@ const cmServerResponse cmServerProtocol1_0::Process( return request.ReportError("Unknown command!"); } -bool cmServerProtocol1_0::IsExperimental() const +bool cmServerProtocol1::IsExperimental() const { return true; } -cmServerResponse cmServerProtocol1_0::ProcessCache( +cmServerResponse cmServerProtocol1::ProcessCache( const cmServerRequest& request) { - if (this->m_State < STATE_CONFIGURED) { - return request.ReportError("This project was not configured yet."); - } - cmState* state = this->CMakeInstance()->GetState(); Json::Value result = Json::objectValue; @@ -530,7 +532,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCache( return request.Reply(result); } -cmServerResponse cmServerProtocol1_0::ProcessCMakeInputs( +cmServerResponse cmServerProtocol1::ProcessCMakeInputs( const cmServerRequest& request) { if (this->m_State < STATE_CONFIGURED) { @@ -731,6 +733,37 @@ static Json::Value DumpSourceFilesList( return result; } +static Json::Value DumpBacktrace(const cmListFileBacktrace& backtrace) +{ + Json::Value result = Json::arrayValue; + + cmListFileBacktrace backtraceCopy = backtrace; + while (!backtraceCopy.Top().FilePath.empty()) { + Json::Value entry = Json::objectValue; + entry[kPATH_KEY] = backtraceCopy.Top().FilePath; + if (backtraceCopy.Top().Line) { + entry[kLINE_NUMBER_KEY] = static_cast<int>(backtraceCopy.Top().Line); + } + if (!backtraceCopy.Top().Name.empty()) { + entry[kNAME_KEY] = backtraceCopy.Top().Name; + } + result.append(entry); + backtraceCopy = backtraceCopy.Pop(); + } + return result; +} + +static void DumpBacktraceRange(Json::Value& result, const std::string& type, + cmBacktraceRange range) +{ + for (const auto& bt : range) { + Json::Value obj = Json::objectValue; + obj[kTYPE_KEY] = type; + obj[kBACKTRACE_KEY] = DumpBacktrace(bt); + result.append(obj); + } +} + static Json::Value DumpTarget(cmGeneratorTarget* target, const std::string& config) { @@ -765,6 +798,22 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, result[kFULL_NAME_KEY] = target->GetFullName(config); + Json::Value crossRefs = Json::objectValue; + crossRefs[kBACKTRACE_KEY] = DumpBacktrace(target->Target->GetBacktrace()); + + Json::Value statements = Json::arrayValue; + DumpBacktraceRange(statements, "target_compile_definitions", + target->Target->GetCompileDefinitionsBacktraces()); + DumpBacktraceRange(statements, "target_include_directories", + target->Target->GetIncludeDirectoriesBacktraces()); + DumpBacktraceRange(statements, "target_compile_options", + target->Target->GetCompileOptionsBacktraces()); + DumpBacktraceRange(statements, "target_link_libraries", + target->Target->GetLinkImplementationBacktraces()); + + crossRefs[kRELATED_STATEMENTS_KEY] = std::move(statements); + result[kTARGET_CROSS_REFERENCES_KEY] = std::move(crossRefs); + if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; artifacts.append( @@ -854,7 +903,7 @@ static Json::Value DumpTargetsList( std::vector<cmGeneratorTarget*> targetList; for (const auto& lgIt : generators) { - auto list = lgIt->GetGeneratorTargets(); + const auto& list = lgIt->GetGeneratorTargets(); targetList.insert(targetList.end(), list.begin(), list.end()); } std::sort(targetList.begin(), targetList.end()); @@ -917,7 +966,7 @@ static Json::Value DumpConfigurationsList(const cmake* cm) return result; } -cmServerResponse cmServerProtocol1_0::ProcessCodeModel( +cmServerResponse cmServerProtocol1::ProcessCodeModel( const cmServerRequest& request) { if (this->m_State != STATE_COMPUTED) { @@ -929,7 +978,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCodeModel( return request.Reply(result); } -cmServerResponse cmServerProtocol1_0::ProcessCompute( +cmServerResponse cmServerProtocol1::ProcessCompute( const cmServerRequest& request) { if (this->m_State > STATE_CONFIGURED) { @@ -949,7 +998,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCompute( return request.Reply(Json::Value()); } -cmServerResponse cmServerProtocol1_0::ProcessConfigure( +cmServerResponse cmServerProtocol1::ProcessConfigure( const cmServerRequest& request) { if (this->m_State == STATE_INACTIVE) { @@ -1055,7 +1104,7 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( return request.Reply(Json::Value()); } -cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings( +cmServerResponse cmServerProtocol1::ProcessGlobalSettings( const cmServerRequest& request) { cmake* cm = this->CMakeInstance(); @@ -1091,7 +1140,7 @@ static void setBool(const cmServerRequest& request, const std::string& key, setter(request.Data[key].asBool()); } -cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings( +cmServerResponse cmServerProtocol1::ProcessSetGlobalSettings( const cmServerRequest& request) { const std::vector<std::string> boolValues = { @@ -1123,7 +1172,7 @@ cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings( return request.Reply(Json::Value()); } -cmServerResponse cmServerProtocol1_0::ProcessFileSystemWatchers( +cmServerResponse cmServerProtocol1::ProcessFileSystemWatchers( const cmServerRequest& request) { const cmFileMonitor* const fm = FileMonitor(); @@ -1142,7 +1191,7 @@ cmServerResponse cmServerProtocol1_0::ProcessFileSystemWatchers( return request.Reply(result); } -cmServerProtocol1_0::GeneratorInformation::GeneratorInformation( +cmServerProtocol1::GeneratorInformation::GeneratorInformation( const std::string& generatorName, const std::string& extraGeneratorName, const std::string& toolset, const std::string& platform, const std::string& sourceDirectory, const std::string& buildDirectory) @@ -1155,7 +1204,7 @@ cmServerProtocol1_0::GeneratorInformation::GeneratorInformation( { } -void cmServerProtocol1_0::GeneratorInformation::SetupGenerator( +void cmServerProtocol1::GeneratorInformation::SetupGenerator( cmake* cm, std::string* errorMessage) { const std::string fullGeneratorName = diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index 83b3d58..124ac7f 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cm_jsoncpp_value.h" #include "cmake.h" @@ -11,6 +11,7 @@ #include <string> #include <utility> +class cmConnection; class cmFileMonitor; class cmServer; class cmServerRequest; @@ -52,9 +53,11 @@ public: const std::string Type; const std::string Cookie; const Json::Value Data; + cmConnection* Connection; private: - cmServerRequest(cmServer* server, const std::string& t, const std::string& c, + cmServerRequest(cmServer* server, cmConnection* connection, + const std::string& t, const std::string& c, const Json::Value& d); void ReportProgress(int min, int current, int max, @@ -98,7 +101,7 @@ private: friend class cmServer; }; -class cmServerProtocol1_0 : public cmServerProtocol +class cmServerProtocol1 : public cmServerProtocol { public: std::pair<int, int> ProtocolVersion() const override; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 820e7f6..b32cda3 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -61,7 +61,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, // SET (VAR PARENT_SCOPE) // Removes the definition of VAR // in the parent scope. if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") { - this->Makefile->RaiseScope(variable, CM_NULLPTR); + this->Makefile->RaiseScope(variable, nullptr); return true; } @@ -75,8 +75,8 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, bool force = false; // optional bool parentScope = false; cmStateEnums::CacheEntryType type = - cmStateEnums::STRING; // required if cache - const char* docstring = CM_NULLPTR; // required if cache + cmStateEnums::STRING; // required if cache + const char* docstring = nullptr; // required if cache unsigned int ignoreLastArgs = 0; // look for PARENT_SCOPE argument diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index c0858b1..3faec6f 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetCommand_h #define cmSetCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 8832b33..16a07da 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetDirectoryPropertiesCommand_h #define cmSetDirectoryPropertiesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index b57f62a..338fcea 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -141,7 +141,7 @@ bool cmSetPropertyCommand::HandleGlobalMode() std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { - value = CM_NULLPTR; + value = nullptr; } if (this->AppendMode) { cm->AppendProperty(name, value ? value : "", this->AppendAsString); @@ -191,7 +191,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { - value = CM_NULLPTR; + value = nullptr; } if (this->AppendMode) { mf->AppendProperty(name, value ? value : "", this->AppendAsString); @@ -232,7 +232,7 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { - value = CM_NULLPTR; + value = nullptr; } if (this->AppendMode) { target->AppendProperty(name, value, this->AppendAsString); @@ -271,7 +271,7 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { - value = CM_NULLPTR; + value = nullptr; } if (this->AppendMode) { @@ -319,7 +319,7 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test) std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { - value = CM_NULLPTR; + value = nullptr; } if (this->AppendMode) { test->AppendProperty(name, value, this->AppendAsString); diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 0815824..4d3d996 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetsPropertiesCommand_h #define cmSetsPropertiesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index 2e22dc9..ca3d74d 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetSourceFilesPropertiesCommand_h #define cmSetSourceFilesPropertiesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 4256181..de20a7b 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetTargetsPropertiesCommand_h #define cmSetTargetsPropertiesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 90f004c..cd9f486 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -3,7 +3,7 @@ #ifndef cmSetTestsPropertiesCommand_h #define cmSetTestsPropertiesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 7eace26..d2e83a6 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -52,8 +52,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args, // try to find the hostname for this computer if (!cmSystemTools::IsOff(hostname_cmd.c_str())) { std::string host; - cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, CM_NULLPTR, - CM_NULLPTR, CM_NULLPTR, + cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, nullptr, + nullptr, nullptr, cmSystemTools::OUTPUT_NONE); // got the hostname diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 6c65480..c042a13 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -3,7 +3,7 @@ #ifndef cmSiteNameCommand_h #define cmSiteNameCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 5c4f18b..6d2b98d 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -15,15 +15,13 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name) : Location(mf, name) { - this->CustomCommand = CM_NULLPTR; + this->CustomCommand = nullptr; this->FindFullPathFailed = false; - this->IsUiFile = (".ui" == cmSystemTools::GetFilenameLastExtension( - this->Location.GetName())); } cmSourceFile::~cmSourceFile() { - this->SetCustomCommand(CM_NULLPTR); + this->SetCustomCommand(nullptr); } std::string const& cmSourceFile::GetExtension() const @@ -131,17 +129,17 @@ bool cmSourceFile::FindFullPath(std::string* error) // The file is not generated. It must exist on disk. cmMakefile const* mf = this->Location.GetMakefile(); - const char* tryDirs[3] = { CM_NULLPTR, CM_NULLPTR, CM_NULLPTR }; + const char* tryDirs[3] = { nullptr, nullptr, nullptr }; if (this->Location.DirectoryIsAmbiguous()) { tryDirs[0] = mf->GetCurrentSourceDirectory(); tryDirs[1] = mf->GetCurrentBinaryDirectory(); } else { tryDirs[0] = ""; } - const std::vector<std::string>& srcExts = - mf->GetCMakeInstance()->GetSourceExtensions(); - std::vector<std::string> hdrExts = - mf->GetCMakeInstance()->GetHeaderExtensions(); + + cmake const* const cmakeInst = mf->GetCMakeInstance(); + std::vector<std::string> const& srcExts = cmakeInst->GetSourceExtensions(); + std::vector<std::string> const& hdrExts = cmakeInst->GetHeaderExtensions(); for (const char* const* di = tryDirs; *di; ++di) { std::string tryPath = this->Location.GetDirectory(); if (!tryPath.empty()) { @@ -245,13 +243,6 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) void cmSourceFile::SetProperty(const std::string& prop, const char* value) { this->Properties.SetProperty(prop, value); - - if (this->IsUiFile) { - cmMakefile const* mf = this->Location.GetMakefile(); - if (prop == "AUTOUIC_OPTIONS") { - const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this); - } - } } void cmSourceFile::AppendProperty(const std::string& prop, const char* value, @@ -290,7 +281,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const // Check for computed properties. if (prop == "LOCATION") { if (this->FullPath.empty()) { - return CM_NULLPTR; + return nullptr; } return this->FullPath.c_str(); } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 0be659c..c2105d2 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -3,7 +3,7 @@ #ifndef cmSourceFile_h #define cmSourceFile_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmPropertyMap.h" #include "cmSourceFileLocation.h" @@ -57,7 +57,7 @@ public: * horrible interface, but is necessary for backwards * compatibility). */ - std::string const& GetFullPath(std::string* error = CM_NULLPTR); + std::string const& GetFullPath(std::string* error = nullptr); std::string const& GetFullPath() const; /** @@ -107,7 +107,6 @@ private: std::string ObjectLibrary; std::vector<std::string> Depends; bool FindFullPathFailed; - bool IsUiFile; bool FindFullPath(std::string* error); bool TryFullPath(const std::string& path, const std::string& ext); @@ -120,4 +119,10 @@ private: // TODO: Factor out into platform information modules. #define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$" +#define CM_SOURCE_REGEX \ + "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp|ftn|m|mm|rc|def|r|odl|idl|hpj" \ + "|bat)$" + +#define CM_RESOURCE_REGEX "\\.(pdf|plist|png|jpeg|jpg|storyboard|xcassets)$" + #endif diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 86711d7..727adeb 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSourceFileLocation.h" -#include "cmConfigure.h" - #include "cmAlgorithms.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -15,7 +13,7 @@ #include <vector> cmSourceFileLocation::cmSourceFileLocation() - : Makefile(CM_NULLPTR) + : Makefile(nullptr) , AmbiguousDirectory(true) , AmbiguousExtension(true) { diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 104e959..fba4c31 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -114,7 +114,7 @@ cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const } // if no child with this name was found return NULL - return CM_NULLPTR; + return nullptr; } cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name) @@ -134,7 +134,7 @@ cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name) return result; } } - return CM_NULLPTR; + return nullptr; } cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name) @@ -155,7 +155,7 @@ cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name) return this; } - return CM_NULLPTR; + return nullptr; } std::vector<cmSourceGroup> const& cmSourceGroup::GetGroupChildren() const diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 97affed..e8bd697 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -3,7 +3,7 @@ #ifndef cmSourceGroup_h #define cmSourceGroup_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/RegularExpression.hxx" #include <set> @@ -27,7 +27,7 @@ class cmSourceGroup { public: cmSourceGroup(const char* name, const char* regex, - const char* parentName = CM_NULLPTR); + const char* parentName = nullptr); cmSourceGroup(cmSourceGroup const& r); ~cmSourceGroup(); cmSourceGroup& operator=(cmSourceGroup const&); diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index a966300..77fde7b 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -71,7 +71,7 @@ cmSourceGroup* addSourceGroup(const std::vector<std::string>& tokenizedPath, makefile.AddSourceGroup(tokenizedPath); sg = makefile.GetSourceGroup(tokenizedPath); if (!sg) { - return CM_NULLPTR; + return nullptr; } } @@ -166,7 +166,7 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string> folders = cmSystemTools::tokenize(args[0], delimiter); - cmSourceGroup* sg = CM_NULLPTR; + cmSourceGroup* sg = nullptr; sg = this->Makefile->GetSourceGroup(folders); if (!sg) { this->Makefile->AddSourceGroup(folders); diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 7d56b0d..1af5274 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -3,7 +3,7 @@ #ifndef cmSourceGroupCommand_h #define cmSourceGroupCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 92e47f7..90d8b7b 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -63,12 +63,12 @@ const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType) return "UNKNOWN_LIBRARY"; } assert(false && "Unexpected target type"); - return CM_NULLPTR; + return nullptr; } const char* cmCacheEntryTypes[] = { "BOOL", "PATH", "FILEPATH", "STRING", "INTERNAL", "STATIC", - "UNINITIALIZED", CM_NULLPTR }; + "UNINITIALIZED", nullptr }; const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type) { @@ -132,7 +132,7 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const { cmCacheManager::CacheEntry* e = this->CacheManager->GetCacheEntry(key); if (!e) { - return CM_NULLPTR; + return nullptr; } return e->Value.c_str(); } @@ -188,7 +188,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key, cmCacheManager::CacheIterator it = this->CacheManager->GetCacheIterator(key.c_str()); if (!it.PropertyExists(propertyName)) { - return CM_NULLPTR; + return nullptr; } return it.GetProperty(propertyName); } @@ -224,7 +224,7 @@ void cmState::RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName) { this->CacheManager->GetCacheIterator(key.c_str()) - .SetProperty(propertyName, (void*)CM_NULLPTR); + .SetProperty(propertyName, nullptr); } cmStateSnapshot cmState::Reset() @@ -303,7 +303,7 @@ cmPropertyDefinition const* cmState::GetPropertyDefinition( this->PropertyDefinitions.find(scope)->second; return &defs.find(name)->second; } - return CM_NULLPTR; + return nullptr; } bool cmState::IsPropertyDefined(const std::string& name, @@ -436,7 +436,7 @@ cmCommand* cmState::GetCommand(std::string const& name) const if (pos != this->BuiltinCommands.end()) { return pos->second; } - return CM_NULLPTR; + return nullptr; } std::vector<std::string> cmState::GetCommandNames() const diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 77413c7..bdef3e5 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -220,7 +220,7 @@ void cmStateSnapshot::SetDefinition(std::string const& name, void cmStateSnapshot::RemoveDefinition(std::string const& name) { - this->Position->Vars->Set(name, CM_NULLPTR); + this->Position->Vars->Set(name, nullptr); } std::vector<std::string> cmStateSnapshot::UnusedKeys() const diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index 6293803..94d6274 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -19,7 +19,7 @@ class cmStateDirectory; class cmStateSnapshot { public: - cmStateSnapshot(cmState* state = CM_NULLPTR); + cmStateSnapshot(cmState* state = nullptr); cmStateSnapshot(cmState* state, cmStateDetail::PositionType position); const char* GetDefinition(std::string const& name) const; diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 7a097ba..592f66e 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -62,6 +62,9 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args, if (subCommand == "APPEND") { return this->HandleAppendCommand(args); } + if (subCommand == "PREPEND") { + return this->HandlePrependCommand(args); + } if (subCommand == "CONCAT") { return this->HandleConcatCommand(args); } @@ -309,6 +312,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) std::string output; const char* p = input.c_str(); while (re.find(p)) { + this->Makefile->ClearMatches(); this->Makefile->StoreMatches(re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); @@ -391,6 +395,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string output; std::string::size_type base = 0; while (re.find(input.c_str() + base)) { + this->Makefile->ClearMatches(); this->Makefile->StoreMatches(re); std::string::size_type l2 = re.start(); std::string::size_type r = re.end(); @@ -641,6 +646,30 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args) return true; } +bool cmStringCommand::HandlePrependCommand( + std::vector<std::string> const& args) +{ + if (args.size() < 2) { + this->SetError("sub-command PREPEND requires at least one argument."); + return false; + } + + // Skip if nothing to prepend. + if (args.size() < 3) { + return true; + } + + const std::string& variable = args[1]; + + std::string value = cmJoin(cmMakeRange(args).advance(2), std::string()); + const char* oldValue = this->Makefile->GetDefinition(variable); + if (oldValue) { + value += oldValue; + } + this->Makefile->AddDefinition(variable, value.c_str()); + return true; +} + bool cmStringCommand::HandleConcatCommand(std::vector<std::string> const& args) { if (args.size() < 2) { @@ -789,7 +818,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args) const char* alphaPtr = alphabet.c_str(); int cc; for (cc = 0; cc < length; cc++) { - int idx = (int)(sizeofAlphabet * rand() / (RAND_MAX + 1.0)); + int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0)); result.push_back(*(alphaPtr + idx)); } result.push_back(0); diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 88015ad..f19f871 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -3,7 +3,7 @@ #ifndef cmStringCommand_h #define cmStringCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -46,6 +46,7 @@ protected: bool HandleLengthCommand(std::vector<std::string> const& args); bool HandleSubstringCommand(std::vector<std::string> const& args); bool HandleAppendCommand(std::vector<std::string> const& args); + bool HandlePrependCommand(std::vector<std::string> const& args); bool HandleConcatCommand(std::vector<std::string> const& args); bool HandleStripCommand(std::vector<std::string> const& args); bool HandleRandomCommand(std::vector<std::string> const& args); diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index a2af0fd..e5fbb7d 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -3,7 +3,7 @@ #ifndef cmSubdirCommand_h #define cmSubdirCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index d8ea928..bcda82e 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -3,7 +3,7 @@ #ifndef cmSubdirDependsCommand_h #define cmSubdirDependsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f7192e0..5c63d98 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -654,7 +654,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, a != command.end(); ++a) { argv.push_back(a->c_str()); } - argv.push_back(CM_NULLPTR); + argv.push_back(nullptr); cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -666,12 +666,12 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, if (outputflag == OUTPUT_PASSTHROUGH) { cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); - captureStdOut = CM_NULLPTR; - captureStdErr = CM_NULLPTR; + captureStdOut = nullptr; + captureStdErr = nullptr; } else if (outputflag == OUTPUT_MERGE || (captureStdErr && captureStdErr == captureStdOut)) { cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1); - captureStdErr = CM_NULLPTR; + captureStdErr = nullptr; } assert(!captureStdErr || captureStdErr != captureStdOut); @@ -687,7 +687,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, std::string strdata; if (outputflag != OUTPUT_PASSTHROUGH && (captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) { - while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) > + while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, nullptr)) > 0) { // Translate NULL characters in the output into valid text. for (int i = 0; i < length; ++i) { @@ -727,7 +727,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, } } - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); if (captureStdOut) { captureStdOut->assign(tempStdOut.begin(), tempStdOut.end()); @@ -934,19 +934,17 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) +std::string cmSystemTools::ComputeFileHash(const std::string& source, + cmCryptoHash::Algo algo) { #if defined(CMAKE_BUILD_WITH_CMAKE) - cmCryptoHash md5(cmCryptoHash::AlgoMD5); - std::string const str = md5.HashFile(source); - strncpy(md5out, str.c_str(), 32); - return !str.empty(); + cmCryptoHash hash(algo); + return hash.HashFile(source); #else (void)source; - (void)md5out; - cmSystemTools::Message("md5sum not supported in bootstrapping mode", + cmSystemTools::Message("hashsum not supported in bootstrapping mode", "Error"); - return false; + return std::string(); #endif } @@ -1520,22 +1518,22 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) /* Use uname if it's present, else uid. */ p = archive_entry_uname(entry); - if ((p == CM_NULLPTR) || (*p == '\0')) { - sprintf(tmp, "%lu ", (unsigned long)archive_entry_uid(entry)); + if ((p == nullptr) || (*p == '\0')) { + sprintf(tmp, "%lu ", static_cast<unsigned long>(archive_entry_uid(entry))); p = tmp; } w = strlen(p); if (w > u_width) { u_width = w; } - fprintf(out, "%-*s ", (int)u_width, p); + fprintf(out, "%-*s ", static_cast<int>(u_width), p); /* Use gname if it's present, else gid. */ p = archive_entry_gname(entry); - if (p != CM_NULLPTR && p[0] != '\0') { + if (p != nullptr && p[0] != '\0') { fprintf(out, "%s", p); w = strlen(p); } else { - sprintf(tmp, "%lu", (unsigned long)archive_entry_gid(entry)); + sprintf(tmp, "%lu", static_cast<unsigned long>(archive_entry_gid(entry))); w = strlen(tmp); fprintf(out, "%s", tmp); } @@ -1547,8 +1545,9 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) */ if (archive_entry_filetype(entry) == AE_IFCHR || archive_entry_filetype(entry) == AE_IFBLK) { - sprintf(tmp, "%lu,%lu", (unsigned long)archive_entry_rdevmajor(entry), - (unsigned long)archive_entry_rdevminor(entry)); + unsigned long rdevmajor = archive_entry_rdevmajor(entry); + unsigned long rdevminor = archive_entry_rdevminor(entry); + sprintf(tmp, "%lu,%lu", rdevmajor, rdevminor); } else { /* * Note the use of platform-dependent macros to format @@ -1556,12 +1555,12 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) * corresponding type for the cast. */ sprintf(tmp, BSDTAR_FILESIZE_PRINTF, - (BSDTAR_FILESIZE_TYPE)archive_entry_size(entry)); + static_cast<BSDTAR_FILESIZE_TYPE>(archive_entry_size(entry))); } if (w + strlen(tmp) >= gs_width) { gs_width = w + strlen(tmp) + 1; } - fprintf(out, "%*s", (int)(gs_width - w), tmp); + fprintf(out, "%*s", static_cast<int>(gs_width - w), tmp); /* Format the time using 'ls -l' conventions. */ tim = archive_entry_mtime(entry); @@ -1973,7 +1972,7 @@ unsigned int cmSystemTools::RandomSeed() // Try using a real random source. cmsys::ifstream fin; - fin.rdbuf()->pubsetbuf(CM_NULLPTR, 0); // Unbuffered read. + fin.rdbuf()->pubsetbuf(nullptr, 0); // Unbuffered read. fin.open("/dev/urandom"); if (fin.good() && fin.read(seed.bytes, sizeof(seed)) && fin.gcount() == sizeof(seed)) { @@ -1982,7 +1981,7 @@ unsigned int cmSystemTools::RandomSeed() // Fall back to the time and pid. struct timeval t; - gettimeofday(&t, CM_NULLPTR); + gettimeofday(&t, nullptr); unsigned int pid = static_cast<unsigned int>(getpid()); unsigned int tv_sec = static_cast<unsigned int>(t.tv_sec); unsigned int tv_usec = static_cast<unsigned int>(t.tv_usec); @@ -2298,8 +2297,8 @@ bool cmSystemTools::ChangeRPath(std::string const& file, // Get the RPATH and RUNPATH entries from it. int se_count = 0; - cmELF::StringEntry const* se[2] = { CM_NULLPTR, CM_NULLPTR }; - const char* se_name[2] = { CM_NULLPTR, CM_NULLPTR }; + cmELF::StringEntry const* se[2] = { nullptr, nullptr }; + const char* se_name[2] = { nullptr, nullptr }; if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) { se[se_count] = se_rpath; se_name[se_count] = "RPATH"; @@ -2612,7 +2611,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, // Get the RPATH and RUNPATH entries from it and sort them by index // in the dynamic section header. int se_count = 0; - cmELF::StringEntry const* se[2] = { CM_NULLPTR, CM_NULLPTR }; + cmELF::StringEntry const* se[2] = { nullptr, nullptr }; if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) { se[se_count++] = se_rpath; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9de7967..9bec361 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -3,8 +3,9 @@ #ifndef cmSystemTools_h #define cmSystemTools_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep +#include "cmCryptoHash.h" #include "cmProcessOutput.h" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export @@ -61,34 +62,34 @@ public: * set to false, will disable furthur messages (cancel). */ static void SetMessageCallback(MessageCallback f, - void* clientData = CM_NULLPTR); + void* clientData = nullptr); /** * Display an error message. */ - static void Error(const char* m, const char* m2 = CM_NULLPTR, - const char* m3 = CM_NULLPTR, const char* m4 = CM_NULLPTR); + static void Error(const char* m, const char* m2 = nullptr, + const char* m3 = nullptr, const char* m4 = nullptr); /** * Display a message. */ - static void Message(const char* m, const char* title = CM_NULLPTR); + static void Message(const char* m, const char* title = nullptr); typedef void (*OutputCallback)(const char*, size_t length, void*); ///! Send a string to stdout static void Stdout(const char* s); static void Stdout(const char* s, size_t length); - static void SetStdoutCallback(OutputCallback, void* clientData = CM_NULLPTR); + static void SetStdoutCallback(OutputCallback, void* clientData = nullptr); ///! Send a string to stderr static void Stderr(const char* s); static void Stderr(const char* s, size_t length); - static void SetStderrCallback(OutputCallback, void* clientData = CM_NULLPTR); + static void SetStderrCallback(OutputCallback, void* clientData = nullptr); typedef bool (*InterruptCallback)(void*); static void SetInterruptCallback(InterruptCallback f, - void* clientData = CM_NULLPTR); + void* clientData = nullptr); static bool GetInterruptFlag(); ///! Return true if there was an error at any point. @@ -179,8 +180,9 @@ public: if possible). */ static bool RenameFile(const char* oldname, const char* newname); - ///! Compute the md5sum of a file - static bool ComputeFileMD5(const std::string& source, char* md5out); + ///! Compute the hash of a file + static std::string ComputeFileHash(const std::string& source, + cmCryptoHash::Algo algo); /** Compute the md5sum of a string. */ static std::string ComputeStringMD5(const std::string& input); @@ -218,10 +220,10 @@ public: OUTPUT_PASSTHROUGH }; static bool RunSingleCommand(const char* command, - std::string* captureStdOut = CM_NULLPTR, - std::string* captureStdErr = CM_NULLPTR, - int* retVal = CM_NULLPTR, - const char* dir = CM_NULLPTR, + std::string* captureStdOut = nullptr, + std::string* captureStdErr = nullptr, + int* retVal = nullptr, + const char* dir = nullptr, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); /** @@ -230,10 +232,10 @@ public: * be in comand[1]...command[command.size()] */ static bool RunSingleCommand(std::vector<std::string> const& command, - std::string* captureStdOut = CM_NULLPTR, - std::string* captureStdErr = CM_NULLPTR, - int* retVal = CM_NULLPTR, - const char* dir = CM_NULLPTR, + std::string* captureStdOut = nullptr, + std::string* captureStdErr = nullptr, + int* retVal = nullptr, + const char* dir = nullptr, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0, Encoding encoding = cmProcessOutput::Auto); @@ -461,13 +463,12 @@ public: /** Try to set the RPATH in an ELF binary. */ static bool ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, - std::string* emsg = CM_NULLPTR, - bool* changed = CM_NULLPTR); + std::string* emsg = nullptr, + bool* changed = nullptr); /** Try to remove the RPATH from an ELF binary. */ - static bool RemoveRPath(std::string const& file, - std::string* emsg = CM_NULLPTR, - bool* removed = CM_NULLPTR); + static bool RemoveRPath(std::string const& file, std::string* emsg = nullptr, + bool* removed = nullptr); /** Check whether the RPATH in an ELF binary contains the path given. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c95a3ca..d4a0bf5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -9,6 +9,7 @@ #include <set> #include <sstream> #include <string.h> +#include <unordered_set> #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" @@ -26,7 +27,6 @@ #include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmTargetPropertyComputer.h" -#include "cm_unordered_set.hxx" #include "cmake.h" template <> @@ -75,7 +75,7 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>( { cmStringRange entries = tgt->GetSourceEntries(); if (entries.empty()) { - return CM_NULLPTR; + return nullptr; } std::ostringstream ss; @@ -211,77 +211,79 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, // Setup default property values. if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("ANDROID_API", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_API_MIN", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_ARCH", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_STL_TYPE", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_SKIP_ANT_STEP", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_PROCESS_MAX", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_PROGUARD", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_PROGUARD_CONFIG_PATH", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_SECURE_PROPS_PATH", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_NATIVE_LIB_DIRECTORIES", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_NATIVE_LIB_DEPENDENCIES", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_JAVA_SOURCE_DIR", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_JAR_DIRECTORIES", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", CM_NULLPTR); - this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", CM_NULLPTR); - this->SetPropertyDefault("BUILD_RPATH", CM_NULLPTR); - this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR); + this->SetPropertyDefault("ANDROID_API", nullptr); + this->SetPropertyDefault("ANDROID_API_MIN", nullptr); + this->SetPropertyDefault("ANDROID_ARCH", nullptr); + this->SetPropertyDefault("ANDROID_STL_TYPE", nullptr); + this->SetPropertyDefault("ANDROID_SKIP_ANT_STEP", nullptr); + this->SetPropertyDefault("ANDROID_PROCESS_MAX", nullptr); + this->SetPropertyDefault("ANDROID_PROGUARD", nullptr); + this->SetPropertyDefault("ANDROID_PROGUARD_CONFIG_PATH", nullptr); + this->SetPropertyDefault("ANDROID_SECURE_PROPS_PATH", nullptr); + this->SetPropertyDefault("ANDROID_NATIVE_LIB_DIRECTORIES", nullptr); + this->SetPropertyDefault("ANDROID_NATIVE_LIB_DEPENDENCIES", nullptr); + this->SetPropertyDefault("ANDROID_JAVA_SOURCE_DIR", nullptr); + this->SetPropertyDefault("ANDROID_JAR_DIRECTORIES", nullptr); + this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", nullptr); + this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", nullptr); + this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr); + this->SetPropertyDefault("BUILD_RPATH", nullptr); + this->SetPropertyDefault("INSTALL_NAME_DIR", nullptr); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); - this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", CM_NULLPTR); + this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", nullptr); this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); - this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("Fortran_FORMAT", CM_NULLPTR); - this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", CM_NULLPTR); - this->SetPropertyDefault("GNUtoMS", CM_NULLPTR); - this->SetPropertyDefault("OSX_ARCHITECTURES", CM_NULLPTR); - this->SetPropertyDefault("IOS_INSTALL_COMBINED", CM_NULLPTR); - this->SetPropertyDefault("AUTOMOC", CM_NULLPTR); - this->SetPropertyDefault("AUTOUIC", CM_NULLPTR); - this->SetPropertyDefault("AUTORCC", CM_NULLPTR); - this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR); - this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR); - this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR); - this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR); - this->SetPropertyDefault("AUTORCC_OPTIONS", CM_NULLPTR); - this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", CM_NULLPTR); - this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", CM_NULLPTR); - this->SetPropertyDefault("WIN32_EXECUTABLE", CM_NULLPTR); - this->SetPropertyDefault("MACOSX_BUNDLE", CM_NULLPTR); - this->SetPropertyDefault("MACOSX_RPATH", CM_NULLPTR); - this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", CM_NULLPTR); - this->SetPropertyDefault("C_CLANG_TIDY", CM_NULLPTR); - this->SetPropertyDefault("C_COMPILER_LAUNCHER", CM_NULLPTR); - this->SetPropertyDefault("C_CPPLINT", CM_NULLPTR); - this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", CM_NULLPTR); - this->SetPropertyDefault("LINK_WHAT_YOU_USE", CM_NULLPTR); - this->SetPropertyDefault("C_STANDARD", CM_NULLPTR); - this->SetPropertyDefault("C_STANDARD_REQUIRED", CM_NULLPTR); - this->SetPropertyDefault("C_EXTENSIONS", CM_NULLPTR); - this->SetPropertyDefault("CXX_CLANG_TIDY", CM_NULLPTR); - this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", CM_NULLPTR); - this->SetPropertyDefault("CXX_CPPLINT", CM_NULLPTR); - this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", CM_NULLPTR); - this->SetPropertyDefault("CXX_STANDARD", CM_NULLPTR); - this->SetPropertyDefault("CXX_STANDARD_REQUIRED", CM_NULLPTR); - this->SetPropertyDefault("CXX_EXTENSIONS", CM_NULLPTR); - this->SetPropertyDefault("CUDA_STANDARD", CM_NULLPTR); - this->SetPropertyDefault("CUDA_STANDARD_REQUIRED", CM_NULLPTR); - this->SetPropertyDefault("CUDA_EXTENSIONS", CM_NULLPTR); - this->SetPropertyDefault("LINK_SEARCH_START_STATIC", CM_NULLPTR); - this->SetPropertyDefault("LINK_SEARCH_END_STATIC", CM_NULLPTR); + this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", nullptr); + this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", nullptr); + this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", nullptr); + this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", nullptr); + this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr); + this->SetPropertyDefault("Fortran_FORMAT", nullptr); + this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", nullptr); + this->SetPropertyDefault("GNUtoMS", nullptr); + this->SetPropertyDefault("OSX_ARCHITECTURES", nullptr); + this->SetPropertyDefault("IOS_INSTALL_COMBINED", nullptr); + this->SetPropertyDefault("AUTOMOC", nullptr); + this->SetPropertyDefault("AUTOUIC", nullptr); + this->SetPropertyDefault("AUTORCC", nullptr); + this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", nullptr); + this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", nullptr); + this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", nullptr); + this->SetPropertyDefault("AUTOUIC_OPTIONS", nullptr); + this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", nullptr); + this->SetPropertyDefault("AUTORCC_OPTIONS", nullptr); + this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", nullptr); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", nullptr); + this->SetPropertyDefault("WIN32_EXECUTABLE", nullptr); + this->SetPropertyDefault("MACOSX_BUNDLE", nullptr); + this->SetPropertyDefault("MACOSX_RPATH", nullptr); + this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", nullptr); + this->SetPropertyDefault("C_CLANG_TIDY", nullptr); + this->SetPropertyDefault("C_COMPILER_LAUNCHER", nullptr); + this->SetPropertyDefault("C_CPPLINT", nullptr); + this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", nullptr); + this->SetPropertyDefault("LINK_WHAT_YOU_USE", nullptr); + this->SetPropertyDefault("C_STANDARD", nullptr); + this->SetPropertyDefault("C_STANDARD_REQUIRED", nullptr); + this->SetPropertyDefault("C_EXTENSIONS", nullptr); + this->SetPropertyDefault("CXX_CLANG_TIDY", nullptr); + this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", nullptr); + this->SetPropertyDefault("CXX_CPPLINT", nullptr); + this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", nullptr); + this->SetPropertyDefault("CXX_STANDARD", nullptr); + this->SetPropertyDefault("CXX_STANDARD_REQUIRED", nullptr); + this->SetPropertyDefault("CXX_EXTENSIONS", nullptr); + this->SetPropertyDefault("CUDA_STANDARD", nullptr); + this->SetPropertyDefault("CUDA_STANDARD_REQUIRED", nullptr); + this->SetPropertyDefault("CUDA_EXTENSIONS", nullptr); + this->SetPropertyDefault("CUDA_COMPILER_LAUNCHER", nullptr); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", nullptr); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", nullptr); } if (this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", CM_NULLPTR); + this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", nullptr); } // Collect the set of configuration types. @@ -295,7 +297,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, "ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", - "INTERPROCEDURAL_OPTIMIZATION_", CM_NULLPTR + "INTERPROCEDURAL_OPTIMIZATION_", nullptr }; for (std::vector<std::string>::iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { @@ -309,7 +311,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } std::string property = *p; property += configUpper; - this->SetPropertyDefault(property, CM_NULLPTR); + this->SetPropertyDefault(property, nullptr); } // Initialize per-configuration name postfix property from the @@ -321,7 +323,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->TargetTypeValue != cmStateEnums::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; - this->SetPropertyDefault(property, CM_NULLPTR); + this->SetPropertyDefault(property, nullptr); } } } @@ -365,16 +367,16 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("C_VISIBILITY_PRESET", CM_NULLPTR); - this->SetPropertyDefault("CXX_VISIBILITY_PRESET", CM_NULLPTR); - this->SetPropertyDefault("CUDA_VISIBILITY_PRESET", CM_NULLPTR); - this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", CM_NULLPTR); + this->SetPropertyDefault("C_VISIBILITY_PRESET", nullptr); + this->SetPropertyDefault("CXX_VISIBILITY_PRESET", nullptr); + this->SetPropertyDefault("CUDA_VISIBILITY_PRESET", nullptr); + this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", nullptr); } if (this->TargetTypeValue == cmStateEnums::EXECUTABLE) { - this->SetPropertyDefault("ANDROID_GUI", CM_NULLPTR); - this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", CM_NULLPTR); - this->SetPropertyDefault("ENABLE_EXPORTS", CM_NULLPTR); + this->SetPropertyDefault("ANDROID_GUI", nullptr); + this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", nullptr); + this->SetPropertyDefault("ENABLE_EXPORTS", nullptr); } if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || this->TargetTypeValue == cmStateEnums::MODULE_LIBRARY) { @@ -382,12 +384,12 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || this->TargetTypeValue == cmStateEnums::EXECUTABLE) { - this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", CM_NULLPTR); + this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", CM_NULLPTR); + this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", nullptr); } // Record current policies for later use. @@ -403,8 +405,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("JOB_POOL_COMPILE", CM_NULLPTR); - this->SetPropertyDefault("JOB_POOL_LINK", CM_NULLPTR); + this->SetPropertyDefault("JOB_POOL_COMPILE", nullptr); + this->SetPropertyDefault("JOB_POOL_LINK", nullptr); } } @@ -427,7 +429,7 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( std::map<std::string, cmListFileBacktrace>::const_iterator i = this->UtilityBacktraces.find(u); if (i == this->UtilityBacktraces.end()) { - return CM_NULLPTR; + return nullptr; } return &i->second; @@ -545,7 +547,7 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) { std::string src = this->ProcessSourceItemCMP0049(s); if (!s.empty() && src.empty()) { - return CM_NULLPTR; + return nullptr; } return this->AddSource(src); } @@ -616,7 +618,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { - return CM_NULLPTR; + return nullptr; } return this->Makefile->GetOrCreateSource(src); } @@ -1178,7 +1180,7 @@ const char* cmTarget::GetComputedProperty( const char* cmTarget::GetProperty(const std::string& prop) const { - static CM_UNORDERED_SET<std::string> specialProps; + static std::unordered_set<std::string> specialProps; #define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP MAKE_STATIC_PROP(LINK_LIBRARIES); MAKE_STATIC_PROP(TYPE); @@ -1210,7 +1212,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const if (specialProps.count(prop)) { if (prop == propLINK_LIBRARIES) { if (this->Internal->LinkImplementationPropertyEntries.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1223,7 +1225,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (prop == propINCLUDE_DIRECTORIES) { if (this->Internal->IncludeDirectoriesEntries.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1232,7 +1234,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (prop == propCOMPILE_FEATURES) { if (this->Internal->CompileFeaturesEntries.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1241,7 +1243,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (prop == propCOMPILE_OPTIONS) { if (this->Internal->CompileOptionsEntries.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1250,7 +1252,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (prop == propCOMPILE_DEFINITIONS) { if (this->Internal->CompileDefinitionsEntries.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1259,7 +1261,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (prop == propMANUALLY_ADDED_DEPENDENCIES) { if (this->Utilities.empty()) { - return CM_NULLPTR; + return nullptr; } static std::string output; @@ -1397,8 +1399,8 @@ std::string cmTarget::ImportedGetFullPath( std::string result; - const char* loc = CM_NULLPTR; - const char* imp = CM_NULLPTR; + const char* loc = nullptr; + const char* imp = nullptr; std::string suffix; if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1f00c01..c335c81 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -9,6 +9,7 @@ #include <map> #include <set> #include <string> +#include <unordered_map> #include <utility> #include <vector> @@ -19,7 +20,6 @@ #include "cmPropertyMap.h" #include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" -#include "cm_unordered_map.hxx" class cmGlobalGenerator; class cmMakefile; @@ -184,7 +184,7 @@ public: * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(const std::string& u, cmMakefile* makefile = CM_NULLPTR); + void AddUtility(const std::string& u, cmMakefile* makefile = nullptr); ///! Get the utilities used by this target std::set<std::string> const& GetUtilities() const { return this->Utilities; } cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; @@ -323,7 +323,7 @@ private: cmListFileBacktrace Backtrace; }; -typedef CM_UNORDERED_MAP<std::string, cmTarget> cmTargets; +typedef std::unordered_map<std::string, cmTarget> cmTargets; class cmTargetSet : public std::set<std::string> { diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 11abf57..957123a 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetCompileDefinitionsCommand_h #define cmTargetCompileDefinitionsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h index 9908680..d28cf62 100644 --- a/Source/cmTargetCompileFeaturesCommand.h +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetCompileFeaturesCommand_h #define cmTargetCompileFeaturesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index b5408f7..7786896 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetCompileOptionsCommand_h #define cmTargetCompileOptionsCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 374a867..96eedc8 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetIncludeDirectoriesCommand_h #define cmTargetIncludeDirectoriesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index e173036..bfae53c 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -95,7 +95,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( if (this->Target->GetType() == cmStateEnums::UTILITY) { std::ostringstream e; - const char* modal = CM_NULLPTR; + const char* modal = nullptr; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) { case cmPolicies::WARN: @@ -311,7 +311,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, if (!this->Target->PushTLLCommandTrace( sig, this->Makefile->GetExecutionContext())) { std::ostringstream e; - const char* modal = CM_NULLPTR; + const char* modal = nullptr; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) { case cmPolicies::WARN: diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 3fd20ac..333ab07 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetLinkLibrariesCommand_h #define cmTargetLinkLibrariesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index a57bc5a..3a3c165 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -4,11 +4,11 @@ #include "cmTargetPropertyComputer.h" #include <sstream> +#include <unordered_set> #include "cmMessenger.h" #include "cmPolicies.h" #include "cmStateSnapshot.h" -#include "cm_unordered_set.hxx" #include "cmake.h" bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( @@ -16,7 +16,7 @@ bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( cmListFileBacktrace const& context) { std::ostringstream e; - const char* modal = CM_NULLPTR; + const char* modal = nullptr; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch (context.GetBottom().GetPolicy(cmPolicies::CMP0026)) { case cmPolicies::WARN: @@ -49,7 +49,7 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( if (cmHasLiteralPrefix(prop, "INTERFACE_")) { return true; } - static CM_UNORDERED_SET<std::string> builtIns; + static std::unordered_set<std::string> builtIns; if (builtIns.empty()) { builtIns.insert("COMPATIBLE_INTERFACE_BOOL"); builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index 94688e3..97e4fba 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -26,12 +26,12 @@ public: return loc; } if (cmSystemTools::GetFatalErrorOccured()) { - return CM_NULLPTR; + return nullptr; } if (prop == "SOURCES") { return GetSources(tgt, messenger, context); } - return CM_NULLPTR; + return nullptr; } static bool WhiteListedInterfaceProperty(const std::string& prop); @@ -69,7 +69,7 @@ private: if (!tgt->IsImported() && !HandleLocationPropertyPolicy(tgt->GetName(), messenger, context)) { - return CM_NULLPTR; + return nullptr; } return ComputeLocationForBuild(tgt); } @@ -79,7 +79,7 @@ private: if (!tgt->IsImported() && !HandleLocationPropertyPolicy(tgt->GetName(), messenger, context)) { - return CM_NULLPTR; + return nullptr; } const char* configName = prop.c_str() + 9; return ComputeLocation(tgt, configName); @@ -93,13 +93,13 @@ private: if (!tgt->IsImported() && !HandleLocationPropertyPolicy(tgt->GetName(), messenger, context)) { - return CM_NULLPTR; + return nullptr; } return ComputeLocation(tgt, configName); } } } - return CM_NULLPTR; + return nullptr; } template <typename Target> diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index 09ba729..b4e08e4 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -3,7 +3,7 @@ #ifndef cmTargetSourcesCommand_h #define cmTargetSourcesCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index be4b378..85d4b97 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -23,7 +23,7 @@ cmTestGenerator::cmTestGenerator( { this->ActionsPerConfig = !test->GetOldStyle(); this->TestGenerated = false; - this->LG = CM_NULLPTR; + this->LG = nullptr; } cmTestGenerator::~cmTestGenerator() @@ -80,7 +80,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (emulator != CM_NULLPTR) { + if (emulator != nullptr) { std::vector<std::string> emulatorWithArgs; cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); std::string emulatorExe(emulatorWithArgs[0]); diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index b227305..ab0f635 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -3,7 +3,7 @@ #ifndef cmTestGenerator_h #define cmTestGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmScriptGenerator.h" diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 4b97188..4dea24c 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTimestamp.h" -#include "cmConfigure.h" #include <cstring> #include <sstream> #include <stdlib.h> @@ -12,7 +11,7 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString, bool utcFlag) { - time_t currentTimeT = time(CM_NULLPTR); + time_t currentTimeT = time(nullptr); std::string source_date_epoch; cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch); if (!source_date_epoch.empty()) { @@ -56,14 +55,14 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, struct tm timeStruct; memset(&timeStruct, 0, sizeof(timeStruct)); - struct tm* ptr = (struct tm*)CM_NULLPTR; + struct tm* ptr = nullptr; if (utcFlag) { ptr = gmtime(&timeT); } else { ptr = localtime(&timeT); } - if (ptr == CM_NULLPTR) { + if (ptr == nullptr) { return std::string(); } diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 4836548..b1f0da9 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -3,7 +3,7 @@ #ifndef cmTryCompileCommand_h #define cmTryCompileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 07e20e6..cc93b03 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -125,9 +125,8 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, std::string runOutputContents; if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") && !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) { - this->DoNotRunExecutable(runArgs, argv[3], captureRunOutput - ? &runOutputContents - : CM_NULLPTR); + this->DoNotRunExecutable( + runArgs, argv[3], captureRunOutput ? &runOutputContents : nullptr); } else { this->RunExecutable(runArgs, &runOutputContents); } @@ -189,7 +188,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, } int timeout = 0; bool worked = cmSystemTools::RunSingleCommand( - finalCommand.c_str(), out, out, &retVal, CM_NULLPTR, + finalCommand.c_str(), out, out, &retVal, nullptr, cmSystemTools::OUTPUT_NONE, timeout); // set the run var char retChar[1000]; @@ -233,7 +232,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, this->RunResultVariable + "__TRYRUN_OUTPUT"; bool error = false; - if (this->Makefile->GetDefinition(this->RunResultVariable) == CM_NULLPTR) { + if (this->Makefile->GetDefinition(this->RunResultVariable) == nullptr) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced std::string comment; @@ -255,8 +254,8 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, } // is the output from the executable used ? - if (out != CM_NULLPTR) { - if (this->Makefile->GetDefinition(internalRunOutputName) == CM_NULLPTR) { + if (out != nullptr) { + if (this->Makefile->GetDefinition(internalRunOutputName) == nullptr) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced std::string comment; @@ -304,7 +303,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += " to\n" " the exit code (in many cases 0 for success), otherwise " "enter \"FAILED_TO_RUN\".\n"; - if (out != CM_NULLPTR) { + if (out != nullptr) { comment += internalRunOutputName; comment += "\n contains the text the executable " @@ -335,7 +334,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, << this->Makefile->GetDefinition(this->RunResultVariable) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; - if (out != CM_NULLPTR) { + if (out != nullptr) { file << "set( " << internalRunOutputName << " \n \"" << this->Makefile->GetDefinition(internalRunOutputName) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; @@ -348,7 +347,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "please set the following cache variables " "appropriately:\n"; errorMessage += " " + this->RunResultVariable + " (advanced)\n"; - if (out != CM_NULLPTR) { + if (out != nullptr) { errorMessage += " " + internalRunOutputName + " (advanced)\n"; } errorMessage += detailsString; @@ -356,7 +355,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, return; } - if (out != CM_NULLPTR) { + if (out != nullptr) { (*out) = this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index c27b026..732dff1 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -3,7 +3,7 @@ #ifndef cmTryRunCommand_h #define cmTryRunCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h index 995d8a5..5e3ac74 100644 --- a/Source/cmUnexpectedCommand.h +++ b/Source/cmUnexpectedCommand.h @@ -3,7 +3,7 @@ #ifndef cmUnexpectedCommand_h #define cmUnexpectedCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 31525ba..18bbdd7 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -46,7 +46,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, } // unset(VAR PARENT_SCOPE) if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) { - this->Makefile->RaiseScope(variable, CM_NULLPTR); + this->Makefile->RaiseScope(variable, nullptr); return true; } // ERROR: second argument isn't CACHE or PARENT_SCOPE diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 2a1f3f0..96d7010 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -3,7 +3,7 @@ #ifndef cmUnsetCommand_h #define cmUnsetCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index 5118829..86ebbf1 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -3,7 +3,7 @@ #ifndef cmUseMangledMesaCommand_h #define cmUseMangledMesaCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index eabd7ef..0ce437c 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -33,7 +33,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, bool haveCacheValue = false; if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) { - haveCacheValue = (cacheValue != CM_NULLPTR); + haveCacheValue = (cacheValue != nullptr); if (!haveCacheValue) { std::string msg = "UTILITY_SOURCE is used in cross compiling mode for "; msg += cacheEntry; @@ -45,7 +45,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, } else { cmState* state = this->Makefile->GetState(); haveCacheValue = - (cacheValue && (strstr(cacheValue, "(IntDir)") == CM_NULLPTR || + (cacheValue && (strstr(cacheValue, "(IntDir)") == nullptr || (intDir && strcmp(intDir, "$(IntDir)") == 0)) && (state->GetCacheMajorVersion() != 0 && state->GetCacheMinorVersion() != 0)); diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index a95b48d..404ef3e 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -3,7 +3,7 @@ #ifndef cmUtilitySourceCommand_h #define cmUtilitySourceCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmVS10CLFlagTable.h b/Source/cmVS10CLFlagTable.h index dbd760e..df4d58c 100644 --- a/Source/cmVS10CLFlagTable.h +++ b/Source/cmVS10CLFlagTable.h @@ -70,7 +70,8 @@ static cmVS7FlagTable cmVS10CLFlagTable[] = { cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "PrecompiledHeader", "Yu", "Use", "Use", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + { "PrecompiledHeader", "Y-", "Not Using Precompiled Headers", "NotUsing", + 0 }, { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, diff --git a/Source/cmVS10CSharpFlagTable.h b/Source/cmVS10CSharpFlagTable.h index 493ec2b..18d587c 100644 --- a/Source/cmVS10CSharpFlagTable.h +++ b/Source/cmVS10CSharpFlagTable.h @@ -25,7 +25,8 @@ static cmVS7FlagTable cmVS10CSharpFlagTable[] = { { "ApplicationIcon", "win32icon", "", "", cmIDEFlagTable::UserValueRequired }, - { "Win32Manifest", "win32manifest:", "", "true", 0 }, + { "ApplicationManifest", "win32manifest:", "", "", + cmIDEFlagTable::UserValueRequired }, { "NoWin32Manifest", "nowin32manifest", "", "true", 0 }, diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h index 7531709..d156938 100644 --- a/Source/cmVS11CLFlagTable.h +++ b/Source/cmVS11CLFlagTable.h @@ -74,7 +74,8 @@ static cmVS7FlagTable cmVS11CLFlagTable[] = { cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "PrecompiledHeader", "Yu", "Use", "Use", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + { "PrecompiledHeader", "Y-", "Not Using Precompiled Headers", "NotUsing", + 0 }, { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, diff --git a/Source/cmVS11CSharpFlagTable.h b/Source/cmVS11CSharpFlagTable.h index 71870b6..e3ba83c 100644 --- a/Source/cmVS11CSharpFlagTable.h +++ b/Source/cmVS11CSharpFlagTable.h @@ -25,7 +25,8 @@ static cmVS7FlagTable cmVS11CSharpFlagTable[] = { { "ApplicationIcon", "win32icon", "", "", cmIDEFlagTable::UserValueRequired }, - { "Win32Manifest", "win32manifest:", "", "true", 0 }, + { "ApplicationManifest", "win32manifest:", "", "", + cmIDEFlagTable::UserValueRequired }, { "NoWin32Manifest", "nowin32manifest", "", "true", 0 }, diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h index 9515c91..a4f2518 100644 --- a/Source/cmVS12CLFlagTable.h +++ b/Source/cmVS12CLFlagTable.h @@ -78,7 +78,8 @@ static cmVS7FlagTable cmVS12CLFlagTable[] = { cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "PrecompiledHeader", "Yu", "Use", "Use", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + { "PrecompiledHeader", "Y-", "Not Using Precompiled Headers", "NotUsing", + 0 }, { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, diff --git a/Source/cmVS12CSharpFlagTable.h b/Source/cmVS12CSharpFlagTable.h index f98b184..f8db636 100644 --- a/Source/cmVS12CSharpFlagTable.h +++ b/Source/cmVS12CSharpFlagTable.h @@ -25,7 +25,8 @@ static cmVS7FlagTable cmVS12CSharpFlagTable[] = { { "ApplicationIcon", "win32icon", "", "", cmIDEFlagTable::UserValueRequired }, - { "Win32Manifest", "win32manifest:", "", "true", 0 }, + { "ApplicationManifest", "win32manifest:", "", "", + cmIDEFlagTable::UserValueRequired }, { "NoWin32Manifest", "nowin32manifest", "", "true", 0 }, diff --git a/Source/cmVS140CLFlagTable.h b/Source/cmVS140CLFlagTable.h index 60b4379..2b89042 100644 --- a/Source/cmVS140CLFlagTable.h +++ b/Source/cmVS140CLFlagTable.h @@ -80,7 +80,8 @@ static cmVS7FlagTable cmVS140CLFlagTable[] = { cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "PrecompiledHeader", "Yu", "Use", "Use", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + { "PrecompiledHeader", "Y-", "Not Using Precompiled Headers", "NotUsing", + 0 }, { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, diff --git a/Source/cmVS140CSharpFlagTable.h b/Source/cmVS140CSharpFlagTable.h index 256c35f..055d5cb 100644 --- a/Source/cmVS140CSharpFlagTable.h +++ b/Source/cmVS140CSharpFlagTable.h @@ -25,7 +25,8 @@ static cmVS7FlagTable cmVS140CSharpFlagTable[] = { { "ApplicationIcon", "win32icon", "", "", cmIDEFlagTable::UserValueRequired }, - { "Win32Manifest", "win32manifest:", "", "true", 0 }, + { "ApplicationManifest", "win32manifest:", "", "", + cmIDEFlagTable::UserValueRequired }, { "NoWin32Manifest", "nowin32manifest", "", "true", 0 }, diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h index f751fc8..e8b8f5c 100644 --- a/Source/cmVS141CLFlagTable.h +++ b/Source/cmVS141CLFlagTable.h @@ -87,7 +87,8 @@ static cmVS7FlagTable cmVS141CLFlagTable[] = { cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "PrecompiledHeader", "Yu", "Use", "Use", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + { "PrecompiledHeader", "Y-", "Not Using Precompiled Headers", "NotUsing", + 0 }, { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, diff --git a/Source/cmVS141CSharpFlagTable.h b/Source/cmVS141CSharpFlagTable.h index 8508581..5de9bf3 100644 --- a/Source/cmVS141CSharpFlagTable.h +++ b/Source/cmVS141CSharpFlagTable.h @@ -25,7 +25,8 @@ static cmVS7FlagTable cmVS141CSharpFlagTable[] = { { "ApplicationIcon", "win32icon", "", "", cmIDEFlagTable::UserValueRequired }, - { "Win32Manifest", "win32manifest:", "", "true", 0 }, + { "ApplicationManifest", "win32manifest:", "", "", + cmIDEFlagTable::UserValueRequired }, { "NoWin32Manifest", "nowin32manifest", "", "true", 0 }, diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index 9808d5f..811e02e 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -3,7 +3,7 @@ #ifndef cmVariableRequiresCommand_h #define cmVariableRequiresCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index a575afe..05a0a56 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -31,10 +31,9 @@ public: * Add watch to the variable */ bool AddWatch(const std::string& variable, WatchMethod method, - void* client_data = CM_NULLPTR, - DeleteData delete_data = CM_NULLPTR); + void* client_data = nullptr, DeleteData delete_data = nullptr); void RemoveWatch(const std::string& variable, WatchMethod method, - void* client_data = CM_NULLPTR); + void* client_data = nullptr); /** * This method is called when variable is accessed @@ -67,9 +66,9 @@ protected: void* ClientData; DeleteData DeleteDataCall; Pair() - : Method(CM_NULLPTR) - , ClientData(CM_NULLPTR) - , DeleteDataCall(CM_NULLPTR) + : Method(nullptr) + , ClientData(nullptr) + , DeleteDataCall(nullptr) { } ~Pair() diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index 9f04391..59baa4d 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -3,7 +3,7 @@ #ifndef cmVariableWatchCommand_h #define cmVariableWatchCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 88fa19c..0e73806 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -25,6 +25,12 @@ static std::string cmVS10EscapeXML(std::string arg) return arg; } +static std::string cmVS10EscapeQuotes(std::string arg) +{ + cmSystemTools::ReplaceString(arg, "\"", """); + return arg; +} + static std::string cmVS10EscapeComment(std::string comment) { // MSBuild takes the CDATA of a <Message></Message> element and just @@ -79,7 +85,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->LocalGenerator = (cmLocalVisualStudio7Generator*)this->GeneratorTarget->GetLocalGenerator(); this->Name = this->GeneratorTarget->GetName(); - this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); + this->GUID = this->GlobalGenerator->GetGUID(this->Name); this->Platform = gg->GetPlatformName(); this->NsightTegra = gg->IsNsightTegra(); for (int i = 0; i < 4; ++i) { @@ -144,7 +150,7 @@ void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( (*stream) << config << "|" << this->Platform; (*stream) << "'"; // handle special case for 32 bit C# targets - if (csproj == this->ProjectType && this->Platform == "Win32") { + if (this->ProjectType == csproj && this->Platform == "Win32") { (*stream) << " Or "; (*stream) << "'$(Configuration)|$(Platform)'=='"; (*stream) << config << "|x86"; @@ -292,7 +298,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("</PropertyGroup>\n", 1); } - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { this->WriteProjectConfigurations(); } this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1); @@ -309,7 +315,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES"); if (vsProjectTypes) { std::string tagName = "ProjectTypes"; - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { tagName = "ProjectTypeGuids"; } this->WriteString("", 2); @@ -405,7 +411,7 @@ void cmVisualStudio10TargetGenerator::Generate() globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") { continue; } - const char* value = this->GeneratorTarget->GetProperty(keyIt->c_str()); + const char* value = this->GeneratorTarget->GetProperty(*keyIt); if (!value) continue; this->WriteString("<", 2); @@ -463,7 +469,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteProjectConfigurationValues(); - if (vcxproj == this->ProjectType) { + if (this->ProjectType == vcxproj) { this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1); } this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1); @@ -566,7 +572,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString(import.c_str(), 2); } this->WriteString("</ImportGroup>\n", 1); - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { @@ -576,6 +582,18 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteEvents(*i); this->WriteString("</PropertyGroup>\n", 1); } + // make sure custom commands are executed before build (if necessary) + this->WriteString("<PropertyGroup>\n", 1); + this->WriteString("<BuildDependsOn>\n", 2); + for (std::set<std::string>::const_iterator i = + this->CSharpCustomCommandNames.begin(); + i != this->CSharpCustomCommandNames.end(); ++i) { + this->WriteString(i->c_str(), 3); + (*this->BuildFileStream) << ";\n"; + } + this->WriteString("$(BuildDependsOn)\n", 3); + this->WriteString("</BuildDependsOn>\n", 2); + this->WriteString("</PropertyGroup>\n", 1); } this->WriteString("</Project>", 0); // The groups are stored in a separate file for VS 10 @@ -657,9 +675,39 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference( this->WriteString("<HintPath>", 3); (*this->BuildFileStream) << hint << "</HintPath>\n"; } + this->WriteDotNetReferenceCustomTags(ref); this->WriteString("</Reference>\n", 2); } +void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( + std::string const& ref) +{ + + static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_"; + static const std::string refpropInfix = "_TAG_"; + const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix; + typedef std::map<std::string, std::string> CustomTags; + CustomTags tags; + cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); + for (cmPropertyMap::const_iterator i = props.begin(); i != props.end(); + ++i) { + if (i->first.find(refPropFullPrefix) == 0) { + std::string refTag = i->first.substr(refPropFullPrefix.length()); + std::string refVal = i->second.GetValue(); + if (!refTag.empty() && !refVal.empty()) { + tags[refTag] = refVal; + } + } + } + for (CustomTags::const_iterator tag = tags.begin(); tag != tags.end(); + ++tag) { + this->WriteString("<", 3); + (*this->BuildFileStream) << tag->first << ">" + << cmVS10EscapeXML(tag->second) << "</" + << tag->first << ">\n"; + } +} + void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { std::vector<cmSourceFile const*> resxObjs; @@ -675,7 +723,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() this->WriteString("<EmbeddedResource Include=\"", 2); this->ConvertToWindowsSlash(obj); bool useRelativePath = false; - if (csproj == this->ProjectType && this->InSourceBuild) { + if (this->ProjectType == csproj && this->InSourceBuild) { // If we do an in-source build and the resource file is in a // subdirectory // of the .csproj file, we have to use relative pathnames, otherwise @@ -688,7 +736,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() } (*this->BuildFileStream) << obj << "\">\n"; - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { this->WriteString("<DependentUpon>", 3); std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; (*this->BuildFileStream) << hFileName << "</DependentUpon>\n"; @@ -696,7 +744,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); + this->WritePlatformConfigTag("LogicalName", *i, 3); if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE") || // Handle variant of VS_GLOBAL_<variable> for RootNamespace. this->GeneratorTarget->GetProperty("VS_GLOBAL_RootNamespace")) { @@ -758,7 +806,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); ++p) { static const std::string propNamePrefix = "VS_CSHARP_"; - if (p->first.find(propNamePrefix.c_str()) == 0) { + if (p->first.find(propNamePrefix) == 0) { std::string tagName = p->first.substr(propNamePrefix.length()); if (!tagName.empty()) { std::string value = props.GetPropertyValue(p->first); @@ -798,7 +846,7 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup() } this->WriteSource(xamlType, *oi, ">\n"); - if (csproj == this->ProjectType && !this->InSourceBuild) { + if (this->ProjectType == csproj && !this->InSourceBuild) { // add <Link> tag to written XAML source if necessary const std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); const std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); @@ -914,10 +962,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - this->WritePlatformConfigTag("PropertyGroup", i->c_str(), 1, + this->WritePlatformConfigTag("PropertyGroup", *i, 1, " Label=\"Configuration\"", "\n"); - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { std::string configType = "<ConfigurationType>"; if (const char* vsConfigurationType = this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) { @@ -1038,8 +1086,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( this->WriteString("<DefineDebug>true</DefineDebug>\n", 2); } - std::string outDir = - this->GeneratorTarget->GetDirectory(config.c_str()) + "/"; + std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; this->ConvertToWindowsSlash(outDir); this->WriteString("<OutputPath>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(outDir) << "</OutputPath>\n"; @@ -1119,6 +1166,7 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues( void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); + this->CSharpCustomCommandNames.clear(); std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands, ""); for (std::vector<cmSourceFile const*>::const_iterator si = @@ -1140,9 +1188,14 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand( } } if (cmCustomCommand const* command = sf->GetCustomCommand()) { - this->WriteString("<ItemGroup>\n", 1); + // C# projects write their <Target> within WriteCustomRule() + if (this->ProjectType != csproj) { + this->WriteString("<ItemGroup>\n", 1); + } this->WriteCustomRule(sf, *command); - this->WriteString("</ItemGroup>\n", 1); + if (this->ProjectType != csproj) { + this->WriteString("</ItemGroup>\n", 1); + } } } } @@ -1177,8 +1230,20 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - this->WriteSource("CustomBuild", source, ">\n"); - + if (this->ProjectType != csproj) { + this->WriteSource("CustomBuild", source, ">\n"); + } else { + this->WriteString("<ItemGroup>\n", 1); + std::string link; + this->GetCSharpSourceLink(source, link); + this->WriteSource("None", source, ">\n"); + if (!link.empty()) { + this->WriteString("<Link>", 3); + (*this->BuildFileStream) << link << "</Link>\n"; + } + this->WriteString("</None>\n", 2); + this->WriteString("</ItemGroup>\n", 1); + } for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { @@ -1186,41 +1251,90 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( std::string comment = lg->ConstructComment(ccg); comment = cmVS10EscapeComment(comment); std::string script = cmVS10EscapeXML(lg->ConstructScript(ccg)); - this->WritePlatformConfigTag("Message", i->c_str(), 3); - (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n"; - this->WritePlatformConfigTag("Command", i->c_str(), 3); - (*this->BuildFileStream) << script << "</Command>\n"; - this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3); - - (*this->BuildFileStream) << cmVS10EscapeXML(source->GetFullPath()); + // input files for custom command + std::stringstream inputs; + inputs << cmVS10EscapeXML(source->GetFullPath()); for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin(); d != ccg.GetDepends().end(); ++d) { std::string dep; - if (this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), - dep)) { + if (this->LocalGenerator->GetRealDependency(*d, *i, dep)) { this->ConvertToWindowsSlash(dep); - (*this->BuildFileStream) << ";" << cmVS10EscapeXML(dep); + inputs << ";" << cmVS10EscapeXML(dep); } } - (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n"; - this->WritePlatformConfigTag("Outputs", i->c_str(), 3); + // output files for custom command + std::stringstream outputs; const char* sep = ""; for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin(); o != ccg.GetOutputs().end(); ++o) { std::string out = *o; this->ConvertToWindowsSlash(out); - (*this->BuildFileStream) << sep << cmVS10EscapeXML(out); + outputs << sep << cmVS10EscapeXML(out); sep = ";"; } - (*this->BuildFileStream) << "</Outputs>\n"; - if (this->LocalGenerator->GetVersion() > - cmGlobalVisualStudioGenerator::VS10) { - // VS >= 11 let us turn off linking of custom command outputs. - this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3); - (*this->BuildFileStream) << "false</LinkObjects>\n"; + if (this->ProjectType == csproj) { + std::string name = "CustomCommand_" + *i + "_" + + cmSystemTools::ComputeStringMD5(sourcePath); + std::string inputs_s = inputs.str(); + std::string outputs_s = outputs.str(); + comment = cmVS10EscapeQuotes(comment); + script = cmVS10EscapeQuotes(script); + inputs_s = cmVS10EscapeQuotes(inputs_s); + outputs_s = cmVS10EscapeQuotes(outputs_s); + this->WriteCustomRuleCSharp(*i, name, script, inputs_s, outputs_s, + comment); + } else { + this->WriteCustomRuleCpp(*i, script, inputs.str(), outputs.str(), + comment); } } - this->WriteString("</CustomBuild>\n", 2); + if (this->ProjectType != csproj) { + this->WriteString("</CustomBuild>\n", 2); + } +} + +void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( + std::string const& config, std::string const& script, + std::string const& inputs, std::string const& outputs, + std::string const& comment) +{ + this->WritePlatformConfigTag("Message", config, 3); + (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n"; + this->WritePlatformConfigTag("Command", config, 3); + (*this->BuildFileStream) << script << "</Command>\n"; + this->WritePlatformConfigTag("AdditionalInputs", config, 3); + (*this->BuildFileStream) << inputs; + (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n"; + this->WritePlatformConfigTag("Outputs", config, 3); + (*this->BuildFileStream) << outputs << "</Outputs>\n"; + if (this->LocalGenerator->GetVersion() > + cmGlobalVisualStudioGenerator::VS10) { + // VS >= 11 let us turn off linking of custom command outputs. + this->WritePlatformConfigTag("LinkObjects", config, 3); + (*this->BuildFileStream) << "false</LinkObjects>\n"; + } +} + +void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp( + std::string const& config, std::string const& name, + std::string const& script, std::string const& inputs, + std::string const& outputs, std::string const& comment) +{ + this->CSharpCustomCommandNames.insert(name); + std::stringstream attributes; + attributes << "\n Name=\"" << name << "\""; + attributes << "\n Inputs=\"" << inputs << "\""; + attributes << "\n Outputs=\"" << outputs << "\""; + this->WritePlatformConfigTag("Target", config, 1, attributes.str().c_str(), + "\n"); + if (!comment.empty()) { + this->WriteString("<Exec Command=\"", 2); + (*this->BuildFileStream) << "echo " << cmVS10EscapeXML(comment) + << "\" />\n"; + } + this->WriteString("<Exec Command=\"", 2); + (*this->BuildFileStream) << script << "\" />\n"; + this->WriteString("</Target>\n", 1); } std::string cmVisualStudio10TargetGenerator::ConvertPath( @@ -1243,7 +1357,7 @@ void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s) } void cmVisualStudio10TargetGenerator::WriteGroups() { - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { return; } @@ -1355,7 +1469,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guidName = "SG_Filter_"; guidName += name; this->WriteString("<UniqueIdentifier>", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); + std::string guid = this->GlobalGenerator->GetGUID(guidName); (*this->BuildFileStream) << "{" << guid << "}" << "</UniqueIdentifier>\n"; this->WriteString("</Filter>\n", 2); @@ -1366,7 +1480,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("<Filter Include=\"Resource Files\">\n", 2); std::string guidName = "SG_Filter_Resource Files"; this->WriteString("<UniqueIdentifier>", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); + std::string guid = this->GlobalGenerator->GetGUID(guidName); (*this->BuildFileStream) << "{" << guid << "}" << "</UniqueIdentifier>\n"; this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3); @@ -1485,7 +1599,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) std::string copyToOutDir; std::string includeInVsix; std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { // EVERY extra source file must have a <Link>, otherwise it might not // be visible in Visual Studio at all. The path relative to current // source- or binary-dir is used within the link, if the file is @@ -1564,6 +1678,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) toolHasSettings = true; } + // Collect VS_CSHARP_* property values (if some are set) + std::map<std::string, std::string> sourceFileTags; + this->GetCSharpSourceProperties(sf, sourceFileTags); + if (this->NsightTegra) { // Nsight Tegra needs specific file types to check up-to-dateness. std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName()); @@ -1680,7 +1798,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) (*this->BuildFileStream) << cmVS10EscapeXML(includeInVsix) << "</IncludeInVSIX>\n"; } - + // write source file specific tags + this->WriteCSharpSourceProperties(sourceFileTags); this->WriteString("</", 2); (*this->BuildFileStream) << tool << ">\n"; } else { @@ -1929,7 +2048,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string configDefines = defines; std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += configUpper; - if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) { + if (const char* ccdefs = sf.GetProperty(defPropName)) { if (!configDefines.empty()) { configDefines += ";"; } @@ -1944,7 +2063,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( hasFlags = true; cmGlobalVisualStudio10Generator* gg = static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); - cmIDEFlagTable const* flagtable = CM_NULLPTR; + cmIDEFlagTable const* flagtable = nullptr; const std::string& srclang = source->GetLanguage(); if (srclang == "C" || srclang == "CXX") { flagtable = gg->GetClFlagTable(); @@ -2002,48 +2121,23 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n"; } - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { std::string f = source->GetFullPath(); typedef std::map<std::string, std::string> CsPropMap; CsPropMap sourceFileTags; // set <Link> tag if necessary - if (!this->InSourceBuild) { - const std::string stripFromPath = - this->Makefile->GetCurrentSourceDirectory(); - if (f.find(stripFromPath) != std::string::npos) { - std::string link = f.substr(stripFromPath.length() + 1); - this->ConvertToWindowsSlash(link); - sourceFileTags["Link"] = link; - } - } - const cmPropertyMap& props = sf.GetProperties(); - for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); - ++p) { - static const std::string propNamePrefix = "VS_CSHARP_"; - if (p->first.find(propNamePrefix.c_str()) == 0) { - std::string tagName = p->first.substr(propNamePrefix.length()); - if (!tagName.empty()) { - const std::string val = props.GetPropertyValue(p->first); - if (!val.empty()) { - sourceFileTags[tagName] = val; - } else { - sourceFileTags.erase(tagName); - } - } - } + std::string link; + this->GetCSharpSourceLink(source, link); + if (!link.empty()) { + sourceFileTags["Link"] = link; } + this->GetCSharpSourceProperties(&sf, sourceFileTags); // write source file specific tags if (!sourceFileTags.empty()) { hasFlags = true; (*this->BuildFileStream) << firstString; firstString = ""; - for (CsPropMap::const_iterator i = sourceFileTags.begin(); - i != sourceFileTags.end(); ++i) { - this->WriteString("<", 3); - (*this->BuildFileStream) - << i->first << ">" << cmVS10EscapeXML(i->second) << "</" << i->first - << ">\n"; - } + this->WriteCSharpSourceProperties(sourceFileTags); } } @@ -2069,7 +2163,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() if (ttype > cmStateEnums::GLOBAL_TARGET) { return; } - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { return; } @@ -2081,7 +2175,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() this->Configurations.begin(); config != this->Configurations.end(); ++config) { if (ttype >= cmStateEnums::UTILITY) { - this->WritePlatformConfigTag("IntDir", config->c_str(), 2); + this->WritePlatformConfigTag("IntDir", *config, 2); *this->BuildFileStream << "$(Platform)\\$(Configuration)\\$(ProjectName)\\" << "</IntDir>\n"; @@ -2098,30 +2192,30 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() targetNameFull = this->GeneratorTarget->GetName(); targetNameFull += ".lib"; } else { - outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); + outDir = this->GeneratorTarget->GetDirectory(*config) + "/"; + targetNameFull = this->GeneratorTarget->GetFullName(*config); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); - this->WritePlatformConfigTag("OutDir", config->c_str(), 2); + this->WritePlatformConfigTag("OutDir", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n"; - this->WritePlatformConfigTag("IntDir", config->c_str(), 2); + this->WritePlatformConfigTag("IntDir", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(intermediateDir) << "</IntDir>\n"; if (const char* workingDir = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_WORKING_DIRECTORY")) { - this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", - config->c_str(), 2); + this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", *config, + 2); *this->BuildFileStream << cmVS10EscapeXML(workingDir) << "</LocalDebuggerWorkingDirectory>\n"; } std::string name = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); - this->WritePlatformConfigTag("TargetName", config->c_str(), 2); + this->WritePlatformConfigTag("TargetName", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n"; std::string ext = @@ -2131,7 +2225,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() // A single "." appears to be treated as an empty extension. ext = "."; } - this->WritePlatformConfigTag("TargetExt", config->c_str(), 2); + this->WritePlatformConfigTag("TargetExt", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n"; this->OutputLinkIncremental(*config); @@ -2146,7 +2240,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( if (!this->MSTools) { return; } - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { return; } // static libraries and things greater than modules do not need @@ -2158,13 +2252,13 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( Options& linkOptions = *(this->LinkOptions[configName]); const char* incremental = linkOptions.GetFlag("LinkIncremental"); - this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 2); + this->WritePlatformConfigTag("LinkIncremental", configName, 2); *this->BuildFileStream << (incremental ? incremental : "true") << "</LinkIncremental>\n"; linkOptions.RemoveFlag("LinkIncremental"); const char* manifest = linkOptions.GetFlag("GenerateManifest"); - this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 2); + this->WritePlatformConfigTag("GenerateManifest", configName, 2); *this->BuildFileStream << (manifest ? manifest : "true") << "</GenerateManifest>\n"; linkOptions.RemoveFlag("GenerateManifest"); @@ -2175,7 +2269,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( for (const char** f = flags; *f; ++f) { const char* flag = *f; if (const char* value = linkOptions.GetFlag(flag)) { - this->WritePlatformConfigTag(flag, configName.c_str(), 2); + this->WritePlatformConfigTag(flag, configName, 2); *this->BuildFileStream << value << "</" << flag << ">\n"; linkOptions.RemoveFlag(flag); } @@ -2219,7 +2313,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName); if (linkLanguage.empty()) { cmSystemTools::Error( "CMake can not determine linker language for target: ", @@ -2250,13 +2344,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( baseFlagVar += "_FLAGS"; flags = this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - baseFlagVar.c_str()); + baseFlagVar); std::string flagVar = baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName); flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - flagVar.c_str()); + flagVar); this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, langForClCompile, configName); } @@ -2275,7 +2369,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string defineFlags = this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags(); if (this->MSTools) { - if (vcxproj == this->ProjectType) { + if (this->ProjectType == vcxproj) { clOptions.FixExceptionHandlingDefault(); clOptions.AddFlag("PrecompiledHeader", "NotUsing"); std::string asmLocation = configName + "/"; @@ -2287,12 +2381,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::vector<std::string> targetDefines; switch (this->ProjectType) { case vcxproj: - this->GeneratorTarget->GetCompileDefinitions(targetDefines, - configName.c_str(), "CXX"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CXX"); break; case csproj: - this->GeneratorTarget->GetCompileDefinitions( - targetDefines, configName.c_str(), "CSharp"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CSharp"); break; } clOptions.AddDefines(targetDefines); @@ -2332,7 +2426,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } - if (csproj != this->ProjectType && clOptions.IsManaged()) { + if (this->ProjectType != csproj && clOptions.IsManaged()) { this->Managed = true; std::string managedType = clOptions.GetFlag("CompileAsManaged"); if (managedType == "Safe") { @@ -2340,6 +2434,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AddFlag("CallingConvention", ""); } } + if (this->ProjectType == csproj) { + // /nowin32manifest overrides /win32manifest: parameter + if (clOptions.HasFlag("NoWin32Manifest")) { + clOptions.RemoveFlag("ApplicationManifest"); + } + } this->ClOptions[configName] = pOptions.release(); return true; @@ -2392,8 +2492,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = - this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); + std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); if (!pdb.empty()) { this->ConvertToWindowsSlash(pdb); this->WriteString("<ProgramDataBaseFileName>", 3); @@ -2535,8 +2634,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.FixCudaCodeGeneration(); std::vector<std::string> targetDefines; - this->GeneratorTarget->GetCompileDefinitions(targetDefines, - configName.c_str(), "CUDA"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CUDA"); cudaOptions.AddDefines(targetDefines); // Add a definition for the configuration name. @@ -3006,11 +3105,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkFlagVarBase += "_LINKER_FLAGS"; flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - linkFlagVarBase.c_str()); + linkFlagVarBase); std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG; flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - linkFlagVar.c_str()); + linkFlagVar); const char* targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { @@ -3020,13 +3119,13 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string flagsProp = "LINK_FLAGS_"; flagsProp += CONFIG; if (const char* flagsConfig = - this->GeneratorTarget->GetProperty(flagsProp.c_str())) { + this->GeneratorTarget->GetProperty(flagsProp)) { flags += " "; flags += flagsConfig; } cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( "CMake can not compute cmComputeLinkInformation for target: ", @@ -3054,8 +3153,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string standardLibsVar = "CMAKE_"; standardLibsVar += linkLanguage; standardLibsVar += "_STANDARD_LIBRARIES"; - std::string const libs = - this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); + std::string const libs = this->Makefile->GetSafeDefinition(standardLibsVar); cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec); linkOptions.AddFlag("AdditionalDependencies", libVec); @@ -3083,13 +3181,12 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string targetNameImport; std::string targetNamePDB; if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, - targetNameImport, targetNamePDB, - config.c_str()); + this->GeneratorTarget->GetExecutableNames( + targetName, targetNameFull, targetNameImport, targetNamePDB, config); } else { this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, - targetNamePDB, config.c_str()); + targetNamePDB, config); } if (this->MSTools) { @@ -3130,11 +3227,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AddFlag("GenerateDebugInformation", "false"); - std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); + std::string pdb = this->GeneratorTarget->GetPDBDirectory(config); pdb += "/"; pdb += targetNamePDB; std::string imLib = this->GeneratorTarget->GetDirectory( - config.c_str(), cmStateEnums::ImportLibraryArtifact); + config, cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; @@ -3209,7 +3306,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( std::string const& config) { cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( "CMake can not compute cmComputeLinkInformation for target: ", @@ -3224,8 +3321,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( this->LocalGenerator->GetCurrentBinaryDirectory(); for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { if (l->IsPath && cmVS10IsTargetsFile(l->Value)) { - std::string path = this->LocalGenerator->ConvertToRelativePath( - currentBinDir, l->Value.c_str()); + std::string path = + this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value); this->ConvertToWindowsSlash(path); this->AddTargetsFileAndConfigPair(path, config); } @@ -3241,7 +3338,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) { return; } - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { return; } Options& linkOptions = *(this->LinkOptions[config]); @@ -3270,8 +3367,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries( this->LocalGenerator->GetCurrentBinaryDirectory(); for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { if (l->IsPath) { - std::string path = this->LocalGenerator->ConvertToRelativePath( - currentBinDir, l->Value.c_str()); + std::string path = + this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value); this->ConvertToWindowsSlash(path); if (cmVS10IsTargetsFile(l->Value)) { vsTargetVec.push_back(path); @@ -3311,7 +3408,7 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions( if (!this->MSTools) { return; } - if (csproj == this->ProjectType) { + if (this->ProjectType == csproj) { return; } @@ -3353,17 +3450,20 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions( void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() { + if (this->ProjectType == csproj) { + return; + } for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { std::vector<std::string> includes; this->LocalGenerator->GetIncludeDirectories( - includes, this->GeneratorTarget, "C", i->c_str()); + includes, this->GeneratorTarget, "C", *i); for (std::vector<std::string>::iterator ii = includes.begin(); ii != includes.end(); ++ii) { this->ConvertToWindowsSlash(*ii); } - this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); + this->WritePlatformConfigTag("ItemDefinitionGroup", *i, 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { @@ -3377,7 +3477,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() // output midl flags <Midl></Midl> this->WriteMidlOptions(*i, includes); // write events - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { this->WriteEvents(*i); } // output link flags <Link></Link> @@ -3443,17 +3543,21 @@ void cmVisualStudio10TargetGenerator::WriteEvent( script += cmVS10EscapeXML(lg->ConstructScript(ccg)); } comment = cmVS10EscapeComment(comment); - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { this->WriteString("<Message>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n"; this->WriteString("<Command>", 3); } else { - if (!comment.empty()) { + std::string strippedComment = comment; + strippedComment.erase( + std::remove(strippedComment.begin(), strippedComment.end(), '\t'), + strippedComment.end()); + if (!comment.empty() && !strippedComment.empty()) { (*this->BuildFileStream) << "echo " << cmVS10EscapeXML(comment) << "\n"; } } (*this->BuildFileStream) << script; - if (csproj != this->ProjectType) { + if (this->ProjectType != csproj) { (*this->BuildFileStream) << "</Command>"; } (*this->BuildFileStream) << "\n"; @@ -3497,11 +3601,12 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("<Project>", 3); - (*this->BuildFileStream) - << "{" << this->GlobalGenerator->GetGUID(name.c_str()) << "}"; + (*this->BuildFileStream) << "{" << this->GlobalGenerator->GetGUID(name) + << "}"; (*this->BuildFileStream) << "</Project>\n"; this->WriteString("<Name>", 3); (*this->BuildFileStream) << name << "</Name>\n"; + this->WriteDotNetReferenceCustomTags(name); this->WriteString("</ProjectReference>\n", 2); } this->WriteString("</ItemGroup>\n", 1); @@ -3593,10 +3698,10 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences() this->WriteSingleSDKReference("WindowsIoT", iotExtensionsVersion); } } + } - if (hasWrittenItemGroup) { - this->WriteString("</ItemGroup>\n", 1); - } + if (hasWrittenItemGroup) { + this->WriteString("</ItemGroup>\n", 1); } } @@ -3770,7 +3875,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() this->WriteString("<XapOutputs>true</XapOutputs>\n", 2); this->WriteString("<XapFilename>", 2); (*this->BuildFileStream) - << cmVS10EscapeXML(this->Name.c_str()) + << cmVS10EscapeXML(this->Name) << "_$(Configuration)_$(Platform).xap</XapFilename>\n"; } } @@ -4289,6 +4394,59 @@ bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const return true; } +void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties( + cmSourceFile const* sf, std::map<std::string, std::string>& tags) +{ + if (this->ProjectType == csproj) { + const cmPropertyMap& props = sf->GetProperties(); + for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); + ++p) { + static const std::string propNamePrefix = "VS_CSHARP_"; + if (p->first.find(propNamePrefix) == 0) { + std::string tagName = p->first.substr(propNamePrefix.length()); + if (!tagName.empty()) { + const std::string val = props.GetPropertyValue(p->first); + if (!val.empty()) { + tags[tagName] = val; + } else { + tags.erase(tagName); + } + } + } + } + } +} + +void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties( + const std::map<std::string, std::string>& tags) +{ + if (!tags.empty()) { + for (std::map<std::string, std::string>::const_iterator i = tags.begin(); + i != tags.end(); ++i) { + this->WriteString("<", 3); + (*this->BuildFileStream) << i->first << ">" << cmVS10EscapeXML(i->second) + << "</" << i->first << ">\n"; + } + } +} + +void cmVisualStudio10TargetGenerator::GetCSharpSourceLink( + cmSourceFile const* sf, std::string& link) +{ + std::string f = sf->GetFullPath(); + if (!this->InSourceBuild) { + const std::string stripFromPath = + this->Makefile->GetCurrentSourceDirectory(); + if (f.find(stripFromPath) != std::string::npos) { + link = f.substr(stripFromPath.length() + 1); + if (const char* l = sf->GetProperty("VS_CSHARP_Link")) { + link = l; + } + this->ConvertToWindowsSlash(link); + } + } +} + std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( const char* relativeFilePath) const { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 6106615..fb24f1a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioTargetGenerator_h #define cmVisualStudioTargetGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> @@ -66,6 +66,7 @@ private: void WriteAllSources(); void WriteDotNetReferences(); void WriteDotNetReference(std::string const& ref, std::string const& hint); + void WriteDotNetReferenceCustomTags(std::string const& ref); void WriteEmbeddedResourceGroup(); void WriteWinRTReferences(); void WriteWinRTPackageCertificateKeyFile(); @@ -126,6 +127,16 @@ private: void OutputLinkIncremental(std::string const& configName); void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const& command); + void WriteCustomRuleCpp(std::string const& config, std::string const& script, + std::string const& inputs, + std::string const& outputs, + std::string const& comment); + void WriteCustomRuleCSharp(std::string const& config, + std::string const& commandName, + std::string const& script, + std::string const& inputs, + std::string const& outputs, + std::string const& comment); void WriteCustomCommands(); void WriteCustomCommand(cmSourceFile const* sf); void WriteGroups(); @@ -153,6 +164,12 @@ private: bool ForceOld(const std::string& source) const; + void GetCSharpSourceProperties(cmSourceFile const* sf, + std::map<std::string, std::string>& tags); + void WriteCSharpSourceProperties( + const std::map<std::string, std::string>& tags); + void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link); + private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map<std::string, Options*> OptionsMap; @@ -187,6 +204,7 @@ private: cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; std::set<cmSourceFile const*> SourcesVisited; + std::set<std::string> CSharpCustomCommandNames; bool IsMissingFiles; std::vector<std::string> AddedFiles; std::string DefaultArtifactDir; diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h index 4233337..c736a49 100644 --- a/Source/cmVisualStudio10ToolsetOptions.h +++ b/Source/cmVisualStudio10ToolsetOptions.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudio10ToolsetOptions_h #define cmVisualStudio10ToolsetOptions_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 1f808c8..51944fa 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -89,7 +89,7 @@ void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table) void cmVisualStudioGeneratorOptions::ClearTables() { for (int i = 0; i < FlagTableCount; ++i) { - this->FlagTable[i] = CM_NULLPTR; + this->FlagTable[i] = nullptr; } } diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 44d2719..8d7942b 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioGeneratorOptions_h #define cmVisualStudioGeneratorOptions_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h index e12047f..9c1dffc 100644 --- a/Source/cmVisualStudioSlnData.h +++ b/Source/cmVisualStudioSlnData.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioSlnData_h #define cmVisualStudioSlnData_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h index d517324..d6345a8 100644 --- a/Source/cmVisualStudioSlnParser.h +++ b/Source/cmVisualStudioSlnParser.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioSlnParser_h #define cmVisualStudioSlnParser_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <bitset> #include <iosfwd> diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h index 75c3d1a..c19691a 100644 --- a/Source/cmVisualStudioWCEPlatformParser.h +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioWCEPlatformParser_h #define cmVisualStudioWCEPlatformParser_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <stddef.h> diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index a95e4c3..dfd5afc 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -3,7 +3,7 @@ #ifndef cmWhileCommand_h #define cmWhileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 19922cd..36a08a4 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -3,7 +3,7 @@ #ifndef cmWriteFileCommand_h #define cmWriteFileCommand_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 5c22531..bca39af 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -10,13 +10,12 @@ #include "cmGeneratorTarget.h" #include "cmXMLSafe.h" -cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, +cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, const std::vector<std::string>& configList, unsigned int xcVersion) : Target(xcObj) + , Tests(tests) , TargetName(xcObj->GetTarget()->GetName()) - , BuildableName(xcObj->GetTarget()->GetFullName()) - , TargetId(xcObj->GetId()) , ConfigList(configList) , XcodeVersion(xcVersion) { @@ -58,7 +57,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, xout.Attribute("version", "1.3"); WriteBuildAction(xout, container); - WriteTestAction(xout, FindConfiguration("Debug")); + WriteTestAction(xout, FindConfiguration("Debug"), container); WriteLaunchAction(xout, FindConfiguration("Debug"), container); WriteProfileAction(xout, FindConfiguration("Release")); WriteAnalyzeAction(xout, FindConfiguration("Debug")); @@ -84,14 +83,7 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, xout.Attribute("buildForArchiving", "YES"); xout.Attribute("buildForAnalyzing", "YES"); - xout.StartElement("BuildableReference"); - xout.BreakAttributes(); - xout.Attribute("BuildableIdentifier", "primary"); - xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->BuildableName); - xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + container); - xout.EndElement(); + WriteBuildableReference(xout, this->Target, container); xout.EndElement(); // BuildActionEntry xout.EndElement(); // BuildActionEntries @@ -99,7 +91,8 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, } void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, - std::string configuration) + std::string configuration, + const std::string& container) { xout.StartElement("TestAction"); xout.BreakAttributes(); @@ -111,8 +104,22 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); xout.StartElement("Testables"); + for (TestObjects::const_iterator it = this->Tests.begin(); + it != this->Tests.end(); ++it) { + xout.StartElement("TestableReference"); + xout.BreakAttributes(); + xout.Attribute("skipped", "NO"); + WriteBuildableReference(xout, *it, container); + xout.EndElement(); // TestableReference + } xout.EndElement(); + if (IsTestable()) { + xout.StartElement("MacroExpansion"); + WriteBuildableReference(xout, this->Target, container); + xout.EndElement(); // MacroExpansion + } + xout.StartElement("AdditionalOptions"); xout.EndElement(); @@ -146,14 +153,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.StartElement("MacroExpansion"); } - xout.StartElement("BuildableReference"); - xout.BreakAttributes(); - xout.Attribute("BuildableIdentifier", "primary"); - xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->BuildableName); - xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + container); - xout.EndElement(); + WriteBuildableReference(xout, this->Target, container); xout.EndElement(); // MacroExpansion @@ -195,6 +195,20 @@ void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout, xout.EndElement(); } +void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout, + const cmXCodeObject* xcObj, + const std::string& container) +{ + xout.StartElement("BuildableReference"); + xout.BreakAttributes(); + xout.Attribute("BuildableIdentifier", "primary"); + xout.Attribute("BlueprintIdentifier", xcObj->GetId()); + xout.Attribute("BuildableName", xcObj->GetTarget()->GetFullName()); + xout.Attribute("BlueprintName", xcObj->GetTarget()->GetName()); + xout.Attribute("ReferencedContainer", "container:" + container); + xout.EndElement(); +} + std::string cmXCodeScheme::WriteVersionString() { std::ostringstream v; @@ -215,6 +229,11 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name) return name; } +bool cmXCodeScheme::IsTestable() const +{ + return !this->Tests.empty() || IsExecutable(this->Target); +} + bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target) { cmGeneratorTarget* gt = target->GetTarget(); diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 379afed..def75b1 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <vector> + #include "cmGlobalXCodeGenerator.h" #include "cmSystemTools.h" #include "cmXCodeObject.h" @@ -16,7 +18,9 @@ class cmXCodeScheme { public: - cmXCodeScheme(cmXCodeObject* xcObj, + typedef std::vector<const cmXCodeObject*> TestObjects; + + cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, const std::vector<std::string>& configList, unsigned int xcVersion); @@ -25,25 +29,30 @@ public: private: const cmXCodeObject* const Target; + const TestObjects Tests; const std::string& TargetName; - const std::string BuildableName; - const std::string& TargetId; const std::vector<std::string>& ConfigList; const unsigned int XcodeVersion; void WriteXCodeXCScheme(std::ostream& fout, const std::string& container); void WriteBuildAction(cmXMLWriter& xout, const std::string& container); - void WriteTestAction(cmXMLWriter& xout, std::string configuration); + void WriteTestAction(cmXMLWriter& xout, std::string configuration, + const std::string& container); void WriteLaunchAction(cmXMLWriter& xout, std::string configuration, const std::string& container); void WriteProfileAction(cmXMLWriter& xout, std::string configuration); void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration); void WriteArchiveAction(cmXMLWriter& xout, std::string configuration); + void WriteBuildableReference(cmXMLWriter& xout, const cmXCodeObject* xcObj, + const std::string& container); + std::string WriteVersionString(); std::string FindConfiguration(const std::string& name); + bool IsTestable() const; + static bool IsExecutable(const cmXCodeObject* target); }; diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 18afbf3..920e3a5 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -11,10 +11,10 @@ cmXMLParser::cmXMLParser() { - this->Parser = CM_NULLPTR; + this->Parser = nullptr; this->ParseError = 0; - this->ReportCallback = CM_NULLPTR; - this->ReportCallbackData = CM_NULLPTR; + this->ReportCallback = nullptr; + this->ReportCallbackData = nullptr; } cmXMLParser::~cmXMLParser() @@ -26,7 +26,7 @@ cmXMLParser::~cmXMLParser() int cmXMLParser::Parse(const char* string) { - return (int)this->InitializeParser() && + return this->InitializeParser() && this->ParseChunk(string, strlen(string)) && this->CleanupParser(); } @@ -55,7 +55,7 @@ int cmXMLParser::InitializeParser() } // Create the expat XML parser. - this->Parser = XML_ParserCreate(CM_NULLPTR); + this->Parser = XML_ParserCreate(nullptr); XML_SetElementHandler(static_cast<XML_Parser>(this->Parser), &cmXMLParserStartElement, &cmXMLParserEndElement); XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser), @@ -99,7 +99,7 @@ int cmXMLParser::CleanupParser() // Clean up the parser. XML_ParserFree(static_cast<XML_Parser>(this->Parser)); - this->Parser = CM_NULLPTR; + this->Parser = nullptr; return result; } @@ -156,7 +156,7 @@ const char* cmXMLParser::FindAttribute(const char** atts, } } } - return CM_NULLPTR; + return nullptr; } void cmXMLParserStartElement(void* parser, const char* name, const char** atts) diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index ed76a88..9d89fec 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -3,7 +3,7 @@ #ifndef cmXMLWiter_h #define cmXMLWiter_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmXMLSafe.h" diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx index 773602a..1ac9220 100644 --- a/Source/cm_auto_ptr.hxx +++ b/Source/cm_auto_ptr.hxx @@ -112,7 +112,7 @@ public: * * auto_ptr<X> ptr(new X()); */ - explicit auto_ptr(X* p = CM_NULLPTR) throw() + explicit auto_ptr(X* p = nullptr) throw() : x_(p) { } @@ -154,7 +154,7 @@ public: X* release() throw() { X* x = this->x_; - this->x_ = CM_NULLPTR; + this->x_ = nullptr; return x; } diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h index 26e4baa..796f027 100644 --- a/Source/cm_sys_stat.h +++ b/Source/cm_sys_stat.h @@ -7,6 +7,11 @@ typedef unsigned short mode_t; #endif +#if defined(WIN32) +typedef unsigned short uid_t; +typedef unsigned short gid_t; +#endif + #include <sys/types.h> // include sys/stat.h after sys/types.h #include <sys/stat.h> diff --git a/Source/cm_unordered_map.hxx b/Source/cm_unordered_map.hxx deleted file mode 100644 index bf38903..0000000 --- a/Source/cm_unordered_map.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_UNORDERED_MAP_HXX -#define CM_UNORDERED_MAP_HXX - -#include "cmConfigure.h" - -#if defined(CMake_HAVE_CXX_UNORDERED_MAP) - -#include <unordered_map> -#define CM_UNORDERED_MAP std::unordered_map - -#elif defined(CMAKE_BUILD_WITH_CMAKE) - -#include "cmsys/hash_map.hxx" -#define CM_UNORDERED_MAP cmsys::hash_map - -#else - -#include <map> -#define CM_UNORDERED_MAP std::map - -#endif - -#endif diff --git a/Source/cm_unordered_set.hxx b/Source/cm_unordered_set.hxx deleted file mode 100644 index dd1a9a1..0000000 --- a/Source/cm_unordered_set.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_UNORDERED_SET_HXX -#define CM_UNORDERED_SET_HXX - -#include "cmConfigure.h" - -#if defined(CMake_HAVE_CXX_UNORDERED_SET) - -#include <unordered_set> -#define CM_UNORDERED_SET std::unordered_set - -#elif defined(CMAKE_BUILD_WITH_CMAKE) - -#include "cmsys/hash_set.hxx" -#define CM_UNORDERED_SET cmsys::hash_set - -#else - -#include <set> -#define CM_UNORDERED_SET std::set - -#endif - -#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6894393..425e221 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -32,7 +32,7 @@ #include "cmGraphVizWriter.h" #include "cmVariableWatch.h" -#include "cm_unordered_map.hxx" +#include <unordered_map> #endif // only build kdevelop generator on non-windows platforms @@ -120,7 +120,7 @@ namespace { #if defined(CMAKE_BUILD_WITH_CMAKE) -typedef CM_UNORDERED_MAP<std::string, Json::Value> JsonValueMapType; +typedef std::unordered_map<std::string, Json::Value> JsonValueMapType; #endif } // namespace @@ -163,9 +163,9 @@ cmake::cmake(Role role) } #endif - this->GlobalGenerator = CM_NULLPTR; - this->ProgressCallback = CM_NULLPTR; - this->ProgressCallbackClientData = CM_NULLPTR; + this->GlobalGenerator = nullptr; + this->ProgressCallback = nullptr; + this->ProgressCallbackClientData = nullptr; this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE @@ -215,7 +215,7 @@ cmake::~cmake() delete this->Messenger; if (this->GlobalGenerator) { delete this->GlobalGenerator; - this->GlobalGenerator = CM_NULLPTR; + this->GlobalGenerator = nullptr; } cmDeleteAll(this->Generators); #ifdef CMAKE_BUILD_WITH_CMAKE @@ -555,7 +555,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) gg->CreateGenerationObjects(); cmLocalGenerator* lg = gg->LocalGenerators[0]; std::string includeFlags = - lg->GetIncludeFlags(includeDirs, CM_NULLPTR, language); + lg->GetIncludeFlags(includeDirs, nullptr, language); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); @@ -983,7 +983,7 @@ createExtraGenerator( } } return std::make_pair( - static_cast<cmExternalMakefileProjectGenerator*>(CM_NULLPTR), name); + static_cast<cmExternalMakefileProjectGenerator*>(nullptr), name); } cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) @@ -993,7 +993,7 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) cmExternalMakefileProjectGenerator* extraGenerator = extra.first; const std::string name = extra.second; - cmGlobalGenerator* generator = CM_NULLPTR; + cmGlobalGenerator* generator = nullptr; for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(); i != this->Generators.end(); ++i) { generator = (*i)->CreateGlobalGenerator(name, this); @@ -2127,7 +2127,7 @@ cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const cmInstalledFile const& file = i->second; return &file; } - return CM_NULLPTR; + return nullptr; } int cmake::GetSystemInformation(std::vector<std::string>& args) diff --git a/Source/cmake.h b/Source/cmake.h index 4ddacf7..a2054ef 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -3,7 +3,7 @@ #ifndef cmake_h #define cmake_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <set> @@ -268,8 +268,7 @@ public: * number provided may be negative in cases where a message is * to be displayed without any progress percentage. */ - void SetProgressCallback(ProgressCallbackType f, - void* clientData = CM_NULLPTR); + void SetProgressCallback(ProgressCallbackType f, void* clientData = nullptr); ///! this is called by generators to update the progress void UpdateProgress(const char* msg, float prog); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index c5a6836..d4e1925 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmConfigure.h" +#include "cmake.h" #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" #include "cmGlobalGenerator.h" @@ -9,12 +9,16 @@ #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" #include "cmcmd.h" #ifdef CMAKE_BUILD_WITH_CMAKE #include "cmDocumentation.h" #include "cmDynamicLoader.h" +#ifdef _WIN32 +#include <fcntl.h> /* _O_TEXT */ +#include <stdlib.h> /* _set_fmode, _fmode */ +#endif +#include "cm_uv.h" #endif #include "cmsys/Encoding.hxx" @@ -26,33 +30,24 @@ #include <string> #include <vector> -#ifdef CMAKE_USE_LIBUV -#ifdef _WIN32 -#include <fcntl.h> /* _O_TEXT */ -#include <stdlib.h> /* _set_fmode, _fmode */ -#endif -#include "cm_uv.h" -#endif - #ifdef CMAKE_BUILD_WITH_CMAKE static const char* cmDocumentationName[][2] = { - { CM_NULLPTR, " cmake - Cross-Platform Makefile Generator." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " cmake - Cross-Platform Makefile Generator." }, + { nullptr, nullptr } }; static const char* cmDocumentationUsage[][2] = { - { CM_NULLPTR, " cmake [options] <path-to-source>\n" - " cmake [options] <path-to-existing-build>" }, - { CM_NULLPTR, - "Specify a source directory to (re-)generate a build system for " - "it in the current working directory. Specify an existing build " - "directory to re-generate its build system." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " cmake [options] <path-to-source>\n" + " cmake [options] <path-to-existing-build>" }, + { nullptr, "Specify a source directory to (re-)generate a build system for " + "it in the current working directory. Specify an existing build " + "directory to re-generate its build system." }, + { nullptr, nullptr } }; static const char* cmDocumentationUsageNote[][2] = { - { CM_NULLPTR, "Run 'cmake --help' for more information." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, "Run 'cmake --help' for more information." }, + { nullptr, nullptr } }; #define CMAKE_BUILD_OPTIONS \ @@ -88,7 +83,7 @@ static const char* cmDocumentationOptions[][2] = { { "--no-warn-unused-cli", "Don't warn about command line options." }, { "--check-system-vars", "Find problems with variable usage in system " "files." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; #endif @@ -107,14 +102,14 @@ static int do_build(int ac, char const* const* av); static cmMakefile* cmakemainGetMakefile(void* clientdata) { - cmake* cm = (cmake*)clientdata; + cmake* cm = reinterpret_cast<cmake*>(clientdata); if (cm && cm->GetDebugOutput()) { cmGlobalGenerator* gg = cm->GetGlobalGenerator(); if (gg) { return gg->GetCurrentMakefile(); } } - return CM_NULLPTR; + return nullptr; } static std::string cmakemainGetStack(void* clientdata) @@ -172,7 +167,7 @@ int main(int ac, char const* const* av) ac = args.argc(); av = args.argv(); -#if defined(CMAKE_USE_LIBUV) && defined(_WIN32) +#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) // Perform libuv one-time initialization now, and then un-do its // global _fmode setting so that using libuv does not change the // default file text/binary mode. See libuv issue 840. @@ -197,8 +192,6 @@ int main(int ac, char const* const* av) int ret = do_cmake(ac, av); #ifdef CMAKE_BUILD_WITH_CMAKE cmDynamicLoader::FlushCache(); -#endif -#ifdef CMAKE_USE_LIBUV uv_loop_close(uv_default_loop()); #endif return ret; @@ -310,8 +303,8 @@ int do_cmake(int ac, char const* const* av) cmake cm(role); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); - cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm); - cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm); + cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); + cm.SetProgressCallback(cmakemainProgressCallback, &cm); cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); @@ -426,8 +419,8 @@ static int do_build(int ac, char const* const* av) } cmake cm(cmake::RoleInternal); - cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm); - cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm); + cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); + cm.SetProgressCallback(cmakemainProgressCallback, &cm); return cm.Build(dir, target, config, nativeOptions, clean); #endif } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index d5b0861..bf5479c 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -15,13 +15,10 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE -#include "cmServer.h" -#include "cmServerConnection.h" -#endif - #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. +#include "cmServer.h" +#include "cmServerConnection.h" #endif #if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) @@ -32,7 +29,6 @@ #include "cmVisualStudioWCEPlatformParser.h" #endif -#include "cmConfigure.h" #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" #include "cmsys/Process.h" @@ -44,6 +40,8 @@ #include <stdlib.h> #include <time.h> +class cmConnection; + int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, std::vector<std::string>::const_iterator argEnd); int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, @@ -88,6 +86,11 @@ void CMakeCommandUsage(const char* program) << " environment - display the current environment\n" << " make_directory <dir>... - create parent and <dir> directories\n" << " md5sum <file>... - create MD5 checksum of files\n" + << " sha1sum <file>... - create SHA1 checksum of files\n" + << " sha224sum <file>... - create SHA224 checksum of files\n" + << " sha256sum <file>... - create SHA256 checksum of files\n" + << " sha384sum <file>... - create SHA384 checksum of files\n" + << " sha512sum <file>... - create SHA512 checksum of files\n" << " remove [-f] <file>... - remove the file(s), use -f to force " "it\n" << " remove_directory dir - remove a directory and its contents\n" @@ -342,8 +345,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the iwyu command line. Capture its stderr and hide its stdout. // Ignore its return code because the tool always returns non-zero. std::string stdErr; - if (!cmSystemTools::RunSingleCommand(iwyu_cmd, CM_NULLPTR, &stdErr, - &ret, CM_NULLPTR, + if (!cmSystemTools::RunSingleCommand(iwyu_cmd, nullptr, &stdErr, &ret, + nullptr, cmSystemTools::OUTPUT_NONE)) { std::cerr << "Error running '" << iwyu_cmd[0] << "': " << stdErr << "\n"; @@ -373,7 +376,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::string stdOut; std::string stdErr; if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret, - CM_NULLPTR, + nullptr, cmSystemTools::OUTPUT_NONE)) { std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr << "\n"; @@ -403,7 +406,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::string stdOut; std::string stdErr; if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, &stdErr, &ret, - CM_NULLPTR, + nullptr, cmSystemTools::OUTPUT_NONE)) { std::cerr << "Error running '" << lwyu_cmd[0] << "': " << stdErr << "\n"; @@ -426,7 +429,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the cpplint command line. Capture its output. std::string stdOut; if (!cmSystemTools::RunSingleCommand(cpplint_cmd, &stdOut, &stdOut, - &ret, CM_NULLPTR, + &ret, nullptr, cmSystemTools::OUTPUT_NONE)) { std::cerr << "Error running '" << cpplint_cmd[0] << "': " << stdOut << "\n"; @@ -446,7 +449,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Now run the real compiler command and return its result value. if (lwyu.empty() && !cmSystemTools::RunSingleCommand( - orig_cmd, CM_NULLPTR, CM_NULLPTR, &ret, CM_NULLPTR, + orig_cmd, nullptr, nullptr, &ret, nullptr, cmSystemTools::OUTPUT_PASSTHROUGH)) { std::cerr << "Error running '" << orig_cmd[0] << "'\n"; return 1; @@ -497,8 +500,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Execute command from remaining arguments. std::vector<std::string> cmd(ai, ae); int retval; - if (cmSystemTools::RunSingleCommand(cmd, CM_NULLPTR, CM_NULLPTR, &retval, - CM_NULLPTR, + if (cmSystemTools::RunSingleCommand(cmd, nullptr, nullptr, &retval, + nullptr, cmSystemTools::OUTPUT_PASSTHROUGH)) { return retval; } @@ -584,7 +587,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } cmake cm(cmake::RoleInternal); -#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE +#if defined(CMAKE_BUILD_WITH_CMAKE) std::cout << cm.ReportCapabilities(true); #else std::cout << cm.ReportCapabilities(false); @@ -623,7 +626,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) time(&time_start); clock_start = clock(); int ret = 0; - cmSystemTools::RunSingleCommand(command, CM_NULLPTR, CM_NULLPTR, &ret); + cmSystemTools::RunSingleCommand(command, nullptr, nullptr, &ret); clock_finish = clock(); time(&time_finish); @@ -641,24 +644,28 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Command to calculate the md5sum of a file if (args[1] == "md5sum" && args.size() >= 3) { - char md5out[32]; - int retval = 0; - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - const char* filename = args[cc].c_str(); - // Cannot compute md5sum of a directory - if (cmSystemTools::FileIsDirectory(filename)) { - std::cerr << "Error: " << filename << " is a directory" << std::endl; - retval++; - } else if (!cmSystemTools::ComputeFileMD5(filename, md5out)) { - // To mimic md5sum behavior in a shell: - std::cerr << filename << ": No such file or directory" << std::endl; - retval++; - } else { - std::cout << std::string(md5out, 32) << " " << filename - << std::endl; - } - } - return retval; + return HashSumFile(args, cmCryptoHash::AlgoMD5); + } + + // Command to calculate the sha1sum of a file + if (args[1] == "sha1sum" && args.size() >= 3) { + return HashSumFile(args, cmCryptoHash::AlgoSHA1); + } + + if (args[1] == "sha224sum" && args.size() >= 3) { + return HashSumFile(args, cmCryptoHash::AlgoSHA224); + } + + if (args[1] == "sha256sum" && args.size() >= 3) { + return HashSumFile(args, cmCryptoHash::AlgoSHA256); + } + + if (args[1] == "sha384sum" && args.size() >= 3) { + return HashSumFile(args, cmCryptoHash::AlgoSHA384); + } + + if (args[1] == "sha512sum" && args.size() >= 3) { + return HashSumFile(args, cmCryptoHash::AlgoSHA512); } // Command to change directory and run a program. @@ -675,8 +682,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) int retval = 0; int timeout = 0; if (cmSystemTools::RunSingleCommand( - command.c_str(), CM_NULLPTR, CM_NULLPTR, &retval, - directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout)) { + command.c_str(), nullptr, nullptr, &retval, directory.c_str(), + cmSystemTools::OUTPUT_PASSTHROUGH, timeout)) { return retval; } @@ -1012,8 +1019,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } } -#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE - cmServerConnection* conn; +#if defined(CMAKE_BUILD_WITH_CMAKE) + cmConnection* conn; if (isDebug) { conn = new cmServerStdIoConnection; } else { @@ -1074,6 +1081,33 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } +int cmcmd::HashSumFile(std::vector<std::string>& args, cmCryptoHash::Algo algo) +{ + if (args.size() < 3) { + return -1; + } + int retval = 0; + + for (std::string::size_type cc = 2; cc < args.size(); cc++) { + const char* filename = args[cc].c_str(); + // Cannot compute sum of a directory + if (cmSystemTools::FileIsDirectory(filename)) { + std::cerr << "Error: " << filename << " is a directory" << std::endl; + retval++; + } else { + std::string value = cmSystemTools::ComputeFileHash(filename, algo); + if (value.empty()) { + // To mimic "md5sum/shasum" behavior in a shell: + std::cerr << filename << ": No such file or directory" << std::endl; + retval++; + } else { + std::cout << value << " " << filename << std::endl; + } + } + } + return retval; +} + int cmcmd::SymlinkLibrary(std::vector<std::string>& args) { int result = 0; @@ -1277,7 +1311,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) } // Setup this command line. - const char* cmd[2] = { command.c_str(), CM_NULLPTR }; + const char* cmd[2] = { command.c_str(), nullptr }; cmsysProcess_SetCommand(cp, cmd); // Report the command if verbose output is enabled. @@ -1287,7 +1321,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) // Run the command and wait for it to exit. cmsysProcess_Execute(cp); - cmsysProcess_WaitForExit(cp, CM_NULLPTR); + cmsysProcess_WaitForExit(cp, nullptr); // Report failure if any. switch (cmsysProcess_GetState(cp)) { @@ -1404,7 +1438,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) } static bool RunCommand(const char* comment, std::vector<std::string>& command, - bool verbose, int* retCodeOut = CM_NULLPTR) + bool verbose, int* retCodeOut = nullptr) { if (verbose) { std::cout << comment << ":\n"; @@ -1413,9 +1447,8 @@ static bool RunCommand(const char* comment, std::vector<std::string>& command, std::string output; int retCode = 0; // use rc command to create .res file - bool res = - cmSystemTools::RunSingleCommand(command, &output, &output, &retCode, - CM_NULLPTR, cmSystemTools::OUTPUT_NONE); + bool res = cmSystemTools::RunSingleCommand( + command, &output, &output, &retCode, nullptr, cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command // returned an error code then print the output anyway as diff --git a/Source/cmcmd.h b/Source/cmcmd.h index 929f1ae..faac1d2 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -4,6 +4,7 @@ #define cmcmd_h #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCryptoHash.h" #include <string> #include <vector> @@ -18,6 +19,8 @@ public: static int ExecuteCMakeCommand(std::vector<std::string>&); protected: + static int HashSumFile(std::vector<std::string>& args, + cmCryptoHash::Algo algo); static int SymlinkLibrary(std::vector<std::string>& args); static int SymlinkExecutable(std::vector<std::string>& args); static bool SymlinkInternal(std::string const& file, diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 84e815d..fe24a72 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -1,6 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmConfigure.h" #include "CTest/cmCTestLaunch.h" #include "CTest/cmCTestScriptHandler.h" @@ -18,13 +17,13 @@ #include <vector> static const char* cmDocumentationName[][2] = { - { CM_NULLPTR, " ctest - Testing driver provided by CMake." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, " ctest - Testing driver provided by CMake." }, + { nullptr, nullptr } }; -static const char* cmDocumentationUsage[][2] = { { CM_NULLPTR, +static const char* cmDocumentationUsage[][2] = { { nullptr, " ctest [options]" }, - { CM_NULLPTR, CM_NULLPTR } }; + { nullptr, nullptr } }; static const char* cmDocumentationOptions[][2] = { { "-C <cfg>, --build-config <cfg>", "Choose configuration to test." }, @@ -83,6 +82,8 @@ static const char* cmDocumentationOptions[][2] = { { "--max-width <width>", "Set the max width for a test name to output" }, { "--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1." }, { "--no-label-summary", "Disable timing summary information for labels." }, + { "--no-subproject-summary", "Disable timing summary information for " + "subprojects." }, { "--build-and-test", "Configure, build and run a test." }, { "--build-target", "Specify a specific target to build." }, { "--build-nocmake", "Run the build without running cmake first." }, @@ -118,7 +119,7 @@ static const char* cmDocumentationOptions[][2] = { { "--http1.0", "Submit using HTTP 1.0." }, { "--no-compress-output", "Do not compress test output when submitting." }, { "--print-labels", "Print all available test labels." }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; // this is a test driver program for cmCTest. diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index e915b1a..d7d0c51 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -20,6 +20,21 @@ # KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers. # A directory called "${KWSYS_NAMESPACE}" will be # created under this root directory to hold the files. +# KWSYS_SPLIT_OBJECTS_FROM_INTERFACE +# = Instead of creating a single ${KWSYS_NAMESPACE} library +# target, create three separate targets: +# ${KWSYS_NAMESPACE} +# - An INTERFACE library only containing usage +# requirements. +# ${KWSYS_NAMESPACE}_objects +# - An OBJECT library for the built kwsys objects. +# Note: This is omitted from the install rules +# ${KWSYS_NAMESPACE}_private +# - An INTERFACE library combining both that is +# appropriate for use with PRIVATE linking in +# target_link_libraries. Because of how interface +# properties propagate, this target is not suitable +# for use with PUBLIC or INTERFACE linking. # # Example: # @@ -79,6 +94,10 @@ FOREACH(p ENDFOREACH() SET(CMAKE_LEGACY_CYGWIN_WIN32 0) +IF(CMAKE_VERSION VERSION_LESS 3.0) + SET(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE 0) +ENDIF() + #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. # This should be the case only when kwsys is not included inside @@ -430,6 +449,11 @@ SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}" ) +IF(DEFINED KWSYS_PROCESS_USE_SELECT) + GET_PROPERTY(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS) + SET_PROPERTY(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}") +ENDIF() + IF(KWSYS_USE_DynamicLoader) GET_PROPERTY(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) IF(KWSYS_SUPPORTS_SHARED_LIBS) @@ -795,68 +819,144 @@ ENDFOREACH() #----------------------------------------------------------------------------- # Add the library with the configured name and list of sources. IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) - ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE} - ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY C_CLANG_TIDY "") - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY CXX_CLANG_TIDY "") - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY C_INCLUDE_WHAT_YOU_USE "") - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB}) + IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE) + SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE}) + SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects) + SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private) + SET(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK}) + SET(KWSYS_LINK_DEPENDENCY INTERFACE) + ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT + ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) + IF(KWSYS_BUILD_SHARED) + SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY + POSITION_INDEPENDENT_CODE TRUE) + ENDIF() + ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} INTERFACE) + ADD_LIBRARY(${KWSYS_TARGET_LINK} INTERFACE) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_LINK} INTERFACE + ${KWSYS_TARGET_INTERFACE}) + TARGET_SOURCES(${KWSYS_TARGET_LINK} INTERFACE + $<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>) + ELSE() + SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE}) + SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}) + SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}) + set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK}) + SET(KWSYS_LINK_DEPENDENCY PUBLIC) + ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE} + ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) + ENDIF() + SET_TARGET_PROPERTIES(${KWSYS_TARGET_OBJECT} PROPERTIES + C_CLANG_TIDY "" + CXX_CLANG_TIDY "" + C_INCLUDE_WHAT_YOU_USE "" + CXX_INCLUDE_WHAT_YOU_USE "" + LABELS "${KWSYS_LABELS_LIB}") IF(KWSYS_USE_DynamicLoader) IF(UNIX) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} + ${CMAKE_DL_LIBS}) ENDIF() ENDIF() IF(KWSYS_USE_SystemInformation) IF(WIN32) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32) IF(KWSYS_SYS_HAS_PSAPI) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} + Psapi) ENDIF() ELSEIF(UNIX) IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE) # backtrace on FreeBSD is not in libc - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${EXECINFO_LIB}) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} + ${EXECINFO_LIB}) ENDIF() IF (KWSYS_CXX_HAS_DLADDR) # for symbol lookup using dladdr - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} + ${CMAKE_DL_LIBS}) ENDIF() IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS") - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} socket) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} + socket) ENDIF() ENDIF() ENDIF() # Apply user-defined target properties to the library. IF(KWSYS_PROPERTIES_CXX) - SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES - ${KWSYS_PROPERTIES_CXX} - ) + SET_TARGET_PROPERTIES(${KWSYS_TARGET_INTERFACE} PROPERTIES + ${KWSYS_PROPERTIES_CXX}) + ENDIF() + + # Set up include usage requirement + IF(COMMAND TARGET_INCLUDE_DIRECTORIES) + TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>) + IF(KWSYS_INSTALL_INCLUDE_DIR) + TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE + $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>) + ENDIF() ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) - INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE}) + INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE}) ENDIF() ENDIF() # Add a C-only library if requested. IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) - ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS}) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB}) + IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE) + SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c) + SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects) + SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private) + SET(KWSYS_TARGET_C_INSTALL + ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK}) + SET(KWSYS_LINK_DEPENDENCY INTERFACE) + ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS}) + IF(KWSYS_BUILD_SHARED) + SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY + POSITION_INDEPENDENT_CODE TRUE) + ENDIF() + ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} INTERFACE) + ADD_LIBRARY(${KWSYS_TARGET_C_LINK} INTERFACE) + TARGET_LINK_LIBRARIES(${KWSYS_TARGET_C_LINK} INTERFACE + ${KWSYS_TARGET_C_INTERFACE}) + TARGET_SOURCES(${KWSYS_TARGET_C_LINK} INTERFACE + $<TARGET_OBJECTS:${KWSYS_TARGET_C_OBJECT}>) + ELSE() + SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c) + SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c) + SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c) + SET(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK}) + SET(KWSYS_LINK_DEPENDENCY PUBLIC) + ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE} + ${KWSYS_C_SRCS}) + ENDIF() + SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_OBJECT} PROPERTIES + LABELS "${KWSYS_LABELS_LIB}") # Apply user-defined target properties to the library. IF(KWSYS_PROPERTIES_C) - SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE}_c PROPERTIES - ${KWSYS_PROPERTIES_C} - ) + SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_INTERFACE} PROPERTIES + ${KWSYS_PROPERTIES_C}) + ENDIF() + + # Set up include usage requirement + IF(COMMAND TARGET_INCLUDE_DIRECTORIES) + TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>) + IF(KWSYS_INSTALL_INCLUDE_DIR) + TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE + $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>) + ENDIF() ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) - INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE}) + INSTALL(TARGETS ${KWSYS_TARGET_C_INSTALL}) ENDIF() ENDIF() @@ -915,7 +1015,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS}) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE}) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK}) FOREACH(test ${KWSYS_C_TESTS}) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}) SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) @@ -950,7 +1050,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE}) - TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_NAMESPACE}) + TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_TARGET_LINK}) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testConsoleBuf ) @@ -969,7 +1069,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) - ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE}) ENDIF() CREATE_TEST_SOURCELIST( KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx @@ -981,7 +1081,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE}) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK}) SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") @@ -1032,7 +1132,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # Process tests. ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE}) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK}) IF(NOT CYGWIN) SET(KWSYS_TEST_PROCESS_7 7) ENDIF() @@ -1060,7 +1160,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward ${PROJECT_BINARY_DIR}/testSharedForward.c) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE}) - ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_TARGET_C_LINK}) ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1) SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST}) diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 9ebcfce..3b32ca7 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -99,7 +99,8 @@ static inline void kwsysProcess_usleep(unsigned int msec) * pipes' file handles to be non-blocking and just poll them directly * without select(). */ -#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__) +#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__) && \ + !defined(KWSYSPE_USE_SELECT) #define KWSYSPE_USE_SELECT 1 #endif diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx index 6d7f832..26e84e0 100644 --- a/Source/kwsys/RegularExpression.cxx +++ b/Source/kwsys/RegularExpression.cxx @@ -258,11 +258,6 @@ const unsigned char MAGIC = 0234; #define UCHARAT(p) (reinterpret_cast<const unsigned char*>(p))[0] -#define FAIL(m) \ - { \ - regerror(m); \ - return (0); \ - } #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') #define META "^$.[()|?+*\\" diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 1c4fe33..11f3b81 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -22,7 +22,6 @@ #include KWSYS_HEADER(FStream.hxx) #include KWSYS_HEADER(Encoding.hxx) -#include <algorithm> #include <fstream> #include <iostream> #include <set> @@ -848,6 +847,8 @@ void SystemTools::ReplaceString(std::string& source, const char* replace, free(orig); } +#if defined(_WIN32) && !defined(__CYGWIN__) + #if defined(KEY_WOW64_32KEY) && defined(KEY_WOW64_64KEY) #define KWSYS_ST_KEY_WOW64_32KEY KEY_WOW64_32KEY #define KWSYS_ST_KEY_WOW64_64KEY KEY_WOW64_64KEY @@ -856,7 +857,6 @@ void SystemTools::ReplaceString(std::string& source, const char* replace, #define KWSYS_ST_KEY_WOW64_64KEY 0x0100 #endif -#if defined(_WIN32) && !defined(__CYGWIN__) static bool SystemToolsParseRegistryKey(const std::string& key, HKEY& primaryKey, std::string& second, std::string& valuename) @@ -3709,16 +3709,6 @@ std::string SystemTools::JoinPath( return result; } -void SystemTools::RemoveEmptyPathElements(std::vector<std::string>& path) -{ - if (path.empty()) { - return; - } - - path.erase(std::remove(path.begin() + 1, path.end(), std::string("")), - path.end()); -} - bool SystemTools::ComparePath(const std::string& c1, const std::string& c2) { #if defined(_WIN32) || defined(__APPLE__) @@ -3807,11 +3797,7 @@ std::string SystemTools::GetFilenamePath(const std::string& filename) */ std::string SystemTools::GetFilenameName(const std::string& filename) { -#if defined(_WIN32) std::string::size_type slash_pos = filename.find_last_of("/\\"); -#else - std::string::size_type slash_pos = filename.rfind('/'); -#endif if (slash_pos != std::string::npos) { return filename.substr(slash_pos + 1); } else { diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 5e091c2..1672e92 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -461,6 +461,10 @@ public: * produce the original path. Home directory references are * automatically expanded if expand_home_dir is true and this * platform supports them. + * + * This does *not* normalize the input path. All components are + * preserved, including empty ones. Typically callers should use + * this only on paths that have already been normalized. */ static void SplitPath(const std::string& p, std::vector<std::string>& components, @@ -469,15 +473,15 @@ public: /** * Join components of a path name into a single string. See * SplitPath for the format of the components. + * + * This does *not* normalize the input path. All components are + * preserved, including empty ones. Typically callers should use + * this only on paths that have already been normalized. */ static std::string JoinPath(const std::vector<std::string>& components); static std::string JoinPath(std::vector<std::string>::const_iterator first, std::vector<std::string>::const_iterator last); - /** Removes empty components from path. - */ - static void RemoveEmptyPathElements(std::vector<std::string>& path); - /** * Compare a path or components of a path. */ diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index e6fbf6c..1871f5d 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -758,6 +758,30 @@ static bool CheckGetPath() return res; } +static bool CheckGetFilenameName() +{ + const char* windowsFilepath = "C:\\somewhere\\something"; + const char* unixFilepath = "/somewhere/something"; + + std::string expectedFilename = "something"; + + bool res = true; + std::string filename = kwsys::SystemTools::GetFilenameName(windowsFilepath); + if (filename != expectedFilename) { + std::cerr << "GetFilenameName(" << windowsFilepath << ") yielded " + << filename << " instead of " << expectedFilename << std::endl; + res = false; + } + + filename = kwsys::SystemTools::GetFilenameName(unixFilepath); + if (filename != expectedFilename) { + std::cerr << "GetFilenameName(" << unixFilepath << ") yielded " << filename + << " instead of " << expectedFilename << std::endl; + res = false; + } + return res; +} + static bool CheckFind() { bool res = true; @@ -875,5 +899,7 @@ int testSystemTools(int, char* []) res &= CheckGetLineFromStream(); + res &= CheckGetFilenameName(); + return res ? 0 : 1; } |