mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-22 18:52:40 +01:00
Updated c99std and c11std to index footnotes
This commit is contained in:
parent
e5028eded6
commit
59e100a44c
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 348,
|
||||
BUILD_DATE => "2012-01-16",
|
||||
BUILD_REVISION => 349,
|
||||
BUILD_DATE => "2012-01-23",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -65,7 +65,7 @@ if($list_only and not length $search) {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
open FH, "<n1570.txt" or die "Could not open n1570.txt: $!";
|
||||
open FH, "<n1570.out" or die "Could not open n1570: $!";
|
||||
my @contents = <FH>;
|
||||
close FH;
|
||||
|
||||
@ -94,26 +94,33 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
print "----------------------------------\n" if $debug >= 2;
|
||||
print "Processing section [$this_section]\n" if $debug;
|
||||
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
my $section_text;
|
||||
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}[0-9A-Z]+\.)/msg) {
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
$section_text = $1;
|
||||
} else {
|
||||
print "No section text, end of file marker found.\n" if $debug >= 4;
|
||||
last;
|
||||
}
|
||||
|
||||
if($section =~ /FOOTNOTE/) {
|
||||
$section_text =~ s/^\s{4}//ms;
|
||||
$section_text =~ s/^\s{4}FOOTNOTE.*//ms;
|
||||
$section_text =~ s/^\d.*//ms;
|
||||
}
|
||||
|
||||
if($section_text =~ m/(.*?)$/msg) {
|
||||
$section_title = $1 if length $1;
|
||||
$section_title =~ s/^\s+//;
|
||||
$section_title =~ s/\s+$//;
|
||||
}
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
print "$this_section [$section_title]\n" if $debug >= 2;
|
||||
|
||||
while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgc or $section_text =~ m/^(\d+)\s(.*)/msg) {
|
||||
|
@ -65,7 +65,7 @@ if($list_only and not length $search) {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
open FH, "<n1256.txt" or die "Could not open n1256.txt: $!";
|
||||
open FH, "<n1256.out" or die "Could not open n1256: $!";
|
||||
my @contents = <FH>;
|
||||
close FH;
|
||||
|
||||
@ -94,26 +94,32 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
print "----------------------------------\n" if $debug >= 2;
|
||||
print "Processing section [$this_section]\n" if $debug;
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
my $section_text;
|
||||
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}[0-9A-Z]+\.)/msg) {
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
$section_text = $1;
|
||||
} else {
|
||||
print "No section text, end of file marker found.\n" if $debug >= 4;
|
||||
last;
|
||||
}
|
||||
|
||||
if($section =~ /FOOTNOTE/) {
|
||||
$section_text =~ s/^\s{4}//ms;
|
||||
$section_text =~ s/^\s{4}FOOTNOTE.*//ms;
|
||||
$section_text =~ s/^\d.*//ms;
|
||||
}
|
||||
|
||||
if($section_text =~ m/(.*?)$/msg) {
|
||||
$section_title = $1 if length $1;
|
||||
$section_title =~ s/^\s+//;
|
||||
$section_title =~ s/\s+$//;
|
||||
}
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
print "$this_section [$section_title]\n" if $debug >= 2;
|
||||
|
||||
while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgc or $section_text =~ m/^(\d+)\s(.*)/msg) {
|
||||
|
@ -1,29 +1,44 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# ugly and hacked together
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use HTML::Entities;
|
||||
use Data::Dumper;
|
||||
|
||||
my $debug = 9999;
|
||||
|
||||
sub gen_data;
|
||||
sub gen_txt;
|
||||
sub gen_html;
|
||||
|
||||
open FH, "<n1256.txt" or die "Could not open n1256.txt: $!";
|
||||
#open FH, "<n1570.txt" or die "Could not open n1570.txt: $!";
|
||||
my @contents = <FH>;
|
||||
close FH;
|
||||
|
||||
|
||||
my $text = join '', @contents;
|
||||
$text =~ s/\r//g;
|
||||
|
||||
print "<html>\n<body>\n";
|
||||
|
||||
my ($section_title, $this_section);
|
||||
|
||||
my %sections;
|
||||
my $last_section_number = 0;
|
||||
my $section_number = 0;
|
||||
my $last_section;
|
||||
my @footnotes;
|
||||
my $footnote = 0;
|
||||
my $last_footnote = 0;
|
||||
|
||||
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
gen_data;
|
||||
gen_txt;
|
||||
#gen_html;
|
||||
|
||||
sub gen_data {
|
||||
while($text =~ m/^\s{0,5}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
$last_section_number = $section_number;
|
||||
$last_section = $this_section;
|
||||
$this_section = $1;
|
||||
@ -60,19 +75,15 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
}
|
||||
|
||||
print STDERR "$this_section [$section_title]\n" if $debug >= 2;
|
||||
|
||||
print "<hr>\n";
|
||||
print "<a name='$this_section'>";
|
||||
print "<h3>$this_section [$section_title]</h3>";
|
||||
print "</a>\n";
|
||||
$sections{$this_section}{title} = $section_title;
|
||||
|
||||
print STDERR "section text: [$section_text]\n" if $debug >= 2;
|
||||
|
||||
if(not $section_text =~ m/^(?=\d+\s)/msg) {
|
||||
print "<pre>$section_text</pre>\n";
|
||||
$sections{$this_section}{text} = $section_text;
|
||||
} else {
|
||||
my $last_p;
|
||||
my $p;
|
||||
my $last_p = 0;
|
||||
my $p = 0;
|
||||
while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgc or $section_text =~ m/^(\d+)\s(.*)/msg) {
|
||||
$last_p = $p;
|
||||
$p = $1;
|
||||
@ -84,13 +95,275 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
die "Paragraph diff invalid";
|
||||
}
|
||||
|
||||
$t = encode_entities($t);
|
||||
|
||||
print "<a name='$this_section" . "p$p'>";
|
||||
print "<pre>$p $t</pre>\n";
|
||||
print "</a>\n";
|
||||
while($t =~ m/^(\s*)(\d+)\)(\s*)(.*?)$/msg) {
|
||||
my $leading_spaces = $1;
|
||||
$footnote = $2;
|
||||
my $middle_spaces = $3;
|
||||
my $footnote_text = "$4\n";
|
||||
print STDERR "1st footnote\n";
|
||||
print STDERR "processing footnote $footnote [last: $last_footnote]\n" if $debug >= 2;
|
||||
if($last_footnote - $footnote != -1) {
|
||||
print STDERR "footnotes dump: \n";
|
||||
shift @footnotes;
|
||||
my $dump = Dumper(@footnotes);
|
||||
#print STDERR "$dump\n";
|
||||
die "Footnote diff invalid";
|
||||
}
|
||||
$last_footnote = $footnote;
|
||||
|
||||
my $indent = (length $leading_spaces) + (length $footnote) + (length ')') + (length $middle_spaces);
|
||||
$indent--;
|
||||
|
||||
print STDERR "footnote $footnote text [indent=$indent]: [$footnote_text]\n" if $debug >= 4;
|
||||
|
||||
while ($t =~ m/^(.*?)$/msgc) {
|
||||
my $line = $1;
|
||||
print STDERR "processing [$line]\n";
|
||||
|
||||
if($line =~ m/^(\s*)(\d+)\)(\s*)(.*?)$/msg) {
|
||||
print STDERR "----------------\n" if $debug >= 10;
|
||||
print STDERR "footnote $footnote: [$footnote_text]\n" if $debug >= 5;
|
||||
$footnotes[$footnote] = $footnote_text;
|
||||
print STDERR "----------------\n" if $debug >= 10;
|
||||
|
||||
$leading_spaces = $1;
|
||||
$footnote = $2;
|
||||
$middle_spaces = $3;
|
||||
$footnote_text = "$4\n";
|
||||
|
||||
print STDERR "2nd footnote\n";
|
||||
print STDERR "processing footnote $footnote [last: $last_footnote]\n" if $debug >= 2;
|
||||
if($last_footnote - $footnote != -1) {
|
||||
print STDERR "footnotes dump: \n";
|
||||
shift @footnotes;
|
||||
my $dump = Dumper(@footnotes);
|
||||
#print STDERR "$dump\n";
|
||||
die "Footnote diff invalid";
|
||||
}
|
||||
$last_footnote = $footnote;
|
||||
|
||||
my $indent = (length $leading_spaces) + (length $footnote) + (length ')') + (length $middle_spaces);
|
||||
$indent--;
|
||||
|
||||
print STDERR "footnote $footnote text [indent=$indent]: [$footnote_text]\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
if(not $line =~ m/^\s{$indent}/msg) {
|
||||
print STDERR "INTERRUPTED FOOTNOTE\n";
|
||||
last;
|
||||
}
|
||||
$footnote_text .= "$line\n";
|
||||
print STDERR "footnote $footnote text: appending [$line]\n" if $debug >= 3;
|
||||
}
|
||||
|
||||
print STDERR "----------------\n" if $debug >= 10;
|
||||
print STDERR "footnote $footnote: [$footnote_text]\n" if $debug >= 5;
|
||||
$footnotes[$footnote] = $footnote_text;
|
||||
print STDERR "----------------\n" if $debug >= 10;
|
||||
}
|
||||
|
||||
$sections{$this_section . "p$p"}{text} = "$p $t";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub bysection {
|
||||
my $inverse = 1;
|
||||
print STDERR "section cmp $a <=> $b\n";
|
||||
|
||||
my ($a1, $p1) = split /p/, $a;
|
||||
my ($b1, $p2) = split /p/, $b;
|
||||
|
||||
$p1 = 0 if not defined $p1;
|
||||
$p2 = 0 if not defined $p2;
|
||||
|
||||
my @k1 = split /\./, $a1;
|
||||
my @k2 = split /\./, $b1;
|
||||
my @r;
|
||||
|
||||
if($#k2 > $#k1) {
|
||||
my @t = @k1;
|
||||
@k1 = @k2;
|
||||
@k2 = @t;
|
||||
my $tp = $p1;
|
||||
$p1 = $p2;
|
||||
$p2 = $tp;
|
||||
$inverse = -1;
|
||||
} else {
|
||||
$inverse = 1;
|
||||
}
|
||||
|
||||
=cut
|
||||
print STDERR "k1 vals:\n";
|
||||
print STDERR Dumper(@k1), "\n";
|
||||
print STDERR "p1: $p1\n";
|
||||
|
||||
print STDERR "k2 vals:\n";
|
||||
print STDERR Dumper(@k2), "\n";
|
||||
print STDERR "p2: $p2\n";
|
||||
=cut
|
||||
|
||||
my $i = 0;
|
||||
for(; $i < $#k1 + 1; $i++) {
|
||||
if(not defined $k2[$i]) {
|
||||
$r[$i] = 1;
|
||||
} else {
|
||||
print STDERR " cmp k1[$i] ($k1[$i]) vs k2[$i] ($k2[$i])\n";
|
||||
if($i == 0) {
|
||||
$r[$i] = $k1[$i] cmp $k2[$i];
|
||||
} else {
|
||||
$r[$i] = $k1[$i] <=> $k2[$i];
|
||||
}
|
||||
}
|
||||
print STDERR " r[$i] = $r[$i]\n";
|
||||
}
|
||||
|
||||
$r[$i] = ($p1 <=> $p2);
|
||||
print STDERR " $p1 <=> $p2 => r[$i] = $r[$i]\n";
|
||||
|
||||
my $ret = 0;
|
||||
foreach my $rv (@r) {
|
||||
print STDERR " checking r: $rv\n";
|
||||
if($rv != 0) {
|
||||
$ret = $rv;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$ret = $ret * $inverse;
|
||||
|
||||
print STDERR "ret $ret\n";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub gen_txt {
|
||||
my $footer = "";
|
||||
my $paren = 0;
|
||||
my $section_head;
|
||||
my $section_title;
|
||||
|
||||
foreach my $this_section (sort bysection keys %sections) {
|
||||
print STDERR "writing section $this_section\n";
|
||||
if(not $this_section =~ m/p/) {
|
||||
print " $this_section $sections{$this_section}{title}\n";
|
||||
$section_head = $this_section;
|
||||
$section_title = $sections{$this_section}{title};
|
||||
}
|
||||
|
||||
my $section_text = $sections{$this_section}{text};
|
||||
|
||||
for($footnote = 1; $footnote < $#footnotes; $footnote++) {
|
||||
my $sub = quotemeta $footnotes[$footnote];
|
||||
$sub =~ s/(\\ )+/\\s*/g;
|
||||
#print STDERR "subbing out [$footnote) $sub]\n";
|
||||
$section_text =~ s/^\s*$footnote\)\s*$sub//ms;
|
||||
}
|
||||
|
||||
while($section_text =~ m/^(.*?)$/msg) {
|
||||
my $line = $1;
|
||||
|
||||
print STDERR "paren reset, line [$line]\n";
|
||||
my $number = "";
|
||||
while($line =~ m/(.)/g) {
|
||||
my $c = $1;
|
||||
|
||||
if($c =~ m/[0-9]/) {
|
||||
$number .= $c;
|
||||
} elsif($c eq ' ') {
|
||||
$number = "";
|
||||
} elsif($c eq '(') {
|
||||
$paren++;
|
||||
print STDERR "got $paren (\n";
|
||||
} elsif($c eq ')') {
|
||||
$paren--;
|
||||
print STDERR "got $paren )\n";
|
||||
|
||||
if($paren == -1) {
|
||||
if(length $number and defined $footnotes[$number]) {
|
||||
print STDERR "Got footnote $number here!\n";
|
||||
$footer .= " FOOTNOTE.$number\n $footnotes[$number]\n";
|
||||
}
|
||||
|
||||
$paren = 0;
|
||||
}
|
||||
} else {
|
||||
$number = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "$section_text\n";
|
||||
|
||||
if(length $footer) {
|
||||
print $footer;
|
||||
$footer = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub gen_html {
|
||||
print "<html>\n<body>\n";
|
||||
|
||||
my $footer = "";
|
||||
my $paren = 0;
|
||||
|
||||
foreach my $this_section (sort bysection keys %sections) {
|
||||
print STDERR "writing section $this_section\n";
|
||||
print "<a name='", encode_entities $this_section, "'>\n";
|
||||
print "<hr>\n<h3>", encode_entities $this_section, " [", encode_entities $sections{$this_section}{title}, "]</h3>\n" if not $this_section =~ m/p/;
|
||||
|
||||
my $section_text = $sections{$this_section}{text};
|
||||
|
||||
for($footnote = 1; $footnote < $#footnotes; $footnote++) {
|
||||
my $sub = quotemeta $footnotes[$footnote];
|
||||
$sub =~ s/(\\ )+/\\s*/g;
|
||||
#print STDERR "subbing out [$footnote) $sub]\n";
|
||||
$section_text =~ s/^\s*$footnote\)\s*$sub//ms;
|
||||
}
|
||||
|
||||
while($section_text =~ m/^(.*?)$/msg) {
|
||||
my $line = $1;
|
||||
|
||||
print STDERR "paren reset, line [$line]\n";
|
||||
my $number = "";
|
||||
while($line =~ m/(.)/g) {
|
||||
my $c = $1;
|
||||
|
||||
if($c =~ m/[0-9]/) {
|
||||
$number .= $c;
|
||||
} elsif($c eq ' ') {
|
||||
$number = "";
|
||||
} elsif($c eq '(') {
|
||||
$paren++;
|
||||
print STDERR "got $paren (\n";
|
||||
} elsif($c eq ')') {
|
||||
$paren--;
|
||||
print STDERR "got $paren )\n";
|
||||
|
||||
if($paren == -1) {
|
||||
if(length $number and defined $footnotes[$number]) {
|
||||
print STDERR "Got footnote $number here!\n";
|
||||
$footer .= "<a name='FOOTNOTE.$number'>\n<pre><i><b>Footnote $number)</b> $footnotes[$number]</i></pre>\n</a>\n";
|
||||
}
|
||||
|
||||
$paren = 0;
|
||||
}
|
||||
} else {
|
||||
$number = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "<pre>", encode_entities $section_text, "</pre>\n";
|
||||
print "</a>\n";
|
||||
|
||||
if(length $footer) {
|
||||
print $footer;
|
||||
$footer = "";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</body>\n</html>\n";
|
||||
}
|
||||
|
16662
modules/n1256.html
16662
modules/n1256.html
File diff suppressed because it is too large
Load Diff
2562
modules/n1256.txt
2562
modules/n1256.txt
File diff suppressed because it is too large
Load Diff
21368
modules/n1570.html
21368
modules/n1570.html
File diff suppressed because it is too large
Load Diff
2896
modules/n1570.txt
2896
modules/n1570.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user