+sub output {
+ my ($podname, $header, $dochash, $missing, $footer) = @_;
+ my $fh = open_new("pod/$podname.pod", undef,
+ {by => "$0 extracting documentation",
+ from => 'the C source files'}, 1);
+
+ print $fh $header;
+
+ my $key;
+ # case insensitive sort, with fallback for determinacy
+ for $key (sort { uc($a) cmp uc($b) || $a cmp $b } keys %$dochash) {
+ my $section = $dochash->{$key};
+ print $fh "\n=head1 $key\n\n";
+
+ # Output any heading-level documentation and delete so won't get in
+ # the way later
+ if (exists $section->{""}) {
+ print $fh $section->{""} . "\n";
+ delete $section->{""};
+ }
+ print $fh "=over 8\n\n";
+
+ # Again, fallback for determinacy
+ for my $key (sort { uc($a) cmp uc($b) || $a cmp $b } keys %$section) {
+ docout($fh, $key, $section->{$key});
+ }
+ print $fh "\n=back\n";
+ }
+
+ if (@$missing) {
+ print $fh "\n=head1 Undocumented functions\n\n";
+ print $fh $podname eq 'perlapi' ? <<'_EOB_' : <<'_EOB_';
+The following functions have been flagged as part of the public API,
+but are currently undocumented. Use them at your own risk, as the
+interfaces are subject to change. Functions that are not listed in this
+document are not intended for public use, and should NOT be used under any
+circumstances.
+
+If you use one of the undocumented functions below, you may wish to consider
+creating and submitting documentation
+for it. If your patch is accepted, this
+will indicate that the interface is stable (unless it is explicitly marked
+otherwise).
+
+=over
+
+_EOB_
+The following functions are currently undocumented. If you use one of
+them, you may wish to consider creating and submitting documentation for
+it.
+
+=over
+
+_EOB_
+ for my $missing (sort @$missing) {
+ print $fh "=item $missing\nX<$missing>\n\n";
+ }
+ print $fh "=back\n\n";
+}
+ print $fh $footer, "=cut\n";
+
+ read_only_bottom_close_and_rename($fh);
+}
+
+foreach (@{(setup_embed())[0]}) {
+ next if @$_ < 2;
+ my ($flags, $retval, $func, @args) = @$_;
+ s/\b(?:NN|NULLOK)\b\s+//g for @args;
+
+ $funcflags{$func} = {
+ flags => $flags,
+ retval => $retval,
+ args => \@args,
+ };
+}
+