kernel-doc (7c0d7e87a16fe615e7913a3d56ce7bd26104ef0b) kernel-doc (84ce5b987783d362ee4e737b653d6e2feacfa40c)
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 ##

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

1025 # replace DECLARE_KFIFO
1026 $members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
1027 # replace DECLARE_KFIFO_PTR
1028 $members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
1029
1030 my $declaration = $members;
1031
1032 # Split nested struct/union elements as newer ones
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 ##

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

1025 # replace DECLARE_KFIFO
1026 $members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
1027 # replace DECLARE_KFIFO_PTR
1028 $members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
1029
1030 my $declaration = $members;
1031
1032 # Split nested struct/union elements as newer ones
1033 my $cont = 1;
1034 while ($cont) {
1035 $cont = 0;
1036 while ($members =~ m/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/) {
1037 my $newmember = "$1 $4;";
1038 my $id = $4;
1039 my $content = $3;
1033 while ($members =~ m/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/) {
1034 my $newmember;
1035 my $maintype = $1;
1036 my $ids = $4;
1037 my $content = $3;
1038 foreach my $id(split /,/, $ids) {
1039 $newmember .= "$maintype $id; ";
1040
1040 $id =~ s/[:\[].*//;
1041 $id =~ s/[:\[].*//;
1041 $id =~ s/^\*+//;
1042 $id =~ s/^\s*\**(\S+)\s*/$1/;
1042 foreach my $arg (split /;/, $content) {
1043 next if ($arg =~ m/^\s*$/);
1044 if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
1045 # pointer-to-function
1046 my $type = $1;
1047 my $name = $2;
1048 my $extra = $3;
1049 next if (!$name);
1050 if ($id =~ m/^\s*$/) {
1051 # anonymous struct/union
1043 foreach my $arg (split /;/, $content) {
1044 next if ($arg =~ m/^\s*$/);
1045 if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
1046 # pointer-to-function
1047 my $type = $1;
1048 my $name = $2;
1049 my $extra = $3;
1050 next if (!$name);
1051 if ($id =~ m/^\s*$/) {
1052 # anonymous struct/union
1052 $newmember .= "$type$name$extra;";
1053 $newmember .= "$type$name$extra; ";
1053 } else {
1054 } else {
1054 $newmember .= "$type$id.$name$extra;";
1055 $newmember .= "$type$id.$name$extra; ";
1055 }
1056 } else {
1056 }
1057 } else {
1057 my $type = $arg;
1058 my $name = $arg;
1059 $type =~ s/\s\S+$//;
1060 $name =~ s/.*\s+//;
1061 $name =~ s/[:\[].*//;
1062 $name =~ s/^\*+//;
1063 next if (($name =~ m/^\s*$/));
1064 if ($id =~ m/^\s*$/) {
1065 # anonymous struct/union
1066 $newmember .= "$type $name;";
1058 my $type;
1059 my $names;
1060 $arg =~ s/^\s+//;
1061 $arg =~ s/\s+$//;
1062 # Handle bitmaps
1063 $arg =~ s/:\s*\d+\s*//g;
1064 # Handle arrays
1065 $arg =~ s/\[\S+\]//g;
1066 # The type may have multiple words,
1067 # and multiple IDs can be defined, like:
1068 # const struct foo, *bar, foobar
1069 # So, we remove spaces when parsing the
1070 # names, in order to match just names
1071 # and commas for the names
1072 $arg =~ s/\s*,\s*/,/g;
1073 if ($arg =~ m/(.*)\s+([\S+,]+)/) {
1074 $type = $1;
1075 $names = $2;
1067 } else {
1076 } else {
1068 $newmember .= "$type $id.$name;";
1077 $newmember .= "$arg; ";
1078 next;
1069 }
1079 }
1080 foreach my $name (split /,/, $names) {
1081 $name =~ s/^\s*\**(\S+)\s*/$1/;
1082 next if (($name =~ m/^\s*$/));
1083 if ($id =~ m/^\s*$/) {
1084 # anonymous struct/union
1085 $newmember .= "$type $name; ";
1086 } else {
1087 $newmember .= "$type $id.$name; ";
1088 }
1089 }
1070 }
1071 }
1090 }
1091 }
1072 $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
1073 $cont = 1;
1074 };
1075 };
1092 }
1093 $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)}([^\{\}\;]*)\;/$newmember/;
1094 }
1076
1077 # Ignore other nested elements, like enums
1078 $members =~ s/({[^\{\}]*})//g;
1079
1080 create_parameterlist($members, ';', $file, $declaration_name);
1081 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
1082
1083 # Adjust declaration for better display

--- 1013 unchanged lines hidden ---
1095
1096 # Ignore other nested elements, like enums
1097 $members =~ s/({[^\{\}]*})//g;
1098
1099 create_parameterlist($members, ';', $file, $declaration_name);
1100 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
1101
1102 # Adjust declaration for better display

--- 1013 unchanged lines hidden ---