Current Path : /usr/src/tools/tools/epfe/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/src/tools/tools/epfe/epfe.pl |
#!/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 # # $FreeBSD: release/9.1.0/tools/tools/epfe/epfe.pl 50477 1999-08-28 01:08:13Z peter $ $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; } }