diff options
Diffstat (limited to 'cpp/demo/Manual/map_filesystem/Parser.cpp')
-rw-r--r-- | cpp/demo/Manual/map_filesystem/Parser.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/cpp/demo/Manual/map_filesystem/Parser.cpp b/cpp/demo/Manual/map_filesystem/Parser.cpp index 8f8644234b1..6bd3c139efe 100644 --- a/cpp/demo/Manual/map_filesystem/Parser.cpp +++ b/cpp/demo/Manual/map_filesystem/Parser.cpp @@ -44,7 +44,7 @@ Parser::usage() } // Print the contents of directory "dir". If recursive is true, -// print in tree fashion. +// print in tree fashion. // For files, show the contents of each file. The "depth" // parameter is the current nesting level (for indentation). @@ -294,7 +294,7 @@ Parser::destroy(const std::list<string>& names) } // -// With older flex version <= 2.5.35 YY_INPUT second +// With older flex version <= 2.5.35 YY_INPUT second // paramenter is of type int&, in newer versions it // changes to size_t& // @@ -344,25 +344,22 @@ Parser::getInput(char* buf, size_t& result, size_t maxSize) cout << parser->getPrompt() << flush; string line; - while(true) + char c; + do { - char c = static_cast<char>(getc(yyin)); + c = static_cast<char>(getc(yyin)); if(c == EOF) { if(line.size()) { line += '\n'; } - break; } - - line += c; - - if(c == '\n') + else { - break; + line += c; } - } + } while(c != EOF && c != '\n'); result = line.length(); if(result > maxSize) |