quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

test1140.pl (3346B)


      1 #!/usr/bin/env perl
      2 #***************************************************************************
      3 #                                  _   _ ____  _
      4 #  Project                     ___| | | |  _ \| |
      5 #                             / __| | | | |_) | |
      6 #                            | (__| |_| |  _ <| |___
      7 #                             \___|\___/|_| \_\_____|
      8 #
      9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
     10 #
     11 # This software is licensed as described in the file COPYING, which
     12 # you should have received as part of this distribution. The terms
     13 # are also available at https://curl.se/docs/copyright.html.
     14 #
     15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
     16 # copies of the Software, and permit persons to whom the Software is
     17 # furnished to do so, under the terms of the COPYING file.
     18 #
     19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     20 # KIND, either express or implied.
     21 #
     22 # SPDX-License-Identifier: curl
     23 #
     24 ###########################################################################
     25 #
     26 # scan manpages to find basic syntactic problems such as unbalanced \f
     27 # codes or references to non-existing curl manpages.
     28 
     29 my $docsroot = $ARGV[0];
     30 
     31 if(!$docsroot || ($docsroot eq "-g")) {
     32     print "Usage: test1140.pl <docs root dir> [manpages]\n";
     33     exit;
     34 }
     35 
     36 
     37 shift @ARGV;
     38 
     39 my @f = @ARGV;
     40 
     41 my %manp;
     42 
     43 sub manpresent {
     44     my ($man) = @_;
     45     if($manp{$man}) {
     46         return 1;
     47     }
     48     elsif(-r "$docsroot/$man" ||
     49           -r "$docsroot/libcurl/$man" ||
     50           -r "$docsroot/libcurl/opts/$man") {
     51         $manp{$man}=1;
     52         return 1;
     53     }
     54     return 0;
     55 }
     56 
     57 sub file {
     58     my ($f) = @_;
     59     open(my $fh, "<", "$f") ||
     60         die "test1140.pl could not open $f";
     61     my $line = 1;
     62     while(<$fh>) {
     63         chomp;
     64         my $l = $_;
     65         while($l =~ s/\\f(.)([^ ]*)\\f(.)//) {
     66             my ($pre, $str, $post)=($1, $2, $3);
     67             if($str =~ /^\\f[ib]/i) {
     68                 print "error: $f:$line: double-highlight\n";
     69                 $errors++;
     70             }
     71             if($post ne "P") {
     72                 print "error: $f:$line: missing \\fP after $str\n";
     73                 $errors++;
     74             }
     75             if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) {
     76                 my $man = "$1.3";
     77                 $man =~ s/\\//g; # cut off backslashes
     78                 if(!manpresent($man)) {
     79                     print "error: $f:$line: referring to non-existing manpage $man\n";
     80                     $errors++;
     81                 }
     82                 if($pre ne "I") {
     83                     print "error: $f:$line: use \\fI before $str\n";
     84                     $errors++;
     85                 }
     86             }
     87         }
     88         if($l =~ /(curl([^ ]*)\(3\))/i) {
     89             print "error: $f:$line: non-referencing $1\n";
     90             $errors++;
     91         }
     92         if($l =~ /^\.BR (.*)/) {
     93             my $i= $1;
     94             while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) {
     95                 my $man = "$1.3";
     96                 $man =~ s/\\//g; # cut off backslashes
     97                 if(!manpresent($man)) {
     98                     print "error: $f:$line: referring to non-existing manpage $man\n";
     99                     $errors++;
    100                 }
    101             }
    102         }
    103         $line++;
    104     }
    105     close($fh);
    106 }
    107 
    108 foreach my $f (@f) {
    109     file($f);
    110 }
    111 
    112 print "OK\n" if(!$errors);
    113 
    114 exit $errors?1:0;