curl/.github/scripts/verify-synopsis.pl
Viktor Szakats 84c5dcdb05
tidy-up: syntax and code nits
- cmp-pkg-config.sh: replace `-r -f` with `-rf` to match rest of repo.
- configure.ac: add double quotes for robustness (not a bug).
- curl-openssl.m4: merge nested `if`s.
- CurlTests.c: drop `!= 0`, also to sync with m4.
- CurlTests.c: replace `example.com` with `localhost` in
  `gethostbyname()` feature test code. (compile-only, not a bug)
- GHA/http3-linux: drop literal `true` from bool expression.
- lib650: drop redundant `&`.
- move variable/call to left-hand side of equality checks, where
  missing.
- perl: detach `<`/`>` from filename in `open()`, where missing.
- schannel: apply two nit fixes lost in rebase.
- scripts/verify-release: drop redundant double quotes.
- scripts/verify-release: exit with error code on error.
- synctime: replace magic numbers with `sizeof()`.
- telnet: add missing parentheses to macro value.
- tests/Makefile.am: use single quotes.
- tool_operate: drop redundant `break` after `return` in VMS code.
- unit2413: drop unused NULL pointer + free call.
- unit2413: fix duplicate test case name.
- urlapi: drop redundant parentheses.
- urlapi: drop `CURL_UNCONST()` that became redundant.

Closes #22186
2026-06-26 15:45:24 +02:00

87 lines
2.2 KiB
Perl
Executable file

#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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
#
###########################################################################
use strict;
use warnings;
my @files = @ARGV;
my $cfile = "test.c";
if(!@files || $files[0] eq "-h") {
print "Usage: verify-synopsis [man pages]\n";
exit;
}
sub testcompile {
my $rc = system('gcc -c test.c -I include -W -Wall -pedantic -Werror ' .
'-DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_TYPECHECK') >> 8;
return $rc;
}
sub extract {
my($f) = @_;
my $syn = 0;
my $l = 0;
my $iline = 0;
open(F, "<", $f);
open(O, ">", $cfile);
while(<F>) {
$iline++;
if(/^# SYNOPSIS/) {
$syn = 1
}
elsif($syn == 1) {
if(/^\~\~\~/) {
$syn++;
print O "#line $iline \"$f\"\n";
}
}
elsif($syn == 2) {
if(/^\~\~\~/) {
last;
}
# turn the vararg argument into vararg
$_ =~ s/, parameter\)\;/, ...);/;
print O $_;
$l++;
}
}
close(F);
close(O);
if($syn < 2) {
print STDERR "Found no synopsis in $f\n";
return 1;
}
return 0;
}
my $error;
for my $m (@files) {
$error |= extract($m);
$error |= testcompile($m);
}
exit $error;