epfe - extract printing filter examples from printing.sgml
usage: $ cd /usr/share/examples/printing $ epfe < printing.sgml
This commit is contained in:
parent
fa2cedd44a
commit
08d366cf6b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20974
38
tools/tools/epfe/epfe.pl
Normal file
38
tools/tools/epfe/epfe.pl
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
|
||||
#
|
||||
# epfe - extract printing filter examples from printing.sgml
|
||||
#
|
||||
# usage:
|
||||
# $ cd /usr/share/examples/printing
|
||||
# $ epfe < ../../doc/handbook/printing.sgml
|
||||
#
|
||||
# $Id$
|
||||
|
||||
$in = 0; @a = ();
|
||||
sub Print { s/\&\;/&/g; push(@a,$_); }
|
||||
sub out {
|
||||
local($name, *lines) = @_;
|
||||
open(F, "> $name") || die "open $_[0]: $!\n";
|
||||
print F @lines;
|
||||
close F;
|
||||
}
|
||||
|
||||
while(<>) {
|
||||
if (/^<code>/) {
|
||||
$in = 1;
|
||||
} elsif (m%</code>% && $in > 0) {
|
||||
if ($in > 1) {
|
||||
$name = 'unknown' if !$name;
|
||||
while(1) { if ($d{$name}) { $name .= 'X'; } else { last } }
|
||||
&out("$name", *a);
|
||||
$d{$name} = $name;
|
||||
}
|
||||
$in = 0; $name = ''; @a = ();
|
||||
} elsif ($in == 1 && /^\#\s*!/) {
|
||||
$in++; &Print;
|
||||
} elsif ($in > 1) {
|
||||
$name = $1 if (!$name && /^\#\s+(\S+)\s+-\s+/);
|
||||
$in++; &Print;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user