version-scan.pl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. # Verify that curl_version_info.3 documents all the CURL_VERSION_ bits
  27. # from the header.
  28. #
  29. use strict;
  30. use warnings;
  31. my $manpage=$ARGV[0];
  32. my $header=$ARGV[1];
  33. my $source=$ARGV[2];
  34. my %manversion;
  35. my %headerversion;
  36. my %manname;
  37. my %sourcename;
  38. my $error=0;
  39. open(my $m, "<", "$manpage");
  40. while(<$m>) {
  41. if($_ =~ / mask bit: (CURL_VERSION_[A-Z0-9_]+)/i) {
  42. $manversion{$1}++;
  43. }
  44. if($_ =~ /^\.ip """([^"]+)"""/i) {
  45. $manname{$1}++;
  46. }
  47. }
  48. close($m);
  49. open(my $h, "<", "$header");
  50. while(<$h>) {
  51. if($_ =~ /^\#define (CURL_VERSION_[A-Z0-9_]+)/i) {
  52. $headerversion{$1}++;
  53. }
  54. }
  55. close($h);
  56. open(my $s, "<", "$source");
  57. while(<$s>) {
  58. if($_ =~ /FEATURE\("([^"]*)"/) {
  59. $sourcename{$1}++;
  60. }
  61. }
  62. close($s);
  63. for my $h (keys %headerversion) {
  64. if(!$manversion{$h}) {
  65. print STDERR "$manpage: missing $h\n";
  66. $error++;
  67. }
  68. }
  69. for my $h (keys %manversion) {
  70. if(!$headerversion{$h}) {
  71. print STDERR "$manpage: $h is not in the header!\n";
  72. $error++;
  73. }
  74. }
  75. for my $n (keys %sourcename) {
  76. if(!$manname{$n}) {
  77. print STDERR "$manpage: missing feature name $n\n";
  78. $error++;
  79. }
  80. }
  81. for my $n (keys %manname) {
  82. if(!$sourcename{$n}) {
  83. print STDERR "$manpage: $n is not in the source!\n";
  84. $error++;
  85. }
  86. }
  87. exit $error;