File: compare_pot

package info (click to toggle)
boinc 7.14.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,132 kB
  • sloc: cpp: 163,589; php: 113,173; ansic: 49,284; pascal: 35,620; xml: 17,864; java: 13,521; python: 6,551; sh: 4,082; perl: 1,843; makefile: 1,796; objc: 1,543; sql: 959; csh: 126; lisp: 47
file content (38 lines) | stat: -rwxr-xr-x 887 bytes parent folder | download | duplicates (12)
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
38
#! /usr/bin/env php
<?php

// compare_pot file1 file2 [--email email_addr ...]
//
// compare two .pot files, ignoring comments and creation time.
// If they differ, send email to the given addresses

function strip_comments($x) {
    $y = "";
    foreach ($x as $l) {
        if (substr($l, 0, 1) == '#') continue;
        if (strstr($l, "POT-Creation-Date")) continue;
        $y .= $l;
    }
    return $y;
}

function pot_same($f1, $f2) {
    $c1 = strip_comments(file($f1));
    $c2 = strip_comments(file($f2));
    return ($c1 == $c2);
}

if ($argc < 3) die("Usage\n");
if (pot_same($argv[1], $argv[2])) {
    echo "files match\n";
} else {
    echo "files don't match\n";
    for ($i=3; $i<$argc; $i++) {
        mail($argv[$i],
            $argv[1]." updated",
            $argv[1]." was updated.  Please review, copy to boinc/locale/templates, and commit"
        );
    }
}

?>