File: maketext

package info (click to toggle)
psutils 1.17.dfsg-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 796 kB
  • ctags: 605
  • sloc: ansic: 6,567; sh: 756; perl: 705; makefile: 639; lisp: 74
file content (52 lines) | stat: -rwxr-xr-x 1,849 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
   & eval 'exec perl -S $0 $argv:q'
   if 0;

# maketext: perl filter to substitute names in scripts and man pages.

%change = ();			# names -> substitutions

# get release and patchlevel for all scripts
open(H, "patchlev.h") || die "can't open patchlev.h";
while(<H>) {
   $change{$1} = $2 if /^\#define\s*(\S*)\s*(\S*)/;
}
close(H);

$os = "" ;

%perlstart = ("UNIX", "\#!PERL\neval 'exec perl -S \$0 \"\$\@\"'\n\tif \$running_under_some_shell;\n",
	      "DOS", "\@rem = '-*- Perl -*-\n\@echo off\nPERL -S %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9\ngoto endofperl\n';\n",
	      "WINNT", "\@rem = '-*- Perl -*-\n\@echo off\nPERL -S %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9\ngoto endofperl\n';\n",
	      "OS2", "extproc PERL -x\n\#! PERL\n",
	      "", "PSUTILS MAKEFILE CONFIGURATION ERROR") ;
%perlend = ("UNIX", "",
	    "DOS", "__END__\n:endofperl\n",
	    "WINNT", "__END__\n:endofperl\n",
	    "OS2", "\# End of Script",
	    "", "PSUTILS MAKEFILE CONFIGURATION ERROR");

foreach (@ARGV) {
   if (/MAN=(.*)/) {		# name.ext name.ext -> name(ext), name(ext)
      local(@man) = split(' ', $1);
      $change{"MAN"} = join(", ", grep(s/\.(.)/($1)/, @man));
   } elsif (/OS=(.*)/) {	# set operating system name
      $os = $1 ;
   } elsif (/PERL=(.*)/) {	# substitute name for value
      local($perl) = $1 ;
      $change{"PERL"} = $perlstart{$os} ;
      $change{"END"} = $perlend{$os} ;
      $change{"PERL"} =~ s/PERL/$perl/g ;
      $change{"END"} =~ s/PERL/$perl/g ;
   } elsif (/(.*)=(.*)/) {	# substitute name for value
      $change{$1} = $2;
   } else {			# open file and substitute
      local(@change) = keys %change;
      open(FILE, $_) || die "can't open $_";
      while ($line = <FILE>) {
	 grep($line =~ s/\@$_\@/$change{$_}/g, @change);
	 print $line;
      }
      close(FILE);
   }
}