For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > September 2005 > cvs: phpdoc /scripts make-partial.php









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: phpdoc /scripts make-partial.php
anatoly techtonik

2005-09-28, 6:57 pm

techtonik Wed Sep 28 11:47:52 2005 EDT

Modified files:
/phpdoc/scripts make-partial.php
Log:
* (sync) recover manual.xml.in if the script was terminated unexpectedly

http://cvs.php.net/diff.php/phpdoc/...1.2&r2=1.3&ty=u
Index: phpdoc/scripts/make-partial.php
diff -u phpdoc/scripts/make-partial.php:1.2 phpdoc/scripts/make-partial.php:1.3
--- phpdoc/scripts/make-partial.php:1.2 Tue Sep 13 19:41:19 2005
+++ phpdoc/scripts/make-partial.php Wed Sep 28 11:47:51 2005
@@ -12,7 +12,7 @@
*
* @author Martin Jansen <mj@php.net>
* @copyright 2005 The PEAR Group
- * @version CVS: $Id: make-partial.php,v 1.2 2005/09/13 23:41:19 techtonik Exp $
+ * @version CVS: $Id: make-partial.php,v 1.3 2005/09/28 15:47:51 techtonik Exp $
*/

// NOTE: originally from peardoc:/make-partial.php ;
@@ -33,6 +33,7 @@
$format = "html";
$sections = array();

+$incflag = false;
foreach ($args[0] as $arg) {
if ($arg[0] == "--help") {
showHelp();
@@ -41,6 +42,14 @@
$format = $arg[1];
} elseif ($arg[0] == '--include') {
$sections[] = $arg[1];
+ $incflag = true;
+ }
+}
+
+if ($incflag) {
+ // collect other space delimited names as section names
+ foreach ($args[1] as $arg) {
+ $sections[] = $arg;
}
}

@@ -57,15 +66,18 @@
}
}

+// recover manual.xml.in if the script was terminated unexpectedly
+restoreFile();
+
+copy("manual.xml.in", "manual.xml.in.partial-backup");
+register_shutdown_function("restoreFile", filemtime("manual.xml.in"));
+
$file = file("manual.xml.in");
if (!$file) {
echo "Error: Unable to read manual.xml.in!";
exit(1);
}

-copy("manual.xml.in", "manual.xml.in.partial-backup");
-register_shutdown_function("restoreFile", filemtime("manual.xml.in"));
-
$newFile = "";
$partStack = array();
$includePart = true;
@@ -162,14 +174,14 @@
/**
* Restores the original manual.xml.in file
*/
-function restoreFile($savedmtime) {
+function restoreFile($savedmtime = null) {
if (!is_file("manual.xml.in.partial-backup")) {
return;
}

unlink("manual.xml.in");
rename("manual.xml.in.partial-backup", "manual.xml.in");
- touch("manual.xml.in", $savedmtime);
+ if ($savedmtime) touch("manual.xml.in", $savedmtime);
}

/**
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com