Skip to content

Commit 4e5b9dc

Browse files
committed
Refactorization: Removed lengthy comment and actually check std::ifstream::operator bool().
1 parent b788d96 commit 4e5b9dc

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,13 @@
3434
#include <cstdlib> // EXIT_FAILURE
3535

3636
#ifdef HAVE_RULES
37-
// xml is used in rules
37+
// xml is used for rules
3838
#include <tinyxml2.h>
3939
#endif
4040

4141
static void AddFilesToList(const std::string& FileList, std::vector<std::string>& PathNames)
4242
{
43-
// to keep things initially simple, if the file can't be opened, just be
44-
// silent and move on
45-
// ideas : we could also require this should be an xml file, with the filenames
46-
// specified in an xml structure
47-
// we could elaborate this then, to also include the I-paths, ...
48-
// basically for everything that makes the command line very long
49-
// xml is a bonus then, since we can easily extend it
50-
// we need a good parser then -> suggestion : TinyXml
51-
// drawback : creates a dependency
43+
// To keep things initially simple, if the file can't be opened, just be silent and move on.
5244
std::istream *Files;
5345
std::ifstream Infile;
5446
if (FileList.compare("-") == 0) { // read from stdin
@@ -57,7 +49,7 @@ static void AddFilesToList(const std::string& FileList, std::vector<std::string>
5749
Infile.open(FileList.c_str());
5850
Files = &Infile;
5951
}
60-
if (Files) {
52+
if (Files && *Files) {
6153
std::string FileName;
6254
while (std::getline(*Files, FileName)) { // next line
6355
if (!FileName.empty()) {
@@ -69,8 +61,7 @@ static void AddFilesToList(const std::string& FileList, std::vector<std::string>
6961

7062
static void AddInclPathsToList(const std::string& FileList, std::list<std::string>* PathNames)
7163
{
72-
// to keep things initially simple, if the file can't be opened, just be
73-
// silent and move on
64+
// To keep things initially simple, if the file can't be opened, just be silent and move on.
7465
std::ifstream Files(FileList.c_str());
7566
if (Files) {
7667
std::string PathName;

0 commit comments

Comments
 (0)