diff options
author | wosch <wosch@FreeBSD.org> | 1996-12-28 16:24:57 +0000 |
---|---|---|
committer | wosch <wosch@FreeBSD.org> | 1996-12-28 16:24:57 +0000 |
commit | 8da9a185e58b71e1a7533c15c08b142f2a901575 (patch) | |
tree | f3f18a0eeaff999c72df61d70b91c7a6adae616d /tools | |
parent | fd6e85f6ad93504ece1db8c12f2964c6b2d00e7a (diff) | |
download | FreeBSD-src-8da9a185e58b71e1a7533c15c08b142f2a901575.zip FreeBSD-src-8da9a185e58b71e1a7533c15c08b142f2a901575.tar.gz |
epfe - extract printing filter examples from printing.sgml
usage:
$ cd /usr/share/examples/printing
$ epfe < printing.sgml
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/epfe/epfe.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/tools/epfe/epfe.pl b/tools/tools/epfe/epfe.pl new file mode 100644 index 0000000..4afd824 --- /dev/null +++ b/tools/tools/epfe/epfe.pl @@ -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; + } +} |