wikiheaders.pl: make it work with older perl versions, e.g. 5.10.

This commit is contained in:
Ozkan Sezer 2023-03-24 11:56:40 +03:00
parent b57a6a1adf
commit 45a6ad8e57

View file

@ -520,8 +520,8 @@ if (defined $readmesubdir) {
} }
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n"); opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
next if not $dent =~ /$selectheaderregex/; # just selected headers. next if not $dent =~ /$selectheaderregex/; # just selected headers.
open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n"); open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n");
@ -669,8 +669,8 @@ my %wikitypes = (); # contains string of wiki page extension, like $wikitypes{"
my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}. my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}.
my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks' my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks'
opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n"); opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
my $type = ''; my $type = '';
if ($dent =~ /\.(md|mediawiki)\Z/) { if ($dent =~ /\.(md|mediawiki)\Z/) {
$type = $1; $type = $1;
@ -807,14 +807,14 @@ if ($copy_direction == 1) { # --copy-to-headers
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it. next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
my $wikitype = $wikitypes{$fn}; my $wikitype = $wikitypes{$fn};
my $sectionsref = $wikifuncs{$fn}; my $sectionsref = $wikifuncs{$fn};
my $remarks = %$sectionsref{'Remarks'}; my $remarks = $sectionsref->{'Remarks'};
my $params = %$sectionsref{'Function Parameters'}; my $params = $sectionsref->{'Function Parameters'};
my $returns = %$sectionsref{'Return Value'}; my $returns = $sectionsref->{'Return Value'};
my $threadsafety = %$sectionsref{'Thread Safety'}; my $threadsafety = $sectionsref->{'Thread Safety'};
my $version = %$sectionsref{'Version'}; my $version = $sectionsref->{'Version'};
my $related = %$sectionsref{'Related Functions'}; my $related = $sectionsref->{'Related Functions'};
my $deprecated = %$sectionsref{'Deprecated'}; my $deprecated = $sectionsref->{'Deprecated'};
my $brief = %$sectionsref{'[Brief]'}; my $brief = $sectionsref->{'[Brief]'};
my $addblank = 0; my $addblank = 0;
my $str = ''; my $str = '';
@ -1377,8 +1377,8 @@ if ($copy_direction == 1) { # --copy-to-headers
if ( -d $readmepath ) { if ( -d $readmepath ) {
mkdir($wikireadmepath); # just in case mkdir($wikireadmepath); # just in case
opendir(DH, $readmepath) or die("Can't opendir '$readmepath': $!\n"); opendir(DH, $readmepath) or die("Can't opendir '$readmepath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
if ($dent =~ /\AREADME\-(.*?\.md)\Z/) { # we only bridge Markdown files here. if ($dent =~ /\AREADME\-(.*?\.md)\Z/) { # we only bridge Markdown files here.
my $wikifname = $1; my $wikifname = $1;
next if $wikifname eq 'FrontPage.md'; next if $wikifname eq 'FrontPage.md';
@ -1389,8 +1389,8 @@ if ($copy_direction == 1) { # --copy-to-headers
my @pages = (); my @pages = ();
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n"); opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
if ($dent =~ /\A(.*?)\.(mediawiki|md)\Z/) { if ($dent =~ /\A(.*?)\.(mediawiki|md)\Z/) {
my $wikiname = $1; my $wikiname = $1;
next if $wikiname eq 'FrontPage'; next if $wikiname eq 'FrontPage';
@ -1456,15 +1456,15 @@ if ($copy_direction == 1) { # --copy-to-headers
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it. next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
my $wikitype = $wikitypes{$fn}; my $wikitype = $wikitypes{$fn};
my $sectionsref = $wikifuncs{$fn}; my $sectionsref = $wikifuncs{$fn};
my $remarks = %$sectionsref{'Remarks'}; my $remarks = $sectionsref->{'Remarks'};
my $params = %$sectionsref{'Function Parameters'}; my $params = $sectionsref->{'Function Parameters'};
my $returns = %$sectionsref{'Return Value'}; my $returns = $sectionsref->{'Return Value'};
my $version = %$sectionsref{'Version'}; my $version = $sectionsref->{'Version'};
my $threadsafety = %$sectionsref{'Thread Safety'}; my $threadsafety = $sectionsref->{'Thread Safety'};
my $related = %$sectionsref{'Related Functions'}; my $related = $sectionsref->{'Related Functions'};
my $examples = %$sectionsref{'Code Examples'}; my $examples = $sectionsref->{'Code Examples'};
my $deprecated = %$sectionsref{'Deprecated'}; my $deprecated = $sectionsref->{'Deprecated'};
my $brief = %$sectionsref{'[Brief]'}; my $brief = $sectionsref->{'[Brief]'};
my $decl = $headerdecls{$fn}; my $decl = $headerdecls{$fn};
my $str = ''; my $str = '';