about summary refs log tree commit diff
path: root/scripts/gen-FAQ.pl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-05-08 20:56:30 +0000
committerUlrich Drepper <drepper@redhat.com>1998-05-08 20:56:30 +0000
commit5bc2f642a77010ef3d118dc286b39fa4a7f21699 (patch)
tree93d643946175191a02d997b300d02f918e7b8877 /scripts/gen-FAQ.pl
parentc7562c74ed1b18fda99bfd5f6c4b61a449bcb35f (diff)
downloadglibc-5bc2f642a77010ef3d118dc286b39fa4a7f21699.tar.gz
glibc-5bc2f642a77010ef3d118dc286b39fa4a7f21699.tar.xz
glibc-5bc2f642a77010ef3d118dc286b39fa4a7f21699.zip
Update.
1998-05-08 21:56  Zack Weinberg  <zack@rabi.phys.columbia.edu>

	* autolock.sh: Removed.
	* manual/move-if-change: Removed.

	* scripts: new directory.
	* =__ify: moved to scripts.
	* config.guess: Likewise.
	* config.sub: Likewise.
	* gen-FAQ.pl: Likewise.
	* install-sh: Likewise.
	* mkinstalldirs: Likewise.
	* move-if-change: Likewise.
	* printsources: Likewise.
	* rellns.sh: Likewise.
	* test-installation.pl: Likewise.

	* configure.in: Look in scripts for config.guess, config.sub,
	install-sh.
	* Makefile: Distribute all above files in their
	new home.  Find gen-FAQ.pl and test-installation.pl in scripts.
	* manual/Makefile: Find mkinstalldirs and move-if-change in
	$(..)scripts.  Drop them from distribute.  Minor cleanups.
	* Makerules: Find mkinstalldirs and rellns-sh in scripts.
	* sysdeps/mach/hurd/Makefile: Find move-if-change in scripts.
	* timezone/Makefile: Find rellns-sh in scripts.
Diffstat (limited to 'scripts/gen-FAQ.pl')
-rwxr-xr-xscripts/gen-FAQ.pl144
1 files changed, 144 insertions, 0 deletions
diff --git a/scripts/gen-FAQ.pl b/scripts/gen-FAQ.pl
new file mode 100755
index 0000000000..9503903f8c
--- /dev/null
+++ b/scripts/gen-FAQ.pl
@@ -0,0 +1,144 @@
+#! /usr/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";
+}