Commit:    c5052bab613f996134ee90610bee3ccf045de216
Author:    Sara Golemon <[email protected]>         Wed, 5 Jun 2019 14:03:35 -0400
Parents:   168229fa403897d6d9bffca8d93f96171fdb04e4
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=c5052bab613f996134ee90610bee3ccf045de216

Log:
Clean up news2html a little

Changed paths:
  M  bin/news2html


Diff:
diff --git a/bin/news2html b/bin/news2html
index 882a492..6258b89 100755
--- a/bin/news2html
+++ b/bin/news2html
@@ -3,46 +3,54 @@
 PHP_SAPI == 'cli' or die("Please run this script using the cli sapi");
 
 // get args
-if($argc < 3) {
-       echo "Use: $argv[0] /path/to/php-5.4.16/NEWS 5.4.16\n";
+$cmd = array_shift($_SERVER['argv']);
+
+if (count($_SERVER['argv']) < 2) {
+       echo "Use: $cmd /path/to/php-5.4.16/NEWS 5.4.16\n";
        exit(1);
 }
+$news_file = array_shift($_SERVER['argv']);
+$version = array_shift($_SERVER['argv']);
+
 // find NEWS entry
-$fp = fopen($argv[1], "r");
+$fp = fopen($news_file, "r");
 if(!$fp) {
-       die("Can not open $argv[1]");
+       die("Can not open {$news_file}\n");
 }
-$version = $argv[2];
+
 $inside = false;
-$entries = array();
+$entries = [];
 while(($ln = fgets($fp)) !== false) {
-       if(preg_match("/(.. ... ....),? PHP $version/", $ln, $m)) {
+       if (preg_match("/(.. ... ....),? PHP $version/", $ln, $m)) {
                // got entry start
                $inside = true;
                $date = strtr($m[1], " ", "-");
                continue;
        }
-       if($inside) {
-               if(preg_match('/,? PHP \d+.\d+.\d+/', $ln)) {
-                       // next entry - we're done
-                       break;
-               }
-               if($ln == "\n") {
-                       $module = 'Core';
-                       continue;
-               }
-               if($ln[0] == '-') {
-                       // module
-                       $module = trim(substr($ln, 1), " \t\n:");
-               } elseif(preg_match('/^\s+\.\s/',$ln)) {
-                       $entries[$module][] = trim(preg_replace('/^\s+\.\s+/', 
'', $ln));
-               } else {
-                       // continued line
-                       $c = count($entries[$module])-1;
-                       $entries[$module][$c] = trim($entries[$module][$c] )." 
".trim($ln);
-               }
+       if (!$inside) { continue; }
+
+       if (preg_match('/,? PHP \d+.\d+.\d+/', $ln)) {
+               // next entry - we're done
+               break;
+       }
+
+       if ($ln == "\n") {
+               $module = 'Core';
+               continue;
+       }
+       if ($ln[0] == '-') {
+               // module
+               $module = trim(substr($ln, 1), " \t\n:");
+       } elseif (preg_match('/^\s+\.\s/',$ln)) {
+               $entries[$module][] = trim(preg_replace('/^\s+\.\s+/', '', 
$ln));
+       } else {
+               // continued line
+               $c = count($entries[$module])-1;
+               $entries[$module][$c] = trim($entries[$module][$c] )." 
".trim($ln);
        }
 }
+
+
 echo <<<HEAD
 <section class="version" id="$version"><!-- {{{ $version -->
 <h3>Version $version</h3>


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to