goba Wed Jan 9 08:09:56 2002 EDT
Modified files:
/phpdoc/scripts process.php
Log:
Do not write to file if return value is FALSE
Tabs -> spaces
Apply PEAR style delimiter placing for control structures
Index: phpdoc/scripts/process.php
diff -u phpdoc/scripts/process.php:1.2 phpdoc/scripts/process.php:1.3
--- phpdoc/scripts/process.php:1.2 Mon Jan 7 05:47:48 2002
+++ phpdoc/scripts/process.php Wed Jan 9 08:09:56 2002
@@ -1,8 +1,5 @@
#!/usr/bin/php -q
-<?php
-
-if ($argc < 2 || $argc > 3)
-{ ?>
+<?php if ($argc < 2 || $argc > 3) { ?>
Process the manual to do some replacements.
Usage:
@@ -19,80 +16,79 @@
Written by [EMAIL PROTECTED]
- <?php
- exit;
+<?php
+ exit;
}
echo "Starting with manual-process\n";
echo "Including $argv[1]...";
include("apply/$argv[1]");
echo " done\n";
-if (!function_exists('apply'))
-{
- ?>
-
+if (!function_exists('apply')) {
+?>
### FATAL ERROR ###
In <?=$argv[1]?> you should define a function:
string apply(string $string)
- <?php
- exit;
+<?php
+ exit;
}
$startdir = isset($argv[2]) ? $argv[2] : '.';
-
echo "Constructing list of all xml-files (may take a while)...";
$files = all_xml_files($startdir);
echo " done (".count($files)." xml files found)\n";
-foreach ($files as $file)
-{
- echo "[Processing $file]\n";
- $fp = fopen($file,'r');
- $old = fread($fp,filesize($file));
- fclose($fp);
- if (!$old)
- {
- echo "WARNING: problem reading $file, skipping\n";
- continue;
- }
- $new = apply($old);
+foreach ($files as $file) {
+
+ echo "[Processing $file]\n";
+ $fp = fopen($file,'r');
+ $old = fread($fp,filesize($file));
+ fclose($fp);
+
+ if (!$old) {
+ echo "WARNING: problem reading $file, skipping\n";
+ continue;
+ }
+
+ $new = apply($old);
if ($new === FALSE) { echo "NO MODIFICATION: $file not modified"; }
- $fp = fopen($file,'w');
- $res = fwrite($fp,$new);
- fclose($fp);
- if (!$res)
- {
- echo "WARNING: problem writing $file, file might be damaged\n";
- continue;
- }
+ else {
+ $fp = fopen($file,'w');
+ $res = fwrite($fp,$new);
+ fclose($fp);
+ if (!$res) {
+ echo "WARNING: problem writing $file, file might be damaged\n";
+ continue;
+ }
+ }
}
-
+
/* Utility functions: */
function all_xml_files($startdir)
{
- $startdir = ereg_replace('/+$','',$startdir);
- //echo "\$startdir = $startdir\n";
- $entries = array();
-
- $handle=opendir($startdir);
- while ($file = readdir($handle))
- {
- $ffile = "$startdir/$file"; // full file(path)
- //echo "$file\n";
- if (ereg('\.xml$',$file))
- $entries[] = $ffile;
- if ($file{0} != '.' && is_dir($ffile))
- $entries = array_merge($entries,all_xml_files($ffile));
- }
- closedir($handle);
+ $startdir = ereg_replace('/+$','',$startdir);
+ //echo "\$startdir = $startdir\n";
+ $entries = array();
+
+ $handle=opendir($startdir);
+ while ($file = readdir($handle)) {
+
+ $ffile = "$startdir/$file"; // full file(path)
+ //echo "$file\n";
+ if (ereg('\.xml$',$file))
+ $entries[] = $ffile;
+ if ($file{0} != '.' && is_dir($ffile))
+ $entries = array_merge($entries,all_xml_files($ffile));
+ }
+ closedir($handle);
- return $entries;
+ return $entries;
}
-
+