# Has an optional arg, which is the directory to chdir to before reading
# MANIFEST and *.[ch].
#
-# This script is normally invoked as part of 'make all', but is also
-# called from regen.pl.
+# This script is invoked as part of 'make all'
#
# '=head1' are the only headings looked for. If the next line after the
# heading begins with a word character, it is considered to be the first line
use strict;
+if (@ARGV) {
+ my $workdir = shift;
+ chdir $workdir
+ or die "Couldn't chdir to '$workdir': $!";
+}
+require 'regen/regen_lib.pl';
+require 'regen/embed_lib.pl';
+
#
# See database of global and static function prototypes in embed.fnc
# This is used to generate prototype headers under various configurations,
sub output {
my ($podname, $header, $dochash, $missing, $footer) = @_;
- my $filename = "pod/$podname.pod";
- open my $fh, '>', $filename or die "Can't open $filename: $!";
+ my $fh = open_new("pod/$podname.pod", undef,
+ {by => "$0 extracting documentation",
+ from => 'the C source files'}, 1);
- print $fh <<"_EOH_", $header;
--*- buffer-read-only: t -*-
-
-!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
-This file is built by $0 extracting documentation from the C source
-files.
-
-_EOH_
+ print $fh $header;
my $key;
# case insensitive sort, with fallback for determinacy
}
print $fh "=back\n\n";
}
+ print $fh $footer, "=cut\n";
-print $fh $footer, <<'_EOF_';
-=cut
-
- ex: set ro:
-_EOF_
-
- close $fh or die "Can't close $filename: $!";
+ read_only_bottom_close_and_rename($fh);
}
-if (@ARGV) {
- my $workdir = shift;
- chdir $workdir
- or die "Couldn't chdir to '$workdir': $!";
-}
-
-open IN, "embed.fnc" or die $!;
-
-while (<IN>) {
- chomp;
- next if /^:/;
- while (s|\\\s*$||) {
- $_ .= <IN>;
- chomp;
- }
- s/\s+$//;
- next if /^\s*(#|$)/;
-
- my ($flags, $retval, $func, @args) = split /\s*\|\s*/, $_;
-
- next unless $func;
-
- s/\b(NN|NULLOK)\b\s+//g for @args;
- $func =~ s/\t//g; # clean up fields from embed.pl
- $retval =~ s/\t//;
+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,
};
}
-my $file;
# glob() picks up docs from extra .c or .h files that may be in unclean
# development trees.
-my $MANIFEST = do {
- local ($/, *FH);
- open FH, "MANIFEST" or die "Can't open MANIFEST: $!";
- <FH>;
-};
+open my $fh, '<', 'MANIFEST'
+ or die "Can't open MANIFEST: $!";
+while (my $line = <$fh>) {
+ next unless my ($file) = $line =~ /^(\S+\.[ch])\t/;
-for $file (($MANIFEST =~ /^(\S+\.c)\t/gm), ($MANIFEST =~ /^(\S+\.h)\t/gm)) {
open F, "< $file" or die "Cannot open $file for docs: $!\n";
$curheader = "Functions in file $file\n";
autodoc(\*F,$file);
close F or die "Error closing $file: $!\n";
}
+close $fh or die "Error whilst reading MANIFEST: $!";
for (sort keys %funcflags) {
next unless $funcflags{$_}{flags} =~ /d/;