From b97f193abf83e30ef43317ba4883ce3a82f8e8b2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 30 Mar 2017 17:11:28 -0300 Subject: scripts/kernel-doc: fix parser for apostrophes On ReST, adding a text like ``literal`` is valid. However, the kernel-doc script won't handle it fine. We really need this feature, in order to escape things like %ph, with is found on some C files. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Corbet --- scripts/kernel-doc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 33c85dfdfce9..a4e5cc3b38e8 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -202,6 +202,7 @@ EOF # '&struct_name.member' - name of a structure member # '@parameter' - name of a parameter # '%CONST' - name of a constant. +# '``LITERAL``' - literal string without any spaces on it. ## init lots of data @@ -210,7 +211,8 @@ my $warnings = 0; my $anon_struct_union = 0; # match expressions used to find embedded type information -my $type_constant = '\%([-_\w]+)'; +my $type_constant = '\b``([^\`]+)``\b'; +my $type_constant2 = '\%([-_\w]+)'; my $type_func = '(\w+)\(\)'; my $type_param = '\@(\w+(\.\.\.)?)'; my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params @@ -235,6 +237,7 @@ my $type_member_func = $type_member . '\(\)'; # these work fairly well my @highlights_html = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\$1"], [$type_enum_xml, "\$1"], [$type_struct_xml, "\$1"], @@ -252,6 +255,7 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "

" # html version 5 my @highlights_html5 = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\$1"], [$type_enum_xml, "\$1"], [$type_struct_xml, "\$1"], @@ -268,6 +272,7 @@ my $blankline_html5 = $local_lt . "br /" . $local_gt; my @highlights_xml = ( ["([^=])\\\"([^\\\"<]+)\\\"", "\$1\$2"], [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_enum_xml, "\$1"], [$type_struct_xml, "\$1"], [$type_typedef_xml, "\$1"], @@ -283,6 +288,7 @@ my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $loca # gnome, docbook format my @highlights_gnome = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\$1"], [$type_enum, "\$1"], [$type_struct, "\$1"], @@ -298,6 +304,7 @@ my $blankline_gnome = "\n"; # these are pretty rough my @highlights_man = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\\\\fB\$1\\\\fP"], [$type_enum, "\\\\fI\$1\\\\fP"], [$type_struct, "\\\\fI\$1\\\\fP"], @@ -312,6 +319,7 @@ my $blankline_man = ""; # text-mode my @highlights_text = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\$1"], [$type_enum, "\$1"], [$type_struct, "\$1"], @@ -326,6 +334,7 @@ my $blankline_text = ""; # rst-mode my @highlights_rst = ( [$type_constant, "``\$1``"], + [$type_constant2, "``\$1``"], # Note: need to escape () to avoid func matching later [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"], [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], @@ -344,6 +353,7 @@ my $blankline_rst = "\n"; # list mode my @highlights_list = ( [$type_constant, "\$1"], + [$type_constant2, "\$1"], [$type_func, "\$1"], [$type_enum, "\$1"], [$type_struct, "\$1"], -- cgit v1.2.3-59-g8ed1b From f9b5c5304ce212b72c5c997b298ab96002e1634f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 30 Mar 2017 17:11:29 -0300 Subject: scripts/kernel-doc: fix handling of parameters with parenthesis lib/crc32c defines one parameter as: const u32 (*tab)[256] Better handle parenthesis, to avoid those warnings: ./lib/crc32.c:149: warning: No description found for parameter 'tab)[256]' ./lib/crc32.c:149: warning: Excess function parameter 'tab' description in 'crc32_le_generic' ./lib/crc32.c:294: warning: No description found for parameter 'tab)[256]' ./lib/crc32.c:294: warning: Excess function parameter 'tab' description in 'crc32_be_generic' Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Corbet --- scripts/kernel-doc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index a4e5cc3b38e8..a26a5f2dce39 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -2402,8 +2402,7 @@ sub push_parameter($$$) { } $anon_struct_union = 0; - my $param_name = $param; - $param_name =~ s/\[.*//; + $param =~ s/[\[\)].*//; if ($type eq "" && $param =~ /\.\.\.$/) { @@ -2434,9 +2433,9 @@ sub push_parameter($$$) { # but inline preprocessor statements); # also ignore unnamed structs/unions; if (!$anon_struct_union) { - if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { + if (!defined $parameterdescs{$param} && $param !~ /^#/) { - $parameterdescs{$param_name} = $undescribed; + $parameterdescs{$param} = $undescribed; if (($type eq 'function') || ($type eq 'enum')) { print STDERR "${file}:$.: warning: Function parameter ". -- cgit v1.2.3-59-g8ed1b