New helper functions to help deal with parameter parsing.

Use the helpers in do_cmd_*() and do_env_*(); *much* cleaner!
This commit is contained in:
Fred Drake 1998-04-17 02:15:42 +00:00
parent 64bdc24301
commit 08932054e9
1 changed files with 274 additions and 395 deletions

View File

@ -9,6 +9,29 @@
package main; package main;
sub next_argument_id{
my ($param,$br_id);
$param = missing_braces()
unless ((s/$next_pair_pr_rx/$br_id=$1;$param=$2;''/eo)
||(s/$next_pair_rx/$br_id=$1;$param=$2;''/eo));
($param, $br_id);
}
sub next_argument{
my ($param,$br_id) = next_argument_id();
$param;
}
sub next_optional_argument{
my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
s/$rx/$param=$1;''/eo;
$param;
}
sub swallow_newline{
s/[\n]?//o;
}
# words typeset in a special way (not in HTML though) # words typeset in a special way (not in HTML though)
sub do_cmd_ABC{ 'ABC' . @_[0]; } sub do_cmd_ABC{ 'ABC' . @_[0]; }
@ -28,98 +51,78 @@ $PYTHON_VERSION = '';
sub do_cmd_version{ $PYTHON_VERSION . @_[0]; } sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
sub do_cmd_release{ sub do_cmd_release{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; $PYTHON_VERSION = next_argument();
$PYTHON_VERSION = "$2";
$_; $_;
} }
sub do_cmd_authoraddress{ sub do_cmd_authoraddress{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; $AUTHOR_ADDRESS = next_argument();
$AUTHOR_ADDRESS = "$2";
$_; $_;
} }
sub do_cmd_hackscore{ sub do_cmd_hackscore{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx/_/; next_argument();
$_; '_' . $_;
} }
sub use_wrappers{
local($_,$before,$after) = @_;
my $stuff = next_argument();
$before . $stuff . $after . $_;
}
sub use_current{ use_wrappers(@_[0], '', ''); }
sub use_sans_serif{ use_wrappers(@_[0], '<font face=sans-serif>', '</font>'); }
sub use_italics{ use_wrappers(@_[0], '<i>', '</i>'); }
sub do_cmd_optional{ sub do_cmd_optional{
local($_) = @_; use_wrappers(@_[0], "</var><big>\[</big><var>",
s|$next_pair_pr_rx|</var><big>\[</big><var>\2</var><big>\]</big><var>|; "</var><big>\]</big><var>");
$_;
} }
sub do_cmd_varvars{
local($_) = @_;
s|$next_pair_pr_rx|<var>\2</var>|;
$_;
}
sub use_current{
local($_) = @_;
s|$next_pair_pr_rx|\2|;
$_;
}
sub do_cmd_pytype{ use_current(@_); }
sub do_cmd_makevar{ use_current(@_); }
# Logical formatting (some based on texinfo), needs to be converted to # Logical formatting (some based on texinfo), needs to be converted to
# minimalist HTML. The "minimalist" is primarily to reduce the size of # minimalist HTML. The "minimalist" is primarily to reduce the size of
# output files for users that read them over the network rather than # output files for users that read them over the network rather than
# from local repositories. # from local repositories.
sub do_cmd_code{ sub do_cmd_pytype{ use_current(@_); }
local($_) = @_; sub do_cmd_makevar{ use_current(@_); }
s|$next_pair_pr_rx|<tt>\2</tt>|; sub do_cmd_code{ use_wrappers(@_[0], '<tt>', '</tt>'); }
$_; sub do_cmd_module{ do_cmd_code(@_); }
} sub do_cmd_keyword{ do_cmd_code(@_); }
sub do_cmd_exception{ do_cmd_code(@_); }
sub do_cmd_class{ do_cmd_code(@_); }
sub do_cmd_function{ do_cmd_code(@_); }
sub do_cmd_constant{ do_cmd_code(@_); }
sub do_cmd_member{ do_cmd_code(@_); }
sub do_cmd_method{ do_cmd_code(@_); }
sub do_cmd_cfunction{ do_cmd_code(@_); }
sub do_cmd_cdata{ do_cmd_code(@_); }
sub do_cmd_ctype{ do_cmd_code(@_); }
sub do_cmd_regexp{ do_cmd_code(@_); }
sub do_cmd_key{ do_cmd_code(@_); }
sub do_cmd_character{ do_cmd_samp(@_); }
sub do_cmd_program{ do_cmd_strong(@_); }
sub do_cmd_email{ use_sans_serif(@_); }
sub do_cmd_mimetype{ use_sans_serif(@_); }
sub do_cmd_var{ use_italics(@_); }
sub do_cmd_dfn{ use_italics(@_); } # make an index entry?
sub do_cmd_emph{ use_italics(@_); }
sub do_cmd_file{ use_wrappers(@_[0], '"<tt>', '</tt>"'); }
sub do_cmd_samp{ use_wrappers(@_[0], '"<tt>', '</tt>"'); }
sub do_cmd_kbd{ use_wrappers(@_[0], '<kbd>', '</kbd>'); }
sub do_cmd_strong{ use_wrappers(@_[0], '<b>', '</b>'); }
sub use_sans_serif{ # \sectcode is obsolete, but keep it around here for a little while;
local($_) = @_; # mostly expected to be useful for HOWTO support until that stuff is
s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|; # more stable and checked.
$_; sub do_cmd_sectcode{ do_cmd_code(@_); }
}
sub use_italics{
local($_) = @_;
s|$next_pair_pr_rx|<i>\2</i>|;
$_;
}
sub do_cmd_sectcode{ &do_cmd_code(@_); }
sub do_cmd_module{ &do_cmd_code(@_); }
sub do_cmd_keyword{ &do_cmd_code(@_); }
sub do_cmd_exception{ &do_cmd_code(@_); }
sub do_cmd_class{ &do_cmd_code(@_); }
sub do_cmd_function{ &do_cmd_code(@_); }
sub do_cmd_constant{ &do_cmd_code(@_); }
sub do_cmd_member{ &do_cmd_code(@_); }
sub do_cmd_method{ &do_cmd_code(@_); }
sub do_cmd_cfunction{ &do_cmd_code(@_); }
sub do_cmd_cdata{ &do_cmd_code(@_); }
sub do_cmd_ctype{ &do_cmd_code(@_); }
sub do_cmd_regexp{ &do_cmd_code(@_); }
sub do_cmd_key{ &do_cmd_code(@_); }
sub do_cmd_character{ &do_cmd_samp(@_); }
sub do_cmd_program{ &do_cmd_strong(@_); }
sub do_cmd_email{ &use_sans_serif(@_); }
sub do_cmd_mimetype{ &use_sans_serif(@_); }
sub do_cmd_var{ &use_italics(@_); }
sub do_cmd_dfn{ &use_italics(@_); } # make an index entry?
sub do_cmd_emph{ &use_italics(@_); }
sub do_cmd_newsgroup{ sub do_cmd_newsgroup{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my $newsgroup = next_argument();
my $newsgroup = $2;
my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>" my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
. "$newsgroup</font></a>"; . "$newsgroup</font></a>";
$stuff . $_; $stuff . $_;
@ -127,8 +130,7 @@ sub do_cmd_newsgroup{
sub do_cmd_envvar{ sub do_cmd_envvar{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; my($envvar,$br_id) = next_argument_id();
my($br_id,$envvar) = ($1, $2);
my($name,$aname,$ahref) = link_info($br_id); my($name,$aname,$ahref) = link_info($br_id);
# The <tt> here is really to keep buildindex.py from making # The <tt> here is really to keep buildindex.py from making
# the variable name case-insensitive. # the variable name case-insensitive.
@ -138,11 +140,11 @@ sub do_cmd_envvar{
"$aname\$$envvar</a>" . $_; "$aname\$$envvar</a>" . $_;
} }
sub do_cmd_url{ sub do_cmd_url{
# use the URL as both text and hyperlink # use the URL as both text and hyperlink
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; my $url = next_argument();
my $url = $2;
$url =~ s/~/&#126;/g; $url =~ s/~/&#126;/g;
"<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_; "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
} }
@ -150,40 +152,27 @@ sub do_cmd_url{
sub do_cmd_manpage{ sub do_cmd_manpage{
# two parameters: \manpage{name}{section} # two parameters: \manpage{name}{section}
local($_) = @_; local($_) = @_;
my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3"; my $page = next_argument();
s|$rx|<i>\2</i>(\4)|; my $section = next_argument();
$_; "<i>$page</i>($section)" . $_;
} }
sub do_cmd_rfc{ sub do_cmd_rfc{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; my($rfcnumber,$br_id) = next_argument();
my($br_id,$rfcnumber) = ($1, $2);
# Save the reference # Save the reference
my $nstr = &gen_index_id("RFC!RFC $rfcnumber", ''); my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
$index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); $index{$nstr} .= make_half_href("$CURRENT_FILE#$br_id");
"<a name=$br_id>RFC $rfcnumber</a>" .$_; "<a name=$br_id>RFC $rfcnumber</a>" .$_;
} }
sub do_cmd_kbd{
local($_) = @_;
s|$next_pair_pr_rx|<kbd>\2</kbd>|;
$_;
}
sub do_cmd_strong{
local($_) = @_;
s|$next_pair_pr_rx|<b>\2</b>|;
$_;
}
sub do_cmd_deprecated{ sub do_cmd_deprecated{
# two parameters: \deprecated{version}{whattodo} # two parameters: \deprecated{version}{whattodo}
local($_) = @_; local($_) = @_;
my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3"; my $release = next_argument();
s|$rx|<b>Deprecated since release \2.</b>\n\4<p>|; my $reason = next_argument();
$_; "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
} }
# file and samp are at the end of this file since they screw up fontlock. # file and samp are at the end of this file since they screw up fontlock.
@ -199,8 +188,7 @@ sub get_indexsubitem{
sub do_cmd_setindexsubitem{ sub do_cmd_setindexsubitem{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//; $INDEX_SUBITEM = next_argument();
$INDEX_SUBITEM = $2;
$_; $_;
} }
@ -210,18 +198,20 @@ sub do_cmd_withsubitem{
# out, and leave anything that the second argument expanded out to. # out, and leave anything that the second argument expanded out to.
# #
local($_) = @_; local($_) = @_;
my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; next_argument();
s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/; my $stuff = next_argument();
$INDEX_SUBITEM = $2; $stuff . $_;
$_;
} }
# This is the prologue macro which is required to start writing the
# mod\jobname.idx file; we can just ignore it.
#
sub do_cmd_makemodindex{ @_[0]; } sub do_cmd_makemodindex{ @_[0]; }
# We're in the document subdirectory when this happens! # We're in the document subdirectory when this happens!
# #
open(IDXFILE, ">index.dat") || die "\n$!\n"; open(IDXFILE, '>index.dat') || die "\n$!\n";
open(INTLABELS, ">intlabels.pl") || die "\n$!\n"; open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
print INTLABELS "%internal_labels = ();\n"; print INTLABELS "%internal_labels = ();\n";
print INTLABELS "1; # hack in case there are no entries\n\n"; print INTLABELS "1; # hack in case there are no entries\n\n";
@ -236,7 +226,7 @@ sub gen_target_name{
} }
sub gen_target{ sub gen_target{
"<a name=\"" . @_[0] . "\">"; '<a name="' . @_[0] . '">';
} }
sub gen_link{ sub gen_link{
@ -269,8 +259,8 @@ sub link_info{
sub do_cmd_index{ sub do_cmd_index{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx[\n]?//o; my($str,$br_id) = next_argument_id();
my($br_id,$str) = ($1, $2); swallow_newline();
# #
my($name,$aname,$ahref) = link_info($br_id); my($name,$aname,$ahref) = link_info($br_id);
add_index_entry("$str", $ahref); add_index_entry("$str", $ahref);
@ -279,12 +269,10 @@ sub do_cmd_index{
sub do_cmd_indexii{ sub do_cmd_indexii{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my($str1,$br_id) = next_argument_id();
my($br_id1,$str1) = ($1, $2); my $str2 = next_argument();
s/$next_pair_pr_rx[\n]?//o;
my($br_id2,$str2) = ($1, $2);
# #
my($name,$aname,$ahref) = link_info($br_id1); my($name,$aname,$ahref) = link_info($br_id);
add_index_entry("$str1!$str2", $ahref); add_index_entry("$str1!$str2", $ahref);
add_index_entry("$str2!$str1", $ahref); add_index_entry("$str2!$str1", $ahref);
"$aname$anchor_invisible_mark</a>" . $_; "$aname$anchor_invisible_mark</a>" . $_;
@ -292,14 +280,11 @@ sub do_cmd_indexii{
sub do_cmd_indexiii{ sub do_cmd_indexiii{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my($str1,$br_id) = next_argument();
my($br_id1,$str1) = ($1, $2); my $str2 = next_argument();
s/$next_pair_pr_rx//o; my $str3 = next_argument();
my($br_id2,$str2) = ($1, $2);
s/$next_pair_pr_rx[\n]?//o;
my($br_id3,$str3) = ($1, $2);
# #
my($name,$aname,$ahref) = link_info($br_id1); my($name,$aname,$ahref) = link_info($br_id);
add_index_entry("$str1!$str2 $str3", $ahref); add_index_entry("$str1!$str2 $str3", $ahref);
add_index_entry("$str2!$str3, $str1", $ahref); add_index_entry("$str2!$str3, $str1", $ahref);
add_index_entry("$str3!$str1 $str2", $ahref); add_index_entry("$str3!$str1 $str2", $ahref);
@ -308,16 +293,12 @@ sub do_cmd_indexiii{
sub do_cmd_indexiv{ sub do_cmd_indexiv{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my($str1,$br_id) = next_argument();
my($br_id1,$str1) = ($1, $2); my $str2 = next_argument();
s/$next_pair_pr_rx//o; my $str3 = next_argument();
my($br_id2,$str2) = ($1, $2); my $str4 = next_argument();
s/$next_pair_pr_rx//o;
my($br_id3,$str3) = ($1, $2);
s/$next_pair_pr_rx[\n]?//o;
my($br_id4,$str4) = ($1, $2);
# #
my($name,$aname,$ahref) = link_info($br_id1); my($name,$aname,$ahref) = link_info($br_id);
add_index_entry("$str1!$str2 $str3 $str4", $ahref); add_index_entry("$str1!$str2 $str3 $str4", $ahref);
add_index_entry("$str2!$str3 $str4, $str1", $ahref); add_index_entry("$str2!$str3 $str4, $str1", $ahref);
add_index_entry("$str3!$str4, $str1 $str2", $ahref); add_index_entry("$str3!$str4, $str1 $str2", $ahref);
@ -327,15 +308,15 @@ sub do_cmd_indexiv{
sub do_cmd_ttindex{ sub do_cmd_ttindex{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx[\n]?//; my($str,$br_id) = next_argument_id();
my($br_id,$str) = ($1, $2); swallow_newline();
&make_index_entry($br_id, $str . &get_indexsubitem) . $_; make_index_entry($br_id, $str . get_indexsubitem()) . $_;
} }
sub my_typed_index_helper{ sub my_typed_index_helper{
local($word,$_) = @_; local($word,$_) = @_;
s/$next_pair_pr_rx[\n]?//o; my($str,$br_id) = next_argument();
my($br_id,$str) = ($1, $2); swallow_newline();
# #
my($name,$aname,$ahref) = link_info($br_id1); my($name,$aname,$ahref) = link_info($br_id1);
add_index_entry("$str $word", $ahref); add_index_entry("$str $word", $ahref);
@ -343,15 +324,15 @@ sub my_typed_index_helper{
"$aname$anchor_invisible_mark</a>" . $_; "$aname$anchor_invisible_mark</a>" . $_;
} }
sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); } sub do_cmd_stindex{ my_typed_index_helper('statement', @_); }
sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); } sub do_cmd_opindex{ my_typed_index_helper('operator', @_); }
sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); } sub do_cmd_exindex{ my_typed_index_helper('exception', @_); }
sub do_cmd_obindex{ &my_typed_index_helper('object', @_); } sub do_cmd_obindex{ my_typed_index_helper('object', @_); }
sub my_parword_index_helper{ sub my_parword_index_helper{
local($word,$_) = @_; local($word,$_) = @_;
s/$next_pair_pr_rx[\n]?//o; my($str,$br_id) = next_argument_id();
my($br_id,$str) = ($1, $2); swallow_newline();
make_index_entry($br_id, "$str ($word)") . $_; make_index_entry($br_id, "$str ($word)") . $_;
} }
@ -377,8 +358,8 @@ $THIS_CLASS = '';
sub my_module_index_helper{ sub my_module_index_helper{
local($word, $_) = @_; local($word, $_) = @_;
s/$next_pair_pr_rx[\n]*//o; my($str,$br_id) = next_argument_id();
my($br_id, $str) = ($1, $2); swallow_newline();
my $section_tag = join('', @curr_sec_id); my $section_tag = join('', @curr_sec_id);
$word = "$word " if $word; $word = "$word " if $word;
$THIS_MODULE = "$str"; $THIS_MODULE = "$str";
@ -388,16 +369,17 @@ sub my_module_index_helper{
sub ref_module_index_helper{ sub ref_module_index_helper{
local($word, $_) = @_; local($word, $_) = @_;
s/$next_pair_pr_rx[\n]?//o; my($str,$br_id) = next_argument();
my($br_id, $str) = ($1, $2); swallow_newline();
$word = "$word " if $word; $word = "$word " if $word;
make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_; make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
} }
sub do_cmd_bifuncindex{ sub do_cmd_bifuncindex{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx[\n]?//o; my($str,$br_id) = next_argument();
my($br_id,$str,$fname) = ($1, $2, "<tt>$2()</tt>"); swallow_newline();
my $fname = "<tt>$str()</tt>";
make_index_entry($br_id, "$fname (built-in function)") . $_; make_index_entry($br_id, "$fname (built-in function)") . $_;
} }
@ -415,22 +397,9 @@ sub do_cmd_refstmodindex{ ref_module_index_helper('standard', @_); }
sub do_cmd_nodename{ do_cmd_label(@_); } sub do_cmd_nodename{ do_cmd_label(@_); }
sub init_myformat{ sub init_myformat{
# XXX need some way for this to be called after &initialise; ??? # $anchor_invisible_mark = '';
$anchor_mark = ''; $anchor_mark = '';
$icons{'anchor_mark'} = ''; $icons{'anchor_mark'} = '';
my $cmark = "(?:$comment_mark)?";
# <<2>>...<<2>>
$next_pair_rx = "^[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\1$C";
$any_next_pair_rx3 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\3$C";
$any_next_pair_rx5 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\5$C";
$any_next_pair_rx7 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\7$C";
$any_next_pair_rx9 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\9$C";
# <#2#>...<#2#>
$next_pair_pr_rx = "^[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\1$CP$cmark";
$any_next_pair_pr_rx3 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP$cmark";
$any_next_pair_pr_rx5 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP$cmark";
$any_next_pair_pr_rx7 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP$cmark";
$any_next_pair_pr_rx9 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP$cmark";
} }
init_myformat(); init_myformat();
@ -446,90 +415,69 @@ sub make_str_index_entry{
sub do_env_cfuncdesc{ sub do_env_cfuncdesc{
local($_) = @_; local($_) = @_;
my($return_type,$function_name,$arg_list,$idx) = ('', '', '', ''); my $return_type = next_argument();
my $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C"; my($function_name,$br_id) = next_argument_id();
my $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C"; my $arg_list = next_argument();
my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5"; my $idx = make_str_index_entry($br_id,
if (/$cfuncdesc_rx/o) { "<tt>$function_name()</tt>" . get_indexsubitem());
$return_type = "$2"; $idx =~ s/ \(.*\)//;
$function_name = "$4"; $idx =~ s/\(\)//; # ????
$arg_list = "$6";
$idx = make_str_index_entry($3,
"<tt>$function_name()</tt>" . &get_indexsubitem);
$idx =~ s/ \(.*\)//;
$idx =~ s/\(\)//;
}
"<dl><dt>$return_type <b>$idx</b>" "<dl><dt>$return_type <b>$idx</b>"
. "(<var>$arg_list</var>)\n<dd>$'</dl>" . "(<var>$arg_list</var>)\n<dd>"
. $_
. '</dl>';
} }
sub do_env_ctypedesc{ sub do_env_ctypedesc{
local($_) = @_; local($_) = @_;
my $type_name = (''); my($type_name,$br_id) = next_argument_id();
my $cfuncdesc_rx = "$next_pair_rx"; my $idx = make_str_index_entry($br_id,
if (/$cfuncdesc_rx/o) { "<tt>$type_name</tt>" . get_indexsubitem());
$type_name = "$2"; $idx =~ s/ \(.*\)//;
$idx = make_str_index_entry($1, "<dl><dt><b>$idx</b>\n<dd>"
"<tt>$type_name</tt>" . &get_indexsubitem); . $_
$idx =~ s/ \(.*\)//; . '</dl>'
}
"<dl><dt><b>$idx</b>\n<dd>$'</dl>"
} }
sub do_env_cvardesc{ sub do_env_cvardesc{
local($_) = @_; local($_) = @_;
my($var_type,$var_name,$idx) = ('', '', ''); my $var_type = next_argument();
my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3"; my($var_name,$br_id) = next_argument_id();
if (/$cfuncdesc_rx/o) { my $idx = make_str_index_entry($br_id,
$var_type = "$2"; "<tt>$var_name</tt>" . get_indexsubitem());
$var_name = "$4"; $idx =~ s/ \(.*\)//;
$idx = make_str_index_entry($3,
"<tt>$var_name</tt>" . &get_indexsubitem);
$idx =~ s/ \(.*\)//;
}
"<dl><dt>$var_type <b>$idx</b>\n" "<dl><dt>$var_type <b>$idx</b>\n"
. "<dd>$'</dl>"; . '<dd>'
. $_
. '</dl>';
} }
sub do_env_funcdesc{ sub do_env_funcdesc{
local($_) = @_; local($_) = @_;
my($function_name,$arg_list,$idx) = ('', '', ''); my $function_name = next_argument();
my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; my($arg_list,$br_id) = next_argument_id();
if (/$funcdesc_rx/o) { my $idx = make_str_index_entry($br_id, "<tt>$function_name()</tt>"
$function_name = "$2"; . get_indexsubitem());
$arg_list = "$4"; $idx =~ s/ \(.*\)//;
$idx = make_str_index_entry($3, "<tt>$function_name()</tt>" $idx =~ s/\(\)//;
. &get_indexsubitem); "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
$idx =~ s/ \(.*\)//;
$idx =~ s/\(\)//;
}
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
} }
sub do_env_funcdescni{ sub do_env_funcdescni{
local($_) = @_; local($_) = @_;
my($function_name,$arg_list,$idx) = ('', '', ''); my $function_name = next_argument();
my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; my $arg_list = next_argument();
if (/$funcdesc_rx/o) { "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n<dd>"
$function_name = "$2"; . $_ . '</dl>';
$arg_list = "$4";
$idx = "<tt>$function_name</tt>";
}
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
} }
sub do_cmd_funcline{ sub do_cmd_funcline{
local($_) = @_; local($_) = @_;
my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; my $function_name = next_argument();
my($arg_list,$br_id) = next_argument_id();
s/$next_pair_pr_rx//o;
my $function_name = $2;
s/$next_pair_pr_rx//o;
my($br_id,$arg_list) = ($1, $2);
my $idx = make_str_index_entry($br_id, "<tt>$function_name()</tt>" my $idx = make_str_index_entry($br_id, "<tt>$function_name()</tt>"
. &get_indexsubitem); . get_indexsubitem());
$idx =~ s/\(\)//; $idx =~ s/\(\)//;
"<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_; "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
} }
@ -541,67 +489,58 @@ $INDEX_OPCODES = 0;
sub do_env_opcodedesc{ sub do_env_opcodedesc{
local($_) = @_; local($_) = @_;
my($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', ''); my $opcode_name = next_argument();
my $opcodedesc_rx = "$next_pair_rx$any_next_pair_rx3"; my($arg_list,$br_id) = next_argument_id();
if (/$opcodedesc_rx/o) { my $idx;
$opcode_name = "$2"; if ($INDEX_OPCODES) {
$arg_list = "$4"; $idx = make_str_index_entry($br_id,
if ($INDEX_OPCODES) {
$idx = make_str_index_entry($3,
"<tt>$opcode_name</tt> (byte code instruction)"); "<tt>$opcode_name</tt> (byte code instruction)");
$idx =~ s/ \(byte code instruction\)//; $idx =~ s/ \(byte code instruction\)//;
} }
else { else {
$idx = "<tt>$opcode_name</tt>"; $idx = "<tt>$opcode_name</tt>";
} }
} my $stuff = "<dl><dt><b>$idx</b>";
$stuff = "<dl><dt><b>$idx</b>";
if ($arg_list) { if ($arg_list) {
$stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>"; $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
} }
$stuff . "\n<dd>$'</dl>"; $stuff . "\n<dd>" . $_ . '</dl>';
} }
sub do_env_datadesc{ sub do_env_datadesc{
local($_) = @_; local($_) = @_;
my $idx = ''; my($dataname,$br_id) = next_argument_id();
if (/$next_pair_rx/o) { my $idx = make_str_index_entry($br_id,
$idx = make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem); "<tt>$dataname</tt>" . get_indexsubitem());
$idx =~ s/ \(.*\)//; $idx =~ s/ \(.*\)//;
} "<dl><dt><b>$idx</b>\n<dd>"
"<dl><dt><b>$idx</b>\n<dd>$'</dl>" . $_
. '</dl>';
} }
sub do_env_datadescni{ sub do_env_datadescni{
local($_) = @_; local($_) = @_;
my $idx = ''; my $idx = next_argument();
if (/$next_pair_rx/o) { if (! $STRING_INDEX_TT) {
if ($STRING_INDEX_TT) { $idx = "<tt>$idx</tt>";
$idx = "$2"; }
else {
$idx = "<tt>$2</tt>"; }
} }
"<dl><dt><b>$idx</b>\n<dd>$'</dl>" "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
} }
sub do_cmd_dataline{ sub do_cmd_dataline{
local($_) = @_; local($_) = @_;
my($data_name,$br_id) = next_argument_id();
s/$next_pair_pr_rx//o;
my($br_id, $data_name) = ($1, $2);
my $idx = make_str_index_entry($br_id, "<tt>$data_name</tt>" my $idx = make_str_index_entry($br_id, "<tt>$data_name</tt>"
. &get_indexsubitem); . get_indexsubitem());
$idx =~ s/ \(.*\)//; $idx =~ s/ \(.*\)//;
"<dt><b>$idx</b><dd>" . $_; "<dt><b>$idx</b><dd>" . $_;
} }
sub do_env_excdesc{ sub do_env_excdesc{
local($_) = @_; local($_) = @_;
/$next_pair_rx/o; my($excname,$br_id) = next_argument_id();
my($br_id,$excname,$rest) = ($1, $2, $');
my $idx = make_str_index_entry($br_id, "<tt>$excname</tt>"); my $idx = make_str_index_entry($br_id, "<tt>$excname</tt>");
"<dl><dt><b>$idx</b>\n<dd>$rest</dl>" "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
} }
sub do_env_fulllineitems{ do_env_itemize(@_); } sub do_env_fulllineitems{ do_env_itemize(@_); }
@ -609,85 +548,63 @@ sub do_env_fulllineitems{ do_env_itemize(@_); }
sub do_env_classdesc{ sub do_env_classdesc{
local($_) = @_; local($_) = @_;
my($class_name,$arg_list,$idx) = ('', '', ''); $THIS_CLASS = next_argument();
my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; my($arg_list,$br_id) = next_argument_id();
if (/$funcdesc_rx/o) { $idx = make_str_index_entry($br_id,
$class_name = "$2"; "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
$arg_list = "$4"; $idx =~ s/ \(.*\)//;
$THIS_CLASS = $class_name; "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
$idx = make_str_index_entry($3,
"<tt>$class_name</tt> (class in $THIS_MODULE)" );
$idx =~ s/ \(.*\)//;
}
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
} }
sub do_env_methoddesc{ sub do_env_methoddesc{
local($_) = @_; local($_) = @_;
my($class_name,$arg_list,$idx,$extra); my $class_name = next_optional_argument();
# Predefined $opt_arg_rx & $optional_arg_rx don't work because they $class_name = $THIS_CLASS
# require the argument to be there. unless $class_name;
my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?"; my($method_name,$br_id) = next_argument_id();
my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5"; my $arg_list = next_argument();
if (/$funcdesc_rx/o) { my $extra = '';
$class_name = $2; if ($class_name) {
$class_name = $THIS_CLASS $extra = " ($class_name method)";
unless $class_name;
$method_name = $4;
$arg_list = $6;
if ($class_name) {
$extra = " ($class_name method)";
}
$idx = make_str_index_entry($3, "<tt>$method_name()</tt>$extra");
$idx =~ s/ \(.*\)//;
$idx =~ s/\(\)//;
} }
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>"; my $idx = make_str_index_entry($br_id, "<tt>$method_name()</tt>$extra");
$idx =~ s/ \(.*\)//;
$idx =~ s/\(\)//;
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
} }
sub do_env_methoddescni{ sub do_env_methoddescni{
local($_) = @_; local($_) = @_;
# Predefined $opt_arg_rx & $optional_arg_rx don't work because they next_optional_argument();
# require the argument to be there. my $method = next_argument();
my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?"; my $arg_list = next_argument();
my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5"; "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
/$funcdesc_rx/o;
my $method = $4;
my $arg_list = $6;
"<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
} }
sub do_env_memberdesc{ sub do_env_memberdesc{
local($_) = @_; local($_) = @_;
# Predefined $opt_arg_rx & $optional_arg_rx don't work because they my $class = next_optional_argument();
# require the argument to be there. my($member,$br_id) = next_argument();
my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3";
s/$funcdesc_rx//o;
my($class,$member) = ($2, $4);
$class = $THIS_CLASS $class = $THIS_CLASS
unless $class; unless $class;
my $extra = '';
$extra = " ($class_name attribute)" $extra = " ($class_name attribute)"
if (!($class eq '')); if (!($class eq ''));
my $idx = make_str_index_entry($3, "<tt>$member</tt>$extra"); my $idx = make_str_index_entry($br_id, "<tt>$member</tt>$extra");
$idx =~ s/ \(.*\)//; $idx =~ s/ \(.*\)//;
$idx =~ s/\(\)//; $idx =~ s/\(\)//;
"<dl><dt><b>$idx</b>\n<dd>" . $_ . "</dl>"; "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
} }
sub do_env_memberdescni{ sub do_env_memberdescni{
local($_) = @_; local($_) = @_;
# Predefined $opt_arg_rx & $optional_arg_rx don't work because they next_optional_argument();
# require the argument to be there. my $member = next_argument();
my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?"; "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3";
/$funcdesc_rx/o;
my $member = $4;
"<dl><dt><b>$member</b>\n<dd>$'</dl>";
} }
@ -697,94 +614,83 @@ sub setup_column_alignments{
local($_) = @_; local($_) = @_;
my($a1,$a2,$a3) = split(/[|]/,$_); my($a1,$a2,$a3) = split(/[|]/,$_);
my($th1,$th2,$th3) = ('<th>', '<th>', '<th>'); my($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
$col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>"); $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
$col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>"); $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
$col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>"); $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
# return the aligned header start tags; only used for \begin{tableiii?} # return the aligned header start tags; only used for \begin{tableiii?}
$th1 = (($a1 eq "l") ? "<th align=left>" $th1 = (($a1 eq 'l') ? '<th align=left>'
: ($a1 eq "r" ? "<th align=right>" : "<th>")); : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
$th2 = (($a2 eq "l") ? "<th align=left>" $th2 = (($a2 eq 'l') ? '<th align=left>'
: ($a2 eq "r" ? "<th align=right>" : "<th>")); : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
$th3 = (($a3 eq "l") ? "<th align=left>" $th3 = (($a3 eq 'l') ? '<th align=left>'
: ($a3 eq "r" ? "<th align=right>" : "<th>")); : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
($th1, $th2, $th3); ($th1, $th2, $th3);
} }
sub do_env_tableii{ sub do_env_tableii{
local($_) = @_; local($_) = @_;
my($font,$h1,$h2) = ('', '', ''); my($th1,$th2,$th3) = setup_column_alignments(next_argument());
my $tableiii_rx = my $font = next_argument();
"$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"; my $h1 = next_argument();
if (/$tableiii_rx/o) { my $h2 = next_argument();
$font = $4; $font = ''
$font = '' if ($font eq 'textrm');
if ($font eq 'textrm'); $globals{'lineifont'} = $font;
$h1 = $6; '<table border align=center>'
$h2 = $8;
}
my($th1,$th2,$th3) = setup_column_alignments($2);
$globals{"lineifont"} = $font;
"<table border align=center>"
. "\n <tr>$th1<b>$h1</b></th>" . "\n <tr>$th1<b>$h1</b></th>"
. "\n $th2<b>$h2</b></th>$'" . "\n $th2<b>$h2</b></th>"
. $_
. "\n</table>"; . "\n</table>";
} }
sub do_cmd_lineii{ sub do_cmd_lineii{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my $c1 = next_argument();
my $c1 = $2; my $c2 = next_argument();
s/$next_pair_pr_rx//o; my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
my($c2,$font,$sfont,$efont) = ($2, $globals{"lineifont"}, '', '');
if ($font) { if ($font) {
$sfont = "<$font>"; $sfont = "<$font>";
$efont = "</$font>"; $efont = "</$font>";
} }
my($c1align,$c2align) = @col_aligns[0,1]; my($c1align,$c2align) = @col_aligns[0,1];
"<tr>$c1align$sfont$c1$efont</td>\n" "<tr>$c1align$sfont$c1$efont</td>\n"
. " $c2align$c2</td>$'"; . " $c2align$c2</td>"
. $_;
} }
sub do_env_tableiii{ sub do_env_tableiii{
local($_) = @_; local($_) = @_;
my($font,$h1,$h2,$h3) = ('', '', '', ''); my($th1,$th2,$th3) = setup_column_alignments(next_argument());
my $font = next_argument();
my $tableiii_rx = my $h1 = next_argument();
"$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7" my $h2 = next_argument();
. "$any_next_pair_rx9"; my $h3 = next_argument();
if (/$tableiii_rx/o) { $font = ''
$font = $4; if ($font eq 'textrm');
$font = '' $globals{'lineifont'} = $font;
if ($font eq 'textrm'); '<table border align=center>'
$h1 = $6;
$h2 = $8;
$h3 = $10;
}
my($th1,$th2,$th3) = setup_column_alignments($2);
$globals{"lineifont"} = $font;
"<table border align=center>"
. "\n <tr>$th1<b>$h1</b></th>" . "\n <tr>$th1<b>$h1</b></th>"
. "\n $th2<b>$h2</b></th>" . "\n $th2<b>$h2</b></th>"
. "\n $th3<b>$h3</b></th>$'" . "\n $th3<b>$h3</b></th>"
. $_
. "\n</table>"; . "\n</table>";
} }
sub do_cmd_lineiii{ sub do_cmd_lineiii{
local($_) = @_; local($_) = @_;
s/$next_pair_pr_rx//o; my $c1 = next_argument();
my $c1 = $2; my $c2 = next_argument();
s/$next_pair_pr_rx//o; my $c3 = next_argument();
my $c2 = $2; my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
s/$next_pair_pr_rx//o;
my($c3,$font,$sfont,$efont) = ($2, $globals{"lineifont"}, '', '');
if ($font) { if ($font) {
$sfont = "<$font>"; $sfont = "<$font>";
$efont = "</$font>"; $efont = "</$font>";
} }
my($c1align, $c2align, $c3align) = @col_aligns; my($c1align,$c2align,$c3align) = @col_aligns;
"<tr>$c1align$sfont$c1$efont</td>\n" "<tr>$c1align$sfont$c1$efont</td>\n"
. " $c2align$c2</td>\n" . " $c2align$c2</td>\n"
. " $c3align$c3</td>$'"; . " $c3align$c3</td>"
. $_;
} }
sub do_env_seealso{ sub do_env_seealso{
@ -795,21 +701,18 @@ sub do_cmd_seemodule{
# Insert the right magic to jump to the module definition. This should # Insert the right magic to jump to the module definition. This should
# work most of the time, at least for repeat builds.... # work most of the time, at least for repeat builds....
local($_) = @_; local($_) = @_;
my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; my $key = next_optional_argument();
my $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP"; my $module = next_argument();
# Predefined $opt_arg_rx & $optional_arg_rx don't work because they my $text = next_argument();
# require the argument to be there. $key = $module
my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?"; unless $key;
s/$opt_arg_rx$any_next_pair_pr_rx3$any_next_pair_pr_rx5//;
my($key,$module,$text) = ($2, $4, $6);
$key = $module unless $key;
"<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>" "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
. "&nbsp;&nbsp;&nbsp;($text)</p>" . "&nbsp;&nbsp;&nbsp;($text)</p>"
. $_; . $_;
} }
sub do_cmd_seetext{ sub do_cmd_seetext{
"<p>" . @_[0]; '<p>' . @_[0];
} }
@ -818,17 +721,17 @@ sub do_cmd_maketitle {
my $the_title = ''; my $the_title = '';
if ($t_title) { if ($t_title) {
$the_title .= "<h1 align=center>$t_title</h1>"; $the_title .= "<h1 align=center>$t_title</h1>";
} else { &write_warnings("\nThis document has no title."); } } else { write_warnings("\nThis document has no title."); }
$the_title .= "\n<center>"; $the_title .= "\n<center>";
if ($t_author) { if ($t_author) {
if ($t_authorURL) { if ($t_authorURL) {
my $href = &translate_commands($t_authorURL); my $href = translate_commands($t_authorURL);
$href = &make_named_href('author', $href, "<strong>${t_author}</strong>"); $href = make_named_href('author', $href, "<strong>${t_author}</strong>");
$the_title .= "\n<p>$href</p>"; $the_title .= "\n<p>$href</p>";
} else { } else {
$the_title .= "\n<p><strong>$t_author</strong></p>"; $the_title .= "\n<p><strong>$t_author</strong></p>";
} }
} else { &write_warnings("\nThere is no author for this document."); } } else { write_warnings("\nThere is no author for this document."); }
if ($t_institute) { if ($t_institute) {
$the_title .= "\n<p>$t_institute</p>";} $the_title .= "\n<p>$t_institute</p>";}
if ($AUTHOR_ADDRESS) { if ($AUTHOR_ADDRESS) {
@ -852,28 +755,4 @@ sub do_cmd_maketitle {
} }
# sub do_cmd_indexlabel{
# "genindex" . @_[0];
# }
# These are located down here since they screw up fontlock. -- used to.
sub do_cmd_file{
# This uses a weird HTML construct to adjust the font to be
# reasonable match that used in the printed form as much as
# possible. The expected behavior is that a browser that doesn't
# understand "<font face=...>" markup will use courier (or whatever
# the font is for <tt>).
local($_) = @_;
s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
$_;
}
sub do_cmd_samp{
local($_) = @_;
s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
$_;
}
1; # This must be the last line 1; # This must be the last line