2
0

test1477.pl 2.6 KB

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