aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc140
1 files changed, 85 insertions, 55 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8be269ffbf9d..a325a0c890dc 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -159,7 +159,8 @@ my $warnings = 0;
159my $type_constant = '\%([-_\w]+)'; 159my $type_constant = '\%([-_\w]+)';
160my $type_func = '(\w+)\(\)'; 160my $type_func = '(\w+)\(\)';
161my $type_param = '\@(\w+)'; 161my $type_param = '\@(\w+)';
162my $type_struct = '\&((struct\s*)?[_\w]+)'; 162my $type_struct = '\&((struct\s*)*[_\w]+)';
163my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)';
163my $type_env = '(\$\w+)'; 164my $type_env = '(\$\w+)';
164 165
165# Output conversion substitutions. 166# Output conversion substitutions.
@@ -168,7 +169,8 @@ my $type_env = '(\$\w+)';
168# these work fairly well 169# these work fairly well
169my %highlights_html = ( $type_constant, "<i>\$1</i>", 170my %highlights_html = ( $type_constant, "<i>\$1</i>",
170 $type_func, "<b>\$1</b>", 171 $type_func, "<b>\$1</b>",
171 $type_struct, "<i>\$1</i>", 172 $type_struct_xml, "<i>\$1</i>",
173 $type_env, "<b><i>\$1</i></b>",
172 $type_param, "<tt><b>\$1</b></tt>" ); 174 $type_param, "<tt><b>\$1</b></tt>" );
173my $blankline_html = "<p>"; 175my $blankline_html = "<p>";
174 176
@@ -326,12 +328,21 @@ while ($ARGV[0] =~ m/^-(.*)/) {
326 } 328 }
327} 329}
328 330
331# get kernel version from env
332sub get_kernel_version() {
333 my $version;
334
335 if (defined($ENV{'KERNELVERSION'})) {
336 $version = $ENV{'KERNELVERSION'};
337 }
338 return $version;
339}
329 340
330# generate a sequence of code that will splice in highlighting information 341# generate a sequence of code that will splice in highlighting information
331# using the s// operator. 342# using the s// operator.
332my $dohighlight = ""; 343my $dohighlight = "";
333foreach my $pattern (keys %highlights) { 344foreach my $pattern (keys %highlights) {
334# print "scanning pattern $pattern ($highlights{$pattern})\n"; 345# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
335 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; 346 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
336} 347}
337 348
@@ -378,13 +389,19 @@ sub output_highlight {
378# confess "output_highlight got called with no args?\n"; 389# confess "output_highlight got called with no args?\n";
379# } 390# }
380 391
392# print STDERR "contents b4:$contents\n";
381 eval $dohighlight; 393 eval $dohighlight;
382 die $@ if $@; 394 die $@ if $@;
395 if ($output_mode eq "html") {
396 $contents =~ s/\\\\//;
397 }
398# print STDERR "contents af:$contents\n";
399
383 foreach $line (split "\n", $contents) { 400 foreach $line (split "\n", $contents) {
384 if ($line eq ""){ 401 if ($line eq ""){
385 print $lineprefix, $blankline; 402 print $lineprefix, $blankline;
386 } else { 403 } else {
387 $line =~ s/\\\\\\/\&/g; 404 $line =~ s/\\\\\\/\&/g;
388 print $lineprefix, $line; 405 print $lineprefix, $line;
389 } 406 }
390 print "\n"; 407 print "\n";
@@ -414,7 +431,7 @@ sub output_enum_html(%) {
414 print "<b>enum ".$args{'enum'}."</b> {<br>\n"; 431 print "<b>enum ".$args{'enum'}."</b> {<br>\n";
415 $count = 0; 432 $count = 0;
416 foreach $parameter (@{$args{'parameterlist'}}) { 433 foreach $parameter (@{$args{'parameterlist'}}) {
417 print " <b>".$parameter."</b>"; 434 print " <b>".$parameter."</b>";
418 if ($count != $#{$args{'parameterlist'}}) { 435 if ($count != $#{$args{'parameterlist'}}) {
419 $count++; 436 $count++;
420 print ",\n"; 437 print ",\n";
@@ -462,15 +479,16 @@ sub output_struct_html(%) {
462 my $parameter_name = $parameter; 479 my $parameter_name = $parameter;
463 $parameter_name =~ s/\[.*//; 480 $parameter_name =~ s/\[.*//;
464 481
465 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 482 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
466 $type = $args{'parametertypes'}{$parameter}; 483 $type = $args{'parametertypes'}{$parameter};
467 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { 484 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
468 # pointer-to-function 485 # pointer-to-function
469 print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n"; 486 print "&nbsp; &nbsp; <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
470 } elsif ($type =~ m/^(.*?)\s*(:.*)/) { 487 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
471 print " <i>$1</i> <b>$parameter</b>$2;<br>\n"; 488 # bitfield
489 print "&nbsp; &nbsp; <i>$1</i> <b>$parameter</b>$2;<br>\n";
472 } else { 490 } else {
473 print " <i>$type</i> <b>$parameter</b>;<br>\n"; 491 print "&nbsp; &nbsp; <i>$type</i> <b>$parameter</b>;<br>\n";
474 } 492 }
475 } 493 }
476 print "};<br>\n"; 494 print "};<br>\n";
@@ -483,7 +501,7 @@ sub output_struct_html(%) {
483 my $parameter_name = $parameter; 501 my $parameter_name = $parameter;
484 $parameter_name =~ s/\[.*//; 502 $parameter_name =~ s/\[.*//;
485 503
486 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 504 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
487 print "<dt><b>".$parameter."</b>\n"; 505 print "<dt><b>".$parameter."</b>\n";
488 print "<dd>"; 506 print "<dd>";
489 output_highlight($args{'parameterdescs'}{$parameter_name}); 507 output_highlight($args{'parameterdescs'}{$parameter_name});
@@ -525,7 +543,7 @@ sub output_function_html(%) {
525 my $parameter_name = $parameter; 543 my $parameter_name = $parameter;
526 $parameter_name =~ s/\[.*//; 544 $parameter_name =~ s/\[.*//;
527 545
528 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 546 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
529 print "<dt><b>".$parameter."</b>\n"; 547 print "<dt><b>".$parameter."</b>\n";
530 print "<dd>"; 548 print "<dd>";
531 output_highlight($args{'parameterdescs'}{$parameter_name}); 549 output_highlight($args{'parameterdescs'}{$parameter_name});
@@ -592,6 +610,7 @@ sub output_function_xml(%) {
592 print "<refmeta>\n"; 610 print "<refmeta>\n";
593 print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n"; 611 print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n";
594 print " <manvolnum>9</manvolnum>\n"; 612 print " <manvolnum>9</manvolnum>\n";
613 print " <refmiscinfo class=\"version\">" . get_kernel_version() . "</refmiscinfo>\n";
595 print "</refmeta>\n"; 614 print "</refmeta>\n";
596 print "<refnamediv>\n"; 615 print "<refnamediv>\n";
597 print " <refname>".$args{'function'}."</refname>\n"; 616 print " <refname>".$args{'function'}."</refname>\n";
@@ -668,6 +687,7 @@ sub output_struct_xml(%) {
668 print "<refmeta>\n"; 687 print "<refmeta>\n";
669 print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n"; 688 print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
670 print " <manvolnum>9</manvolnum>\n"; 689 print " <manvolnum>9</manvolnum>\n";
690 print " <refmiscinfo class=\"version\">" . get_kernel_version() . "</refmiscinfo>\n";
671 print "</refmeta>\n"; 691 print "</refmeta>\n";
672 print "<refnamediv>\n"; 692 print "<refnamediv>\n";
673 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n"; 693 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
@@ -691,7 +711,7 @@ sub output_struct_xml(%) {
691 $parameter_name =~ s/\[.*//; 711 $parameter_name =~ s/\[.*//;
692 712
693 defined($args{'parameterdescs'}{$parameter_name}) || next; 713 defined($args{'parameterdescs'}{$parameter_name}) || next;
694 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 714 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
695 $type = $args{'parametertypes'}{$parameter}; 715 $type = $args{'parametertypes'}{$parameter};
696 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { 716 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
697 # pointer-to-function 717 # pointer-to-function
@@ -752,6 +772,7 @@ sub output_enum_xml(%) {
752 print "<refmeta>\n"; 772 print "<refmeta>\n";
753 print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n"; 773 print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n";
754 print " <manvolnum>9</manvolnum>\n"; 774 print " <manvolnum>9</manvolnum>\n";
775 print " <refmiscinfo class=\"version\">" . get_kernel_version() . "</refmiscinfo>\n";
755 print "</refmeta>\n"; 776 print "</refmeta>\n";
756 print "<refnamediv>\n"; 777 print "<refnamediv>\n";
757 print " <refname>enum ".$args{'enum'}."</refname>\n"; 778 print " <refname>enum ".$args{'enum'}."</refname>\n";
@@ -767,11 +788,11 @@ sub output_enum_xml(%) {
767 print "enum ".$args{'enum'}." {\n"; 788 print "enum ".$args{'enum'}." {\n";
768 $count = 0; 789 $count = 0;
769 foreach $parameter (@{$args{'parameterlist'}}) { 790 foreach $parameter (@{$args{'parameterlist'}}) {
770 print " $parameter"; 791 print " $parameter";
771 if ($count != $#{$args{'parameterlist'}}) { 792 if ($count != $#{$args{'parameterlist'}}) {
772 $count++; 793 $count++;
773 print ","; 794 print ",";
774 } 795 }
775 print "\n"; 796 print "\n";
776 } 797 }
777 print "};"; 798 print "};";
@@ -1007,7 +1028,7 @@ sub output_enum_man(%) {
1007 print "enum ".$args{'enum'}." {\n"; 1028 print "enum ".$args{'enum'}." {\n";
1008 $count = 0; 1029 $count = 0;
1009 foreach my $parameter (@{$args{'parameterlist'}}) { 1030 foreach my $parameter (@{$args{'parameterlist'}}) {
1010 print ".br\n.BI \" $parameter\"\n"; 1031 print ".br\n.BI \" $parameter\"\n";
1011 if ($count == $#{$args{'parameterlist'}}) { 1032 if ($count == $#{$args{'parameterlist'}}) {
1012 print "\n};\n"; 1033 print "\n};\n";
1013 last; 1034 last;
@@ -1054,7 +1075,7 @@ sub output_struct_man(%) {
1054 my $parameter_name = $parameter; 1075 my $parameter_name = $parameter;
1055 $parameter_name =~ s/\[.*//; 1076 $parameter_name =~ s/\[.*//;
1056 1077
1057 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 1078 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1058 $type = $args{'parametertypes'}{$parameter}; 1079 $type = $args{'parametertypes'}{$parameter};
1059 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { 1080 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1060 # pointer-to-function 1081 # pointer-to-function
@@ -1077,7 +1098,7 @@ sub output_struct_man(%) {
1077 my $parameter_name = $parameter; 1098 my $parameter_name = $parameter;
1078 $parameter_name =~ s/\[.*//; 1099 $parameter_name =~ s/\[.*//;
1079 1100
1080 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 1101 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1081 print ".IP \"".$parameter."\" 12\n"; 1102 print ".IP \"".$parameter."\" 12\n";
1082 output_highlight($args{'parameterdescs'}{$parameter_name}); 1103 output_highlight($args{'parameterdescs'}{$parameter_name});
1083 } 1104 }
@@ -1187,7 +1208,7 @@ sub output_enum_text(%) {
1187 print "enum ".$args{'enum'}." {\n"; 1208 print "enum ".$args{'enum'}." {\n";
1188 $count = 0; 1209 $count = 0;
1189 foreach $parameter (@{$args{'parameterlist'}}) { 1210 foreach $parameter (@{$args{'parameterlist'}}) {
1190 print "\t$parameter"; 1211 print "\t$parameter";
1191 if ($count != $#{$args{'parameterlist'}}) { 1212 if ($count != $#{$args{'parameterlist'}}) {
1192 $count++; 1213 $count++;
1193 print ","; 1214 print ",";
@@ -1232,7 +1253,7 @@ sub output_struct_text(%) {
1232 my $parameter_name = $parameter; 1253 my $parameter_name = $parameter;
1233 $parameter_name =~ s/\[.*//; 1254 $parameter_name =~ s/\[.*//;
1234 1255
1235 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 1256 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1236 $type = $args{'parametertypes'}{$parameter}; 1257 $type = $args{'parametertypes'}{$parameter};
1237 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { 1258 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
1238 # pointer-to-function 1259 # pointer-to-function
@@ -1252,7 +1273,7 @@ sub output_struct_text(%) {
1252 my $parameter_name = $parameter; 1273 my $parameter_name = $parameter;
1253 $parameter_name =~ s/\[.*//; 1274 $parameter_name =~ s/\[.*//;
1254 1275
1255 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 1276 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
1256 print "$parameter\n\t"; 1277 print "$parameter\n\t";
1257 print $args{'parameterdescs'}{$parameter_name}."\n"; 1278 print $args{'parameterdescs'}{$parameter_name}."\n";
1258 } 1279 }
@@ -1284,7 +1305,7 @@ sub output_declaration {
1284 ( $function_only == 1 && defined($function_table{$name})) || 1305 ( $function_only == 1 && defined($function_table{$name})) ||
1285 ( $function_only == 2 && !defined($function_table{$name}))) 1306 ( $function_only == 2 && !defined($function_table{$name})))
1286 { 1307 {
1287 &$func(@_); 1308 &$func(@_);
1288 $section_counter++; 1309 $section_counter++;
1289 } 1310 }
1290} 1311}
@@ -1317,8 +1338,8 @@ sub dump_struct($$) {
1317 my $file = shift; 1338 my $file = shift;
1318 1339
1319 if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) { 1340 if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
1320 $declaration_name = $2; 1341 $declaration_name = $2;
1321 my $members = $3; 1342 my $members = $3;
1322 1343
1323 # ignore embedded structs or unions 1344 # ignore embedded structs or unions
1324 $members =~ s/{.*?}//g; 1345 $members =~ s/{.*?}//g;
@@ -1345,7 +1366,7 @@ sub dump_struct($$) {
1345 }); 1366 });
1346 } 1367 }
1347 else { 1368 else {
1348 print STDERR "Error(${file}:$.): Cannot parse struct or union!\n"; 1369 print STDERR "Error(${file}:$.): Cannot parse struct or union!\n";
1349 ++$errors; 1370 ++$errors;
1350 } 1371 }
1351} 1372}
@@ -1356,15 +1377,15 @@ sub dump_enum($$) {
1356 1377
1357 $x =~ s@/\*.*?\*/@@gos; # strip comments. 1378 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1358 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { 1379 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1359 $declaration_name = $1; 1380 $declaration_name = $1;
1360 my $members = $2; 1381 my $members = $2;
1361 1382
1362 foreach my $arg (split ',', $members) { 1383 foreach my $arg (split ',', $members) {
1363 $arg =~ s/^\s*(\w+).*/$1/; 1384 $arg =~ s/^\s*(\w+).*/$1/;
1364 push @parameterlist, $arg; 1385 push @parameterlist, $arg;
1365 if (!$parameterdescs{$arg}) { 1386 if (!$parameterdescs{$arg}) {
1366 $parameterdescs{$arg} = $undescribed; 1387 $parameterdescs{$arg} = $undescribed;
1367 print STDERR "Warning(${file}:$.): Enum value '$arg' ". 1388 print STDERR "Warning(${file}:$.): Enum value '$arg' ".
1368 "not described in enum '$declaration_name'\n"; 1389 "not described in enum '$declaration_name'\n";
1369 } 1390 }
1370 1391
@@ -1382,7 +1403,7 @@ sub dump_enum($$) {
1382 }); 1403 });
1383 } 1404 }
1384 else { 1405 else {
1385 print STDERR "Error(${file}:$.): Cannot parse enum!\n"; 1406 print STDERR "Error(${file}:$.): Cannot parse enum!\n";
1386 ++$errors; 1407 ++$errors;
1387 } 1408 }
1388} 1409}
@@ -1393,12 +1414,12 @@ sub dump_typedef($$) {
1393 1414
1394 $x =~ s@/\*.*?\*/@@gos; # strip comments. 1415 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1395 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) { 1416 while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
1396 $x =~ s/\(*.\)\s*;$/;/; 1417 $x =~ s/\(*.\)\s*;$/;/;
1397 $x =~ s/\[*.\]\s*;$/;/; 1418 $x =~ s/\[*.\]\s*;$/;/;
1398 } 1419 }
1399 1420
1400 if ($x =~ /typedef.*\s+(\w+)\s*;/) { 1421 if ($x =~ /typedef.*\s+(\w+)\s*;/) {
1401 $declaration_name = $1; 1422 $declaration_name = $1;
1402 1423
1403 output_declaration($declaration_name, 1424 output_declaration($declaration_name,
1404 'typedef', 1425 'typedef',
@@ -1410,7 +1431,7 @@ sub dump_typedef($$) {
1410 }); 1431 });
1411 } 1432 }
1412 else { 1433 else {
1413 print STDERR "Error(${file}:$.): Cannot parse typedef!\n"; 1434 print STDERR "Error(${file}:$.): Cannot parse typedef!\n";
1414 ++$errors; 1435 ++$errors;
1415 } 1436 }
1416} 1437}
@@ -1424,14 +1445,14 @@ sub create_parameterlist($$$) {
1424 1445
1425 # temporarily replace commas inside function pointer definition 1446 # temporarily replace commas inside function pointer definition
1426 while ($args =~ /(\([^\),]+),/) { 1447 while ($args =~ /(\([^\),]+),/) {
1427 $args =~ s/(\([^\),]+),/$1#/g; 1448 $args =~ s/(\([^\),]+),/$1#/g;
1428 } 1449 }
1429 1450
1430 foreach my $arg (split($splitter, $args)) { 1451 foreach my $arg (split($splitter, $args)) {
1431 # strip comments 1452 # strip comments
1432 $arg =~ s/\/\*.*\*\///; 1453 $arg =~ s/\/\*.*\*\///;
1433 # strip leading/trailing spaces 1454 # strip leading/trailing spaces
1434 $arg =~ s/^\s*//; 1455 $arg =~ s/^\s*//;
1435 $arg =~ s/\s*$//; 1456 $arg =~ s/\s*$//;
1436 $arg =~ s/\s+/ /; 1457 $arg =~ s/\s+/ /;
1437 1458
@@ -1456,7 +1477,16 @@ sub create_parameterlist($$$) {
1456 if ($args[0] =~ m/\*/) { 1477 if ($args[0] =~ m/\*/) {
1457 $args[0] =~ s/(\*+)\s*/ $1/; 1478 $args[0] =~ s/(\*+)\s*/ $1/;
1458 } 1479 }
1459 my @first_arg = split('\s+', shift @args); 1480
1481 my @first_arg;
1482 if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) {
1483 shift @args;
1484 push(@first_arg, split('\s+', $1));
1485 push(@first_arg, $2);
1486 } else {
1487 @first_arg = split('\s+', shift @args);
1488 }
1489
1460 unshift(@args, pop @first_arg); 1490 unshift(@args, pop @first_arg);
1461 $type = join " ", @first_arg; 1491 $type = join " ", @first_arg;
1462 1492
@@ -1514,15 +1544,15 @@ sub push_parameter($$$) {
1514 $parameterdescs{$param_name} = $undescribed; 1544 $parameterdescs{$param_name} = $undescribed;
1515 1545
1516 if (($type eq 'function') || ($type eq 'enum')) { 1546 if (($type eq 'function') || ($type eq 'enum')) {
1517 print STDERR "Warning(${file}:$.): Function parameter ". 1547 print STDERR "Warning(${file}:$.): Function parameter ".
1518 "or member '$param' not " . 1548 "or member '$param' not " .
1519 "described in '$declaration_name'\n"; 1549 "described in '$declaration_name'\n";
1520 } 1550 }
1521 print STDERR "Warning(${file}:$.):". 1551 print STDERR "Warning(${file}:$.):".
1522 " No description found for parameter '$param'\n"; 1552 " No description found for parameter '$param'\n";
1523 ++$warnings; 1553 ++$warnings;
1524 } 1554 }
1525 } 1555 }
1526 1556
1527 push @parameterlist, $param; 1557 push @parameterlist, $param;
1528 $parametertypes{$param} = $type; 1558 $parametertypes{$param} = $type;
@@ -1664,10 +1694,10 @@ sub process_state3_function($$) {
1664 # do nothing 1694 # do nothing
1665 } 1695 }
1666 elsif ($x =~ /([^\{]*)/) { 1696 elsif ($x =~ /([^\{]*)/) {
1667 $prototype .= $1; 1697 $prototype .= $1;
1668 } 1698 }
1669 if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) { 1699 if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) {
1670 $prototype =~ s@/\*.*?\*/@@gos; # strip comments. 1700 $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
1671 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. 1701 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1672 $prototype =~ s@^\s+@@gos; # strip leading spaces 1702 $prototype =~ s@^\s+@@gos; # strip leading spaces
1673 dump_function($prototype,$file); 1703 dump_function($prototype,$file);
@@ -1688,17 +1718,17 @@ sub process_state3_type($$) {
1688 } 1718 }
1689 1719
1690 while (1) { 1720 while (1) {
1691 if ( $x =~ /([^{};]*)([{};])(.*)/ ) { 1721 if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1692 $prototype .= $1 . $2; 1722 $prototype .= $1 . $2;
1693 ($2 eq '{') && $brcount++; 1723 ($2 eq '{') && $brcount++;
1694 ($2 eq '}') && $brcount--; 1724 ($2 eq '}') && $brcount--;
1695 if (($2 eq ';') && ($brcount == 0)) { 1725 if (($2 eq ';') && ($brcount == 0)) {
1696 dump_declaration($prototype,$file); 1726 dump_declaration($prototype,$file);
1697 reset_state(); 1727 reset_state();
1698 last; 1728 last;
1699 } 1729 }
1700 $x = $3; 1730 $x = $3;
1701 } else { 1731 } else {
1702 $prototype .= $x; 1732 $prototype .= $x;
1703 last; 1733 last;
1704 } 1734 }
@@ -1756,7 +1786,7 @@ sub process_file($) {
1756 } else { 1786 } else {
1757 $section = $1; 1787 $section = $1;
1758 } 1788 }
1759 } 1789 }
1760 elsif (/$doc_decl/o) { 1790 elsif (/$doc_decl/o) {
1761 $identifier = $1; 1791 $identifier = $1;
1762 if (/\s*([\w\s]+?)\s*-/) { 1792 if (/\s*([\w\s]+?)\s*-/) {
@@ -1849,13 +1879,13 @@ sub process_file($) {
1849 } 1879 }
1850 } elsif ($state == 3) { # scanning for function '{' (end of prototype) 1880 } elsif ($state == 3) { # scanning for function '{' (end of prototype)
1851 if ($decl_type eq 'function') { 1881 if ($decl_type eq 'function') {
1852 process_state3_function($_, $file); 1882 process_state3_function($_, $file);
1853 } else { 1883 } else {
1854 process_state3_type($_, $file); 1884 process_state3_type($_, $file);
1855 } 1885 }
1856 } elsif ($state == 4) { 1886 } elsif ($state == 4) {
1857 # Documentation block 1887 # Documentation block
1858 if (/$doc_block/) { 1888 if (/$doc_block/) {
1859 dump_section($section, $contents); 1889 dump_section($section, $contents);
1860 output_intro({'sectionlist' => \@sectionlist, 1890 output_intro({'sectionlist' => \@sectionlist,
1861 'sections' => \%sections }); 1891 'sections' => \%sections });
@@ -1873,7 +1903,7 @@ sub process_file($) {
1873 } else { 1903 } else {
1874 $section = $1; 1904 $section = $1;
1875 } 1905 }
1876 } 1906 }
1877 elsif (/$doc_end/) 1907 elsif (/$doc_end/)
1878 { 1908 {
1879 dump_section($section, $contents); 1909 dump_section($section, $contents);
@@ -1900,8 +1930,8 @@ sub process_file($) {
1900 { 1930 {
1901 $contents .= $1 . "\n"; 1931 $contents .= $1 . "\n";
1902 } 1932 }
1903 } 1933 }
1904 } 1934 }
1905 } 1935 }
1906 if ($initial_section_counter == $section_counter) { 1936 if ($initial_section_counter == $section_counter) {
1907 print STDERR "Warning(${file}): no structured comments found\n"; 1937 print STDERR "Warning(${file}): no structured comments found\n";