<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#
#  FixRef.pm
#
#  $Id: FixRef.pm,v 1.2 1997/09/11 22:27:14 cg Exp $
#
#  Start conversion from parsed linuxdoc-sgml to html.
#        - Identify references and file count
#
#  Rules based on fixref.l
#
package SGMLTools::FixRef;

# Externally visible variables
$fixref = {};

# Initialize: set splitlevel before using rules
# Usage: &amp;{$fixref-&gt;{init}}(&lt;split level&gt;);
	# 0 - super page mode
	# 1 - big page mode
	# 2 - small page mode
$fixref-&gt;{init} = sub {
    $splitlevel = shift;
};

# Outputs: Read after using rules
$fixref-&gt;{filenum} = 0;			# Count of files we will create
$fixref-&gt;{lrec} = {};			# label -&gt; filenum

# Package variables
$chapter_mode = 0;	# &lt;report&gt; vs. &lt;article&gt;
$splitlevel = 0;	# See $fixref-&gt;{init} above;
			# Automatically reduced by 1 for chapter mode

# Finalize parsing
$fixref-&gt;{finish} = sub { };		# Do nothing when we're done

# Ruleset
$fixref-&gt;{rules} = {};			# Individual parsing rules
$fixref-&gt;{defaultrule} = sub { };	# If line does not match any rules

# Set the rules
# &lt;@@ssect&gt; - split file if necessary
$fixref-&gt;{rules}-&gt;{'^&lt;@@ssect&gt;.*$'} = sub { &amp;splitfile(2); };

# &lt;@@sect&gt; - split file if necessary
$fixref-&gt;{rules}-&gt;{'^&lt;@@sect&gt;.*$'} = sub { &amp;splitfile(1); };

# &lt;@@chapt&gt; - set chapter mode; reduce splitlevel if needed; split file
$fixref-&gt;{rules}-&gt;{'^&lt;@@chapt&gt;.*$'} = sub { 
    $splitlevel-- if (!$chapter_mode);
    $chapter_mode = 1; &amp;splitfile(0);
};

# &lt;@@label&gt; - Identify label location
$fixref-&gt;{rules}-&gt;{'^&lt;@@label&gt;(.*)$'} = sub { 
    $fixref-&gt;{lrec}-&gt;{$1} = $fixref-&gt;{filenum};
};

#==============================
# Split the file (-split option; level in parentheses):
#  non-chapter mode: -0 -&gt; don't split
#                    -1 -&gt; split at sect (1)
#                    -2 -&gt; split at sect (1) and ssect (2)
#  chapter mode: -0 -&gt; split at chapt (0)
#                -1 -&gt; split at chapt (0)
#                -2 -&gt; split at chapt (0) and sect (1)
sub splitfile
{
    my ($level) = @_;
    if (($level == 0) || ($splitlevel &gt;= $level)) {
        $fixref-&gt;{filenum}++;
    }
}

1;

</pre></body></html>