diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
commit | 2886df93860f983d875b7d6acb418faa31491d5a (patch) | |
tree | b596ddcbb70247c1994f3b1d8ba9e793b9788a9d /debian/tests/find_unused_functions | |
parent | Adding upstream version 2.4.57+dfsg. (diff) | |
download | openldap-debian/2.4.57+dfsg-3+deb11u1.tar.xz openldap-debian/2.4.57+dfsg-3+deb11u1.zip |
Adding debian version 2.4.57+dfsg-3+deb11u1.debian/2.4.57+dfsg-3+deb11u1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/find_unused_functions')
-rwxr-xr-x | debian/tests/find_unused_functions | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/debian/tests/find_unused_functions b/debian/tests/find_unused_functions new file mode 100755 index 0000000..bd31d45 --- /dev/null +++ b/debian/tests/find_unused_functions @@ -0,0 +1,30 @@ +#! /usr/bin/perl -w + +use autouse Data::Dumper, qw{Dumper}; + +# Script to find the unused shell functions in slapd.scripts-common + +our @code; + +# Get all shell code from maintainer scripts + +foreach my $file ((<slapd.*rm>, <slapd.*inst>, <slapd.config>, + <slapd.scripts-common>)) { + open SCRIPT, "<$file" or + die "Can't open $file: $!"; + push @code, <SCRIPT>; + close SCRIPT; +} + +# Find all function declarations + +our @functions = map { /^(\w+)\s*\(\).*$/; } @code; + +# Find unused functions + +foreach $function (@functions) { + @occurences = grep /$function/, @code; + @invocations = grep { !/^$function\s*\(\)/ and !/#.*$function/ } + @occurences; + print "$function\n" if @invocations == 0; +} |