test1477.pl (2787B)
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 # Check that libcurl-errors.3 and the public header files have the same set of 27 # error codes. 28 29 use strict; 30 use warnings; 31 32 # we may get the dir roots pointed out 33 my $root=$ARGV[0] || "."; 34 my $buildroot=$ARGV[1] || "."; 35 my $manpge = "$buildroot/docs/libcurl/libcurl-errors.3"; 36 my $curlh = "$root/include/curl"; 37 my $errors=0; 38 39 my @hnames; 40 my %wherefrom; 41 my @mnames; 42 my %manfrom; 43 44 sub scanheader { 45 my ($file)=@_; 46 open H, "<$file"; 47 my $line = 0; 48 while(<H>) { 49 $line++; 50 if($_ =~ /^ (CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { 51 my ($name)=($1); 52 if(($name !~ /(OBSOLETE|CURLE_RESERVED)/) && ($name !~ /_LAST\z/)) { 53 push @hnames, $name; 54 if($wherefrom{$name}) { 55 print STDERR "double: $name\n"; 56 } 57 $wherefrom{$name}="$file:$line"; 58 } 59 } 60 } 61 close(H); 62 } 63 64 sub scanmanpage { 65 my ($file)=@_; 66 open H, "<$file"; 67 my $line = 0; 68 while(<H>) { 69 $line++; 70 if($_ =~ /^\.IP \"(CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { 71 my ($name)=($1); 72 if($name !~ /(CURLM_CALL_MULTI_SOCKET)/) { 73 push @mnames, $name; 74 $manfrom{$name}="$file:$line"; 75 } 76 } 77 } 78 close(H); 79 } 80 81 82 opendir(my $dh, $curlh) || die "Can't opendir $curlh: $!"; 83 my @hfiles = grep { /\.h$/ } readdir($dh); 84 closedir $dh; 85 86 for(sort @hfiles) { 87 scanheader("$curlh/$_"); 88 } 89 scanmanpage($manpge); 90 91 print "Result\n"; 92 for my $h (sort @hnames) { 93 if(!$manfrom{$h}) { 94 printf "$h from %s, not in manpage\n", $wherefrom{$h}; 95 } 96 } 97 98 for my $m (sort @mnames) { 99 if(!$wherefrom{$m}) { 100 printf "$m from %s, not in any header\n", $manfrom{$m}; 101 } 102 }