diff -r ea943997a8fe -r 3c347c306703 lemon/lemon_reader.h --- a/lemon/lemon_reader.h Thu Jul 05 16:39:42 2007 +0000 +++ b/lemon/lemon_reader.h Thu Jul 26 12:18:02 2007 +0000 @@ -616,6 +616,17 @@ virtual int_type sync() { return EOF; } + + public: + + int line_num() const { + int r = _num; + for (char_type* p = gptr(); p != egptr(); ++p) { + if (*p == '\n') --r; + } + return r; + } + }; public: @@ -700,30 +711,37 @@ void run() { int line_num = 0; std::string line; - try { - SectionReaders::iterator it; - while ((++line_num, getline(*is, line)) && line.find("@end") != 0) { - for (it = readers.begin(); it != readers.end(); ++it) { - if (it->first->header(line)) { - it->second = true; - char buf[2048]; - FilterStreamBuf buffer(*is, line_num); + + SectionReaders::iterator it; + while ((++line_num, getline(*is, line)) && line.find("@end") != 0) { + for (it = readers.begin(); it != readers.end(); ++it) { + if (it->first->header(line)) { + it->second = true; + char buf[2048]; + FilterStreamBuf buffer(*is, line_num); + + try { buffer.pubsetbuf(buf, sizeof(buf)); std::istream ss(&buffer); it->first->read(ss); break; - } + } catch (DataFormatError& error) { + error.line(buffer.line_num()); + throw; + } } } - for (it = readers.begin(); it != readers.end(); ++it) { - if (!it->second) { - it->first->missing(); - } - } - } catch (DataFormatError& error) { - error.line(line_num); - throw; - } + } + for (it = readers.begin(); it != readers.end(); ++it) { + if (!it->second) { + try { + it->first->missing(); + } catch (DataFormatError& error) { + error.line(line_num); + throw; + } + } + } }