[Positioning] TextFileReader: handle comments

TextFileReader::read_nonblank_line() now skips lines beginning with a #,
or with blank characters and then #.
This commit is contained in:
Matteo Cypriani 2010-04-01 19:43:46 +02:00
parent 675d2d7213
commit 2d4c90e4cd
1 changed files with 6 additions and 4 deletions

View File

@ -32,9 +32,11 @@ TextFileReader::~TextFileReader()
/**
* Tabs and spaces at the begining of a
* line are deleted.
* \em text is unchanged in case of error.
* Blank lines or lines containing only blank characters are skipped.
* Tabs and spaces at the begining of a line are deleted.
* If the first non-blank character of a line is a #, then the line is
* skipped (note that comments at the end of a line are *not* handled).
* @param text Output argument; unchanged in case of error.
* @return false in case of error, true else.
*/
bool TextFileReader::read_nonblank_line(string &text)
@ -46,7 +48,7 @@ bool TextFileReader::read_nonblank_line(string &text)
if (! read_line(line))
return false ;
while ((first_non_blank = line.find_first_not_of(" \t"))
== string::npos) ;
== string::npos || line.at(first_non_blank) == '#') ;
line.erase(0, first_non_blank) ;
text = line ;