From 8ed817e84e3a24b5902416718cf445009a032ea9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 6 Dec 2023 09:40:30 +0100 Subject: [PATCH] dist: add tests/errorcodes.pl to the tarball Used by test 1477 Reported-by: Xi Ruoyao Follow-up to 0ca3a4ec9a7 Fixes #12462 Closes #12463 (cherry picked from commit da8c1d15782c8161b455a7ee90197c16ae5edb90) also include missing tests/errorcodes.pl Signed-off-by: Jan Macku --- tests/Makefile.am | 20 ++++----- tests/errorcodes.pl | 99 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 9 deletions(-) create mode 100755 tests/errorcodes.pl diff --git a/tests/Makefile.am b/tests/Makefile.am index 17e9ad049..c6ae7a97a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,15 +26,17 @@ HTMLPAGES = testcurl.html runtests.html PDFPAGES = testcurl.pdf runtests.pdf MANDISTPAGES = runtests.1.dist testcurl.1.dist -EXTRA_DIST = appveyor.pm azure.pm badsymbols.pl check-deprecated.pl CMakeLists.txt \ - devtest.pl dictserver.py directories.pm disable-scan.pl error-codes.pl extern-scan.pl FILEFORMAT.md \ - processhelp.pm ftpserver.pl getpart.pm globalconfig.pm http-server.pl http2-server.pl \ - http3-server.pl manpage-scan.pl manpage-syntax.pl markdown-uppercase.pl mem-include-scan.pl \ - memanalyze.pl negtelnetserver.py nroff-scan.pl option-check.pl options-scan.pl \ - pathhelp.pm README.md rtspserver.pl runner.pm runtests.1 runtests.pl secureserver.pl \ - serverhelp.pm servers.pm smbserver.py sshhelp.pm sshserver.pl stunnel.pem symbol-scan.pl \ - testcurl.1 testcurl.pl testutil.pm tftpserver.pl util.py valgrind.pm \ - valgrind.supp version-scan.pl check-translatable-options.pl +EXTRA_DIST = appveyor.pm azure.pm badsymbols.pl check-deprecated.pl \ + CMakeLists.txt devtest.pl dictserver.py directories.pm disable-scan.pl \ + error-codes.pl extern-scan.pl FILEFORMAT.md processhelp.pm ftpserver.pl \ + getpart.pm globalconfig.pm http-server.pl http2-server.pl http3-server.pl \ + manpage-scan.pl manpage-syntax.pl markdown-uppercase.pl mem-include-scan.pl \ + memanalyze.pl negtelnetserver.py nroff-scan.pl option-check.pl \ + options-scan.pl pathhelp.pm README.md rtspserver.pl runner.pm runtests.1 \ + runtests.pl secureserver.pl serverhelp.pm servers.pm smbserver.py sshhelp.pm \ + sshserver.pl stunnel.pem symbol-scan.pl testcurl.1 testcurl.pl testutil.pm \ + tftpserver.pl util.py valgrind.pm valgrind.supp version-scan.pl \ + check-translatable-options.pl errorcodes.pl DISTCLEANFILES = configurehelp.pm diff --git a/tests/errorcodes.pl b/tests/errorcodes.pl new file mode 100755 index 000000000..9c8f9e882 --- /dev/null +++ b/tests/errorcodes.pl @@ -0,0 +1,99 @@ +#!/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 libcurl-errors.3 and the public header files have the same set of +# error codes. + +use strict; +use warnings; + +# we may get the dir roots pointed out +my $root=$ARGV[0] || "."; +my $manpge = "$root/docs/libcurl/libcurl-errors.3"; +my $curlh = "$root/include/curl"; +my $errors=0; + +my @hnames; +my %wherefrom; +my @mnames; +my %manfrom; + +sub scanheader { + my ($file)=@_; + open H, "<$file"; + my $line = 0; + while() { + $line++; + if($_ =~ /^ (CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { + my ($name)=($1); + if(($name !~ /OBSOLETE/) && ($name !~ /_LAST\z/)) { + push @hnames, $name; + if($wherefrom{$name}) { + print STDERR "double: $name\n"; + } + $wherefrom{$name}="$file:$line"; + } + } + } + close(H); +} + +sub scanmanpage { + my ($file)=@_; + open H, "<$file"; + my $line = 0; + while() { + $line++; + if($_ =~ /^\.IP \"(CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { + my ($name)=($1); + push @mnames, $name; + $manfrom{$name}="$file:$line"; + } + } + close(H); +} + + +opendir(my $dh, $curlh) || die "Can't opendir $curlh: $!"; +my @hfiles = grep { /\.h$/ } readdir($dh); +closedir $dh; + +for(sort @hfiles) { + scanheader("$curlh/$_"); +} +scanmanpage($manpge); + +print "Result\n"; +for my $h (sort @hnames) { + if(!$manfrom{$h}) { + printf "$h from %s, not in man page\n", $wherefrom{$h}; + } +} + +for my $m (sort @mnames) { + if(!$wherefrom{$m}) { + printf "$m from %s, not in any header\n", $manfrom{$m}; + } +} -- 2.43.0