Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tools/zipre')
-rwxr-xr-xtools/zipre37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/zipre b/tools/zipre
new file mode 100755
index 0000000..e16a5e9
--- /dev/null
+++ b/tools/zipre
@@ -0,0 +1,37 @@
+#!/usr/bin/env php
+<?php
+/**
+ * Given a set of sorted zips, generates a regular expression to match only the
+ * given input
+ *
+ * Copyright (C) 2016 LoVullo Associates, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 );