lib: move all UNITTEST prototypes to C files

- make extract-unit-protos handle multi-line prototypes - but they need
  to be above the implementation

- Prototypes for static functions we use in unit tests should not be in
  header files. We generate lib/unitprotos.h for this purpose

- Removed some function wrappers written for unit tests and make them
  use UNITTEST function directly.

- Renamed time2str() in the tool to timebuf() since we have the same
  name in lib/ and in unit tests they can both be used non-static in a
  build.

This reverts commit f95fadd116.

Follow-up to #21010

Closes #21014
This commit is contained in:
Daniel Stenberg 2026-03-19 17:04:00 +01:00
parent 7242cea7f6
commit 98d8e82c74
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
42 changed files with 109 additions and 149 deletions

View file

@ -27,15 +27,38 @@ use strict;
use warnings;
my @proto;
my %func;
my %inc;
sub scanfile {
my ($file) = @_;
open(F, "<$file") || die "$file failed";
my $unit = 0;
while(<F>) {
if($_ =~ /^UNITTEST .*\);/) {
push @proto, $_;
$inc{$file} = 1;
if($_ =~ /^UNITTEST .*[* ]([a-z0-9_]+)\(/i) {
my $n = $1;
if($func{$n}) {
# already prototyped, this is now the function itself
}
else {
$func{$n} = 1;
push @proto, $_;
$inc{$file} = 1;
$unit = 1;
}
}
if($unit) {
if($unit != 1) {
push @proto, $_;
}
if($_ =~ /\);/) {
# end of proto
$unit = 0;
}
else {
# proto continues
$unit++;
}
}
}
close(F);