summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-11 16:09:53 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-11 16:09:53 (GMT)
commit0d37dae5f9f5e143b98bb1766b26fb361fc3edcb (patch)
treee88da3e162a36a3c4f20250c0b8801a044a09f98 /Source
parentf52dac56a012b1456c63ec352b298ed236d059fb (diff)
downloadCMake-0d37dae5f9f5e143b98bb1766b26fb361fc3edcb.zip
CMake-0d37dae5f9f5e143b98bb1766b26fb361fc3edcb.tar.gz
CMake-0d37dae5f9f5e143b98bb1766b26fb361fc3edcb.tar.bz2
cmFileCommand: Update for new signature of GetLineFromStream
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx10
1 files changed, 4 insertions, 6 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 338f3c9..2cce400 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -197,9 +197,10 @@ bool HandleReadCommand(std::vector<std::string> const& args,
}
// is there a limit?
- long sizeLimit = -1;
+ std::string::size_type sizeLimit = std::string::npos;
if (!arguments.Limit.empty()) {
- sizeLimit = atoi(arguments.Limit.c_str());
+ sizeLimit =
+ static_cast<std::string::size_type>(atoi(arguments.Limit.c_str()));
}
// is there an offset?
@@ -231,12 +232,9 @@ bool HandleReadCommand(std::vector<std::string> const& args,
cmSystemTools::GetLineFromStream(file, line, &has_newline, sizeLimit)) {
if (sizeLimit > 0) {
sizeLimit = sizeLimit - static_cast<long>(line.size());
- if (has_newline) {
+ if (has_newline && sizeLimit > 0) {
sizeLimit--;
}
- if (sizeLimit < 0) {
- sizeLimit = 0;
- }
}
output += line;
if (has_newline) {