Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/current/tools/zipre')
-rwxr-xr-xsrc/current/tools/zipre23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/current/tools/zipre b/src/current/tools/zipre
new file mode 100755
index 0000000..4e6966f
--- /dev/null
+++ b/src/current/tools/zipre
@@ -0,0 +1,23 @@
+#!/usr/bin/env php
+<?php
+/**
+ * Given a set of sorted zips, generates a regular expression to match only the
+ * given input
+ *
+ * I wanted to write this in Scheme (it's a perfect recursive application), but
+ * I figured that other developers may get annoyed having to find a Scheme impl
+ * that works for them...so...PHP it is...
+ *
+ *
+ * THIS SCRIPT EXPECTS THE DATA TO BE SORTED! This can be easily accomplished by
+ * doing the following:
+ * sort -d zipfile | ./zipre
+ */
+
+include 'lib/zipre.php';
+
+// grab input from stdin (must be sorted!)
+$data = explode( "\n", file_get_contents( 'php://stdin' ) );
+
+// build and output
+echo gen_re_quick( $data );