packages: php-packagexml2cl/xml2changelog - give code some style

glen glen at pld-linux.org
Thu Mar 25 11:23:32 CET 2010


Author: glen                         Date: Thu Mar 25 10:23:32 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- give code some style

---- Files affected:
packages/php-packagexml2cl:
   xml2changelog (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: packages/php-packagexml2cl/xml2changelog
diff -u packages/php-packagexml2cl/xml2changelog:1.1 packages/php-packagexml2cl/xml2changelog:1.2
--- packages/php-packagexml2cl/xml2changelog:1.1	Thu Mar 25 11:17:14 2010
+++ packages/php-packagexml2cl/xml2changelog	Thu Mar 25 11:23:27 2010
@@ -1,34 +1,44 @@
+#!/usr/bin/php
 <?php
-$prog=array_shift($_SERVER['argv']);
-if ($_SERVER['argc']<2) die ("usage : " . $prog . " path_to_package.xml [ --debug ]\n");
-$file=array_shift($_SERVER['argv']);
+define('PROGRAM', basename(array_shift($argv)));
+if ($argc < 2) {
+   	fwrite(STDERR, "Usage: " . PROGRAM. " path_to_package.xml [ --debug ]\n");
+	exit(1);
+}
+$file = array_shift($argv);
 
-($xml=simplexml_load_file($file)) || die ($file . " not found !\n");
-if (in_array("--debug", $_SERVER['argv'])) print_r($xml);
+$xml = simplexml_load_file($file);
+if (!$xml) {
+	fwrite(STDERR, "Error opening $file\n");
+	exit(1);
+}
+if (in_array("--debug", $argv)) {
+	fwrite(STDERR, print_r($xml, 1));
+}
 
-if ($xml['version'] >= "2"){ // Package.xml V 2.0
+if ($xml['version'] >= '2') { // Package.xml V 2.0
 	printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
 		$xml->version->release, $xml->stability->release, 
 		$xml->version->api, $xml->stability->api, 
 		$xml->date, $xml->notes);
-	$new=$xml->version->release;
+	$new = $xml->version->release;
 
 	if (isset($xml->changelog->release) && count($xml->changelog->release)) 
-	    foreach($xml->changelog->release as $rel) {
-		$old=$rel->version->release;
-		if ("$old" != "$new") {
-		    printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
-			$rel->version->release, $rel->stability->release, 
-			$rel->version->api, $rel->stability->api, 
-			$rel->date, $rel->notes);
-		}
+	    foreach ($xml->changelog->release as $rel) {
+			$old = $rel->version->release;
+			if ($old != $new) {
+				printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
+				$rel->version->release, $rel->stability->release, 
+				$rel->version->api, $rel->stability->api, 
+				$rel->date, $rel->notes);
+			}
 	    }
 } else { // Package.xml V 1.0
 	printf("* Version %s (%s) - %s\n\n%s\n\n",
 		$xml->release->version, $xml->release->state, $xml->release->date, $xml->release->notes);
 
-	foreach($xml->changelog->release as $rel)
+	foreach ($xml->changelog->release as $rel) {
 		printf("* Version %s (%s) - %s\n\n%s\n\n",
 			$rel->version, $rel->state, $rel->date, $rel->notes);
+	}
 }
-?>
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/php-packagexml2cl/xml2changelog?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list