summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-09 11:51:38 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-09 11:59:19 (GMT)
commit760c6c08a5f5ba6390f40a7dddb499bd7f16c702 (patch)
tree7e8b7f2c0744029949facaaa6336e0b075f6ab01
parentc1e087a9d3af74299d7681c9f9de59e5977a1539 (diff)
parent6f2f9ce331179091c6d5c75d78cdf3f67255ded1 (diff)
downloadCMake-760c6c08a5f5ba6390f40a7dddb499bd7f16c702.zip
CMake-760c6c08a5f5ba6390f40a7dddb499bd7f16c702.tar.gz
CMake-760c6c08a5f5ba6390f40a7dddb499bd7f16c702.tar.bz2
Merge branch 'autogen-empty-source-file-fix' into release-3.10
There is no corresponding merge request because this fix was cherry-picked specifically for CMake 3.10.
-rw-r--r--Source/cmQtAutoGenerators.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index a9c9b9d..f91ebb2 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -80,15 +80,21 @@ static bool ReadFile(std::string& content, std::string const& filename,
std::size_t const length = cmSystemTools::FileLength(filename);
cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
if (ifs) {
- content.resize(length);
- ifs.read(&content.front(), content.size());
- if (ifs) {
- success = true;
+ if (length > 0) {
+ content.resize(length);
+ ifs.read(&content.front(), content.size());
+ if (ifs) {
+ success = true;
+ } else {
+ content.clear();
+ if (error != nullptr) {
+ error->append("Reading from the file failed.");
+ }
+ }
} else {
+ // Readable but empty file
content.clear();
- if (error != nullptr) {
- error->append("Reading from the file failed.");
- }
+ success = true;
}
} else if (error != nullptr) {
error->append("Opening the file for reading failed.");