]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
gitignore vendor
[github/wallabag/wallabag.git] / vendor / symfony / intl / Symfony / Component / Intl / Resources / bin / common.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 define('LINE_WIDTH', 75);
13
14 define('LINE', str_repeat('-', LINE_WIDTH) . "\n");
15
16 function bailout($message)
17 {
18 echo wordwrap($message, LINE_WIDTH) . " Aborting.\n";
19
20 exit(1);
21 }
22
23 function strip_minor_versions($version)
24 {
25 preg_match('/^(?P<version>[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches);
26
27 return $matches['version'];
28 }
29
30 function centered($text)
31 {
32 $padding = (int) ((LINE_WIDTH - strlen($text))/2);
33
34 return str_repeat(' ', $padding) . $text;
35 }
36
37 function cd($dir)
38 {
39 if (false === chdir($dir)) {
40 bailout("Could not switch to directory $dir.");
41 }
42 }
43
44 function run($command)
45 {
46 exec($command, $output, $status);
47
48 if (0 !== $status) {
49 $output = implode("\n", $output);
50 echo "Error while running:\n " . getcwd() . '$ ' . $command . "\nOutput:\n" . LINE . "$output\n" . LINE;
51
52 bailout("\"$command\" failed.");
53 }
54 }
55
56 function get_icu_version_from_genrb($genrb)
57 {
58 exec($genrb . ' --version 2>&1', $output, $status);
59
60 if (0 !== $status) {
61 bailout($genrb . ' failed.');
62 }
63
64 if (!preg_match('/ICU version ([\d\.]+)/', implode('', $output), $matches)) {
65 return null;
66 }
67
68 return $matches[1];
69 }