test1488.pl 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. # This script grew out of help from Przemyslaw Iskra and Balint Szilakszi
  27. # a late evening in the #curl IRC channel.
  28. #
  29. use strict;
  30. use warnings;
  31. use vars qw($Cpreprocessor);
  32. #
  33. # configurehelp perl module is generated by configure script
  34. #
  35. my $rc = eval {
  36. require configurehelp;
  37. configurehelp->import(qw(
  38. $Cpreprocessor
  39. ));
  40. 1;
  41. };
  42. # Set default values if configure has not generated a configurehelp.pm file.
  43. # This is the case with cmake.
  44. if (!$rc) {
  45. $Cpreprocessor = 'cpp';
  46. }
  47. # we may get the dir root pointed out
  48. my $root=$ARGV[0] || ".";
  49. # need an include directory when building out-of-tree
  50. my $i = ($ARGV[1]) ? "-I$ARGV[1] " : '';
  51. my $error;
  52. my @syms;
  53. my %manpage;
  54. my %symadded;
  55. sub checkmanpage {
  56. my ($m) = @_;
  57. open(my $mh, "<", "$m");
  58. my $line = 1;
  59. my $title;
  60. my $addedin;
  61. while(<$mh>) {
  62. if(/^Title: (.*)/i) {
  63. $title = $1;
  64. }
  65. elsif(/^Added-in: (.*)/i) {
  66. $addedin = $1;
  67. }
  68. if($addedin && $title) {
  69. if($manpage{$title}) {
  70. print "$title is a duplicate symbol in file $m\n";
  71. $error++;
  72. }
  73. $manpage{$title} = $addedin;
  74. last;
  75. }
  76. $line++;
  77. }
  78. close($mh);
  79. }
  80. sub scanman_md_dir {
  81. my ($d) = @_;
  82. opendir(my $dh, $d) ||
  83. die "Can't opendir: $!";
  84. my @mans = grep { /.md\z/ } readdir($dh);
  85. closedir $dh;
  86. for my $m (@mans) {
  87. checkmanpage("$d/$m");
  88. }
  89. }
  90. scanman_md_dir("$root/docs/libcurl");
  91. scanman_md_dir("$root/docs/libcurl/opts");
  92. open my $s, "<", "$root/docs/libcurl/symbols-in-versions";
  93. while(<$s>) {
  94. if(/(^[^ \n]+) +(.*)/) {
  95. my ($sym, $rest)=($1, $2);
  96. my @a=split(/ +/, $rest);
  97. push @syms, $sym;
  98. $symadded{$sym}=$a[0];
  99. }
  100. }
  101. close $s;
  102. my $ignored=0;
  103. for my $e (sort @syms) {
  104. if( $manpage{$e} ) {
  105. if( $manpage{$e} ne $symadded{$e} ) {
  106. printf "%s.md says version %s, but SIV says %s\n",
  107. $e, $manpage{$e}, $symadded{$e};
  108. $error++;
  109. }
  110. }
  111. }
  112. print "OK\n" if(!$error);
  113. exit $error;