1#!perl
2# $Id: fix_help.pl,v 1.3 2004/09/30 07:34:13 jlinoff Exp $
3#
4# Fix up the help source file by inserting breaks every
5# so often to avoid very long compile times for gcc when
6# it tries to verify the format arguments.
7#
8use strict;
9&Main;
10
11# ================================================
12# MAIN
13# ================================================
14sub Main
15{
16    # Open the help.cc file.
17    my $ifile = "help.cc";
18    my $ofile = "help-tmp.cc";
19    if( ! -e $ifile ) {
20	print STDERR "ERROR: Cannot read '$ifile'.\n";
21	exit 1;
22    }
23    open IFILE,"$ifile" || die "ERROR: Cannot read '$ifile'.\n";
24    open OFILE,">$ofile" || die "ERROR: Cannot ofile '$ofile'.\n";
25    my $prev;
26    while( <IFILE> ) {
27	chop;
28	if( /^    << \"[0-9].*$/ ) {
29	    #print "DEBUG: prev = $prev\n";
30	    if( $prev !~ /ccdoc::s_log/ ) {
31		# Allow this script to be re-entrant.
32		print OFILE "    ;\n";
33		print OFILE "  ccdoc::s_log\n";
34	    }
35	}
36	print OFILE "$_\n";
37	$prev = $_;
38    }
39    close OFILE;
40    close IFILE;
41    rename $ofile, $ifile;
42    exit 0;
43}
44