]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/begin-end-check.pl
Enhance --enable-tunables to select tunables frontend at build time
[thirdparty/glibc.git] / scripts / begin-end-check.pl
CommitLineData
5ef5cbb6
UD
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6# Check __BEGIN_NAMESPACE ... __END_NAMESPACE pairing in an include file.
7
8my $code = 0;
9for my $path (@ARGV) {
10 my $localcode = 0;
11 my @stack;
12
13 open my $in, '<', $path
14 or die "open $path failed: $!";
15
16 while (<$in>) {
17 if ( /^\s*__BEGIN_(.*)\b/ ) {
18 push @stack, $1;
19 }
20 elsif ( /^\s*__END_(.*)\b/ ) {
21 if (@stack) {
22 my $tag = pop @stack;
23 if ($1 ne $tag) {
24 print "$path:$.: BEGIN $tag paired with END $1\n";
25 $localcode = 1;
26 }
27 }
28 else {
29 print "$path:$.: END $1 does not match a begin\n";
30 $localcode = 1;
31 }
32 }
33 }
34
35 if (@stack) {
36 print "$path: Unmatched begin tags " . join (' ', @stack) ."\n";
37 $localcode = 1;
38 }
39
40 if ($localcode == 0) {
41 print "$path: OK\n";
42 } else {
43 $code = $localcode;
44 }
45}
46
47exit $code;