* Handle prematurely ended logfiles, i.e. make sure we emit enough

close tags.
This commit is contained in:
Eelco Dolstra 2008-11-25 01:06:15 +00:00
parent 2ab09a55cf
commit 5024bde8f4

View file

@ -34,6 +34,8 @@ struct Decoder
void pushChar(char c); void pushChar(char c);
void finishLine(); void finishLine();
void decodeFile(istream & st);
}; };
@ -158,16 +160,26 @@ void Decoder::finishLine()
} }
int main(int argc, char * * argv) void Decoder::decodeFile(istream & st)
{ {
Decoder dec;
int c; int c;
cout << "<logfile>" << endl; cout << "<logfile>" << endl;
while ((c = getchar()) != EOF) { while ((c = st.get()) != EOF) {
dec.pushChar(c); pushChar(c);
} }
if (line.size()) finishLine();
while (level--) cout << "</nest>" << endl;
cout << "</logfile>" << endl; cout << "</logfile>" << endl;
} }
int main(int argc, char * * argv)
{
Decoder dec;
dec.decodeFile(cin);
}