From 0d37dae5f9f5e143b98bb1766b26fb361fc3edcb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Jan 2022 11:09:53 -0500 Subject: cmFileCommand: Update for new signature of GetLineFromStream --- Source/cmFileCommand.cxx | 10 ++++------ 1 file 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 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(atoi(arguments.Limit.c_str())); } // is there an offset? @@ -231,12 +232,9 @@ bool HandleReadCommand(std::vector const& args, cmSystemTools::GetLineFromStream(file, line, &has_newline, sizeLimit)) { if (sizeLimit > 0) { sizeLimit = sizeLimit - static_cast(line.size()); - if (has_newline) { + if (has_newline && sizeLimit > 0) { sizeLimit--; } - if (sizeLimit < 0) { - sizeLimit = 0; - } } output += line; if (has_newline) { -- cgit v0.12