mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
Verify if lines are not longer than 192 characters. Also verify if lines have less than 79 repeat spaces (and fix one fallout). To improve readability by avoiding long lines and to prevent adding overly long lines with text that may go unnoticed in an editor or diff viewer. In addition to pre-existing line length limits: 79 for C, 132 for CMake sources. Also: - spacecheck: fix/harden allowlist regexes. - spacecheck: tidy-up quotes and simplify escaping. - spacecheck: allow folding strings with repeat spaces. - GHA: fix a suppressed shellcheck warning. - GHA/macos: simplify by dropping brew bundle. - test1119.pl: precompile a regex. - FAQ.md: delete very long link to a Windows 7/2008 support article that's lost it relevance. Closes #21087
88 lines
2.2 KiB
Perl
Executable File
88 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;
|