--- ./pod/buildtoc~	Wed Jul 22 13:03:00 1998
+++ ./pod/buildtoc	Sun Oct  4 18:13:42 1998
@@ -112,6 +112,8 @@ podset( @modules[ sort { $modname[$a] cm
 	Here should be listed all the extra programs' documentation, but they
 	don't all have manual pages yet:
 
+	=over
+
 	=item a2p
 
 	=item s2p
@@ -130,6 +132,7 @@ podset( @modules[ sort { $modname[$a] cm
 
 	=item wrapsuid
 
+	=back
 
 	=head1 AUTHOR
 
@@ -146,35 +149,38 @@ sub podset {
     local @ARGV = @_;
 
     while(<>) {
-	if (s/^=head1 (NAME)\s*/=head2 /) {
+	if (s/^=head1\s+(NAME)\s*/=head2 /) {
 	    $pod = path2modname($ARGV);
 	    unitem();
 	    unhead2();
+	    unhead1();
 	    output "\n \n\n=head2 ";
 	    $_ = <>;
 	    if ( /^\s*$pod\b/ ) {
 		s/$pod\.pm/$pod/;       # '.pm' in NAME !?
+		s/^$pod\b/L<$pod>/;
 		output $_;
 	    } else {
-		s/^/$pod, /;
+		s/^/L<$pod>, /;
 		output $_;
 	    }
 	    next;
 	}
-	if (s/^=head1 (.*)/=item $1/) {
+	if (s,^=head1\s+(.*?)\s*$,=item * L<$1|$pod/"$1">\n,s) {
 	    unitem(); unhead2();
+	    output "=over\n\n" unless $inhead1;
+	    $inhead1 = 1;
 	    output $_; nl(); next;
 	}
-	if (s/^=head2 (.*)/=item $1/) {
+	if (s,^=head2\s+(.*?)\s*$,=item * L<$1|$pod/"$1">\n,s) {
 	    unitem();
 	    output "=over\n\n" unless $inhead2;
 	    $inhead2 = 1;
 	    output $_; nl(); next;
-
 	}
-	if (s/^=item ([^=].*)\n/$1/) {
+	if (s,^=item\s+([^=].*?)\s*$,$1,s) {
 	    next if $pod eq 'perldiag';
-	    s/^\s*\*\s*$// && next;
+	    m/^\s*\*\s*$/ && next;
 	    s/^\s*\*\s*//;
 	    s/\s+$//;
 	    next if /^[\d.]+$/;
@@ -182,11 +188,18 @@ sub podset {
 	    ##print "=over\n\n" unless $initem;
 	    output ", " if $initem;
 	    $initem = 1;
+	    my $actual = $_;
 	    s/\.$//;
 	    s/^-X\b/-I<X>/;
+	    unless (m,[|>],) {	# Does not work inside L<aaa|pod/"aaa">?
+	      # Remove embedded simple links:
+	      s/L<([^<>]*)>/$1/g;
+	      $_ = qq(L<$_|$pod/"$actual">);
+	    }
 	    output $_; next;
 	}
     }
+    unhead1();
 }
 
 sub path2modname {
@@ -204,6 +217,13 @@ sub unhead2 {
     }
     $inhead2 = 0;
     $initem  = 0;
+}
+
+sub unhead1 {
+    if ($inhead1) {
+	output "\n\n=back\n\n";
+    }
+    $inhead1 = 0;
 }
 
 sub unitem {
