summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2005-12-13 12:38:27 +0000
committerfukachan <fukachan>2005-12-13 12:38:27 +0000
commitb8a241b5e1a876cbfe016e63b92d040aca5750f9 (patch)
treea91b04aab0773433e78d6fc841563fc042d6cd47
parent8b8fd8f2d2320c8e45ad46627c10ffd76be07a5f (diff)
downloadfml8-b8a241b5e1a876cbfe016e63b92d040aca5750f9.tar.gz
fml8-b8a241b5e1a876cbfe016e63b92d040aca5750f9.tar.bz2
fml8-b8a241b5e1a876cbfe016e63b92d040aca5750f9.zip
concatenate and print .sgml files
-rwxr-xr-xregress/doc/cat.pl54
1 files changed, 54 insertions, 0 deletions
diff --git a/regress/doc/cat.pl b/regress/doc/cat.pl
new file mode 100755
index 00000000..eb50708f
--- /dev/null
+++ b/regress/doc/cat.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/env perl
+#-*- perl -*-
+#
+# $FML: check.pl,v 1.1.1.1 2005/09/30 13:30:31 fukachan Exp $
+#
+
+use strict;
+use Carp;
+use vars qw(%entity %file %used %file_in_dir);
+
+my $entity = "include/chapters.ent";
+parse($entity, 0);
+parse("book.sgml", 1);
+
+exit 0;
+
+sub parse
+{
+ my ($file, $is_print) = @_;
+
+ use FileHandle;
+ my $rh = new FileHandle $file;
+ if (defined $rh) {
+ my $buf;
+ LINE:
+ while ($buf = <$rh>) {
+ # <!entity chapter.download SYSTEM "install/download.sgml">
+ if ($buf =~ /<\!entity\s+(\S+)\s+SYSTEM\s+"(\S+)">/) {
+ $entity{ $1 } = $2;
+ $file{ $2 } = $1;
+ }
+
+ # usual file
+ if ($buf =~ /\&(\S+);/) {
+ $used{ $1 } = 1;
+ my $_file = $entity{ $1 } || '';
+ if ($_file && -f $_file) {
+ parse($_file, $is_print);
+ next LINE;
+ }
+ }
+
+ if ($is_print) {
+ print $buf;
+ }
+ }
+ $rh->close();
+ }
+ else {
+ croak("cannot open \"$file\"\n");
+ }
+}
+
+