Add tracing infrastructure.
[SXSI/xpathcomp.git] / src / utils.ml
diff --git a/src/utils.ml b/src/utils.ml
new file mode 100644 (file)
index 0000000..c5547aa
--- /dev/null
@@ -0,0 +1,24 @@
+module String =
+struct
+  include String
+
+  let explode s sep =
+    let len = length s in
+    let buff = Buffer.create 40 in
+    let rec loop i =
+      if i >= len then
+       [ Buffer.contents buff ]
+      else
+       let c = s.[i] in
+       if c == sep then
+         let ss = Buffer.contents buff in
+         Buffer.clear buff;
+         ss :: loop (i+1)
+       else begin
+         Buffer.add_char buff c;
+         loop (i+1);
+       end
+    in
+    loop 0
+end
+;;