about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-11-25T01·06+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-11-25T01·06+0000
commit5024bde8f407582c9cb5a916f3b5603184f76eb7 (patch)
tree4788f155b247e3784787836b16a12b2261874408
parent2ab09a55cf06f547f7b6e94870259e1a51dbcf18 (diff)
* Handle prematurely ended logfiles, i.e. make sure we emit enough
  close tags.

-rw-r--r--src/nix-log2xml/log2xml.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/nix-log2xml/log2xml.cc b/src/nix-log2xml/log2xml.cc
index 9be3978a9274..8a3cbc8c42cd 100644
--- a/src/nix-log2xml/log2xml.cc
+++ b/src/nix-log2xml/log2xml.cc
@@ -34,6 +34,8 @@ struct Decoder
     void pushChar(char c);
 
     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;
-
+    
     cout << "<logfile>" << endl;
     
-    while ((c = getchar()) != EOF) {
-        dec.pushChar(c);
+    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;
+    dec.decodeFile(cin);
+}