Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
blob: e16a5e9acc2a6bd62fec4c9ad264409e30875df6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 );