mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
* Handle prematurely ended logfiles, i.e. make sure we emit enough
close tags.
This commit is contained in:
parent
2ab09a55cf
commit
5024bde8f4
1 changed files with 21 additions and 9 deletions
|
@ -34,6 +34,8 @@ struct Decoder
|
|||
void pushChar(char c);
|
||||
|
||||
void finishLine();
|
||||
|
||||
void decodeFile(istream & st);
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,16 +160,26 @@ void Decoder::finishLine()
|
|||
}
|
||||
|
||||
|
||||
void Decoder::decodeFile(istream & st)
|
||||
{
|
||||
int c;
|
||||
|
||||
cout << "<logfile>" << endl;
|
||||
|
||||
while ((c = st.get()) != EOF) {
|
||||
pushChar(c);
|
||||
}
|
||||
|
||||
if (line.size()) finishLine();
|
||||
|
||||
while (level--) cout << "</nest>" << endl;
|
||||
|
||||
cout << "</logfile>" << endl;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
Decoder dec;
|
||||
int c;
|
||||
|
||||
cout << "<logfile>" << endl;
|
||||
|
||||
while ((c = getchar()) != EOF) {
|
||||
dec.pushChar(c);
|
||||
}
|
||||
|
||||
cout << "</logfile>" << endl;
|
||||
dec.decodeFile(cin);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue