diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-04-21 17:19:29 (GMT) |
---|---|---|
committer | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-04-26 06:59:56 (GMT) |
commit | 1ef22a26c97e2661f0670b5794c47b5339b64da7 (patch) | |
tree | b7e651bf154d56850e19ac835f92215ab500264a /Source/cmDocumentation.cxx | |
parent | ba8571ff2deb3a29bb980e109abef0e7290de56a (diff) | |
download | CMake-1ef22a26c97e2661f0670b5794c47b5339b64da7.zip CMake-1ef22a26c97e2661f0670b5794c47b5339b64da7.tar.gz CMake-1ef22a26c97e2661f0670b5794c47b5339b64da7.tar.bz2 |
cmDocumentation: use ofstream local variable
Diffstat (limited to 'Source/cmDocumentation.cxx')
-rw-r--r-- | Source/cmDocumentation.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 5f25113..c6286b3 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -129,28 +129,19 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) this->CurrentArgument = i->Argument; // If a file name was given, use it. Otherwise, default to the // given stream. - cmsys::ofstream* fout = CM_NULLPTR; + cmsys::ofstream fout; std::ostream* s = &os; if (!i->Filename.empty()) { - fout = new cmsys::ofstream(i->Filename.c_str()); - if (fout) { - s = fout; - } else { - result = false; - } + fout.open(i->Filename.c_str()); + s = &fout; } else if (++count > 1) { os << "\n\n"; } // Print this documentation type to the stream. - if (!this->PrintDocumentation(i->HelpType, *s) || !*s) { + if (!this->PrintDocumentation(i->HelpType, *s) || s->fail()) { result = false; } - - // Close the file if we wrote one. - if (fout) { - delete fout; - } } return result; } |