format.prl 1.12 KB
#!/usr/local/bin/perl5 -w
#
# Copyright (C) 1996-1998 by the Board of Trustees
#    of Leland Stanford Junior University.
# 
# This file is part of the SimOS distribution. 
# See LICENSE file for terms of the license. 
#


# First check for any directory aliases in the environment, if necessary
$string = "@ARGV";
if ($string =~ m!/!){
   while (($var, $value) = each(%ENV)) {
      if ($value =~ m!/!) {
	 if (($var ne "PWD") && ($var ne "CONFIGDIR") &&
             ($var !~ /PATH/) && ($var ne "TERMCAP")) {
	    $alias{$value} = $var;
	 }
      }
   }

# Then substitute them if it's applicable
   foreach $dir (reverse(sort(keys(%alias)))) {
      foreach $item (@ARGV) {
	 if ($item =~ /$dir/) {
	    $item =~ s/$dir/\$($alias{$dir})/;
	 }
      }
   }

}

$line_length = 79;
$tab = 15;			# Determined by Makefile
$i = 0;
grep($lengths[$i++] = length($_) + 1, @ARGV); # for perl4
# @lengths = map { length($_) + 1 } @ARGV; # for perl5

$len = $tab;
for ($i = 0; $i < @ARGV; $i++) {
   $len += $lengths[$i];
   if ($len > $line_length) {
      print "\n", " " x $tab;
      $len = $tab + $lengths[$i];
   }
   print "$ARGV[$i] ";
}
print "\n";