docs/libcurl: make examples build with picky compiler options

Found by improving verify-examples.pl:

- Operate directly on markdown files to remove the need to render nroff files
  first.

- Add -Wall as a compiler option to find more issues

Closes #17028
This commit is contained in:
Daniel Stenberg 2025-04-11 14:40:48 +02:00
parent d9a86b6729
commit 960984263f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
24 changed files with 48 additions and 45 deletions

View file

@ -29,12 +29,12 @@ my $check = "./scripts/checksrc.pl";
my $error;
if($files[0] eq "-h") {
print "Usage: verify-synopsis [man pages]\n";
print "Usage: verify-examples [markdown pages]\n";
exit;
}
sub testcompile {
my $rc = system("gcc -c test.c -DCURL_DISABLE_TYPECHECK -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_DEPRECATION -Wunused -Werror -Wno-unused-but-set-variable -I include") >> 8;
my $rc = system("gcc -c test.c -DCURL_DISABLE_TYPECHECK -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_DEPRECATION -Wunused -Werror -Wall -Wno-unused-but-set-variable -I include") >> 8;
return $rc;
}
@ -54,11 +54,11 @@ sub extract {
print O "#include <curl/curl.h>\n";
while(<F>) {
$iline++;
if(/^.SH EXAMPLE/) {
if(/^# EXAMPLE/) {
$syn = 1
}
elsif($syn == 1) {
if(/^.nf/) {
if(/^~~~/) {
$syn++;
print O "/* !checksrc! disable UNUSEDIGNORE all */\n";
print O "/* !checksrc! disable COPYRIGHT all */\n";
@ -67,16 +67,7 @@ sub extract {
}
}
elsif($syn == 2) {
if(/^.fi/) {
last;
}
if(/(?<!\\)(?:\\{2})*\\(?!\\)/) {
print STDERR
"Error while processing file $f line $iline:\n$_" .
"Error: Single backslashes \\ are not properly shown in " .
"manpage EXAMPLE output unless they are escaped \\\\.\n";
$fail = 1;
$error = 1;
if(/^~~~/) {
last;
}
# two backslashes become one