aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
new file mode 100644
index 00000000..4fadbe82
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
@@ -0,0 +1,69 @@
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
12define('LINE_WIDTH', 75);
13
14define('LINE', str_repeat('-', LINE_WIDTH) . "\n");
15
16function bailout($message)
17{
18 echo wordwrap($message, LINE_WIDTH) . " Aborting.\n";
19
20 exit(1);
21}
22
23function 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
30function centered($text)
31{
32 $padding = (int) ((LINE_WIDTH - strlen($text))/2);
33
34 return str_repeat(' ', $padding) . $text;
35}
36
37function cd($dir)
38{
39 if (false === chdir($dir)) {
40 bailout("Could not switch to directory $dir.");
41 }
42}
43
44function 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
56function 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}