From 2d4c90e4cde9bd2d30ac5a212fca72455dca5d30 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Thu, 1 Apr 2010 19:43:46 +0200 Subject: [PATCH] [Positioning] TextFileReader: handle comments TextFileReader::read_nonblank_line() now skips lines beginning with a #, or with blank characters and then #. --- owlps-positioning/src/textfilereader.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/owlps-positioning/src/textfilereader.cc b/owlps-positioning/src/textfilereader.cc index 1585574..6ae90c6 100644 --- a/owlps-positioning/src/textfilereader.cc +++ b/owlps-positioning/src/textfilereader.cc @@ -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 ;