# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
all: $(MANPAGE)
$(MANPAGE): $(DPAGES) $(OTHERPAGES) Makefile.inc
- @PERL@ $(srcdir)/gen.pl mainpage $(srcdir) > $(MANPAGE)
+ @echo "generate $(MANPAGE)"
+ @(cd $(srcdir) && @PERL@ ./gen.pl mainpage $(DPAGES)) > $(MANPAGE)
This script generates the manpage.
-Example: gen.pl mainpage > curl.1
+Example: gen.pl <command> [files] > curl.1
Dev notes:
=end comment
=cut
-my $some_dir=$ARGV[1] || ".";
-
-opendir(my $dh, $some_dir) || die "Can't opendir $some_dir: $!";
-my @s = grep { /\.d$/ && -f "$some_dir/$_" } readdir($dh);
-closedir $dh;
-
my %optshort;
my %optlong;
my %helplong;
sub single {
my ($f, $standalone)=@_;
- open(F, "<:crlf", "$some_dir/$f") ||
+ open(F, "<:crlf", "$f") ||
return 1;
my $short;
my $long;
sub getshortlong {
my ($f)=@_;
- open(F, "<:crlf", "$some_dir/$f");
+ open(F, "<:crlf", "$f");
my $short;
my $long;
my $help;
}
sub indexoptions {
- foreach my $f (@s) {
- getshortlong($f);
- }
+ my (@files) = @_;
+ foreach my $f (@files) {
+ getshortlong($f);
+ }
}
sub header {
my ($f)=@_;
- open(F, "<:crlf", "$some_dir/$f");
+ open(F, "<:crlf", "$f");
my @d;
while(<F>) {
push @d, $_;
}
sub mainpage {
+ my (@files) = @_;
# show the page header
header("page-header");
# output docs for all options
- foreach my $f (sort @s) {
- single($f, 0);
+ foreach my $f (sort @files) {
+ if(single($f, 0)) {
+ print STDERR "Can't read $f?\n";
+ }
}
header("page-footer");
}
sub getargs {
- my $f;
- do {
- $f = shift @ARGV;
- if($f eq "mainpage") {
- mainpage();
- return;
- }
- elsif($f eq "listhelp") {
- listhelp();
- return;
- }
- elsif($f eq "single") {
- showonly(shift @ARGV);
- return;
- }
- elsif($f eq "protos") {
- showprotocols();
- return;
- }
- } while($f);
+ my ($f, @s) = @_;
+ if($f eq "mainpage") {
+ mainpage(@s);
+ return;
+ }
+ elsif($f eq "listhelp") {
+ listhelp();
+ return;
+ }
+ elsif($f eq "single") {
+ showonly($s[0]);
+ return;
+ }
+ elsif($f eq "protos") {
+ showprotocols();
+ return;
+ }
- print "Usage: gen.pl <mainpage/listhelp/single FILE/protos> [srcdir]\n";
+ print "Usage: gen.pl <mainpage/listhelp/single FILE/protos> [files]\n";
}
#------------------------------------------------------------------------
+my $cmd = shift @ARGV;
+my @files = @ARGV; # the rest are the files
+
# learn all existing options
-indexoptions();
+indexoptions(@files);
-getargs();
+getargs($cmd, @files);