head	1.1;
branch	1.1.1;
access;
symbols
	postmerge-db-4_1_24-release:1.1.1.2
	premerge-db-4_1_24-release:1.1.1.2
	pre-db-4_1_24-release:1.1.1.2
	postmerge-db-4_1_17:1.1.1.2
	premerge-db-4_1_17:1.1.1.2
	pre-db-4_1_17:1.1.1.2
	postmerge-db-4_0_14:1.1.1.2
	premerge-db-4_0_14:1.1.1.2
	pre-db-4_0_14:1.1.1.2
	rpm-4_0_3-release:1.1.1.1
	postmerge-db-4_0_7:1.1.1.2
	premerge-db-4_0_7:1.1.1.2
	pre-db-4_0_7:1.1.1.1
	jbj_b4_rollback:1.1.1.1
	postmerge-db-3_3_11-release:1.1.1.1
	premerge-db-3_3_11-release:1.1.1.1
	db-3_3_11-release:1.1.1.1
	pre-db-3_3_11-release:1.1.1.1
	rpm-4_0:1.1.1.1.0.2
	postmerge-db-3_3_4-release:1.1.1.1
	premerge-db-3_3_4-release:1.1.1.1
	db-3_3_4-release:1.1.1.1
	pre-db-3_3_4-release:1.1.1.1
	db-3_2_9-release:1.1.1.1
	db-3_2_9-vendor:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2001.03.21.18.33.39;	author jbj;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.03.21.18.33.39;	author jbj;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;

1.1.1.2
date	2001.10.15.03.47.08;	author jbj;	state dead;
branches;
next	;

1.1.1.1.2.1
date	2002.01.08.04.07.41;	author jbj;	state dead;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/usr/local/bin/perl5

# Filename: mkpod
#
# Author:	Paul Marquess

# File types
#
#    Macro files end with .M
#    Tagged source files end with .T
#    Output from the code ends with .O
#    Pre-Pod file ends with .P
#    
# Tags
#
#    ## BEGIN tagname
#     ...
#    ## END tagname
#
#    ## 0
#    ## 1
#

# Constants

$TOKEN = '##' ;
$Verbose = 1 if $ARGV[0] =~ /^-v/i ;

# Macros files first
foreach $file (glob("*.M"))
{
    open (F, "<$file") or die "Cannot open '$file':$!\n" ;
    print "    Processing Macro file $file\n"  ;
    while (<F>)
    {
        # Skip blank & comment lines
        next if /^\s*$/ || /^\s*#/ ;
	
	# 
	($name, $expand) = split (/\t+/, $_, 2) ;

	$expand =~ s/^\s*// ;
        $expand =~ s/\s*$// ;

	if ($expand =~ /\[#/ )
	{
	}

	$Macros{$name} = $expand ;
    }
    close F ;
}

# Suck up all the code files
foreach $file (glob("t/*.T"))
{
    ($newfile = $file) =~ s/\.T$// ;
    open (F, "<$file") or die "Cannot open '$file':$!\n" ;
    open (N, ">$newfile") or die "Cannot open '$newfile':$!\n" ;

    print "    Processing $file -> $newfile\n"  ;

    while ($line = <F>)
    {
        if ($line =~ /^$TOKEN\s*BEGIN\s+(\w+)\s*$/ or
            $line =~ m[\s*/\*$TOKEN\s*BEGIN\s+(\w+)\s*$] )
        {
	    print "    Section $1 begins\n" if $Verbose ;
	    $InSection{$1} ++ ;
	    $Section{$1} = '' unless $Section{$1} ;
        }
        elsif ($line =~ /^$TOKEN\s*END\s+(\w+)\s*$/ or
               $line =~ m[^\s*/\*$TOKEN\s*END\s+(\w+)\s*$] )
        {
	    warn "Encountered END without a begin [$line]\n"
		unless $InSection{$1} ;

	    delete $InSection{$1}  ;
	    print "    Section $1 ends\n" if $Verbose ;
        }
        else
        {
	    print N $line ;
	    chop $line ;
	    $line =~ s/\s*$// ;

	    # Save the current line in each of the sections
	    foreach( keys %InSection)
	    {
		if ($line !~ /^\s*$/ )
	          #{ $Section{$_} .= "    $line" }
	          { $Section{$_} .= $line }
	        $Section{$_} .= "\n" ;
	    }
        }

    }

    if (%InSection)
    {
        # Check for unclosed sections
	print "The following Sections are not terminated\n" ;
        foreach (sort keys %InSection)
          { print "\t$_\n" }
	exit 1 ;
    }

    close F ;
    close N ;
}

print "\n\nCreating pod file(s)\n\n" if $Verbose ;

@@ppods = glob('*.P') ;
#$ppod = $ARGV[0] ;
#$pod = $ARGV[1] ;

# Now process the pre-pod file
foreach $ppod (@@ppods)
{
    ($pod = $ppod) =~ s/\.P$// ;
    open (PPOD, "<$ppod") or die "Cannot open file '$ppod': $!\n" ;
    open (POD, ">$pod") or die "Cannot open file '$pod': $!\n" ;

    print "    $ppod -> $pod\n" ;

    while ($line = <PPOD>)
    {
        if ( $line =~ /^\s*$TOKEN\s*(\w+)\s*$/)
        {
            warn "No code insert '$1' available\n"
	        unless $Section{$1} ;
    
	    print "Expanding section $1\n" if $Verbose ;
	    print POD $Section{$1} ;
        }
        else
        {
#	    $line =~ s/\[#([^\]])]/$Macros{$1}/ge ;
	    print POD $line ;
        }
    }
    
    close PPOD ;
    close POD ;
}
@


1.1.1.1
log
@db-3.2.9
@
text
@@


1.1.1.1.2.1
log
@Update to db-4.0.14.
@
text
@@


1.1.1.2
log
@*** empty log message ***
@
text
@@

