3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-22 03:49:29 +01:00

applets/cstd.pl: Fix footnotes

This commit is contained in:
Pragmatic Software 2022-08-12 13:02:00 -07:00
parent 6a61de1026
commit 4551318c56
6 changed files with 1384 additions and 1389 deletions

30
applets/cstd.pl vendored
View File

@ -15,6 +15,9 @@ my %standards = (
C23 => 'n3047.out', C23 => 'n3047.out',
); );
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
@ARGV = map { decode('UTF-8', $_, 1) } @ARGV; @ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
my ($std, $search, $section, $paragraph, $debug); my ($std, $search, $section, $paragraph, $debug);
@ -133,20 +136,20 @@ my $qsearch = quotemeta $search;
$qsearch =~ s/\\ / /g; $qsearch =~ s/\\ / /g;
$qsearch =~ s/\s+/\\s+/g; $qsearch =~ s/\s+/\\s+/g;
while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msg) { while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msgi) {
$this_section = $1; $this_section = $1;
print "----------------------------------\n" if $debug >= 2; print "----------------------------------\n" if $debug >= 2;
print "Processing section [$this_section]\n" if $debug; print "Processing section [$this_section]\n" if $debug;
if ($section_specified and $this_section !~ m/^$section/i) { if ($section_specified and $this_section !~ m/^\Q$section/i) {
print "No section match, skipping.\n" if $debug >= 4; print "No section match, skipping.\n" if $debug >= 4;
next; next;
} }
my $section_text; my $section_text;
if ($text =~ m/(.*?)^(?=\s{0,4}(?!Footnote)[0-9A-Z]+\.)/msg) { if ($text =~ /(.*?)^(?=\s{0,4}(?!Footnote)[0-9A-Z]+\.)/msg) {
$section_text = $1; $section_text = $1;
} else { } else {
print "No section text, end of file marker found.\n" if $debug >= 4; print "No section text, end of file marker found.\n" if $debug >= 4;
@ -157,6 +160,7 @@ while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msg) {
$section_text =~ s/^\s{4}//ms; $section_text =~ s/^\s{4}//ms;
$section_text =~ s/^\s{4}Footnote.*//msi; $section_text =~ s/^\s{4}Footnote.*//msi;
$section_text =~ s/^\d.*//ms; $section_text =~ s/^\d.*//ms;
$section_text = $this_section . $section_text;
} elsif ($section_text =~ m/(.*?)$/msg) { } elsif ($section_text =~ m/(.*?)$/msg) {
$section_title = $1 if length $1; $section_title = $1 if length $1;
$section_title =~ s/^\s+//; $section_title =~ s/^\s+//;
@ -247,28 +251,17 @@ if (not $found and $comma eq "") {
exit 1; exit 1;
} }
$result =~ s/$found_section_title// if length $found_section_title; $result =~ s/\Q$found_section_title// if length $found_section_title;
$result =~ s/^\s+//; $result =~ s/^\s+//;
$result =~ s/\s+$//; $result =~ s/\s+$//;
=cut
$result =~ s/\s+/ /g;
$result =~ s/[\n\r]/ /g;
=cut
if ($matches > 1 and not $list_only) { print "Displaying $match of $matches matches: "; } if ($matches > 1 and not $list_only) { print "Displaying $match of $matches matches: "; }
if ($comma eq "") { if ($comma eq "") {
print "http://www.iso-9899.info/$std_name.html\#$found_section";
=cut
print $found_section;
print "p" . $found_paragraph if $paragraph_specified; print "p" . $found_paragraph if $paragraph_specified;
=cut print "\n\n";
print "[", $found_section_title, "]\n\n" if length $found_section_title;
print "http://www.iso-9899.info/$std_name.html\#$found_section";
print "p" . $found_paragraph if $paragraph_specified;
print "\n\n";
print "[", $found_section_title, "]\n\n" if length $found_section_title;
} }
$result =~ s/\s*Constraints\s*$//; $result =~ s/\s*Constraints\s*$//;
@ -277,6 +270,7 @@ $result =~ s/\s*Description\s*$//;
$result =~ s/\s*Returns\s*$//; $result =~ s/\s*Returns\s*$//;
$result =~ s/\s*Runtime-constraints\s*$//; $result =~ s/\s*Runtime-constraints\s*$//;
$result =~ s/\s*Recommended practice\s*$//; $result =~ s/\s*Recommended practice\s*$//;
$result =~ s/Footnote\.(\d)/Footnote $1/g;
if (length $match_text) { if (length $match_text) {
my $match_result = $result; my $match_result = $result;

6
applets/gencstd.pl vendored
View File

@ -23,7 +23,7 @@ binmode(STDERR, ":utf8");
my $input = "@ARGV"; my $input = "@ARGV";
if (not length $input) { if (not length $input) {
print STDERR "Usage: $0 <input .txt file>\n"; print STDERR "Usage: $0 <input file>\n";
exit 1; exit 1;
} }
@ -270,7 +270,7 @@ sub gen_txt {
foreach my $this_section (sort bysection keys %sections) { foreach my $this_section (sort bysection keys %sections) {
print STDERR "writing section $this_section\n" if $debug; print STDERR "writing section $this_section\n" if $debug;
if (not $this_section =~ m/p/) { if (not $this_section =~ m/p/) {
print " $this_section $sections{$this_section}{title}\n"; print "$this_section $sections{$this_section}{title}\n";
$section_head = $this_section; $section_head = $this_section;
$section_title = $sections{$this_section}{title}; $section_title = $sections{$this_section}{title};
} }
@ -297,7 +297,7 @@ sub gen_txt {
if ($paren == -1) { if ($paren == -1) {
if (length $number and defined $footnotes[$number]) { if (length $number and defined $footnotes[$number]) {
print STDERR "Got footnote $number here!\n" if $debug; print STDERR "Got footnote $number here!\n" if $debug;
$footer .= "\nFOOTNOTE.$number) $footnotes[$number]\n"; $footer .= "\nFootnote.$number) $footnotes[$number]\n";
} }
$paren = 0; $paren = 0;

678
applets/n1256.out vendored

File diff suppressed because it is too large Load Diff

938
applets/n1570.out vendored

File diff suppressed because it is too large Load Diff

1113
applets/n3047.out vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4571, BUILD_REVISION => 4572,
BUILD_DATE => "2022-08-12", BUILD_DATE => "2022-08-12",
}; };