kernel-doc (1081de2d2f9179d7280926e37b7b22b4f2fb32e6) | kernel-doc (151c468b44a89a9f3173ab8575690014b7249893) |
---|---|
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 ## --- 1049 unchanged lines hidden (view full) --- 1058 $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/; 1059 $cont = 1; 1060 }; 1061 }; 1062 1063 # Ignore other nested elements, like enums 1064 $members =~ s/({[^\{\}]*})//g; 1065 | 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 ## --- 1049 unchanged lines hidden (view full) --- 1058 $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/; 1059 $cont = 1; 1060 }; 1061 }; 1062 1063 # Ignore other nested elements, like enums 1064 $members =~ s/({[^\{\}]*})//g; 1065 |
1066 create_parameterlist($members, ';', $file); | 1066 create_parameterlist($members, ';', $file, $declaration_name); |
1067 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); 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 --- 92 unchanged lines hidden (view full) --- 1167 if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ || 1168 $x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) { 1169 1170 # Function typedefs 1171 $return_type = $1; 1172 $declaration_name = $2; 1173 my $args = $3; 1174 | 1067 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); 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 --- 92 unchanged lines hidden (view full) --- 1167 if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ || 1168 $x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) { 1169 1170 # Function typedefs 1171 $return_type = $1; 1172 $declaration_name = $2; 1173 my $args = $3; 1174 |
1175 create_parameterlist($args, ',', $file); | 1175 create_parameterlist($args, ',', $file, $declaration_name); |
1176 1177 output_declaration($declaration_name, 1178 'function', 1179 {'function' => $declaration_name, 1180 'typedef' => 1, 1181 'module' => $modulename, 1182 'functiontype' => $return_type, 1183 'parameterlist' => \@parameterlist, --- 32 unchanged lines hidden (view full) --- 1216sub save_struct_actual($) { 1217 my $actual = shift; 1218 1219 # strip all spaces from the actual param so that it looks like one string item 1220 $actual =~ s/\s*//g; 1221 $struct_actual = $struct_actual . $actual . " "; 1222} 1223 | 1176 1177 output_declaration($declaration_name, 1178 'function', 1179 {'function' => $declaration_name, 1180 'typedef' => 1, 1181 'module' => $modulename, 1182 'functiontype' => $return_type, 1183 'parameterlist' => \@parameterlist, --- 32 unchanged lines hidden (view full) --- 1216sub save_struct_actual($) { 1217 my $actual = shift; 1218 1219 # strip all spaces from the actual param so that it looks like one string item 1220 $actual =~ s/\s*//g; 1221 $struct_actual = $struct_actual . $actual . " "; 1222} 1223 |
1224sub create_parameterlist($$$) { | 1224sub create_parameterlist($$$$) { |
1225 my $args = shift; 1226 my $splitter = shift; 1227 my $file = shift; | 1225 my $args = shift; 1226 my $splitter = shift; 1227 my $file = shift; |
1228 my $declaration_name = shift; |
|
1228 my $type; 1229 my $param; 1230 1231 # temporarily replace commas inside function pointer definition 1232 while ($args =~ /(\([^\),]+),/) { 1233 $args =~ s/(\([^\),]+),/$1#/g; 1234 } 1235 --- 13 unchanged lines hidden (view full) --- 1249 } elsif ($arg =~ m/\(.+\)\s*\(/) { 1250 # pointer-to-function 1251 $arg =~ tr/#/,/; 1252 $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/; 1253 $param = $1; 1254 $type = $arg; 1255 $type =~ s/([^\(]+\(\*?)\s*$param/$1/; 1256 save_struct_actual($param); | 1229 my $type; 1230 my $param; 1231 1232 # temporarily replace commas inside function pointer definition 1233 while ($args =~ /(\([^\),]+),/) { 1234 $args =~ s/(\([^\),]+),/$1#/g; 1235 } 1236 --- 13 unchanged lines hidden (view full) --- 1250 } elsif ($arg =~ m/\(.+\)\s*\(/) { 1251 # pointer-to-function 1252 $arg =~ tr/#/,/; 1253 $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/; 1254 $param = $1; 1255 $type = $arg; 1256 $type =~ s/([^\(]+\(\*?)\s*$param/$1/; 1257 save_struct_actual($param); |
1257 push_parameter($param, $type, $file); | 1258 push_parameter($param, $type, $file, $declaration_name); |
1258 } elsif ($arg) { 1259 $arg =~ s/\s*:\s*/:/g; 1260 $arg =~ s/\s*\[/\[/g; 1261 1262 my @args = split('\s*,\s*', $arg); 1263 if ($args[0] =~ m/\*/) { 1264 $args[0] =~ s/(\*+)\s*/ $1/; 1265 } --- 8 unchanged lines hidden (view full) --- 1274 } 1275 1276 unshift(@args, pop @first_arg); 1277 $type = join " ", @first_arg; 1278 1279 foreach $param (@args) { 1280 if ($param =~ m/^(\*+)\s*(.*)/) { 1281 save_struct_actual($2); | 1259 } elsif ($arg) { 1260 $arg =~ s/\s*:\s*/:/g; 1261 $arg =~ s/\s*\[/\[/g; 1262 1263 my @args = split('\s*,\s*', $arg); 1264 if ($args[0] =~ m/\*/) { 1265 $args[0] =~ s/(\*+)\s*/ $1/; 1266 } --- 8 unchanged lines hidden (view full) --- 1275 } 1276 1277 unshift(@args, pop @first_arg); 1278 $type = join " ", @first_arg; 1279 1280 foreach $param (@args) { 1281 if ($param =~ m/^(\*+)\s*(.*)/) { 1282 save_struct_actual($2); |
1282 push_parameter($2, "$type $1", $file); | 1283 push_parameter($2, "$type $1", $file, $declaration_name); |
1283 } 1284 elsif ($param =~ m/(.*?):(\d+)/) { 1285 if ($type ne "") { # skip unnamed bit-fields 1286 save_struct_actual($1); | 1284 } 1285 elsif ($param =~ m/(.*?):(\d+)/) { 1286 if ($type ne "") { # skip unnamed bit-fields 1287 save_struct_actual($1); |
1287 push_parameter($1, "$type:$2", $file) | 1288 push_parameter($1, "$type:$2", $file, $declaration_name) |
1288 } 1289 } 1290 else { 1291 save_struct_actual($param); | 1289 } 1290 } 1291 else { 1292 save_struct_actual($param); |
1292 push_parameter($param, $type, $file); | 1293 push_parameter($param, $type, $file, $declaration_name); |
1293 } 1294 } 1295 } 1296 } 1297} 1298 | 1294 } 1295 } 1296 } 1297 } 1298} 1299 |
1299sub push_parameter($$$) { | 1300sub push_parameter($$$$) { |
1300 my $param = shift; 1301 my $type = shift; 1302 my $file = shift; | 1301 my $param = shift; 1302 my $type = shift; 1303 my $file = shift; |
1304 my $declaration_name = shift; |
|
1303 1304 if (($anon_struct_union == 1) && ($type eq "") && 1305 ($param eq "}")) { 1306 return; # ignore the ending }; from anon. struct/union 1307 } 1308 1309 $anon_struct_union = 0; 1310 $param =~ s/[\[\)].*//; --- 20 unchanged lines hidden (view full) --- 1331 $param = "{unnamed_" . $param . "}"; 1332 $parameterdescs{$param} = "anonymous\n"; 1333 $anon_struct_union = 1; 1334 } 1335 1336 # warn if parameter has no description 1337 # (but ignore ones starting with # as these are not parameters 1338 # but inline preprocessor statements); | 1305 1306 if (($anon_struct_union == 1) && ($type eq "") && 1307 ($param eq "}")) { 1308 return; # ignore the ending }; from anon. struct/union 1309 } 1310 1311 $anon_struct_union = 0; 1312 $param =~ s/[\[\)].*//; --- 20 unchanged lines hidden (view full) --- 1333 $param = "{unnamed_" . $param . "}"; 1334 $parameterdescs{$param} = "anonymous\n"; 1335 $anon_struct_union = 1; 1336 } 1337 1338 # warn if parameter has no description 1339 # (but ignore ones starting with # as these are not parameters 1340 # but inline preprocessor statements); |
1339 # also ignore unnamed structs/unions; 1340 if (!$anon_struct_union) { | 1341 # Note: It will also ignore void params and unnamed structs/unions |
1341 if (!defined $parameterdescs{$param} && $param !~ /^#/) { | 1342 if (!defined $parameterdescs{$param} && $param !~ /^#/) { |
1343 $parameterdescs{$param} = $undescribed; |
|
1342 | 1344 |
1343 $parameterdescs{$param} = $undescribed; 1344 1345 if (($type eq 'function') || ($type eq 'enum')) { 1346 print STDERR "${file}:$.: warning: Function parameter ". 1347 "or member '$param' not " . 1348 "described in '$declaration_name'\n"; 1349 } 1350 print STDERR "${file}:$.: warning:" . 1351 " No description found for parameter '$param'\n"; 1352 ++$warnings; | 1345 print STDERR 1346 "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; 1347 ++$warnings; |
1353 } | 1348 } |
1354 } | |
1355 1356 $param = xml_escape($param); 1357 1358 # strip spaces from $param so that it is one continuous string 1359 # on @parameterlist; 1360 # this fixes a problem where check_sections() cannot find 1361 # a parameter like "addr[6 + 2]" because it actually appears 1362 # as "addr[6", "+", "2]" on the parameter list; --- 139 unchanged lines hidden (view full) --- 1502 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1503 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1504 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1505 $prototype =~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { 1506 $return_type = $1; 1507 $declaration_name = $2; 1508 my $args = $3; 1509 | 1349 1350 $param = xml_escape($param); 1351 1352 # strip spaces from $param so that it is one continuous string 1353 # on @parameterlist; 1354 # this fixes a problem where check_sections() cannot find 1355 # a parameter like "addr[6 + 2]" because it actually appears 1356 # as "addr[6", "+", "2]" on the parameter list; --- 139 unchanged lines hidden (view full) --- 1496 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1497 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1498 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1499 $prototype =~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { 1500 $return_type = $1; 1501 $declaration_name = $2; 1502 my $args = $3; 1503 |
1510 create_parameterlist($args, ',', $file); | 1504 create_parameterlist($args, ',', $file, $declaration_name); |
1511 } else { 1512 print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n"; 1513 return; 1514 } 1515 1516 my $prms = join " ", @parameterlist; 1517 check_sections($file, $declaration_name, "function", $sectcheck, $prms); 1518 --- 570 unchanged lines hidden --- | 1505 } else { 1506 print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n"; 1507 return; 1508 } 1509 1510 my $prms = join " ", @parameterlist; 1511 check_sections($file, $declaration_name, "function", $sectcheck, $prms); 1512 --- 570 unchanged lines hidden --- |