kernel-doc (8ad72163165265b686902c182c1b4a913e738a81) kernel-doc (1081de2d2f9179d7280926e37b7b22b4f2fb32e6)
1#!/usr/bin/env perl
2
3use warnings;
4use strict;
5
6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
8## Copyright (C) 2001 Simon Huggins ##

--- 989 unchanged lines hidden (view full) ---

998
999sub dump_union($$) {
1000 dump_struct(@_);
1001}
1002
1003sub dump_struct($$) {
1004 my $x = shift;
1005 my $file = shift;
1#!/usr/bin/env perl
2
3use warnings;
4use strict;
5
6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
8## Copyright (C) 2001 Simon Huggins ##

--- 989 unchanged lines hidden (view full) ---

998
999sub dump_union($$) {
1000 dump_struct(@_);
1001}
1002
1003sub dump_struct($$) {
1004 my $x = shift;
1005 my $file = shift;
1006 my $nested;
1007
1008 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
1009 my $decl_type = $1;
1010 $declaration_name = $2;
1011 my $members = $3;
1012
1013 # ignore members marked private:
1014 $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;

--- 43 unchanged lines hidden (view full) ---

1058 }
1059 $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
1060 $cont = 1;
1061 };
1062 };
1063
1064 # Ignore other nested elements, like enums
1065 $members =~ s/({[^\{\}]*})//g;
1006
1007 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
1008 my $decl_type = $1;
1009 $declaration_name = $2;
1010 my $members = $3;
1011
1012 # ignore members marked private:
1013 $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;

--- 43 unchanged lines hidden (view full) ---

1057 }
1058 $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
1059 $cont = 1;
1060 };
1061 };
1062
1063 # Ignore other nested elements, like enums
1064 $members =~ s/({[^\{\}]*})//g;
1066 $nested = $decl_type;
1067 $nested =~ s/\/\*.*?\*\///gos;
1068
1069 create_parameterlist($members, ';', $file);
1065
1066 create_parameterlist($members, ';', $file);
1070 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);
1067 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
1071
1072 # Adjust declaration for better display
1073 $declaration =~ s/([{;])/$1\n/g;
1074 $declaration =~ s/}\s+;/};/g;
1075 # Better handle inlined enums
1076 do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/);
1077
1078 my @def_args = split /\n/, $declaration;

--- 288 unchanged lines hidden (view full) ---

1367 # so just weaken the string compare in check_sections() to ignore
1368 # "[blah" in a parameter string;
1369 ###$param =~ s/\s*//g;
1370 push @parameterlist, $param;
1371 $type =~ s/\s\s+/ /g;
1372 $parametertypes{$param} = $type;
1373}
1374
1068
1069 # Adjust declaration for better display
1070 $declaration =~ s/([{;])/$1\n/g;
1071 $declaration =~ s/}\s+;/};/g;
1072 # Better handle inlined enums
1073 do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/);
1074
1075 my @def_args = split /\n/, $declaration;

--- 288 unchanged lines hidden (view full) ---

1364 # so just weaken the string compare in check_sections() to ignore
1365 # "[blah" in a parameter string;
1366 ###$param =~ s/\s*//g;
1367 push @parameterlist, $param;
1368 $type =~ s/\s\s+/ /g;
1369 $parametertypes{$param} = $type;
1370}
1371
1375sub check_sections($$$$$$) {
1376 my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_;
1372sub check_sections($$$$$) {
1373 my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck) = @_;
1377 my @sects = split ' ', $sectcheck;
1378 my @prms = split ' ', $prmscheck;
1379 my $err;
1380 my ($px, $sx);
1381 my $prm_clean; # strip trailing "[array size]" and/or beginning "*"
1382
1383 foreach $sx (0 .. $#sects) {
1384 $err = 1;

--- 17 unchanged lines hidden (view full) ---

1402 }
1403 if ($err) {
1404 if ($decl_type eq "function") {
1405 print STDERR "${file}:$.: warning: " .
1406 "Excess function parameter " .
1407 "'$sects[$sx]' " .
1408 "description in '$decl_name'\n";
1409 ++$warnings;
1374 my @sects = split ' ', $sectcheck;
1375 my @prms = split ' ', $prmscheck;
1376 my $err;
1377 my ($px, $sx);
1378 my $prm_clean; # strip trailing "[array size]" and/or beginning "*"
1379
1380 foreach $sx (0 .. $#sects) {
1381 $err = 1;

--- 17 unchanged lines hidden (view full) ---

1399 }
1400 if ($err) {
1401 if ($decl_type eq "function") {
1402 print STDERR "${file}:$.: warning: " .
1403 "Excess function parameter " .
1404 "'$sects[$sx]' " .
1405 "description in '$decl_name'\n";
1406 ++$warnings;
1410 } else {
1411 if ($nested !~ m/\Q$sects[$sx]\E/) {
1412 print STDERR "${file}:$.: warning: " .
1413 "Excess $decl_type member " .
1414 "'$sects[$sx]' " .
1415 "description in '$decl_name'\n";
1416 ++$warnings;
1417 }
1418 }
1419 }
1420 }
1421}
1422
1423##
1424# Checks the section describing the return value of a function.
1425sub check_return_section {

--- 94 unchanged lines hidden (view full) ---

1520
1521 create_parameterlist($args, ',', $file);
1522 } else {
1523 print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n";
1524 return;
1525 }
1526
1527 my $prms = join " ", @parameterlist;
1407 }
1408 }
1409 }
1410}
1411
1412##
1413# Checks the section describing the return value of a function.
1414sub check_return_section {

--- 94 unchanged lines hidden (view full) ---

1509
1510 create_parameterlist($args, ',', $file);
1511 } else {
1512 print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n";
1513 return;
1514 }
1515
1516 my $prms = join " ", @parameterlist;
1528 check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
1517 check_sections($file, $declaration_name, "function", $sectcheck, $prms);
1529
1530 # This check emits a lot of warnings at the moment, because many
1531 # functions don't have a 'Return' doc section. So until the number
1532 # of warnings goes sufficiently down, the check is only performed in
1533 # verbose mode.
1534 # TODO: always perform the check.
1535 if ($verbose && !$noret) {
1536 check_return_section($file, $declaration_name, $return_type);

--- 563 unchanged lines hidden ---
1518
1519 # This check emits a lot of warnings at the moment, because many
1520 # functions don't have a 'Return' doc section. So until the number
1521 # of warnings goes sufficiently down, the check is only performed in
1522 # verbose mode.
1523 # TODO: always perform the check.
1524 if ($verbose && !$noret) {
1525 check_return_section($file, $declaration_name, $return_type);

--- 563 unchanged lines hidden ---