#!/usr/local/bin/perl # Title: expand-tables.pl # Version: 1 # Synopsis: Expands "% gentable TABLENAME ..." in "@ignore...@end ignore" # Author: Geoffrey S. Knauth # Created: 22-May-1996 # Modified: 22-May-1996 # # Copyright (C) 1996 Geoffrey S. Knauth # Distribution under the terms of the GNU General Public License (see bottom). use FileHandle; $usage = "usage: expand-tables.pl foo.texi.in > foo.texi\n"; if ($#ARGV != 0) { print STDERR $usage; exit (1); } open (IN, $ARGV[0]) || die "can't fopen(r) \"$ARGV[0]\""; $in_gentable = false; print "% This file was generated automatically by `expand-tables.pl'.\n"; print "% The input file we used was \"$ARGV[0]\".\n\n"; while () { chop; $lastline = $line; $line = $_; if ($in_gentable ne true) { $basename = ""; $first_data_line_is_header = false; if ($lastline =~ /^\@ignore/ && $line =~ /^%\s+gentable/) { print "$line\n"; $basename = $1 if ($line =~ /basename\s+\"(.*)\"/); $first_data_line_is_header = true if ($line =~ /first-data-line-is-header/); $in_gentable = true; $tablefile = $basename . ".tbl"; open (TABLE, ">$tablefile") || die "can't fopen(w) \"$tablefile\""; next; } } else { if ($line =~ /^\@end\s+ignore/) { print "\@end ignore\n"; close TABLE; $in_gentable = false ; &write_tex_table ($tablefile); &write_html_table ($tablefile); unlink $tablefile; } else { print "$line\n"; print TABLE "$line\n"; } next; } print "$_\n"; } sub write_tex_table { local ($filename) = $_[0]; local ($command); print "\@tex\n"; open (TMP, "gentable.pl -tex $filename|"); while () {print;} close TMP; print "\@end tex\n"; } sub write_html_table { local ($filename) = $_[0]; local ($command); print "\@ifhtml\n"; open (TMP, "gentable.pl -html $filename|"); while () {print;} close TMP; print "\@end ifhtml\n"; } __END__ LICENSE TO USE THIS SOFTWARE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307 Voice: +1-617-542-5942 Fax: +1-617-542-2652