mirror of
https://github.com/curl/curl.git
synced 2025-03-31 16:00:35 +08:00
CI: verify libcurl function SYNPOSIS sections
With the .github/scripits/verify-synopsis.pl script Closes #12402
This commit is contained in:
parent
ad1dfc594f
commit
e7112a726b
81
.github/scripts/verify-synopsis.pl
vendored
Executable file
81
.github/scripts/verify-synopsis.pl
vendored
Executable file
@ -0,0 +1,81 @@
|
||||
#!/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
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
my @files = @ARGV;
|
||||
my $cfile = "test.c";
|
||||
|
||||
if($files[0] eq "-h") {
|
||||
print "Usage: verify-synopsis [man pages]\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
sub testcompile {
|
||||
my $rc = system("gcc -c test.c -DCURL_DISABLE_TYPECHECK -DCURL_ALLOW_OLD_MULTI_SOCKET -I include") >> 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(/^.SH SYNOPSIS/) {
|
||||
$syn = 1
|
||||
}
|
||||
elsif($syn == 1) {
|
||||
if(/^.nf/) {
|
||||
$syn++;
|
||||
print O "#line $iline \"$f\"\n";
|
||||
}
|
||||
}
|
||||
elsif($syn == 2) {
|
||||
if(/^.fi/) {
|
||||
last;
|
||||
}
|
||||
# turn the vararg argument into vararg
|
||||
$_ =~ s/, parameter\)\;/, ...);/;
|
||||
print O $_;
|
||||
$l++;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
close(O);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $error;
|
||||
for my $m (@files) {
|
||||
print "Verify $m\n";
|
||||
extract($m);
|
||||
$error |= testcompile($m);
|
||||
}
|
||||
exit $error;
|
||||
|
28
.github/workflows/synopsis.yml
vendored
Normal file
28
.github/workflows/synopsis.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
|
||||
name: SYNOPSIS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- '*/ci'
|
||||
paths:
|
||||
- 'docs/libcurl/curl_*.3'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'docs/libcurl/curl_*.3'
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: verify-synopsis
|
||||
run: ./.github/scripts/verify-synopsis.pl docs/libcurl/curl*.3
|
Loading…
x
Reference in New Issue
Block a user