6 $standard = "XOPEN2K8";
9 GetOptions ('headers=s' => \@headers, 'standard=s' => \$standard,
10 'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir);
11 @headers = split(/,/,join(',',@headers));
13 # List of the headers we are testing.
15 @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
16 "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "uchar.h",
17 "time.h", "tgmath.h", "termios.h", "tar.h", "sys/wait.h",
18 "sys/utsname.h", "sys/un.h", "sys/uio.h", "sys/types.h",
19 "sys/times.h", "sys/timeb.h", "sys/time.h", "sys/statvfs.h",
20 "sys/stat.h", "sys/socket.h", "sys/shm.h", "sys/sem.h",
21 "sys/select.h", "sys/resource.h", "sys/msg.h", "sys/mman.h",
22 "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", "string.h",
23 "stdlib.h", "stdio.h", "stdint.h", "stddef.h", "stdarg.h",
24 "spawn.h", "signal.h", "setjmp.h", "semaphore.h", "search.h",
25 "sched.h", "regex.h", "pwd.h", "pthread.h", "poll.h",
26 "nl_types.h", "netinet/tcp.h", "netinet/in.h", "net/if.h",
27 "netdb.h", "ndbm.h", "mqueue.h", "monetary.h", "math.h",
28 "locale.h", "libgen.h", "limits.h", "langinfo.h", "iso646.h",
29 "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h", "fnmatch.h",
30 "fmtmsg.h", "float.h", "fcntl.h", "errno.h", "dlfcn.h",
31 "dirent.h", "ctype.h", "cpio.h", "complex.h", "assert.h",
32 "arpa/inet.h", "aio.h");
35 $CFLAGS{"ISO"} = "-ansi";
36 $CFLAGS{"ISO99"} = "-std=c99";
37 $CFLAGS{"ISO11"} = "-std=c1x -D_ISOC11_SOURCE";
38 $CFLAGS{"POSIX"} = "-D_POSIX_C_SOURCE=199912 -ansi";
39 $CFLAGS{"XPG3"} = "-ansi -D_XOPEN_SOURCE";
40 $CFLAGS{"XPG4"} = "-ansi -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";
41 $CFLAGS{"UNIX98"} = "-ansi -D_XOPEN_SOURCE=500";
42 $CFLAGS{"XOPEN2K"} = "-std=c99 -D_XOPEN_SOURCE=600";
43 $CFLAGS{"XOPEN2K8"} = "-std=c99 -D_XOPEN_SOURCE=700";
44 $CFLAGS{"POSIX2008"} = "-std=c99 -D_POSIX_C_SOURCE=200809L";
46 $CFLAGS = "$flags -fno-builtin '-D__attribute__(x)=' $CFLAGS{$standard} -D_ISOMAC";
48 # Check standard name for validity.
49 die "unknown standard \"$standard\"" if ($CFLAGS{$standard} eq "");
51 # if ($standard ne "XOPEN2K8" && $standard ne "POSIX2008") {
52 # # Some headers need a bit more attention. At least with XPG7
53 # # all headers should be self-contained.
54 # $mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
55 # $mustprepend{'glob.h'} = "#include <sys/types.h>\n";
56 # $mustprepend{'grp.h'} = "#include <sys/types.h>\n";
57 # $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
58 # $mustprepend{'pwd.h'} = "#include <sys/types.h>\n";
59 # $mustprepend{'sched.h'} = "#include <sys/types.h>\n";
60 # $mustprepend{'signal.h'} = "#include <pthread.h>\n#include <sys/types.h>\n";
61 # $mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
62 # $mustprepend{'sys/stat.h'} = "#include <sys/types.h>\n";
63 # $mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
64 # $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
67 # These are the ISO C99 keywords.
68 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
69 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
70 'if', 'inline', 'int', 'long', 'register', 'restrict', 'return',
71 'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
72 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
74 # Make a hash table from this information.
75 while ($#keywords >= 0) {
76 $iskeyword{pop (@keywords)} = 1;
87 my($pattern, $string) = @_;
88 my($strlen) = length ($string);
91 if (substr ($pattern, 0, 1) eq '*') {
92 my($patlen) = length ($pattern) - 1;
93 $res = ($strlen >= $patlen
94 && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
95 } elsif (substr ($pattern, -1, 1) eq '*') {
96 if (substr ($pattern, -2, 1) eq ']') {
97 my($patlen) = index ($pattern, '[');
98 my($range) = substr ($pattern, $patlen + 1, -2);
99 $res = ($strlen > $patlen
100 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen)
101 && index ($range, substr ($string, $patlen, 1)) != -1);
103 my($patlen) = length ($pattern) - 1;
104 $res = ($strlen >= $patlen
105 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
108 $res = $pattern eq $string;
116 my($fnamebase, $msg, $errmsg, $skip, $optional) = @_;
127 $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
129 if ($optional != 0) {
130 printf (" $errmsg\n");
135 printf (" $errmsg Compiler message:\n");
143 if ($verbose > 1 && -s "$fnamebase.out") {
144 # We print all warnings issued.
148 if ($printlog != 0) {
149 printf (" " . "-" x 71 . "\n");
150 open (MESSAGE, "< $fnamebase.out");
155 printf (" " . "-" x 71 . "\n");
158 unlink "$fnamebase.c";
159 unlink "$fnamebase.o";
160 unlink "$fnamebase.out";
168 my($fnamebase, $msg, $errmsg, $skip) = @_;
179 $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
183 printf (" $errmsg Compiler message:\n");
189 # Now run the program. If the exit code is not zero something is wrong.
190 $result = system "$fnamebase > $fnamebase.out2 2>&1";
193 if ($verbose > 1 && -s "$fnamebase.out") {
194 # We print all warnings issued.
196 system "cat $fnamebase.out2 >> $fnamebase.out";
202 unlink "$fnamebase.out";
203 rename "$fnamebase.out2", "$fnamebase.out";
206 if ($printlog != 0) {
207 printf (" " . "-" x 71 . "\n");
208 open (MESSAGE, "< $fnamebase.out");
213 printf (" " . "-" x 71 . "\n");
217 unlink "$fnamebase.c";
218 unlink "$fnamebase.o";
219 unlink "$fnamebase.out";
220 unlink "$fnamebase.out2";
227 my($token, @allow) = @_;
230 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
232 for ($idx = 0; $idx <= $#allow; ++$idx) {
233 return if (poorfnmatch ($allow[$idx], $token));
242 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
244 if (exists $errors{$token}) {
245 undef $errors{$token};
251 my($h, $fnamebase, @allow) = @_;
255 # Generate a program to get the contents of this header.
256 open (TESTFILE, ">$fnamebase.c");
257 print TESTFILE "#include <$h>\n";
262 open (CONTENT, "$CC $CFLAGS -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
263 loop: while (<CONTENT>) {
265 if (/^#define (.*)/) {
266 newtoken ($1, @allow);
267 } elsif (/^#undef (.*)/) {
270 # We have to tokenize the line.
273 my($len) = length ($str);
275 foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
277 newtoken ($token, @allow);
283 unlink "$fnamebase.c";
286 # Sort the output list so it's easier to compare results with diff.
287 foreach $f (sort keys(%errors)) {
288 if ($errors{$f} == 1) {
289 if ($realerror == 0) {
290 printf ("FAIL\n " . "-" x 72 . "\n");
294 printf (" Namespace violation: \"%s\"\n", $f);
297 printf (" " . "-" x 72 . "\n") if ($realerror != 0);
300 if ($realerror == 0) {
306 while ($#headers >= 0) {
307 my($h) = pop (@headers);
310 my($fnamebase) = "$tmpdir/$hf-test";
313 my(@allowheader) = ();
314 my(%seenheader) = ();
315 my($prepend) = $mustprepend{$h};
318 printf ("Testing <$h>\n");
319 printf ("----------" . "-" x length ($h) . "\n");
321 open (CONTROL, "$CC -E -D$standard -x c data/$h-data |");
322 control: while (<CONTROL>) {
324 next control if (/^#/);
325 next control if (/^[ ]*$/);
329 # Generate a program to test for the availability of this header.
330 open (TESTFILE, ">$fnamebase.c");
331 print TESTFILE "$prepend";
332 print TESTFILE "#include <$h>\n";
335 $missing = compiletest ($fnamebase, "Checking whether <$h> is available",
336 "Header <$h> not available", 0, 0);
338 last control if ($missing);
346 if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
347 my($struct) = "$2$3";
353 # Remember that this name is allowed.
354 push @allow, $member;
356 # Generate a program to test for the availability of this member.
357 open (TESTFILE, ">$fnamebase.c");
358 print TESTFILE "$prepend";
359 print TESTFILE "#include <$h>\n";
360 print TESTFILE "$struct a;\n";
361 print TESTFILE "$struct b;\n";
362 print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
363 print TESTFILE "void foobarbaz (void) {\n";
364 print TESTFILE " xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
365 print TESTFILE "}\n";
368 $res = compiletest ($fnamebase, "Testing for member $member",
371 : "Member \"$member\" not available."), $res,
374 if ($res == 0 || $missing != 0 || !$optional) {
375 # Test the types of the members.
376 open (TESTFILE, ">$fnamebase.c");
377 print TESTFILE "$prepend";
378 print TESTFILE "#include <$h>\n";
379 print TESTFILE "$struct a;\n";
380 print TESTFILE "extern $type b$rest;\n";
381 print TESTFILE "extern __typeof__ (a.$member) b;\n";
384 compiletest ($fnamebase, "Testing for type of member $member",
385 "Member \"$member\" does not have the correct type.",
388 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
389 my($symbol_type) = $1;
395 my($mres) = $missing;
396 my($cres) = $missing;
398 # Remember that this name is allowed.
399 push @allow, $symbol;
401 if ($symbol_type =~ /macro/) {
402 # Generate a program to test for availability of this macro.
403 open (TESTFILE, ">$fnamebase.c");
404 print TESTFILE "$prepend";
405 print TESTFILE "#include <$h>\n";
406 print TESTFILE "#ifndef $symbol\n";
407 print TESTFILE "# error \"Macro $symbol not defined\"\n";
408 print TESTFILE "#endif\n";
411 $mres = compiletest ($fnamebase, "Test availability of macro $symbol",
414 : "Macro \"$symbol\" is not available."), $res,
418 if ($symbol_type =~ /constant/) {
419 # Generate a program to test for the availability of this constant.
420 open (TESTFILE, ">$fnamebase.c");
421 print TESTFILE "$prepend";
422 print TESTFILE "#include <$h>\n";
423 print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
426 $cres = compiletest ($fnamebase, "Testing for constant $symbol",
429 : "Constant \"$symbol\" not available."), $res,
433 $res = $res || $mres || $cres;
435 if ($symbol_type eq "macro-int-constant" && ($res == 0 || !$optional)) {
436 # Test that the symbol is usable in #if.
437 open (TESTFILE, ">$fnamebase.c");
438 print TESTFILE "$prepend";
439 print TESTFILE "#include <$h>\n";
440 print TESTFILE "#if $symbol < 0\n";
441 print TESTFILE "# define conformtest_negative 1\n";
443 for (my $i = 0; $i < 63; $i++) {
444 print TESTFILE "# if $symbol & (1LL << $i)\n";
445 print TESTFILE "# define conformtest_bit_$i 0LL\n";
446 print TESTFILE "# else\n";
447 print TESTFILE "# define conformtest_bit_$i (1LL << $i)\n";
448 print TESTFILE "# endif\n";
449 $s .= "|conformtest_bit_$i";
451 print TESTFILE "# define conformtest_value ~($s)\n";
452 print TESTFILE "#else\n";
453 print TESTFILE "# define conformtest_negative 0\n";
455 for (my $i = 0; $i < 64; $i++) {
456 print TESTFILE "# if $symbol & (1ULL << $i)\n";
457 print TESTFILE "# define conformtest_bit_$i (1ULL << $i)\n";
458 print TESTFILE "# else\n";
459 print TESTFILE "# define conformtest_bit_$i 0ULL\n";
460 print TESTFILE "# endif\n";
461 $s .= "|conformtest_bit_$i";
463 print TESTFILE "# define conformtest_value ($s)\n";
464 print TESTFILE "#endif\n";
465 print TESTFILE "int main (void) { return !((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value)); }\n";
468 runtest ($fnamebase, "Testing for #if usability of symbol $symbol",
469 "Symbol \"$symbol\" not usable in #if.", $res);
472 if (defined ($type) && ($res == 0 || !$optional)) {
473 # Test the type of the symbol.
474 open (TESTFILE, ">$fnamebase.c");
475 print TESTFILE "$prepend";
476 print TESTFILE "#include <$h>\n";
477 if ($type =~ /^promoted:/) {
478 $type =~ s/^promoted://;
479 print TESTFILE "__typeof__ (($type) 0 + ($type) 0) a;\n";
481 print TESTFILE "__typeof__ (($type) 0) a;\n";
483 print TESTFILE "extern __typeof__ ($symbol) a;\n";
486 compiletest ($fnamebase, "Testing for type of symbol $symbol",
487 "Symbol \"$symbol\" does not have the correct type.",
491 if (defined ($op) && ($res == 0 || !$optional)) {
492 # Generate a program to test for the value of this symbol.
493 open (TESTFILE, ">$fnamebase.c");
494 print TESTFILE "$prepend";
495 print TESTFILE "#include <$h>\n";
496 # Negate the value since 0 means ok
497 print TESTFILE "int main (void) { return !($symbol $op $value); }\n";
500 $res = runtest ($fnamebase, "Testing for value of symbol $symbol",
501 "Symbol \"$symbol\" has not the right value.", $res);
503 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
508 # Remember that this name is allowed.
509 push @allow, $symbol;
511 # Generate a program to test for the availability of this constant.
512 open (TESTFILE, ">$fnamebase.c");
513 print TESTFILE "$prepend";
514 print TESTFILE "#include <$h>\n";
515 print TESTFILE "void foobarbaz (void) {\n";
516 print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
517 print TESTFILE "}\n";
520 $res = compiletest ($fnamebase, "Testing for symbol $symbol",
521 "Symbol \"$symbol\" not available.", $res, 0);
524 # Generate a program to test for the value of this constant.
525 open (TESTFILE, ">$fnamebase.c");
526 print TESTFILE "$prepend";
527 print TESTFILE "#include <$h>\n";
528 print TESTFILE "int main (void) { return $symbol != $value; }\n";
531 $res = runtest ($fnamebase, "Testing for value of symbol $symbol",
532 "Symbol \"$symbol\" has not the right value.", $res);
534 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
536 my($maybe_opaque) = 0;
538 # Remember that this name is allowed.
539 if ($type =~ /^struct *(.*)/) {
541 } elsif ($type =~ /^union *(.*)/) {
548 # Generate a program to test for the availability of this type.
549 open (TESTFILE, ">$fnamebase.c");
550 print TESTFILE "$prepend";
551 print TESTFILE "#include <$h>\n";
552 if ($maybe_opaque == 1) {
553 print TESTFILE "$type *a;\n";
555 print TESTFILE "$type a;\n";
559 compiletest ($fnamebase, "Testing for type $type",
562 : "Type \"$type\" not available."), $missing, $optional);
563 } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) {
566 # Remember that this name is allowed.
567 if ($type =~ /^struct *(.*)/) {
569 } elsif ($type =~ /^union *(.*)/) {
575 # Generate a program to test for the availability of this type.
576 open (TESTFILE, ">$fnamebase.c");
577 print TESTFILE "$prepend";
578 print TESTFILE "#include <$h>\n";
579 print TESTFILE "$type;\n";
582 compiletest ($fnamebase, "Testing for type $type",
583 "Type \"$type\" not available.", $missing, 0);
584 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
585 my($rettype) = "$2$3";
590 # Remember that this name is allowed.
593 # Generate a program to test for availability of this function.
594 open (TESTFILE, ">$fnamebase.c");
595 print TESTFILE "$prepend";
596 print TESTFILE "#include <$h>\n";
597 # print TESTFILE "#undef $fname\n";
598 print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
601 $res = compiletest ($fnamebase, "Test availability of function $fname",
604 : "Function \"$fname\" is not available."), $res,
607 if ($res == 0 || $missing == 1 || !$optional) {
608 # Generate a program to test for the type of this function.
609 open (TESTFILE, ">$fnamebase.c");
610 print TESTFILE "$prepend";
611 print TESTFILE "#include <$h>\n";
612 # print TESTFILE "#undef $fname\n";
613 print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
614 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
617 compiletest ($fnamebase, "Test for type of function $fname",
618 "Function \"$fname\" has incorrect type.", $res, 0);
620 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
621 my($rettype) = "$2$3";
626 # Remember that this name is allowed.
629 # Generate a program to test for availability of this function.
630 open (TESTFILE, ">$fnamebase.c");
631 print TESTFILE "$prepend";
632 print TESTFILE "#include <$h>\n";
633 # print TESTFILE "#undef $fname\n";
634 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
637 $res = compiletest ($fnamebase, "Test availability of function $fname",
640 : "Function \"$fname\" is not available."), $res,
643 if ($res == 0 || $missing != 0 || !$optional) {
644 # Generate a program to test for the type of this function.
645 open (TESTFILE, ">$fnamebase.c");
646 print TESTFILE "$prepend";
647 print TESTFILE "#include <$h>\n";
648 # print TESTFILE "#undef $fname\n";
649 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
650 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
653 compiletest ($fnamebase, "Test for type of function $fname",
654 "Function \"$fname\" has incorrect type.", $res, 0);
656 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
662 # Remember that this name is allowed.
665 # Generate a program to test for availability of this function.
666 open (TESTFILE, ">$fnamebase.c");
667 print TESTFILE "$prepend";
668 print TESTFILE "#include <$h>\n";
669 # print TESTFILE "#undef $fname\n";
670 print TESTFILE "typedef $type xyzzy$rest;\n";
671 print TESTFILE "$xyzzy *foobarbaz = &$vname;\n";
674 $res = compiletest ($fnamebase, "Test availability of variable $vname",
675 "Variable \"$vname\" is not available.", $res, 0);
677 # Generate a program to test for the type of this function.
678 open (TESTFILE, ">$fnamebase.c");
679 print TESTFILE "$prepend";
680 print TESTFILE "#include <$h>\n";
681 # print TESTFILE "#undef $fname\n";
682 print TESTFILE "extern $type $vname$rest;\n";
685 compiletest ($fnamebase, "Test for type of variable $fname",
686 "Variable \"$vname\" has incorrect type.", $res, 0);
687 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
688 my($rettype) = "$2$3";
693 # Remember that this name is allowed.
696 # Generate a program to test for availability of this function.
697 open (TESTFILE, ">$fnamebase.c");
698 print TESTFILE "$prepend";
699 print TESTFILE "#include <$h>\n";
700 print TESTFILE "#ifndef $fname\n";
701 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
702 print TESTFILE "#endif\n";
705 $res = compiletest ($fnamebase, "Test availability of macro $fname",
706 "Function \"$fname\" is not available.", $res, 0);
708 # Generate a program to test for the type of this function.
709 open (TESTFILE, ">$fnamebase.c");
710 print TESTFILE "$prepend";
711 print TESTFILE "#include <$h>\n";
712 print TESTFILE "#ifndef $fname\n";
713 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
714 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
715 print TESTFILE "#endif\n";
718 compiletest ($fnamebase, "Test for type of macro $fname",
719 "Function \"$fname\" has incorrect type.", $res, 0);
720 } elsif (/^macro-str *([^ ]*) *(\".*\")/) {
721 # The above regex doesn't handle a \" in a string.
726 # Remember that this name is allowed.
729 # Generate a program to test for availability of this macro.
730 open (TESTFILE, ">$fnamebase.c");
731 print TESTFILE "$prepend";
732 print TESTFILE "#include <$h>\n";
733 print TESTFILE "#ifndef $macro\n";
734 print TESTFILE "# error \"Macro $macro not defined\"\n";
735 print TESTFILE "#endif\n";
738 compiletest ($fnamebase, "Test availability of macro $macro",
739 "Macro \"$macro\" is not available.", $missing, 0);
741 # Generate a program to test for the value of this macro.
742 open (TESTFILE, ">$fnamebase.c");
743 print TESTFILE "$prepend";
744 print TESTFILE "#include <$h>\n";
745 # We can't include <string.h> here.
746 print TESTFILE "extern int (strcmp)(const char *, const char *);\n";
747 print TESTFILE "int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
750 $res = runtest ($fnamebase, "Testing for value of macro $macro",
751 "Macro \"$macro\" has not the right value.", $res);
752 } elsif (/^allow-header *(.*)/) {
754 if ($seenheader{$pattern} != 1) {
755 push @allowheader, $pattern;
756 $seenheader{$pattern} = 1;
759 } elsif (/^allow *(.*)/) {
761 push @allow, $pattern;
764 # printf ("line is `%s'\n", $_);
772 # Read the data files for the header files which are allowed to be included.
773 while ($#allowheader >= 0) {
774 my($ah) = pop @allowheader;
776 open (ALLOW, "$CC -E -D$standard - < data/$ah-data |");
777 acontrol: while (<ALLOW>) {
779 next acontrol if (/^#/);
780 next acontrol if (/^[ ]*$/);
782 if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
784 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
786 } elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
789 # Remember that this name is allowed.
790 if ($type =~ /^struct *(.*)/) {
792 } elsif ($type =~ /^union *(.*)/) {
797 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
799 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
801 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
803 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
805 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
807 } elsif (/^allow-header *(.*)/) {
808 if ($seenheader{$1} != 1) {
809 push @allowheader, $1;
812 } elsif (/^allow *(.*)/) {
820 printf (" Not defined\n");
822 # Now check the namespace.
823 printf (" Checking the namespace of \"%s\"... ", $h);
828 checknamespace ($h, $fnamebase, @allow);
835 printf "-" x 76 . "\n";
836 printf (" Total number of tests : %4d\n", $total);
838 printf (" Number of failed tests : %4d (", $errors);
839 $percent = ($errors * 100) / $total;
840 if ($errors > 0 && $percent < 1.0) {
843 printf ("%3d%%)\n", $percent);
846 printf (" Number of skipped tests : %4d (", $skipped);
847 $percent = ($skipped * 100) / $total;
848 if ($skipped > 0 && $percent < 1.0) {
851 printf ("%3d%%)\n", $percent);
856 # perl-indent-level: 2