#!/usr/bin/env perl #*************************************************************************** # _ _ ____ _ # Project ___| | | | _ \| | # / __| | | | |_) | | # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # # Copyright (C) Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at https://curl.se/docs/copyright.html. # # You may opt to use, copy, modify, merge, publish, distribute and/or sell # copies of the Software, and permit persons to whom the Software is # furnished to do so, under the terms of the COPYING file. # # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # KIND, either express or implied. # # SPDX-License-Identifier: curl # # ########################################################################### # # Check that the deprecated statuses of functions and enum values in header # files, manpages and symbols-in-versions are in sync. use strict; use warnings; use File::Basename; my $root=$ARGV[0] || "."; my $incdir = "$root/include/curl"; my $docdir = "$root/docs"; my $libdocdir = "$docdir/libcurl"; my $errcode = 0; # Symbol-indexed hashes. # Values are: # X Not deprecated # ? Deprecated in unknown version # x.yy.z Deprecated in version x.yy.z my %syminver; # Symbols-in-versions deprecations. my %hdr; # Public header files deprecations. my %funcman; # Function manpages deprecations. my %optman; # Option manpages deprecations. # Scan header file for public function and enum values. Flag them with # the version they are deprecated in, if some. sub scan_header { my ($f)=@_; my $line = ""; my $incomment = 0; my $inenum = 0; open(my $h, "<", "$f"); while(<$h>) { s/^\s*(.*?)\s*$/$1/; # Trim. # Remove multi-line comment trail. if($incomment) { if($_ !~ /.*?\*\/\s*(.*)$/) { next; } $_ = $1; $incomment = 0; } if($line ne "") { # Unfold line. $_ = "$line $1"; $line = ""; } # Remove comments. while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) { $_ = "$1 $2"; } if($_ =~ /^(.*)\/\*/) { $_ = "$1 "; $incomment = 1; } s/^\s*(.*?)\s*$/$1/; # Trim again. # Ignore preprocessor directives and blank lines. if($_ =~ /^(?:#|$)/) { next; } # Handle lines that may be continued as if they were folded. if($_ !~ /[;,{}]$/) { # Folded line. $line = $_; next; } if($_ =~ /CURLOPTDEPRECATED\(/) { # Handle deprecated CURLOPT_* option. if($_ !~ /CURLOPTDEPRECATED\(\s*(\S+)\s*,(?:.*?,){2}\s*(.*?)\s*,.*"\)/) { # Folded line. $line = $_; next; } $hdr{$1} = $2; } elsif($_ =~ /CURLOPT\(/) { # Handle non-deprecated CURLOPT_* option. if($_ !~ /CURLOPT\(\s*(\S+)\s*(?:,.*?){2}\)/) { # Folded line. $line = $_; next; } $hdr{$1} = "X"; } else { my $version = "X"; # Get other kind of deprecation from this line. if($_ =~ /CURL_DEPRECATED\(/) { if($_ !~ /^(.*)CURL_DEPRECATED\(\s*(\S+?)\s*,.*?"\)(.*)$/) { # Folded line. $line = $_; next; } $version = $2; $_ = "$1 $3"; } if($_ =~ /^CURL_EXTERN\s+.*\s+(\S+?)\s*\(/) { # Flag public function. $hdr{$1} = $version; } elsif($inenum && $_ =~ /(\w+)\s*[,=}]/) { # Flag enum value. $hdr{$1} = $version; } } # Remember if we are in an enum definition. $inenum |= ($_ =~ /\benum\b/); if($_ =~ /}/) { $inenum = 0; } } close $h; } # Scan function manpage for options. # Each option has to be declared as ".IP