about summary refs log tree commit diff
path: root/src/log2xml/log2xml.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-03-16T12·47+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-03-16T12·47+0000
commitb5539e7a30da963af3e5967e2af2524a5e99efbb (patch)
tree2ef96ba10653d5582040312b543ec11c3075dad3 /src/log2xml/log2xml.cc
parent9d2669d218d03d64c69a702a96fc87ee1fd3a9d0 (diff)
* Store paths are now abbreviated in the generated HTML file.
  Hovering over the abbreviated path will reveal the full path.  This
  probably only works in Mozilla. 

Diffstat (limited to 'src/log2xml/log2xml.cc')
-rw-r--r--src/log2xml/log2xml.cc43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/log2xml/log2xml.cc b/src/log2xml/log2xml.cc
index 711fc82b89cf..f3e976fd916f 100644
--- a/src/log2xml/log2xml.cc
+++ b/src/log2xml/log2xml.cc
@@ -35,12 +35,7 @@ void Decoder::pushChar(char c)
                 state = stEscape;
             } else if (c == '\n') {
                 finishLine();
-            } else if (c == '<')
-                line += "&lt;";
-            else if (c == '&')
-                line += "&amp;";
-            else
-                line += c;
+            } else line += c;
             break;
 
         case stEscape:
@@ -78,9 +73,43 @@ void Decoder::pushChar(char c)
 
 void Decoder::finishLine()
 {
+    string storeDir = "/nix/store/";
+    int sz = storeDir.size();
     string tag = inHeader ? "head" : "line";
     cout << "<" << tag << ">";
-    cout << line;
+
+    for (int i = 0; i < line.size(); i++) {
+
+        if (line[i] == '<') cout << "&lt;";
+        else if (line[i] == '&') cout << "&amp;";
+        else if (i + sz + 33 < line.size() &&
+            string(line, i, sz) == storeDir &&
+            line[i + sz + 32] == '-')
+        {
+            int j = i + sz + 32;
+            /* skip name */
+            while (!strchr("/\n\r\t ()[]:;?<>", line[j])) j++;
+            int k = j;
+            while (!strchr("\n\r\t ()[]:;?<>", line[k])) k++;
+            // !!! escaping
+            cout << "<storeref>"
+                 << "<storedir>"
+                 << string(line, i, sz)
+                 << "</storedir>"
+                 << "<hash>"
+                 << string(line, i + sz, 32)
+                 << "</hash>"
+                 << "<name>"
+                 << string(line, i + sz + 32, j - (i + sz + 32))
+                 << "</name>"
+                 << "<path>"
+                 << string(line, j, k - j)
+                 << "</path>"
+                 << "</storeref>";
+            i = k - 1;
+        } else cout << line[i];
+    }
+    
     cout << "</" << tag << ">" << endl;
     line = "";
     inHeader = false;