cvs: phd / config.php
| From: | Hannes Magnusson | Date: | Thu, 08 Nov 2007 16:11:44 +0000 |
| Subject: | cvs: phd / config.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-362@lists.php.net to get a copy of this message | ||
bjori Thu Nov 8 16:11:44 2007 UTC
Modified files:
/phd config.php
Log:
Add a dummy getopt() for Windows (prior to PHP5.3)
Fix last-argument check (if -d/--docbook wasn't passed)
http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.10&r2=1.11&diff_format=u
Index: phd/config.php
diff -u phd/config.php:1.10 phd/config.php:1.11
--- phd/config.php:1.10 Mon Nov 5 09:49:45 2007
+++ phd/config.php Thu Nov 8 16:11:44 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: config.php,v 1.10 2007/11/05 09:49:45 bjori Exp $ */
+/* $Id: config.php,v 1.11 2007/11/08 16:11:44 bjori Exp $ */
function v($msg) {
$args = func_get_args();
@@ -61,8 +61,24 @@
"help" => "h", // Print out help
);
-$verbose = 0;
+/* Fix for Windows prior to PHP5.3 */
+if (!function_exists("getopt")) {
+ function getopt($short, $long) {
+ v("I'm sorry, you are running an operating system that does not support
getopt()\n");
+ v("Please either upgrade to PHP5.3 or try '%s
/path/to/your/docbook.xml'\n", $argv[0]);
+
+ return array();
+ }
+}
+
$args = getopt(implode("", array_values($opts)), array_keys($opts));
+if($args === false) {
+ v("Something happend with getopt(), please report a bug\n");
+ exit(-1);
+}
+
+$verbose = 0;
+$docbook = false;
foreach($args as $k => $v) {
switch($k) {
/* {{{ Docbook file */
@@ -78,6 +94,7 @@
}
$OPTIONS["xml_root"] = dirname($v);
$OPTIONS["xml_file"] = $v;
+ $docbook = true;
break;
/* }}} */
@@ -226,11 +243,15 @@
}
-if ($argc == 2) {
- $OPTIONS["xml_root"] = $argv[1];
-} elseif ($argc > 2 && is_file($argv[$argc-1]) && $OPTIONS["xml_file"]
!= $argv[$argc-1]) {
- $OPTIONS["xml_file"] = $argv[$argc-1];
- $OPTIONS["xml_root"] = dirname($argv[$argc-1]);
+if (!$docbook) {
+ $arg = $argv[$argc-1];
+ if (is_dir($arg)) {
+ $OPTIONS["xml_root"] = $arg;
+ $OPTIONS["xml_file"] = $arg . "/.manual.xml";
+ } elseif (is_file($arg)) {
+ $OPTIONS["xml_root"] = dirname($arg);
+ $OPTIONS["xml_file"] = $arg;
+ }
}
while (!is_dir($OPTIONS["xml_root"]) || !is_file($OPTIONS["xml_file"])) {