mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Use Perl function prototypes to help avoid definition/usage mismatches
while modifying these files. Minor style changes to make the use of "my" with arrays more consistent.
This commit is contained in:
parent
ffb294bd34
commit
f547863c63
2 changed files with 106 additions and 102 deletions
|
@ -99,7 +99,7 @@ sub custom_driver_hook {
|
|||
|
||||
$CUSTOM_BUTTONS = '';
|
||||
|
||||
sub make_nav_sectref {
|
||||
sub make_nav_sectref($$) {
|
||||
my($label, $title) = @_;
|
||||
if ($title) {
|
||||
if ($title =~ /\<[aA] /) {
|
||||
|
@ -127,7 +127,7 @@ $my_icon_tags{'modules'} = 'Module Index';
|
|||
$my_icon_names{'previous_page'} = 'previous';
|
||||
$my_icon_names{'next_page'} = 'next';
|
||||
|
||||
sub get_my_icon {
|
||||
sub get_my_icon($) {
|
||||
my $name = @_[0];
|
||||
my $text = $my_icon_tags{$name};
|
||||
if ($my_icon_names{$name}) {
|
||||
|
@ -141,7 +141,7 @@ sub get_my_icon {
|
|||
. " height=\"32\"\n alt=\"$text\" width=\"32\">";
|
||||
}
|
||||
|
||||
sub use_my_icon {
|
||||
sub use_my_icon($) {
|
||||
my $s = @_[0];
|
||||
if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
|
||||
my $r = get_my_icon($1);
|
||||
|
@ -150,7 +150,7 @@ sub use_my_icon {
|
|||
return $s;
|
||||
}
|
||||
|
||||
sub make_nav_panel {
|
||||
sub make_nav_panel() {
|
||||
my $s;
|
||||
my $BLANK_ICON = get_my_icon('blank');
|
||||
$NEXT = $NEXT_TITLE ? use_my_icon("$NEXT") : $BLANK_ICON;
|
||||
|
@ -192,7 +192,7 @@ sub add_child_links {
|
|||
return $toc;
|
||||
}
|
||||
|
||||
sub get_version_text {
|
||||
sub get_version_text() {
|
||||
if ($PACKAGE_VERSION ne '' && $t_date) {
|
||||
return ("<span class=\"release-info\">"
|
||||
. "Release $PACKAGE_VERSION$RELEASE_INFO,"
|
||||
|
@ -210,13 +210,13 @@ sub get_version_text {
|
|||
}
|
||||
|
||||
|
||||
sub top_navigation_panel {
|
||||
sub top_navigation_panel() {
|
||||
return "\n"
|
||||
. make_nav_panel()
|
||||
. "<br><hr>\n";
|
||||
}
|
||||
|
||||
sub bot_navigation_panel {
|
||||
sub bot_navigation_panel() {
|
||||
return "\n<p><hr>\n"
|
||||
. make_nav_panel()
|
||||
. "<hr>\n"
|
||||
|
@ -255,7 +255,7 @@ sub add_link {
|
|||
return (&inactive_img($icon), "");
|
||||
}
|
||||
|
||||
sub add_special_link {
|
||||
sub add_special_link($$$) {
|
||||
my($icon, $file, $current_file) = @_;
|
||||
if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
|
||||
my $r = get_my_icon($1);
|
||||
|
@ -281,13 +281,13 @@ sub do_cmd_arabic {
|
|||
}
|
||||
|
||||
|
||||
sub gen_index_id {
|
||||
sub gen_index_id($$) {
|
||||
# this is used to ensure common index key generation and a stable sort
|
||||
my($str, $extra) = @_;
|
||||
sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
|
||||
}
|
||||
|
||||
sub insert_index {
|
||||
sub insert_index($$$$$) {
|
||||
my($mark, $datafile, $columns, $letters, $prefix) = @_;
|
||||
my $prog = "$myrootdir/tools/buildindex.py";
|
||||
my $index;
|
||||
|
@ -302,7 +302,7 @@ sub insert_index {
|
|||
}
|
||||
}
|
||||
|
||||
sub add_idx {
|
||||
sub add_idx() {
|
||||
print "\nBuilding HTML for the index ...";
|
||||
close(IDXFILE);
|
||||
insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
|
||||
|
@ -312,7 +312,7 @@ sub add_idx {
|
|||
$idx_module_mark = '<tex2html_idx_module_mark>';
|
||||
$idx_module_title = 'Module Index';
|
||||
|
||||
sub add_module_idx {
|
||||
sub add_module_idx() {
|
||||
print "\nBuilding HTML for the module index ...";
|
||||
my $key;
|
||||
my $first = 1;
|
||||
|
@ -585,7 +585,7 @@ sub set_depth_levels {
|
|||
# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
|
||||
# content of the page.
|
||||
$MY_PARTIAL_HEADER = '';
|
||||
sub make_head_and_body {
|
||||
sub make_head_and_body($$) {
|
||||
my($title, $body) = @_;
|
||||
$body = " $body" unless ($body eq '');
|
||||
my $DTDcomment = '';
|
||||
|
|
|
@ -150,7 +150,7 @@ sub do_cmd_hackscore{
|
|||
return '_' . $_;
|
||||
}
|
||||
|
||||
sub use_wrappers{
|
||||
sub use_wrappers($$$){
|
||||
local($_,$before,$after) = @_;
|
||||
my $stuff = next_argument();
|
||||
return $before . $stuff . $after . $_;
|
||||
|
@ -395,7 +395,7 @@ sub do_cmd_deprecated{
|
|||
. $_);
|
||||
}
|
||||
|
||||
sub versionnote{
|
||||
sub versionnote($$){
|
||||
# one or two parameters: \versionnote[explanation]{version}
|
||||
my $type = @_[0];
|
||||
local $_ = @_[1];
|
||||
|
@ -409,11 +409,11 @@ sub versionnote{
|
|||
}
|
||||
|
||||
sub do_cmd_versionadded{
|
||||
return versionnote('New', @_);
|
||||
return versionnote('New', @_[0]);
|
||||
}
|
||||
|
||||
sub do_cmd_versionchanged{
|
||||
return versionnote('Changed', @_);
|
||||
return versionnote('Changed', @_[0]);
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -441,7 +441,7 @@ sub do_cmd_ignorePlatformAnnotation{
|
|||
|
||||
$INDEX_SUBITEM = "";
|
||||
|
||||
sub get_indexsubitem{
|
||||
sub get_indexsubitem(){
|
||||
return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
|
||||
}
|
||||
|
||||
|
@ -487,19 +487,19 @@ print INTLABELS "1; # hack in case there are no entries\n\n";
|
|||
#
|
||||
$IDXFILE_FIELD_SEP = "\1";
|
||||
|
||||
sub write_idxfile{
|
||||
sub write_idxfile($$){
|
||||
my($ahref, $str) = @_;
|
||||
print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
|
||||
}
|
||||
|
||||
|
||||
sub gen_link{
|
||||
sub gen_link($$){
|
||||
my($node, $target) = @_;
|
||||
print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
|
||||
return "<a href=\"$node#$target\">";
|
||||
}
|
||||
|
||||
sub add_index_entry{
|
||||
sub add_index_entry($$){
|
||||
# add an entry to the index structures; ignore the return value
|
||||
my($str, $ahref) = @_;
|
||||
$str = gen_index_id($str, '');
|
||||
|
@ -507,7 +507,7 @@ sub add_index_entry{
|
|||
write_idxfile($ahref, $str);
|
||||
}
|
||||
|
||||
sub new_link_info{
|
||||
sub new_link_info(){
|
||||
my $name = "l2h-" . ++$globals{'max_id'};
|
||||
my $aname = "<a name=\"$name\">";
|
||||
my $ahref = gen_link($CURRENT_FILE, $name);
|
||||
|
@ -515,7 +515,7 @@ sub new_link_info{
|
|||
}
|
||||
|
||||
$IndexMacroPattern = '';
|
||||
sub define_indexing_macro{
|
||||
sub define_indexing_macro(@){
|
||||
my $count = @_;
|
||||
my $i = 0;
|
||||
for (; $i < $count; ++$i) {
|
||||
|
@ -535,7 +535,7 @@ sub define_indexing_macro{
|
|||
}
|
||||
|
||||
$DEBUG_INDEXING = 0;
|
||||
sub process_index_macros{
|
||||
sub process_index_macros($$){
|
||||
local($_) = @_;
|
||||
my $cmdname = @_[1]; # This is what triggered us in the first place;
|
||||
# we know it's real, so just process it.
|
||||
|
@ -564,20 +564,20 @@ sub process_index_macros{
|
|||
}
|
||||
|
||||
define_indexing_macro('index');
|
||||
sub idx_cmd_index{
|
||||
sub idx_cmd_index($){
|
||||
my $str = next_argument();
|
||||
add_index_entry("$str", @_[0]);
|
||||
}
|
||||
|
||||
define_indexing_macro('kwindex');
|
||||
sub idx_cmd_kwindex{
|
||||
sub idx_cmd_kwindex($){
|
||||
my $str = next_argument();
|
||||
add_index_entry("<tt>$str</tt>!keyword", @_[0]);
|
||||
add_index_entry("keyword!<tt>$str</tt>", @_[0]);
|
||||
}
|
||||
|
||||
define_indexing_macro('indexii');
|
||||
sub idx_cmd_indexii{
|
||||
sub idx_cmd_indexii($){
|
||||
my $str1 = next_argument();
|
||||
my $str2 = next_argument();
|
||||
add_index_entry("$str1!$str2", @_[0]);
|
||||
|
@ -585,7 +585,7 @@ sub idx_cmd_indexii{
|
|||
}
|
||||
|
||||
define_indexing_macro('indexiii');
|
||||
sub idx_cmd_indexiii{
|
||||
sub idx_cmd_indexiii($){
|
||||
my $str1 = next_argument();
|
||||
my $str2 = next_argument();
|
||||
my $str3 = next_argument();
|
||||
|
@ -595,7 +595,7 @@ sub idx_cmd_indexiii{
|
|||
}
|
||||
|
||||
define_indexing_macro('indexiv');
|
||||
sub idx_cmd_indexiv{
|
||||
sub idx_cmd_indexiv($){
|
||||
my $str1 = next_argument();
|
||||
my $str2 = next_argument();
|
||||
my $str3 = next_argument();
|
||||
|
@ -607,13 +607,13 @@ sub idx_cmd_indexiv{
|
|||
}
|
||||
|
||||
define_indexing_macro('ttindex');
|
||||
sub idx_cmd_ttindex{
|
||||
sub idx_cmd_ttindex($){
|
||||
my $str = next_argument();
|
||||
my $entry = $str . get_indexsubitem();
|
||||
add_index_entry($entry, @_[0]);
|
||||
}
|
||||
|
||||
sub my_typed_index_helper{
|
||||
sub my_typed_index_helper($$){
|
||||
my($word, $ahref) = @_;
|
||||
my $str = next_argument();
|
||||
add_index_entry("$str $word", $ahref);
|
||||
|
@ -621,20 +621,20 @@ sub my_typed_index_helper{
|
|||
}
|
||||
|
||||
define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
|
||||
sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
|
||||
sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
|
||||
sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
|
||||
sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
|
||||
sub idx_cmd_stindex($){ my_typed_index_helper('statement', @_[0]); }
|
||||
sub idx_cmd_opindex($){ my_typed_index_helper('operator', @_[0]); }
|
||||
sub idx_cmd_exindex($){ my_typed_index_helper('exception', @_[0]); }
|
||||
sub idx_cmd_obindex($){ my_typed_index_helper('object', @_[0]); }
|
||||
|
||||
define_indexing_macro('bifuncindex');
|
||||
sub idx_cmd_bifuncindex{
|
||||
sub idx_cmd_bifuncindex($){
|
||||
my $str = next_argument();
|
||||
add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)",
|
||||
@_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub make_mod_index_entry{
|
||||
sub make_mod_index_entry($$){
|
||||
my($str, $define) = @_;
|
||||
my($name, $aname, $ahref) = new_link_info();
|
||||
# equivalent of add_index_entry() using $define instead of ''
|
||||
|
@ -657,7 +657,7 @@ sub make_mod_index_entry{
|
|||
$THIS_MODULE = '';
|
||||
$THIS_CLASS = '';
|
||||
|
||||
sub define_module{
|
||||
sub define_module($$){
|
||||
my($word, $name) = @_;
|
||||
my $section_tag = join('', @curr_sec_id);
|
||||
if ($word ne "built-in" && $word ne "extension"
|
||||
|
@ -674,7 +674,7 @@ sub define_module{
|
|||
"<tt class=\"module\">$name</tt> (${word}module)", 'DEF');
|
||||
}
|
||||
|
||||
sub my_module_index_helper{
|
||||
sub my_module_index_helper($$){
|
||||
local($word, $_) = @_;
|
||||
my $name = next_argument();
|
||||
return define_module($word, $name) . $_;
|
||||
|
@ -685,7 +685,7 @@ sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
|
|||
sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
|
||||
sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
|
||||
|
||||
sub ref_module_index_helper{
|
||||
sub ref_module_index_helper($$){
|
||||
my($word, $ahref) = @_;
|
||||
my $str = next_argument();
|
||||
$word = "$word " if $word;
|
||||
|
@ -700,14 +700,14 @@ sub ref_module_index_helper{
|
|||
# these should be adjusted a bit....
|
||||
define_indexing_macro('refmodindex', 'refbimodindex',
|
||||
'refexmodindex', 'refstmodindex');
|
||||
sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
|
||||
sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
|
||||
sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
|
||||
sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
|
||||
sub idx_cmd_refmodindex($){ return ref_module_index_helper('', @_); }
|
||||
sub idx_cmd_refbimodindex($){ return ref_module_index_helper('built-in', @_); }
|
||||
sub idx_cmd_refexmodindex($){ return ref_module_index_helper('extension', @_);}
|
||||
sub idx_cmd_refstmodindex($){ return ref_module_index_helper('standard', @_); }
|
||||
|
||||
sub do_cmd_nodename{ return do_cmd_label(@_); }
|
||||
|
||||
sub init_myformat{
|
||||
sub init_myformat(){
|
||||
$anchor_invisible_mark = ' ';
|
||||
$anchor_invisible_mark2 = '';
|
||||
$anchor_mark = '';
|
||||
|
@ -718,8 +718,8 @@ init_myformat();
|
|||
# Create an index entry, but include the string in the target anchor
|
||||
# instead of the dummy filler.
|
||||
#
|
||||
sub make_str_index_entry{
|
||||
my($str) = @_;
|
||||
sub make_str_index_entry($){
|
||||
my $str = @_[0];
|
||||
my($name, $aname, $ahref) = new_link_info();
|
||||
add_index_entry($str, $ahref);
|
||||
return "$aname$str</a>";
|
||||
|
@ -819,7 +819,7 @@ sub do_cmd_productioncont{
|
|||
. $_);
|
||||
}
|
||||
|
||||
sub process_grammar_files{
|
||||
sub process_grammar_files(){
|
||||
my $lang;
|
||||
my $filename;
|
||||
local($_);
|
||||
|
@ -857,7 +857,7 @@ sub process_grammar_files{
|
|||
}
|
||||
}
|
||||
|
||||
sub strip_grammar_markup{
|
||||
sub strip_grammar_markup($){
|
||||
local($_) = @_;
|
||||
s/\\productioncont/ /g;
|
||||
s/\\production(<<\d+>>)(.+)\1/\n\2 ::= /g;
|
||||
|
@ -873,7 +873,7 @@ sub strip_grammar_markup{
|
|||
|
||||
$REFCOUNTS_LOADED = 0;
|
||||
|
||||
sub load_refcounts{
|
||||
sub load_refcounts(){
|
||||
$REFCOUNTS_LOADED = 1;
|
||||
|
||||
my $myname, $mydir, $myext;
|
||||
|
@ -896,7 +896,7 @@ sub load_refcounts{
|
|||
}
|
||||
}
|
||||
|
||||
sub get_refcount{
|
||||
sub get_refcount($$){
|
||||
my($func, $param) = @_;
|
||||
load_refcounts()
|
||||
unless $REFCOUNTS_LOADED;
|
||||
|
@ -907,7 +907,7 @@ sub get_refcount{
|
|||
$TLSTART = '<span class="typelabel">';
|
||||
$TLEND = '</span>';
|
||||
|
||||
sub cfuncline_helper{
|
||||
sub cfuncline_helper($$$){
|
||||
my($type, $name, $args) = @_;
|
||||
my $idx = make_str_index_entry(
|
||||
"<tt class=\"cfunction\">$name()</tt>" . get_indexsubitem());
|
||||
|
@ -1132,7 +1132,7 @@ sub do_env_excdesc{
|
|||
sub do_env_fulllineitems{ return do_env_itemize(@_); }
|
||||
|
||||
|
||||
sub handle_classlike_descriptor{
|
||||
sub handle_classlike_descriptor($$){
|
||||
local($_, $what) = @_;
|
||||
$THIS_CLASS = next_argument();
|
||||
my $arg_list = convert_args(next_argument());
|
||||
|
@ -1290,7 +1290,7 @@ sub do_cmd_memberlineni{
|
|||
'textrm' => '',
|
||||
);
|
||||
|
||||
sub fix_font{
|
||||
sub fix_font($){
|
||||
# do a little magic on a font name to get the right behavior in the first
|
||||
# column of the output table
|
||||
my $font = @_[0];
|
||||
|
@ -1300,7 +1300,7 @@ sub fix_font{
|
|||
return $font;
|
||||
}
|
||||
|
||||
sub figure_column_alignment{
|
||||
sub figure_column_alignment($){
|
||||
my $a = @_[0];
|
||||
my $mark = substr($a, 0, 1);
|
||||
my $r = '';
|
||||
|
@ -1315,7 +1315,7 @@ sub figure_column_alignment{
|
|||
return $r;
|
||||
}
|
||||
|
||||
sub setup_column_alignments{
|
||||
sub setup_column_alignments($){
|
||||
local($_) = @_;
|
||||
my($s1, $s2, $s3, $s4, $a5) = split(/[|]/,$_);
|
||||
my $a1 = figure_column_alignment($s1);
|
||||
|
@ -1332,7 +1332,7 @@ sub setup_column_alignments{
|
|||
return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>");
|
||||
}
|
||||
|
||||
sub get_table_col1_fonts{
|
||||
sub get_table_col1_fonts(){
|
||||
my $font = $globals{'lineifont'};
|
||||
my($sfont, $efont) = ('', '');
|
||||
if ($font) {
|
||||
|
@ -1345,7 +1345,8 @@ sub get_table_col1_fonts{
|
|||
|
||||
sub do_env_tableii{
|
||||
local($_) = @_;
|
||||
my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
|
||||
my $arg = next_argument();
|
||||
my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg);
|
||||
my $font = fix_font(next_argument());
|
||||
my $h1 = next_argument();
|
||||
my $h2 = next_argument();
|
||||
|
@ -1391,7 +1392,8 @@ sub do_cmd_lineii{
|
|||
|
||||
sub do_env_tableiii{
|
||||
local($_) = @_;
|
||||
my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
|
||||
my $arg = next_argument();
|
||||
my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg);
|
||||
my $font = fix_font(next_argument());
|
||||
my $h1 = next_argument();
|
||||
my $h2 = next_argument();
|
||||
|
@ -1442,7 +1444,8 @@ sub do_cmd_lineiii{
|
|||
|
||||
sub do_env_tableiv{
|
||||
local($_) = @_;
|
||||
my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
|
||||
my $arg = next_argument();
|
||||
my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg);
|
||||
my $font = fix_font(next_argument());
|
||||
my $h1 = next_argument();
|
||||
my $h2 = next_argument();
|
||||
|
@ -1498,7 +1501,8 @@ sub do_cmd_lineiv{
|
|||
|
||||
sub do_env_tablev{
|
||||
local($_) = @_;
|
||||
my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
|
||||
my $arg = next_argument();
|
||||
my($th1, $th2, $th3, $th4, $th5) = setup_column_alignments($arg);
|
||||
my $font = fix_font(next_argument());
|
||||
my $h1 = next_argument();
|
||||
my $h2 = next_argument();
|
||||
|
@ -1692,7 +1696,7 @@ sub get_chapter_id(){
|
|||
%ModuleSynopses = ();
|
||||
|
||||
sub get_synopsis_table($){
|
||||
my($chap) = @_;
|
||||
my $chap = @_[0];
|
||||
my $key;
|
||||
foreach $key (keys %ModuleSynopses) {
|
||||
if ($key eq $chap) {
|
||||
|
@ -1747,7 +1751,7 @@ sub do_cmd_localmoduletable{
|
|||
return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
|
||||
}
|
||||
|
||||
sub process_all_localmoduletables{
|
||||
sub process_all_localmoduletables(){
|
||||
my $key;
|
||||
my $st, $file;
|
||||
foreach $key (keys %ModuleSynopses) {
|
||||
|
@ -1762,7 +1766,7 @@ sub process_all_localmoduletables{
|
|||
}
|
||||
}
|
||||
|
||||
sub process_localmoduletables_in_file{
|
||||
sub process_localmoduletables_in_file($){
|
||||
my $file = @_[0];
|
||||
open(MYFILE, "<$file");
|
||||
local($_);
|
||||
|
@ -1780,7 +1784,7 @@ sub process_localmoduletables_in_file{
|
|||
print MYFILE $_;
|
||||
close(MYFILE);
|
||||
}
|
||||
sub process_python_state{
|
||||
sub process_python_state(){
|
||||
process_all_localmoduletables();
|
||||
process_grammar_files();
|
||||
}
|
||||
|
@ -1831,7 +1835,7 @@ sub strip_html_markup($){
|
|||
return $s;
|
||||
}
|
||||
|
||||
sub handle_rfclike_reference{
|
||||
sub handle_rfclike_reference($$$){
|
||||
local($_, $what, $format) = @_;
|
||||
my $rfcnum = next_argument();
|
||||
my $title = next_argument();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue