]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
gen.pl: quote "bare" minuses in the nroff curl.1
authorDaniel Stenberg <daniel@haxx.se>
Thu, 11 Mar 2021 07:50:11 +0000 (08:50 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 14 Mar 2021 22:44:43 +0000 (23:44 +0100)
Reported-by: Alejandro Colomar
Fixes #6698
Closes #6722

docs/cmdline-opts/gen.pl
tests/manpage-scan.pl

index 4bcedc36d275b26153fcbf66ea34c174745dee43..1fe4a92c995160344d0c802e141b390e8e7983b3 100755 (executable)
@@ -70,6 +70,9 @@ sub printdesc {
                 $d =~ s/--$k([^a-z0-9_-])/$l$1/;
             }
         }
+        # quote "bare" minuses in the output
+        $d =~ s/( |\\fI|^)--/$1\\-\\-/g;
+        $d =~ s/([ -]|\\fI|^)-/$1\\-/g;
         print $d;
     }
 }
@@ -203,6 +206,9 @@ sub single {
         $opt .= " $arg";
     }
 
+    # quote "bare" minuses in opt
+    $opt =~ s/( |^)--/$1\\-\\-/g;
+    $opt =~ s/( |^)-/$1\\-/g;
     if($standalone) {
         print ".TH curl 1 \"30 Nov 2016\" \"curl 7.52.0\" \"curl manual\"\n";
         print ".SH OPTION\n";
index 78ceddd7eb20092fcbdc4ce6279d39746398dba2..ec2e7253df4b1c0af9d512fab8a40550478deb53 100755 (executable)
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 2016 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 2016 - 2021, 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
@@ -66,12 +66,19 @@ sub scanmanpage {
     my ($file, @words) = @_;
 
     open(M, "<$file");
-    my @m = <M>;
+    my @m;
+    while(<M>) {
+        if($_ =~ /^\.IP (.*)/) {
+            my $w = $1;
+            # "unquote" minuses
+            $w =~ s/\\-/-/g;
+            push @m, $w;
+        }
+    }
     close(M);
 
     foreach my $m (@words) {
-
-        my @g = grep(/^\.IP $m/, @m);
+        my @g = grep(/$m/, @m);
         if(!$g[0]) {
             print STDERR "Missing mention of $m in $file\n";
             $errors++;
@@ -206,7 +213,8 @@ my @manpage; # store all parsed parameters
 while(<R>) {
     chomp;
     my $l= $_;
-    if(/^\.IP \"(-[^\"]*)\"/) {
+    $l =~ s/\\-/-/g;
+    if($l =~ /^\.IP \"(-[^\"]*)\"/) {
         my $str = $1;
         my $combo;
         if($str =~ /^-(.), --([a-z0-9.-]*)/) {