2016-09-14 07:12:22 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
if ($_SERVER['argc'] < 2) {
|
|
|
|
die("Usage {$_SERVER['argv'][0]} /path/to/NEWS\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
$text = file_get_contents($_SERVER['argv'][1]);
|
|
|
|
if (!$text) {
|
|
|
|
die("Can't read {$_SERVER['argv'][1]}\n");
|
|
|
|
}
|
2016-09-16 06:16:25 +00:00
|
|
|
$debug = (isset($_SERVER['argv'][2]) && $_SERVER['argv'][2]==-'d');
|
2016-09-14 07:12:22 +00:00
|
|
|
|
|
|
|
$text = explode("\n", $text);
|
|
|
|
$in=false;
|
|
|
|
foreach ($text as $line) {
|
2019-04-03 05:22:17 +00:00
|
|
|
if (preg_match('/(^[0-9]+ .* 20[0-9][0-9])[,]* PHP (.*)$/', $line, $reg)) {
|
2016-09-14 07:12:22 +00:00
|
|
|
if ($in) {
|
|
|
|
break;
|
|
|
|
}
|
2017-01-19 09:16:52 +00:00
|
|
|
printf("**PHP version %s** (%s)", $reg[2], $reg[1]);
|
2016-09-14 07:12:22 +00:00
|
|
|
$in = true;
|
|
|
|
continue;
|
|
|
|
} else if (!$in) {
|
2016-09-16 06:16:25 +00:00
|
|
|
if ($debug) echo "+ Ignore $line\n";
|
2016-09-14 07:12:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
2023-02-16 06:36:06 +00:00
|
|
|
$github = 'https://github.com/php/php-src';
|
|
|
|
|
2021-06-29 17:41:33 +00:00
|
|
|
$line = preg_replace('/(#[0-9]+)/', 'php\1', $line);
|
2023-02-16 06:36:06 +00:00
|
|
|
$line = preg_replace('/(GH-([0-9]+))/', "[\\1]($github/issues/\\2)", $line);
|
|
|
|
$line = preg_replace('/(GHSA-([^ ]+))/', "[\\1]($github/security/advisories/\\1)", $line);
|
2021-06-29 17:41:33 +00:00
|
|
|
$line = preg_replace('/(CVE-[0-9]+-[0-9]+)/', '**\1**', $line);
|
2016-09-14 07:12:22 +00:00
|
|
|
if (empty($line)) {
|
|
|
|
echo "\n\n";
|
|
|
|
} else if (substr($line, 0, 2) == '- ') {
|
|
|
|
echo "**" . substr($line, 2) . "**\n";
|
|
|
|
} else if (substr($line, 0, 4) == ' . ') {
|
|
|
|
echo "\n* " . substr($line, 4);
|
|
|
|
} else {
|
|
|
|
echo " ".trim($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|