glibc/gen-FAQ.pl

145 lines
2.4 KiB
Perl
Raw Normal View History

Update. 1997-12-05 00:01 Ulrich Drepper <drepper@cygnus.com> The kernel expects the arguments in a different order. * sysdeps/unix/sysv/linux/i386/s_pread64.S: New file. * sysdeps/unix/sysv/linux/i386/s_pwrite64.S: New file. * FAQ.in: New file. * gen-FAQ.pl: New file. * Makefile (FAQ): Add rule to generate from FAQ.in. * iconvdata/Makefile: Treat libJIS like the other modules. * rt/librt.map: New file. * sysdeps/wordsize-32/bits/environments.h: Add test for direct inclusion. * sysdeps/wordsize-64/bits/environments.h: Likewise. Correct comment. 1997-12-04 22:29 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/rt_sigprocmask.c: Fix prototype. * sysdeps/unix/sysv/linux/rt_sigsuspend.c: Likewise. * sysdeps/unix/sysv/linux/rt_sigqueueinfo.c: Include <sys/types.h>. Patches by Thorsten Kukuk <kukuk@weber.uni-paderborn.de>. 1997-11-27 Andreas Jaeger <aj@arthur.rhein-neckar.de> * string/bits/string2.h: Fix spellings. * string/string.h: Fix spellings. 1997-12-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/i386/sigaction.c: Rename extern declaration to __syscall_rt_sigaction. * sysdeps/unix/sysv/linux/sigreturn.c: Remove inclusion of non-existant <sigcontext.h>. 1997-12-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/generic/enbl-secure.c (__libc_init_secure): Correct typo. 1997-12-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/wordsize-64/bits/environments.h: Correct spelling. * Makeconfig (shared-thread-library): Correct spelling. * sysdeps/unix/sysv/linux/sys/pci.h: Include <linux/pci.h> and not <asm/pci.h>. 1997-12-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/bits/socket.h: Add AF_* and PF_ constants from Linux headers. Pointed out by csmall@scooter.o.i.net. [PR libc/369] 1997-12-04 10:21 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * sunrpc/xcrypt.c: Fix lower/upper characters in optimized hexval. 1997-12-04 00:06 Zack Weinberg <zack@rabi.phys.columbia.edu> * configure.in: If --enable-add-ons is given without an argument, set the addons list to all subdirs with a configure script.
1997-12-05 01:40:29 +01:00
#! /usr/local/bin/perl
=pod
This is a silly little program for generating the libc FAQ.
The input format is:
top boilerplate
^L
? section name (one line)
?? question...
...
{ID} answer...
...
^L
{ID} name <email@address>
...
which gets mapped to:
top boilerplate
^L
1. section 1...
1.1. q1.1
1.2. q1.2
...
^L
1. section 1...
1.1. q1.1
answer 1.1....
^L
Answers were provided by:
...
=cut
# We slurp the whole file into a pair of assoc arrays indexed by
# the 'section.question' number.
%questions = ();
%answers = ();
$question = 0;
# These arrays and counter keep track of the sections.
@sectcount = ();
@sections = ();
$section = 0;
# Cross reference list.
%refs = ();
# Separators.
$sepmaj = "\f\n" . ('~ ' x 36) . "\n\n";
$sepmin = "\f\n" . ('. ' x 36) . "\n\n";
# Pass through the top boilerplate.
while(<>)
{
last if $_ eq "\f\n";
print;
}
# Now the body.
while(<>)
{
/\f/ && do
{
$sectcount[$section] = $question;
last;
};
s/^\?\s+// && do
{
chomp;
$sectcount[$section] = $question if $section > 0;
$section++;
$sections[$section] = $_;
$question = 0;
next;
};
s/^\?\?(\w*?)\s+// && do
{
$cur = \%questions;
$question++;
$questions{$section,$question} = $_;
$refs{$1} = "$section.$question" if $1 ne "";
next;
};
/^\{/ && do
{
$cur = \%answers;
$answers{$section,$question} .= $_;
next;
};
${$cur}{$section,$question} .= $_;
}
# Now we have to clean up the newlines and deal with cross references.
foreach(keys %questions) { $questions{$_} =~ s/\n+$//; }
foreach(keys %answers)
{
$answers{$_} =~ s/\n+$//;
$answers{$_} =~ s/(\s)\?(\w+)\b/$1 . "question " . ($refs{$2} or badref($2,$_), "!!$2")/eg;
}
# Now output the formatted FAQ.
print $sepmaj;
for($i = 1; $i <= $section; $i++)
{
print "$i. $sections[$i]\n\n";
for($j = 1; $j <= $sectcount[$i]; $j++)
{
print "$i.$j.\t$questions{$i,$j}\n";
}
print "\n";
}
print $sepmaj;
for($i = 1; $i <= $section; $i++)
{
print "$i. $sections[$i]\n\n";
for($j = 1; $j <= $sectcount[$i]; $j++)
{
print "$i.$j.\t$questions{$i,$j}\n\n";
print $answers{$i,$j}, "\n\n";
print "\n" if $j < $sectcount[$i];
}
print $sepmin if $i < $section;
}
print $sepmaj;
# Pass through the trailer.
while(<>) { print; }
sub badref
{
my($ref,$quest) = @_;
$quest =~ s/$;/./;
print STDERR "Undefined reference to $ref in answer to Q$quest\n";
}