summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt16
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx6
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx82
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.h3
-rw-r--r--Source/CPack/cmCPackGenerator.cxx18
-rw-r--r--Source/CPack/cmCPackGenerator.h2
-rw-r--r--Source/cmCommands.cxx43
-rw-r--r--Source/cmElseCommand.cxx14
-rw-r--r--Source/cmElseCommand.h45
-rw-r--r--Source/cmElseIfCommand.cxx13
-rw-r--r--Source/cmElseIfCommand.h45
-rw-r--r--Source/cmEndForEachCommand.cxx15
-rw-r--r--Source/cmEndForEachCommand.h56
-rw-r--r--Source/cmEndFunctionCommand.cxx15
-rw-r--r--Source/cmEndFunctionCommand.h56
-rw-r--r--Source/cmEndIfCommand.cxx24
-rw-r--r--Source/cmEndIfCommand.h45
-rw-r--r--Source/cmEndMacroCommand.cxx15
-rw-r--r--Source/cmEndMacroCommand.h56
-rw-r--r--Source/cmEndWhileCommand.cxx22
-rw-r--r--Source/cmEndWhileCommand.h56
-rw-r--r--Source/cmGlobalVisualStudio15Generator.cxx11
-rw-r--r--Source/cmMakefileTargetGenerator.cxx7
-rw-r--r--Source/cmNinjaTargetGenerator.cxx7
-rw-r--r--Source/cmServerProtocol.cxx2
-rw-r--r--Source/cmUnexpectedCommand.cxx22
-rw-r--r--Source/cmUnexpectedCommand.h40
-rw-r--r--Source/cmVS140CLFlagTable.h2
-rw-r--r--Source/cmVS141CLFlagTable.h1
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx44
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/kwsys/CMakeLists.txt15
-rw-r--r--Source/kwsys/ConsoleBuf.hxx.in71
34 files changed, 311 insertions, 562 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index f7e0944..5b381b4 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -440,24 +440,10 @@ set(SRCS
cmCreateTestSourceList.h
cmDefinePropertyCommand.cxx
cmDefinePropertyCommand.h
- cmElseCommand.cxx
- cmElseCommand.h
- cmElseIfCommand.cxx
- cmElseIfCommand.h
cmEnableLanguageCommand.cxx
cmEnableLanguageCommand.h
cmEnableTestingCommand.cxx
cmEnableTestingCommand.h
- cmEndForEachCommand.cxx
- cmEndForEachCommand.h
- cmEndFunctionCommand.cxx
- cmEndFunctionCommand.h
- cmEndIfCommand.cxx
- cmEndIfCommand.h
- cmEndMacroCommand.cxx
- cmEndMacroCommand.h
- cmEndWhileCommand.cxx
- cmEndWhileCommand.h
cmExecProgramCommand.cxx
cmExecProgramCommand.h
cmExecuteProcessCommand.cxx
@@ -612,6 +598,8 @@ set(SRCS
cmTryCompileCommand.h
cmTryRunCommand.cxx
cmTryRunCommand.h
+ cmUnexpectedCommand.cxx
+ cmUnexpectedCommand.h
cmUnsetCommand.cxx
cmUnsetCommand.h
cmUseMangledMesaCommand.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 3086639..d5f5724 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 7)
-set(CMake_VERSION_PATCH 20161129)
+set(CMake_VERSION_PATCH 20161202)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index ba3248f..a6d443b 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -405,7 +405,11 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
// Check package group
if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) {
package.ConfigureFromGroup(option);
- package.ForcedInstallation = "true";
+ std::string forcedOption = "CPACK_IFW_COMPONENT_GROUP_" +
+ cmsys::SystemTools::UpperCase(option) + "_FORCED_INSTALLATION";
+ if (!GetOption(forcedOption)) {
+ package.ForcedInstallation = "true";
+ }
} else {
package.ConfigureFromOptions();
}
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 4d46120..902c85d 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -109,6 +109,16 @@ bool cmCPackIFWPackage::IsOn(const std::string& op) const
return Generator ? Generator->IsOn(op) : false;
}
+bool cmCPackIFWPackage::IsSetToOff(const std::string& op) const
+{
+ return Generator ? Generator->IsSetToOff(op) : false;
+}
+
+bool cmCPackIFWPackage::IsSetToEmpty(const std::string& op) const
+{
+ return Generator ? Generator->IsSetToEmpty(op) : false;
+}
+
bool cmCPackIFWPackage::IsVersionLess(const char* version)
{
return Generator ? Generator->IsVersionLess(version) : false;
@@ -286,7 +296,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
// ForcedInstallation
ForcedInstallation = component->IsRequired ? "true" : "false";
- return 1;
+ return ConfigureFromPrefix(prefix);
}
int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
@@ -344,7 +354,7 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
SortingPriority = option;
}
- return 1;
+ return ConfigureFromPrefix(prefix);
}
int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
@@ -380,6 +390,74 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
return ConfigureFromGroup(&group);
}
+// Common options for components and groups
+int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
+{
+ // Temporary variable for full option name
+ std::string option;
+
+ // Display name
+ option = prefix + "DISPLAY_NAME";
+ if (IsSetToEmpty(option)) {
+ DisplayName.clear();
+ } else if (const char* value = GetOption(option)) {
+ DisplayName = value;
+ }
+
+ // Description
+ option = prefix + "DESCRIPTION";
+ if (IsSetToEmpty(option)) {
+ Description.clear();
+ } else if (const char* value = GetOption(option)) {
+ Description = value;
+ }
+
+ // Release date
+ option = prefix + "RELEASE_DATE";
+ if (IsSetToEmpty(option)) {
+ ReleaseDate.clear();
+ } else if (const char* value = GetOption(option)) {
+ ReleaseDate = value;
+ }
+
+ // Visibility
+ option = prefix + "VIRTUAL";
+ if (IsSetToEmpty(option)) {
+ Virtual.clear();
+ } else if (IsOn(option)) {
+ Virtual = "true";
+ }
+
+ // Default selection
+ option = prefix + "DEFAULT";
+ if (IsSetToEmpty(option)) {
+ Default.clear();
+ } else if (const char* value = GetOption(option)) {
+ std::string lowerValue = cmsys::SystemTools::LowerCase(value);
+ if (lowerValue.compare("true") == 0) {
+ Default = "true";
+ } else if (lowerValue.compare("false") == 0) {
+ Default = "false";
+ } else if (lowerValue.compare("script") == 0) {
+ Default = "script";
+ } else {
+ Default = value;
+ }
+ }
+
+ // Forsed installation
+ option = prefix + "FORCED_INSTALLATION";
+ if (IsSetToEmpty(option)) {
+ ForcedInstallation.clear();
+ } else if (IsOn(option)) {
+ ForcedInstallation = "true";
+ } else if (IsSetToOff(option)) {
+ ForcedInstallation = "false";
+ }
+
+ return 1;
+}
+
void cmCPackIFWPackage::GeneratePackageFile()
{
// Lazy directory initialization
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index d1af2bd..76ed540 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -112,6 +112,8 @@ public:
const char* GetOption(const std::string& op) const;
bool IsOn(const std::string& op) const;
+ bool IsSetToOff(const std::string& op) const;
+ bool IsSetToEmpty(const std::string& op) const;
bool IsVersionLess(const char* version);
bool IsVersionGreater(const char* version);
@@ -125,6 +127,7 @@ public:
int ConfigureFromComponent(cmCPackComponent* component);
int ConfigureFromGroup(cmCPackComponentGroup* group);
int ConfigureFromGroup(const std::string& groupName);
+ int ConfigureFromPrefix(const std::string& prefix);
void GeneratePackageFile();
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 3878a32..21eda79 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -1074,6 +1074,24 @@ bool cmCPackGenerator::IsOn(const std::string& name) const
return cmSystemTools::IsOn(GetOption(name));
}
+bool cmCPackGenerator::IsSetToOff(const std::string& op) const
+{
+ const char* ret = this->MakefileMap->GetDefinition(op);
+ if (ret && *ret) {
+ return cmSystemTools::IsOff(ret);
+ }
+ return false;
+}
+
+bool cmCPackGenerator::IsSetToEmpty(const std::string& op) const
+{
+ const char* ret = this->MakefileMap->GetDefinition(op);
+ if (ret) {
+ return !*ret;
+ }
+ return false;
+}
+
const char* cmCPackGenerator::GetOption(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index b43bf8a..10a5a36 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -92,6 +92,8 @@ public:
std::vector<std::string> GetOptions() const;
bool IsSet(const std::string& name) const;
bool IsOn(const std::string& name) const;
+ bool IsSetToOff(const std::string& op) const;
+ bool IsSetToEmpty(const std::string& op) const;
//! Set the logger
void SetLogger(cmCPackLog* log) { this->Logger = log; }
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 103e72c..4c5b093 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -18,14 +18,8 @@
#include "cmContinueCommand.h"
#include "cmCreateTestSourceList.h"
#include "cmDefinePropertyCommand.h"
-#include "cmElseCommand.h"
#include "cmEnableLanguageCommand.h"
#include "cmEnableTestingCommand.h"
-#include "cmEndForEachCommand.h"
-#include "cmEndFunctionCommand.h"
-#include "cmEndIfCommand.h"
-#include "cmEndMacroCommand.h"
-#include "cmEndWhileCommand.h"
#include "cmExecProgramCommand.h"
#include "cmExecuteProcessCommand.h"
#include "cmFileCommand.h"
@@ -74,6 +68,7 @@
#include "cmTargetLinkLibrariesCommand.h"
#include "cmTryCompileCommand.h"
#include "cmTryRunCommand.h"
+#include "cmUnexpectedCommand.h"
#include "cmUnsetCommand.h"
#include "cmWhileCommand.h"
@@ -82,7 +77,6 @@
#include "cmAuxSourceDirectoryCommand.h"
#include "cmBuildNameCommand.h"
#include "cmCMakeHostSystemInformationCommand.h"
-#include "cmElseIfCommand.h"
#include "cmExportCommand.h"
#include "cmExportLibraryDependenciesCommand.h"
#include "cmFLTKWrapUICommand.h"
@@ -130,14 +124,8 @@ std::vector<cmCommand*> GetPredefinedCommands()
commands.push_back(new cmContinueCommand);
commands.push_back(new cmCreateTestSourceList);
commands.push_back(new cmDefinePropertyCommand);
- commands.push_back(new cmElseCommand);
commands.push_back(new cmEnableLanguageCommand);
commands.push_back(new cmEnableTestingCommand);
- commands.push_back(new cmEndForEachCommand);
- commands.push_back(new cmEndFunctionCommand);
- commands.push_back(new cmEndIfCommand);
- commands.push_back(new cmEndMacroCommand);
- commands.push_back(new cmEndWhileCommand);
commands.push_back(new cmExecProgramCommand);
commands.push_back(new cmExecuteProcessCommand);
commands.push_back(new cmFileCommand);
@@ -189,12 +177,39 @@ std::vector<cmCommand*> GetPredefinedCommands()
commands.push_back(new cmUnsetCommand);
commands.push_back(new cmWhileCommand);
+ commands.push_back(new cmUnexpectedCommand(
+ "else", "An ELSE command was found outside of a proper "
+ "IF ENDIF structure. Or its arguments did not match "
+ "the opening IF command."));
+ commands.push_back(new cmUnexpectedCommand(
+ "elseif", "An ELSEIF command was found outside of a proper "
+ "IF ENDIF structure."));
+ commands.push_back(new cmUnexpectedCommand(
+ "endforeach", "An ENDFOREACH command was found outside of a proper "
+ "FOREACH ENDFOREACH structure. Or its arguments did "
+ "not match the opening FOREACH command."));
+ commands.push_back(new cmUnexpectedCommand(
+ "endfunction", "An ENDFUNCTION command was found outside of a proper "
+ "FUNCTION ENDFUNCTION structure. Or its arguments did not "
+ "match the opening FUNCTION command."));
+ commands.push_back(new cmUnexpectedCommand(
+ "endif", "An ENDIF command was found outside of a proper "
+ "IF ENDIF structure. Or its arguments did not match "
+ "the opening IF command."));
+ commands.push_back(new cmUnexpectedCommand(
+ "endmacro", "An ENDMACRO command was found outside of a proper "
+ "MACRO ENDMACRO structure. Or its arguments did not "
+ "match the opening MACRO command."));
+ commands.push_back(new cmUnexpectedCommand(
+ "endwhile", "An ENDWHILE command was found outside of a proper "
+ "WHILE ENDWHILE structure. Or its arguments did not "
+ "match the opening WHILE command."));
+
#if defined(CMAKE_BUILD_WITH_CMAKE)
commands.push_back(new cmAddCompileOptionsCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmCMakeHostSystemInformationCommand);
- commands.push_back(new cmElseIfCommand);
commands.push_back(new cmExportCommand);
commands.push_back(new cmExportLibraryDependenciesCommand);
commands.push_back(new cmFLTKWrapUICommand);
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
deleted file mode 100644
index 207777e..0000000
--- a/Source/cmElseCommand.cxx
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmElseCommand.h"
-
-class cmExecutionStatus;
-
-bool cmElseCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
-{
- this->SetError("An ELSE command was found outside of a proper "
- "IF ENDIF structure. Or its arguments did not match "
- "the opening IF command.");
- return false;
-}
diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h
deleted file mode 100644
index c0162ad..0000000
--- a/Source/cmElseCommand.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmElseCommand_h
-#define cmElseCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-
-/** \class cmElseCommand
- * \brief ends an if block
- *
- * cmElseCommand ends an if block
- */
-class cmElseCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmElseCommand; }
-
- /**
- * 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;
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "else"; }
-};
-
-#endif
diff --git a/Source/cmElseIfCommand.cxx b/Source/cmElseIfCommand.cxx
deleted file mode 100644
index 1c32248..0000000
--- a/Source/cmElseIfCommand.cxx
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmElseIfCommand.h"
-
-class cmExecutionStatus;
-
-bool cmElseIfCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
-{
- this->SetError("An ELSEIF command was found outside of a proper "
- "IF ENDIF structure.");
- return false;
-}
diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h
deleted file mode 100644
index 3f1ddde..0000000
--- a/Source/cmElseIfCommand.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmElseIfCommand_h
-#define cmElseIfCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-
-/** \class cmElseIfCommand
- * \brief ends an if block
- *
- * cmElseIfCommand ends an if block
- */
-class cmElseIfCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmElseIfCommand; }
-
- /**
- * 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;
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "elseif"; }
-};
-
-#endif
diff --git a/Source/cmEndForEachCommand.cxx b/Source/cmEndForEachCommand.cxx
deleted file mode 100644
index fe6a7f3..0000000
--- a/Source/cmEndForEachCommand.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmEndForEachCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-bool cmEndForEachCommand::InvokeInitialPass(
- std::vector<cmListFileArgument> const&, cmExecutionStatus&)
-{
- this->SetError("An ENDFOREACH command was found outside of a proper "
- "FOREACH ENDFOREACH structure. Or its arguments did "
- "not match the opening FOREACH command.");
- return false;
-}
diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h
deleted file mode 100644
index 772a139..0000000
--- a/Source/cmEndForEachCommand.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmEndForEachCommand_h
-#define cmEndForEachCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-/** \class cmEndForEachCommand
- * \brief ends an if block
- *
- * cmEndForEachCommand ends an if block
- */
-class cmEndForEachCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEndForEachCommand; }
-
- /**
- * Override cmCommand::InvokeInitialPass to get arguments before
- * expansion.
- */
- bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "endforeach"; }
-};
-
-#endif
diff --git a/Source/cmEndFunctionCommand.cxx b/Source/cmEndFunctionCommand.cxx
deleted file mode 100644
index 6adb42b..0000000
--- a/Source/cmEndFunctionCommand.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmEndFunctionCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-bool cmEndFunctionCommand::InvokeInitialPass(
- std::vector<cmListFileArgument> const&, cmExecutionStatus&)
-{
- this->SetError("An ENDFUNCTION command was found outside of a proper "
- "FUNCTION ENDFUNCTION structure. Or its arguments did not "
- "match the opening FUNCTION command.");
- return false;
-}
diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h
deleted file mode 100644
index 2599637..0000000
--- a/Source/cmEndFunctionCommand.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmEndFunctionCommand_h
-#define cmEndFunctionCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-/** \class cmEndFunctionCommand
- * \brief ends an if block
- *
- * cmEndFunctionCommand ends an if block
- */
-class cmEndFunctionCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEndFunctionCommand; }
-
- /**
- * Override cmCommand::InvokeInitialPass to get arguments before
- * expansion.
- */
- bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "endfunction"; }
-};
-
-#endif
diff --git a/Source/cmEndIfCommand.cxx b/Source/cmEndIfCommand.cxx
deleted file mode 100644
index 50c2b42..0000000
--- a/Source/cmEndIfCommand.cxx
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmEndIfCommand.h"
-
-#include <stdlib.h> // required for atof
-
-#include "cmMakefile.h"
-
-class cmExecutionStatus;
-
-bool cmEndIfCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
-{
- const char* versionValue =
- this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
- if (!versionValue || (atof(versionValue) <= 1.4)) {
- return true;
- }
-
- this->SetError("An ENDIF command was found outside of a proper "
- "IF ENDIF structure. Or its arguments did not match "
- "the opening IF command.");
- return false;
-}
diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h
deleted file mode 100644
index dfd6049..0000000
--- a/Source/cmEndIfCommand.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmEndIfCommand_h
-#define cmEndIfCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-
-/** \class cmEndIfCommand
- * \brief ends an if block
- *
- * cmEndIfCommand ends an if block
- */
-class cmEndIfCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEndIfCommand; }
-
- /**
- * 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;
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "endif"; }
-};
-
-#endif
diff --git a/Source/cmEndMacroCommand.cxx b/Source/cmEndMacroCommand.cxx
deleted file mode 100644
index 046b0af..0000000
--- a/Source/cmEndMacroCommand.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmEndMacroCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-bool cmEndMacroCommand::InvokeInitialPass(
- std::vector<cmListFileArgument> const&, cmExecutionStatus&)
-{
- this->SetError("An ENDMACRO command was found outside of a proper "
- "MACRO ENDMACRO structure. Or its arguments did not "
- "match the opening MACRO command.");
- return false;
-}
diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h
deleted file mode 100644
index 3c462d4..0000000
--- a/Source/cmEndMacroCommand.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmEndMacroCommand_h
-#define cmEndMacroCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-/** \class cmEndMacroCommand
- * \brief ends an if block
- *
- * cmEndMacroCommand ends an if block
- */
-class cmEndMacroCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEndMacroCommand; }
-
- /**
- * Override cmCommand::InvokeInitialPass to get arguments before
- * expansion.
- */
- bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "endmacro"; }
-};
-
-#endif
diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx
deleted file mode 100644
index 5623f33..0000000
--- a/Source/cmEndWhileCommand.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmEndWhileCommand.h"
-
-#include "cmListFileCache.h"
-
-class cmExecutionStatus;
-
-bool cmEndWhileCommand::InvokeInitialPass(
- std::vector<cmListFileArgument> const& args, cmExecutionStatus&)
-{
- if (args.empty()) {
- this->SetError("An ENDWHILE command was found outside of a proper "
- "WHILE ENDWHILE structure.");
- } else {
- this->SetError("An ENDWHILE command was found outside of a proper "
- "WHILE ENDWHILE structure. Or its arguments did not "
- "match the opening WHILE command.");
- }
-
- return false;
-}
diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h
deleted file mode 100644
index d4e97b4..0000000
--- a/Source/cmEndWhileCommand.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmEndWhileCommand_h
-#define cmEndWhileCommand_h
-
-#include <cmConfigure.h>
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-struct cmListFileArgument;
-
-/** \class cmEndWhileCommand
- * \brief ends a while loop
- *
- * cmEndWhileCommand ends a while loop
- */
-class cmEndWhileCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEndWhileCommand; }
-
- /**
- * Override cmCommand::InvokeInitialPass to get arguments before
- * expansion.
- */
- bool InvokeInitialPass(std::vector<cmListFileArgument> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-
- /**
- * This determines if the command is invoked when in script mode.
- */
- bool IsScriptable() const CM_OVERRIDE { return true; }
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- std::string GetName() const CM_OVERRIDE { return "endwhile"; }
-};
-
-#endif
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx
index 19b48df..091a03e 100644
--- a/Source/cmGlobalVisualStudio15Generator.cxx
+++ b/Source/cmGlobalVisualStudio15Generator.cxx
@@ -8,16 +8,19 @@
#include "cmMakefile.h"
#include "cmVS141CLFlagTable.h"
-static const char vs15generatorName[] = "Visual Studio 15";
+static const char vs15generatorName[] = "Visual Studio 15 2017";
// Map generator name without year to name with year.
static const char* cmVS15GenName(const std::string& name, std::string& genName)
{
if (strncmp(name.c_str(), vs15generatorName,
- sizeof(vs15generatorName) - 1) != 0) {
+ sizeof(vs15generatorName) - 6) != 0) {
return 0;
}
- const char* p = name.c_str() + sizeof(vs15generatorName) - 1;
+ const char* p = name.c_str() + sizeof(vs15generatorName) - 6;
+ if (cmHasLiteralPrefix(p, " 2017")) {
+ p += 5;
+ }
genName = std::string(vs15generatorName) + p;
return p;
}
@@ -52,7 +55,7 @@ public:
virtual void GetDocumentation(cmDocumentationEntry& entry) const
{
entry.Name = std::string(vs15generatorName) + " [arch]";
- entry.Brief = "Generates Visual Studio 15 project files. "
+ entry.Brief = "Generates Visual Studio 2017 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 2e5173d..6906a90 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -520,8 +520,15 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
targetFullPathCompilePDB =
this->GeneratorTarget->GetCompilePDBPath(this->ConfigName);
if (targetFullPathCompilePDB.empty()) {
+ // Match VS default: `$(IntDir)vc$(PlatformToolsetVersion).pdb`.
+ // A trailing slash tells the toolchain to add its default file name.
targetFullPathCompilePDB =
this->GeneratorTarget->GetSupportDirectory() + "/";
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ // Match VS default for static libs: `$(IntDir)$(ProjectName).pdb`.
+ targetFullPathCompilePDB += this->GeneratorTarget->GetName();
+ targetFullPathCompilePDB += ".pdb";
+ }
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index e47de97..8090542 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -359,7 +359,14 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
compilePdbPath =
this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
if (compilePdbPath.empty()) {
+ // Match VS default: `$(IntDir)vc$(PlatformToolsetVersion).pdb`.
+ // A trailing slash tells the toolchain to add its default file name.
compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/";
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ // Match VS default for static libs: `$(IntDir)$(ProjectName).pdb`.
+ compilePdbPath += this->GeneratorTarget->GetName();
+ compilePdbPath += ".pdb";
+ }
}
}
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 9a06f05..3776538 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -936,7 +936,7 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure(
}
// Make sure the types of cacheArguments matches (if given):
- std::vector<std::string> cacheArgs;
+ std::vector<std::string> cacheArgs = { "unused" };
bool cacheArgumentsError = false;
const Json::Value passedArgs = request.Data[kCACHE_ARGUMENTS_KEY];
if (!passedArgs.isNull()) {
diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx
new file mode 100644
index 0000000..a8de9e6
--- /dev/null
+++ b/Source/cmUnexpectedCommand.cxx
@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmUnexpectedCommand.h"
+
+#include <stdlib.h>
+
+#include "cmMakefile.h"
+
+class cmExecutionStatus;
+
+bool cmUnexpectedCommand::InitialPass(std::vector<std::string> const&,
+ cmExecutionStatus&)
+{
+ const char* versionValue =
+ this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+ if (this->Name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) {
+ return true;
+ }
+
+ this->SetError(this->Error);
+ return false;
+}
diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h
new file mode 100644
index 0000000..897dfb6
--- /dev/null
+++ b/Source/cmUnexpectedCommand.h
@@ -0,0 +1,40 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmUnexpectedCommand_h
+#define cmUnexpectedCommand_h
+
+#include <cmConfigure.h>
+#include <string>
+#include <vector>
+
+#include "cmCommand.h"
+
+class cmExecutionStatus;
+
+class cmUnexpectedCommand : public cmCommand
+{
+public:
+ cmUnexpectedCommand(std::string const& name, const char* error)
+ : Name(name)
+ , Error(error)
+ {
+ }
+
+ cmCommand* Clone() CM_OVERRIDE
+ {
+ return new cmUnexpectedCommand(this->Name, this->Error);
+ }
+
+ bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status) CM_OVERRIDE;
+
+ bool IsScriptable() const CM_OVERRIDE { return true; }
+
+ std::string GetName() const CM_OVERRIDE { return this->Name; }
+
+private:
+ std::string Name;
+ const char* Error;
+};
+
+#endif
diff --git a/Source/cmVS140CLFlagTable.h b/Source/cmVS140CLFlagTable.h
index 317cc18..60b4379 100644
--- a/Source/cmVS140CLFlagTable.h
+++ b/Source/cmVS140CLFlagTable.h
@@ -164,6 +164,8 @@ static cmVS7FlagTable cmVS140CLFlagTable[] = {
{ "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
{ "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
{ "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+ { "RemoveUnreferencedCodeData", "Zc:inline-", "", "false", 0 },
+ { "RemoveUnreferencedCodeData", "Zc:inline", "", "true", 0 },
{ "RuntimeTypeInfo", "GR-", "", "false", 0 },
{ "RuntimeTypeInfo", "GR", "", "true", 0 },
{ "OpenMPSupport", "openmp-", "", "false", 0 },
diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h
index 895b3e8..f751fc8 100644
--- a/Source/cmVS141CLFlagTable.h
+++ b/Source/cmVS141CLFlagTable.h
@@ -171,6 +171,7 @@ static cmVS7FlagTable cmVS141CLFlagTable[] = {
{ "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
{ "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
{ "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+ { "RemoveUnreferencedCodeData", "Zc:inline-", "", "false", 0 },
{ "RemoveUnreferencedCodeData", "Zc:inline", "", "true", 0 },
{ "EnforceTypeConversionRules", "Zc:rvalueCast-", "", "false", 0 },
{ "EnforceTypeConversionRules", "Zc:rvalueCast", "", "true", 0 },
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 4dabd51..3632663 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -139,7 +139,11 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
(*this->BuildFileStream) << line;
}
-#define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
+#define VS10_CXX_DEFAULT_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"
+#define VS10_CXX_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.props"
+#define VS10_CXX_USER_PROPS \
+ "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
+#define VS10_CXX_TARGETS "$(VCTargetsPath)\\Microsoft.Cpp.targets"
void cmVisualStudio10TargetGenerator::Generate()
{
@@ -345,12 +349,9 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("</PropertyGroup>\n", 1);
- this->WriteString("<Import Project="
- "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
- 1);
+ this->WriteString("<Import Project=\"" VS10_CXX_DEFAULT_PROPS "\" />\n", 1);
this->WriteProjectConfigurationValues();
- this->WriteString(
- "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
+ this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1);
this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
if (this->GlobalGenerator->IsMasmEnabled()) {
this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
@@ -359,10 +360,19 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
- this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
- " Condition=\"exists('" VS10_USER_PROPS "')\""
- " Label=\"LocalAppDataPlatform\" />\n",
- 2);
+ {
+ std::string props = VS10_CXX_USER_PROPS;
+ if (const char* p =
+ this->GeneratorTarget->GetProperty("VS_USER_PROPS_CXX")) {
+ props = p;
+ this->ConvertToWindowsSlash(props);
+ }
+ this->WriteString("", 2);
+ (*this->BuildFileStream)
+ << "<Import Project=\"" << cmVS10EscapeXML(props) << "\""
+ << " Condition=\"exists('" << cmVS10EscapeXML(props) << "')\""
+ << " Label=\"LocalAppDataPlatform\" />\n";
+ }
this->WritePlatformExtensions();
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
@@ -377,10 +387,8 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteWinRTReferences();
this->WriteProjectReferences();
this->WriteSDKReferences();
- this->WriteString(
- "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
- " />\n",
- 1);
+ this->WriteString("<Import Project=\"" VS10_CXX_TARGETS "\" />\n", 1);
+
this->WriteTargetSpecificReferences();
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
this->WriteTargetsFileReferences();
@@ -1561,6 +1569,14 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
*this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
<< "</IntDir>\n";
+ if (const char* workingDir = this->GeneratorTarget->GetProperty(
+ "VS_DEBUGGER_WORKING_DIRECTORY")) {
+ this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory",
+ config->c_str(), 3);
+ *this->BuildFileStream << cmVS10EscapeXML(workingDir)
+ << "</LocalDebuggerWorkingDirectory>\n";
+ }
+
std::string name =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
this->WritePlatformConfigTag("TargetName", config->c_str(), 3);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 59290ff..733e0e4 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1457,7 +1457,7 @@ void cmake::CreateDefaultGlobalGenerator()
const char* GeneratorName;
};
static VSVersionedGenerator const vsGenerators[] = {
- { "15.0", "Visual Studio 15" }, //
+ { "15.0", "Visual Studio 15 2017" }, //
{ "14.0", "Visual Studio 14 2015" }, //
{ "12.0", "Visual Studio 12 2013" }, //
{ "11.0", "Visual Studio 11 2012" }, //
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index a2d313c..b8a9a6b 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -67,12 +67,15 @@
# written.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
-IF(POLICY CMP0025)
- CMAKE_POLICY(SET CMP0025 NEW)
-ENDIF()
-IF(POLICY CMP0056)
- CMAKE_POLICY(SET CMP0056 NEW)
-ENDIF()
+FOREACH(p
+ CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang.
+ CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
+ CMP0063 # CMake 3.3, Honor visibility properties for all target types.
+ )
+ IF(POLICY ${p})
+ CMAKE_POLICY(SET ${p} NEW)
+ ENDIF()
+ENDFOREACH()
SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
#-----------------------------------------------------------------------------
diff --git a/Source/kwsys/ConsoleBuf.hxx.in b/Source/kwsys/ConsoleBuf.hxx.in
index 717462e..c45a351 100644
--- a/Source/kwsys/ConsoleBuf.hxx.in
+++ b/Source/kwsys/ConsoleBuf.hxx.in
@@ -147,42 +147,47 @@ protected:
return Traits::eof();
}
if (m_isConsoleInput) {
- wchar_t wbuffer[128];
+ // ReadConsole doesn't tell if there's more input available
+ // don't support reading more characters than this
+ wchar_t wbuffer[8192];
DWORD charsRead;
- if (::ReadConsoleW(m_hInput, wbuffer,
- (sizeof(wbuffer) / sizeof(wbuffer[0])) - 1,
- &charsRead, NULL) == 0 ||
+ if (ReadConsoleW(m_hInput, wbuffer,
+ (sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead,
+ NULL) == 0 ||
charsRead == 0) {
_setg(true);
return Traits::eof();
}
- wbuffer[charsRead] = L'\0';
- setBuffer(wbuffer, m_ibuffer);
+ setBuffer(std::wstring(wbuffer, charsRead), m_ibuffer);
} else {
- std::wstring totalBuffer;
std::wstring wbuffer;
- char buffer[128];
+ std::string strbuffer;
DWORD bytesRead;
- while (::ReadFile(m_hInput, buffer,
- (sizeof(buffer) / sizeof(buffer[0])) - 1, &bytesRead,
- NULL) == 0) {
- if (::GetLastError() == ERROR_MORE_DATA) {
- buffer[bytesRead] = '\0';
- if (decodeInputBuffer(buffer, wbuffer)) {
- totalBuffer += wbuffer;
- continue;
- }
+ LARGE_INTEGER size;
+ if (GetFileSizeEx(m_hInput, &size) == 0) {
+ _setg(true);
+ return Traits::eof();
+ }
+ char* buffer = new char[size.LowPart];
+ while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) ==
+ 0) {
+ if (GetLastError() == ERROR_MORE_DATA) {
+ strbuffer += std::string(buffer, bytesRead);
+ continue;
}
_setg(true);
+ delete[] buffer;
return Traits::eof();
}
- buffer[bytesRead] = '\0';
- if (!decodeInputBuffer(buffer, wbuffer)) {
+ if (bytesRead > 0) {
+ strbuffer += std::string(buffer, bytesRead);
+ }
+ delete[] buffer;
+ if (!decodeInputBuffer(strbuffer, wbuffer)) {
_setg(true);
return Traits::eof();
}
- totalBuffer += wbuffer;
- setBuffer(totalBuffer, m_ibuffer);
+ setBuffer(wbuffer, m_ibuffer);
}
_setg();
}
@@ -315,6 +320,10 @@ private:
}
bool encodeOutputBuffer(const std::wstring wbuffer, std::string& buffer)
{
+ if (wbuffer.size() == 0) {
+ buffer = std::string();
+ return true;
+ }
const int length =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
(int)wbuffer.size(), NULL, 0, NULL, NULL);
@@ -329,23 +338,31 @@ private:
delete[] buf;
return success;
}
- bool decodeInputBuffer(const char* buffer, std::wstring& wbuffer)
+ bool decodeInputBuffer(const std::string buffer, std::wstring& wbuffer)
{
+ int length = int(buffer.length());
+ if (length == 0) {
+ wbuffer = std::wstring();
+ return true;
+ }
int actualCodepage = m_activeInputCodepage;
const char BOM_UTF8[] = { char(0xEF), char(0xBB), char(0xBF) };
- if (std::memcmp(buffer, BOM_UTF8, sizeof(BOM_UTF8)) == 0) {
+ const char* data = buffer.data();
+ const size_t BOMsize = sizeof(BOM_UTF8);
+ if (length >= BOMsize && std::memcmp(data, BOM_UTF8, BOMsize) == 0) {
// PowerShell uses UTF-8 with BOM for pipes
actualCodepage = CP_UTF8;
- buffer += sizeof(BOM_UTF8);
+ data += BOMsize;
+ length -= BOMsize;
}
const int wlength =
- MultiByteToWideChar(actualCodepage, 0, buffer, -1, NULL, 0);
+ MultiByteToWideChar(actualCodepage, 0, data, length, NULL, 0);
wchar_t* wbuf = new wchar_t[wlength];
const bool success =
- MultiByteToWideChar(actualCodepage, 0, buffer, -1, wbuf, wlength) > 0
+ MultiByteToWideChar(actualCodepage, 0, data, length, wbuf, wlength) > 0
? true
: false;
- wbuffer = wbuf;
+ wbuffer = std::wstring(wbuf, wlength);
delete[] wbuf;
return success;
}