epfe - extract printing filter examples from printing.sgml
usage: $ cd /usr/share/examples/printing $ epfe < printing.sgml
This commit is contained in:
parent
9228f9b22a
commit
11edfd2a07
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