Hosted by
|
#!/usr/bin/php -qC <?php
// $Date: 2004/01/20 06:23:09 $ // $Revision: 1.7 $ // $Author: jcrocholl $
require('plain.php');
function warning($filename, $line_number, $line, $text) { print "$filename:$line_number: illegal formatting\n"; print " $text\n"; print " $line\n"; }
function myprint($line) { if (!$line) return; global $outfilename; global $outfilehandle; if (!fwrite($outfilehandle, $line)) die("Cannot write $line to file $outfilename\n"); }
require('parser.php');
function parsefile($filename, $sure) { $outfilename = "$filename,f"; global $outfilehandle; if (!$outfilehandle = fopen($outfilename, 'w')) die("Cannot open file $outfilename"); global $line_number; $line_number = 0; parse($filename); fclose($outfilehandle); if ($sure) { unlink($filename); $success = rename($outfilename, $filename); if (!$success) print "rename failed\n"; // else print "rename successful\n"; } }
// print "'" . implode("', '", $argv) . "'\n"; $progname = array_shift($argv); if ($argv[0] == '--sure') $sure = array_shift($argv); $filename = array_shift($argv); if ($argv[0] == '--sure') $sure = array_shift($argv); // print "$sure $filename\n";
if ($argv or !$filename) die("usage : $progname [--sure] <filename>\n");
if (preg_match('/^(.+)\.ads$/', $filename, $m)) { $auto_comments_save = true; // print "saving heads for $filename\n"; parsefile($filename, $sure); $auto_comments_save = false; $adb = "$m[1].adb"; if (file_exists($adb)) { $auto_comments_load = true; // print "loading heads for $adb\n"; if ($indent_level) { print "indent level $indent_level, should be 0.\n"; $indent_level = 0; } parsefile($adb, $sure); $auto_comments_load = false; } } elseif (preg_match('/^(.+)\.adb$/', $filename, $m)) { $ads = "$m[1].ads"; if (file_exists($ads)) { print "please specify $ads\n" . " instead of $filename\n"; } else { parsefile($filename, $sure); } }
?>
|