diff options
Diffstat (limited to 'meta-oe/recipes-support/multipath-tools/files/0008-multipath-tools-refresh-kernel-doc-from-kernel-sourc.patch')
-rw-r--r-- | meta-oe/recipes-support/multipath-tools/files/0008-multipath-tools-refresh-kernel-doc-from-kernel-sourc.patch | 784 |
1 files changed, 784 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/multipath-tools/files/0008-multipath-tools-refresh-kernel-doc-from-kernel-sourc.patch b/meta-oe/recipes-support/multipath-tools/files/0008-multipath-tools-refresh-kernel-doc-from-kernel-sourc.patch new file mode 100644 index 0000000000..3752158704 --- /dev/null +++ b/meta-oe/recipes-support/multipath-tools/files/0008-multipath-tools-refresh-kernel-doc-from-kernel-sourc.patch | |||
@@ -0,0 +1,784 @@ | |||
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
2 | From: Xose Vazquez Perez <xose.vazquez@gmail.com> | ||
3 | Date: Sun, 13 May 2018 00:39:42 +0200 | ||
4 | Subject: [PATCH] multipath-tools: refresh kernel-doc from kernel sources | ||
5 | |||
6 | Cc: Gris Ge <fge@redhat.com> | ||
7 | Cc: Christophe Varoqui <christophe.varoqui@opensvc.com> | ||
8 | Cc: device-mapper development <dm-devel@redhat.com> | ||
9 | Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com> | ||
10 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> | ||
11 | --- | ||
12 | libdmmp/docs/kernel-doc | 671 ++++++++++++++++++++++++++---------------------- | ||
13 | 1 file changed, 368 insertions(+), 303 deletions(-) | ||
14 | |||
15 | diff --git a/libdmmp/docs/kernel-doc b/libdmmp/docs/kernel-doc | ||
16 | index fee8952..0057d8e 100755 | ||
17 | --- a/libdmmp/docs/kernel-doc | ||
18 | +++ b/libdmmp/docs/kernel-doc | ||
19 | @@ -1,4 +1,5 @@ | ||
20 | #!/usr/bin/env perl | ||
21 | +# SPDX-License-Identifier: GPL-2.0 | ||
22 | |||
23 | use warnings; | ||
24 | use strict; | ||
25 | @@ -328,13 +329,15 @@ my $lineprefix=""; | ||
26 | use constant { | ||
27 | STATE_NORMAL => 0, # normal code | ||
28 | STATE_NAME => 1, # looking for function name | ||
29 | - STATE_FIELD => 2, # scanning field start | ||
30 | - STATE_PROTO => 3, # scanning prototype | ||
31 | - STATE_DOCBLOCK => 4, # documentation block | ||
32 | - STATE_INLINE => 5, # gathering documentation outside main block | ||
33 | + STATE_BODY_MAYBE => 2, # body - or maybe more description | ||
34 | + STATE_BODY => 3, # the body of the comment | ||
35 | + STATE_PROTO => 4, # scanning prototype | ||
36 | + STATE_DOCBLOCK => 5, # documentation block | ||
37 | + STATE_INLINE => 6, # gathering documentation outside main block | ||
38 | }; | ||
39 | my $state; | ||
40 | my $in_doc_sect; | ||
41 | +my $leading_space; | ||
42 | |||
43 | # Inline documentation state | ||
44 | use constant { | ||
45 | @@ -363,7 +366,7 @@ my $doc_sect = $doc_com . | ||
46 | my $doc_content = $doc_com_body . '(.*)'; | ||
47 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; | ||
48 | my $doc_inline_start = '^\s*/\*\*\s*$'; | ||
49 | -my $doc_inline_sect = '\s*\*\s*(@[\w\s]+):(.*)'; | ||
50 | +my $doc_inline_sect = '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)'; | ||
51 | my $doc_inline_end = '^\s*\*/\s*$'; | ||
52 | my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$'; | ||
53 | my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;'; | ||
54 | @@ -553,10 +556,9 @@ sub output_highlight { | ||
55 | } | ||
56 | if ($line eq ""){ | ||
57 | if (! $output_preformatted) { | ||
58 | - print $lineprefix, local_unescape($blankline); | ||
59 | + print $lineprefix, $blankline; | ||
60 | } | ||
61 | } else { | ||
62 | - $line =~ s/\\\\\\/\&/g; | ||
63 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { | ||
64 | print "\\&$line"; | ||
65 | } else { | ||
66 | @@ -747,17 +749,73 @@ sub output_blockhead_rst(%) { | ||
67 | } | ||
68 | } | ||
69 | |||
70 | -sub output_highlight_rst { | ||
71 | - my $contents = join "\n",@_; | ||
72 | - my $line; | ||
73 | - | ||
74 | - # undo the evil effects of xml_escape() earlier | ||
75 | - $contents = xml_unescape($contents); | ||
76 | - | ||
77 | +# | ||
78 | +# Apply the RST highlights to a sub-block of text. | ||
79 | +# | ||
80 | +sub highlight_block($) { | ||
81 | + # The dohighlight kludge requires the text be called $contents | ||
82 | + my $contents = shift; | ||
83 | eval $dohighlight; | ||
84 | die $@ if $@; | ||
85 | + return $contents; | ||
86 | +} | ||
87 | |||
88 | - foreach $line (split "\n", $contents) { | ||
89 | +# | ||
90 | +# Regexes used only here. | ||
91 | +# | ||
92 | +my $sphinx_literal = '^[^.].*::$'; | ||
93 | +my $sphinx_cblock = '^\.\.\ +code-block::'; | ||
94 | + | ||
95 | +sub output_highlight_rst { | ||
96 | + my $input = join "\n",@_; | ||
97 | + my $output = ""; | ||
98 | + my $line; | ||
99 | + my $in_literal = 0; | ||
100 | + my $litprefix; | ||
101 | + my $block = ""; | ||
102 | + | ||
103 | + foreach $line (split "\n",$input) { | ||
104 | + # | ||
105 | + # If we're in a literal block, see if we should drop out | ||
106 | + # of it. Otherwise pass the line straight through unmunged. | ||
107 | + # | ||
108 | + if ($in_literal) { | ||
109 | + if (! ($line =~ /^\s*$/)) { | ||
110 | + # | ||
111 | + # If this is the first non-blank line in a literal | ||
112 | + # block we need to figure out what the proper indent is. | ||
113 | + # | ||
114 | + if ($litprefix eq "") { | ||
115 | + $line =~ /^(\s*)/; | ||
116 | + $litprefix = '^' . $1; | ||
117 | + $output .= $line . "\n"; | ||
118 | + } elsif (! ($line =~ /$litprefix/)) { | ||
119 | + $in_literal = 0; | ||
120 | + } else { | ||
121 | + $output .= $line . "\n"; | ||
122 | + } | ||
123 | + } else { | ||
124 | + $output .= $line . "\n"; | ||
125 | + } | ||
126 | + } | ||
127 | + # | ||
128 | + # Not in a literal block (or just dropped out) | ||
129 | + # | ||
130 | + if (! $in_literal) { | ||
131 | + $block .= $line . "\n"; | ||
132 | + if (($line =~ /$sphinx_literal/) || ($line =~ /$sphinx_cblock/)) { | ||
133 | + $in_literal = 1; | ||
134 | + $litprefix = ""; | ||
135 | + $output .= highlight_block($block); | ||
136 | + $block = "" | ||
137 | + } | ||
138 | + } | ||
139 | + } | ||
140 | + | ||
141 | + if ($block) { | ||
142 | + $output .= highlight_block($block); | ||
143 | + } | ||
144 | + foreach $line (split "\n", $output) { | ||
145 | print $lineprefix . $line . "\n"; | ||
146 | } | ||
147 | } | ||
148 | @@ -1062,7 +1120,7 @@ sub dump_struct($$) { | ||
149 | # Handle bitmaps | ||
150 | $arg =~ s/:\s*\d+\s*//g; | ||
151 | # Handle arrays | ||
152 | - $arg =~ s/\[\S+\]//g; | ||
153 | + $arg =~ s/\[.*\]//g; | ||
154 | # The type may have multiple words, | ||
155 | # and multiple IDs can be defined, like: | ||
156 | # const struct foo, *bar, foobar | ||
157 | @@ -1422,8 +1480,6 @@ sub push_parameter($$$$) { | ||
158 | } | ||
159 | } | ||
160 | |||
161 | - $param = xml_escape($param); | ||
162 | - | ||
163 | # strip spaces from $param so that it is one continuous string | ||
164 | # on @parameterlist; | ||
165 | # this fixes a problem where check_sections() cannot find | ||
166 | @@ -1522,6 +1578,7 @@ sub dump_function($$) { | ||
167 | $prototype =~ s/__meminit +//; | ||
168 | $prototype =~ s/__must_check +//; | ||
169 | $prototype =~ s/__weak +//; | ||
170 | + $prototype =~ s/__sched +//; | ||
171 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added | ||
172 | $prototype =~ s/__attribute__\s*\(\( | ||
173 | (?: | ||
174 | @@ -1748,47 +1805,6 @@ sub process_proto_type($$) { | ||
175 | } | ||
176 | } | ||
177 | |||
178 | -# xml_escape: replace <, >, and & in the text stream; | ||
179 | -# | ||
180 | -# however, formatting controls that are generated internally/locally in the | ||
181 | -# kernel-doc script are not escaped here; instead, they begin life like | ||
182 | -# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings | ||
183 | -# are converted to their mnemonic-expected output, without the 4 * '\' & ':', | ||
184 | -# just before actual output; (this is done by local_unescape()) | ||
185 | -sub xml_escape($) { | ||
186 | - my $text = shift; | ||
187 | - if ($output_mode eq "man") { | ||
188 | - return $text; | ||
189 | - } | ||
190 | - $text =~ s/\&/\\\\\\amp;/g; | ||
191 | - $text =~ s/\</\\\\\\lt;/g; | ||
192 | - $text =~ s/\>/\\\\\\gt;/g; | ||
193 | - return $text; | ||
194 | -} | ||
195 | - | ||
196 | -# xml_unescape: reverse the effects of xml_escape | ||
197 | -sub xml_unescape($) { | ||
198 | - my $text = shift; | ||
199 | - if ($output_mode eq "man") { | ||
200 | - return $text; | ||
201 | - } | ||
202 | - $text =~ s/\\\\\\amp;/\&/g; | ||
203 | - $text =~ s/\\\\\\lt;/</g; | ||
204 | - $text =~ s/\\\\\\gt;/>/g; | ||
205 | - return $text; | ||
206 | -} | ||
207 | - | ||
208 | -# convert local escape strings to html | ||
209 | -# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) | ||
210 | -sub local_unescape($) { | ||
211 | - my $text = shift; | ||
212 | - if ($output_mode eq "man") { | ||
213 | - return $text; | ||
214 | - } | ||
215 | - $text =~ s/\\\\\\\\lt:/</g; | ||
216 | - $text =~ s/\\\\\\\\gt:/>/g; | ||
217 | - return $text; | ||
218 | -} | ||
219 | |||
220 | sub map_filename($) { | ||
221 | my $file; | ||
222 | @@ -1826,15 +1842,291 @@ sub process_export_file($) { | ||
223 | close(IN); | ||
224 | } | ||
225 | |||
226 | -sub process_file($) { | ||
227 | - my $file; | ||
228 | +# | ||
229 | +# Parsers for the various processing states. | ||
230 | +# | ||
231 | +# STATE_NORMAL: looking for the /** to begin everything. | ||
232 | +# | ||
233 | +sub process_normal() { | ||
234 | + if (/$doc_start/o) { | ||
235 | + $state = STATE_NAME; # next line is always the function name | ||
236 | + $in_doc_sect = 0; | ||
237 | + $declaration_start_line = $. + 1; | ||
238 | + } | ||
239 | +} | ||
240 | + | ||
241 | +# | ||
242 | +# STATE_NAME: Looking for the "name - description" line | ||
243 | +# | ||
244 | +sub process_name($$) { | ||
245 | + my $file = shift; | ||
246 | my $identifier; | ||
247 | - my $func; | ||
248 | my $descr; | ||
249 | - my $in_purpose = 0; | ||
250 | + | ||
251 | + if (/$doc_block/o) { | ||
252 | + $state = STATE_DOCBLOCK; | ||
253 | + $contents = ""; | ||
254 | + $new_start_line = $. + 1; | ||
255 | + | ||
256 | + if ( $1 eq "" ) { | ||
257 | + $section = $section_intro; | ||
258 | + } else { | ||
259 | + $section = $1; | ||
260 | + } | ||
261 | + } | ||
262 | + elsif (/$doc_decl/o) { | ||
263 | + $identifier = $1; | ||
264 | + if (/\s*([\w\s]+?)(\(\))?\s*-/) { | ||
265 | + $identifier = $1; | ||
266 | + } | ||
267 | + | ||
268 | + $state = STATE_BODY; | ||
269 | + # if there's no @param blocks need to set up default section | ||
270 | + # here | ||
271 | + $contents = ""; | ||
272 | + $section = $section_default; | ||
273 | + $new_start_line = $. + 1; | ||
274 | + if (/-(.*)/) { | ||
275 | + # strip leading/trailing/multiple spaces | ||
276 | + $descr= $1; | ||
277 | + $descr =~ s/^\s*//; | ||
278 | + $descr =~ s/\s*$//; | ||
279 | + $descr =~ s/\s+/ /g; | ||
280 | + $declaration_purpose = $descr; | ||
281 | + $state = STATE_BODY_MAYBE; | ||
282 | + } else { | ||
283 | + $declaration_purpose = ""; | ||
284 | + } | ||
285 | + | ||
286 | + if (($declaration_purpose eq "") && $verbose) { | ||
287 | + print STDERR "${file}:$.: warning: missing initial short description on line:\n"; | ||
288 | + print STDERR $_; | ||
289 | + ++$warnings; | ||
290 | + } | ||
291 | + | ||
292 | + if ($identifier =~ m/^struct/) { | ||
293 | + $decl_type = 'struct'; | ||
294 | + } elsif ($identifier =~ m/^union/) { | ||
295 | + $decl_type = 'union'; | ||
296 | + } elsif ($identifier =~ m/^enum/) { | ||
297 | + $decl_type = 'enum'; | ||
298 | + } elsif ($identifier =~ m/^typedef/) { | ||
299 | + $decl_type = 'typedef'; | ||
300 | + } else { | ||
301 | + $decl_type = 'function'; | ||
302 | + } | ||
303 | + | ||
304 | + if ($verbose) { | ||
305 | + print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; | ||
306 | + } | ||
307 | + } else { | ||
308 | + print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", | ||
309 | + " - I thought it was a doc line\n"; | ||
310 | + ++$warnings; | ||
311 | + $state = STATE_NORMAL; | ||
312 | + } | ||
313 | +} | ||
314 | + | ||
315 | + | ||
316 | +# | ||
317 | +# STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment. | ||
318 | +# | ||
319 | +sub process_body($$) { | ||
320 | + my $file = shift; | ||
321 | + | ||
322 | + if (/$doc_sect/i) { # case insensitive for supported section names | ||
323 | + $newsection = $1; | ||
324 | + $newcontents = $2; | ||
325 | + | ||
326 | + # map the supported section names to the canonical names | ||
327 | + if ($newsection =~ m/^description$/i) { | ||
328 | + $newsection = $section_default; | ||
329 | + } elsif ($newsection =~ m/^context$/i) { | ||
330 | + $newsection = $section_context; | ||
331 | + } elsif ($newsection =~ m/^returns?$/i) { | ||
332 | + $newsection = $section_return; | ||
333 | + } elsif ($newsection =~ m/^\@return$/) { | ||
334 | + # special: @return is a section, not a param description | ||
335 | + $newsection = $section_return; | ||
336 | + } | ||
337 | + | ||
338 | + if (($contents ne "") && ($contents ne "\n")) { | ||
339 | + if (!$in_doc_sect && $verbose) { | ||
340 | + print STDERR "${file}:$.: warning: contents before sections\n"; | ||
341 | + ++$warnings; | ||
342 | + } | ||
343 | + dump_section($file, $section, $contents); | ||
344 | + $section = $section_default; | ||
345 | + } | ||
346 | + | ||
347 | + $in_doc_sect = 1; | ||
348 | + $state = STATE_BODY; | ||
349 | + $contents = $newcontents; | ||
350 | + $new_start_line = $.; | ||
351 | + while (substr($contents, 0, 1) eq " ") { | ||
352 | + $contents = substr($contents, 1); | ||
353 | + } | ||
354 | + if ($contents ne "") { | ||
355 | + $contents .= "\n"; | ||
356 | + } | ||
357 | + $section = $newsection; | ||
358 | + $leading_space = undef; | ||
359 | + } elsif (/$doc_end/) { | ||
360 | + if (($contents ne "") && ($contents ne "\n")) { | ||
361 | + dump_section($file, $section, $contents); | ||
362 | + $section = $section_default; | ||
363 | + $contents = ""; | ||
364 | + } | ||
365 | + # look for doc_com + <text> + doc_end: | ||
366 | + if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { | ||
367 | + print STDERR "${file}:$.: warning: suspicious ending line: $_"; | ||
368 | + ++$warnings; | ||
369 | + } | ||
370 | + | ||
371 | + $prototype = ""; | ||
372 | + $state = STATE_PROTO; | ||
373 | + $brcount = 0; | ||
374 | + } elsif (/$doc_content/) { | ||
375 | + # miguel-style comment kludge, look for blank lines after | ||
376 | + # @parameter line to signify start of description | ||
377 | + if ($1 eq "") { | ||
378 | + if ($section =~ m/^@/ || $section eq $section_context) { | ||
379 | + dump_section($file, $section, $contents); | ||
380 | + $section = $section_default; | ||
381 | + $contents = ""; | ||
382 | + $new_start_line = $.; | ||
383 | + } else { | ||
384 | + $contents .= "\n"; | ||
385 | + } | ||
386 | + $state = STATE_BODY; | ||
387 | + } elsif ($state == STATE_BODY_MAYBE) { | ||
388 | + # Continued declaration purpose | ||
389 | + chomp($declaration_purpose); | ||
390 | + $declaration_purpose .= " " . $1; | ||
391 | + $declaration_purpose =~ s/\s+/ /g; | ||
392 | + } else { | ||
393 | + my $cont = $1; | ||
394 | + if ($section =~ m/^@/ || $section eq $section_context) { | ||
395 | + if (!defined $leading_space) { | ||
396 | + if ($cont =~ m/^(\s+)/) { | ||
397 | + $leading_space = $1; | ||
398 | + } else { | ||
399 | + $leading_space = ""; | ||
400 | + } | ||
401 | + } | ||
402 | + $cont =~ s/^$leading_space//; | ||
403 | + } | ||
404 | + $contents .= $cont . "\n"; | ||
405 | + } | ||
406 | + } else { | ||
407 | + # i dont know - bad line? ignore. | ||
408 | + print STDERR "${file}:$.: warning: bad line: $_"; | ||
409 | + ++$warnings; | ||
410 | + } | ||
411 | +} | ||
412 | + | ||
413 | + | ||
414 | +# | ||
415 | +# STATE_PROTO: reading a function/whatever prototype. | ||
416 | +# | ||
417 | +sub process_proto($$) { | ||
418 | + my $file = shift; | ||
419 | + | ||
420 | + if (/$doc_inline_oneline/) { | ||
421 | + $section = $1; | ||
422 | + $contents = $2; | ||
423 | + if ($contents ne "") { | ||
424 | + $contents .= "\n"; | ||
425 | + dump_section($file, $section, $contents); | ||
426 | + $section = $section_default; | ||
427 | + $contents = ""; | ||
428 | + } | ||
429 | + } elsif (/$doc_inline_start/) { | ||
430 | + $state = STATE_INLINE; | ||
431 | + $inline_doc_state = STATE_INLINE_NAME; | ||
432 | + } elsif ($decl_type eq 'function') { | ||
433 | + process_proto_function($_, $file); | ||
434 | + } else { | ||
435 | + process_proto_type($_, $file); | ||
436 | + } | ||
437 | +} | ||
438 | + | ||
439 | +# | ||
440 | +# STATE_DOCBLOCK: within a DOC: block. | ||
441 | +# | ||
442 | +sub process_docblock($$) { | ||
443 | + my $file = shift; | ||
444 | + | ||
445 | + if (/$doc_end/) { | ||
446 | + dump_doc_section($file, $section, $contents); | ||
447 | + $section = $section_default; | ||
448 | + $contents = ""; | ||
449 | + $function = ""; | ||
450 | + %parameterdescs = (); | ||
451 | + %parametertypes = (); | ||
452 | + @parameterlist = (); | ||
453 | + %sections = (); | ||
454 | + @sectionlist = (); | ||
455 | + $prototype = ""; | ||
456 | + $state = STATE_NORMAL; | ||
457 | + } elsif (/$doc_content/) { | ||
458 | + if ( $1 eq "" ) { | ||
459 | + $contents .= $blankline; | ||
460 | + } else { | ||
461 | + $contents .= $1 . "\n"; | ||
462 | + } | ||
463 | + } | ||
464 | +} | ||
465 | + | ||
466 | +# | ||
467 | +# STATE_INLINE: docbook comments within a prototype. | ||
468 | +# | ||
469 | +sub process_inline($$) { | ||
470 | + my $file = shift; | ||
471 | + | ||
472 | + # First line (state 1) needs to be a @parameter | ||
473 | + if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { | ||
474 | + $section = $1; | ||
475 | + $contents = $2; | ||
476 | + $new_start_line = $.; | ||
477 | + if ($contents ne "") { | ||
478 | + while (substr($contents, 0, 1) eq " ") { | ||
479 | + $contents = substr($contents, 1); | ||
480 | + } | ||
481 | + $contents .= "\n"; | ||
482 | + } | ||
483 | + $inline_doc_state = STATE_INLINE_TEXT; | ||
484 | + # Documentation block end */ | ||
485 | + } elsif (/$doc_inline_end/) { | ||
486 | + if (($contents ne "") && ($contents ne "\n")) { | ||
487 | + dump_section($file, $section, $contents); | ||
488 | + $section = $section_default; | ||
489 | + $contents = ""; | ||
490 | + } | ||
491 | + $state = STATE_PROTO; | ||
492 | + $inline_doc_state = STATE_INLINE_NA; | ||
493 | + # Regular text | ||
494 | + } elsif (/$doc_content/) { | ||
495 | + if ($inline_doc_state == STATE_INLINE_TEXT) { | ||
496 | + $contents .= $1 . "\n"; | ||
497 | + # nuke leading blank lines | ||
498 | + if ($contents =~ /^\s*$/) { | ||
499 | + $contents = ""; | ||
500 | + } | ||
501 | + } elsif ($inline_doc_state == STATE_INLINE_NAME) { | ||
502 | + $inline_doc_state = STATE_INLINE_ERROR; | ||
503 | + print STDERR "${file}:$.: warning: "; | ||
504 | + print STDERR "Incorrect use of kernel-doc format: $_"; | ||
505 | + ++$warnings; | ||
506 | + } | ||
507 | + } | ||
508 | +} | ||
509 | + | ||
510 | + | ||
511 | +sub process_file($) { | ||
512 | + my $file; | ||
513 | my $initial_section_counter = $section_counter; | ||
514 | my ($orig_file) = @_; | ||
515 | - my $leading_space; | ||
516 | |||
517 | $file = map_filename($orig_file); | ||
518 | |||
519 | @@ -1853,250 +2145,23 @@ sub process_file($) { | ||
520 | } | ||
521 | # Replace tabs by spaces | ||
522 | while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; | ||
523 | + # Hand this line to the appropriate state handler | ||
524 | if ($state == STATE_NORMAL) { | ||
525 | - if (/$doc_start/o) { | ||
526 | - $state = STATE_NAME; # next line is always the function name | ||
527 | - $in_doc_sect = 0; | ||
528 | - $declaration_start_line = $. + 1; | ||
529 | - } | ||
530 | - } elsif ($state == STATE_NAME) {# this line is the function name (always) | ||
531 | - if (/$doc_block/o) { | ||
532 | - $state = STATE_DOCBLOCK; | ||
533 | - $contents = ""; | ||
534 | - $new_start_line = $. + 1; | ||
535 | - | ||
536 | - if ( $1 eq "" ) { | ||
537 | - $section = $section_intro; | ||
538 | - } else { | ||
539 | - $section = $1; | ||
540 | - } | ||
541 | - } | ||
542 | - elsif (/$doc_decl/o) { | ||
543 | - $identifier = $1; | ||
544 | - if (/\s*([\w\s]+?)\s*-/) { | ||
545 | - $identifier = $1; | ||
546 | - } | ||
547 | - | ||
548 | - $state = STATE_FIELD; | ||
549 | - # if there's no @param blocks need to set up default section | ||
550 | - # here | ||
551 | - $contents = ""; | ||
552 | - $section = $section_default; | ||
553 | - $new_start_line = $. + 1; | ||
554 | - if (/-(.*)/) { | ||
555 | - # strip leading/trailing/multiple spaces | ||
556 | - $descr= $1; | ||
557 | - $descr =~ s/^\s*//; | ||
558 | - $descr =~ s/\s*$//; | ||
559 | - $descr =~ s/\s+/ /g; | ||
560 | - $declaration_purpose = xml_escape($descr); | ||
561 | - $in_purpose = 1; | ||
562 | - } else { | ||
563 | - $declaration_purpose = ""; | ||
564 | - } | ||
565 | - | ||
566 | - if (($declaration_purpose eq "") && $verbose) { | ||
567 | - print STDERR "${file}:$.: warning: missing initial short description on line:\n"; | ||
568 | - print STDERR $_; | ||
569 | - ++$warnings; | ||
570 | - } | ||
571 | - | ||
572 | - if ($identifier =~ m/^struct/) { | ||
573 | - $decl_type = 'struct'; | ||
574 | - } elsif ($identifier =~ m/^union/) { | ||
575 | - $decl_type = 'union'; | ||
576 | - } elsif ($identifier =~ m/^enum/) { | ||
577 | - $decl_type = 'enum'; | ||
578 | - } elsif ($identifier =~ m/^typedef/) { | ||
579 | - $decl_type = 'typedef'; | ||
580 | - } else { | ||
581 | - $decl_type = 'function'; | ||
582 | - } | ||
583 | - | ||
584 | - if ($verbose) { | ||
585 | - print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; | ||
586 | - } | ||
587 | - } else { | ||
588 | - print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", | ||
589 | - " - I thought it was a doc line\n"; | ||
590 | - ++$warnings; | ||
591 | - $state = STATE_NORMAL; | ||
592 | - } | ||
593 | - } elsif ($state == STATE_FIELD) { # look for head: lines, and include content | ||
594 | - if (/$doc_sect/i) { # case insensitive for supported section names | ||
595 | - $newsection = $1; | ||
596 | - $newcontents = $2; | ||
597 | - | ||
598 | - # map the supported section names to the canonical names | ||
599 | - if ($newsection =~ m/^description$/i) { | ||
600 | - $newsection = $section_default; | ||
601 | - } elsif ($newsection =~ m/^context$/i) { | ||
602 | - $newsection = $section_context; | ||
603 | - } elsif ($newsection =~ m/^returns?$/i) { | ||
604 | - $newsection = $section_return; | ||
605 | - } elsif ($newsection =~ m/^\@return$/) { | ||
606 | - # special: @return is a section, not a param description | ||
607 | - $newsection = $section_return; | ||
608 | - } | ||
609 | - | ||
610 | - if (($contents ne "") && ($contents ne "\n")) { | ||
611 | - if (!$in_doc_sect && $verbose) { | ||
612 | - print STDERR "${file}:$.: warning: contents before sections\n"; | ||
613 | - ++$warnings; | ||
614 | - } | ||
615 | - dump_section($file, $section, xml_escape($contents)); | ||
616 | - $section = $section_default; | ||
617 | - } | ||
618 | - | ||
619 | - $in_doc_sect = 1; | ||
620 | - $in_purpose = 0; | ||
621 | - $contents = $newcontents; | ||
622 | - $new_start_line = $.; | ||
623 | - while (substr($contents, 0, 1) eq " ") { | ||
624 | - $contents = substr($contents, 1); | ||
625 | - } | ||
626 | - if ($contents ne "") { | ||
627 | - $contents .= "\n"; | ||
628 | - } | ||
629 | - $section = $newsection; | ||
630 | - $leading_space = undef; | ||
631 | - } elsif (/$doc_end/) { | ||
632 | - if (($contents ne "") && ($contents ne "\n")) { | ||
633 | - dump_section($file, $section, xml_escape($contents)); | ||
634 | - $section = $section_default; | ||
635 | - $contents = ""; | ||
636 | - } | ||
637 | - # look for doc_com + <text> + doc_end: | ||
638 | - if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { | ||
639 | - print STDERR "${file}:$.: warning: suspicious ending line: $_"; | ||
640 | - ++$warnings; | ||
641 | - } | ||
642 | - | ||
643 | - $prototype = ""; | ||
644 | - $state = STATE_PROTO; | ||
645 | - $brcount = 0; | ||
646 | -# print STDERR "end of doc comment, looking for prototype\n"; | ||
647 | - } elsif (/$doc_content/) { | ||
648 | - # miguel-style comment kludge, look for blank lines after | ||
649 | - # @parameter line to signify start of description | ||
650 | - if ($1 eq "") { | ||
651 | - if ($section =~ m/^@/ || $section eq $section_context) { | ||
652 | - dump_section($file, $section, xml_escape($contents)); | ||
653 | - $section = $section_default; | ||
654 | - $contents = ""; | ||
655 | - $new_start_line = $.; | ||
656 | - } else { | ||
657 | - $contents .= "\n"; | ||
658 | - } | ||
659 | - $in_purpose = 0; | ||
660 | - } elsif ($in_purpose == 1) { | ||
661 | - # Continued declaration purpose | ||
662 | - chomp($declaration_purpose); | ||
663 | - $declaration_purpose .= " " . xml_escape($1); | ||
664 | - $declaration_purpose =~ s/\s+/ /g; | ||
665 | - } else { | ||
666 | - my $cont = $1; | ||
667 | - if ($section =~ m/^@/ || $section eq $section_context) { | ||
668 | - if (!defined $leading_space) { | ||
669 | - if ($cont =~ m/^(\s+)/) { | ||
670 | - $leading_space = $1; | ||
671 | - } else { | ||
672 | - $leading_space = ""; | ||
673 | - } | ||
674 | - } | ||
675 | - | ||
676 | - $cont =~ s/^$leading_space//; | ||
677 | - } | ||
678 | - $contents .= $cont . "\n"; | ||
679 | - } | ||
680 | - } else { | ||
681 | - # i dont know - bad line? ignore. | ||
682 | - print STDERR "${file}:$.: warning: bad line: $_"; | ||
683 | - ++$warnings; | ||
684 | - } | ||
685 | + process_normal(); | ||
686 | + } elsif ($state == STATE_NAME) { | ||
687 | + process_name($file, $_); | ||
688 | + } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { | ||
689 | + process_body($file, $_); | ||
690 | } elsif ($state == STATE_INLINE) { # scanning for inline parameters | ||
691 | - # First line (state 1) needs to be a @parameter | ||
692 | - if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { | ||
693 | - $section = $1; | ||
694 | - $contents = $2; | ||
695 | - $new_start_line = $.; | ||
696 | - if ($contents ne "") { | ||
697 | - while (substr($contents, 0, 1) eq " ") { | ||
698 | - $contents = substr($contents, 1); | ||
699 | - } | ||
700 | - $contents .= "\n"; | ||
701 | - } | ||
702 | - $inline_doc_state = STATE_INLINE_TEXT; | ||
703 | - # Documentation block end */ | ||
704 | - } elsif (/$doc_inline_end/) { | ||
705 | - if (($contents ne "") && ($contents ne "\n")) { | ||
706 | - dump_section($file, $section, xml_escape($contents)); | ||
707 | - $section = $section_default; | ||
708 | - $contents = ""; | ||
709 | - } | ||
710 | - $state = STATE_PROTO; | ||
711 | - $inline_doc_state = STATE_INLINE_NA; | ||
712 | - # Regular text | ||
713 | - } elsif (/$doc_content/) { | ||
714 | - if ($inline_doc_state == STATE_INLINE_TEXT) { | ||
715 | - $contents .= $1 . "\n"; | ||
716 | - # nuke leading blank lines | ||
717 | - if ($contents =~ /^\s*$/) { | ||
718 | - $contents = ""; | ||
719 | - } | ||
720 | - } elsif ($inline_doc_state == STATE_INLINE_NAME) { | ||
721 | - $inline_doc_state = STATE_INLINE_ERROR; | ||
722 | - print STDERR "${file}:$.: warning: "; | ||
723 | - print STDERR "Incorrect use of kernel-doc format: $_"; | ||
724 | - ++$warnings; | ||
725 | - } | ||
726 | - } | ||
727 | - } elsif ($state == STATE_PROTO) { # scanning for function '{' (end of prototype) | ||
728 | - if (/$doc_inline_oneline/) { | ||
729 | - $section = $1; | ||
730 | - $contents = $2; | ||
731 | - if ($contents ne "") { | ||
732 | - $contents .= "\n"; | ||
733 | - dump_section($file, $section, xml_escape($contents)); | ||
734 | - $section = $section_default; | ||
735 | - $contents = ""; | ||
736 | - } | ||
737 | - } elsif (/$doc_inline_start/) { | ||
738 | - $state = STATE_INLINE; | ||
739 | - $inline_doc_state = STATE_INLINE_NAME; | ||
740 | - } elsif ($decl_type eq 'function') { | ||
741 | - process_proto_function($_, $file); | ||
742 | - } else { | ||
743 | - process_proto_type($_, $file); | ||
744 | - } | ||
745 | + process_inline($file, $_); | ||
746 | + } elsif ($state == STATE_PROTO) { | ||
747 | + process_proto($file, $_); | ||
748 | } elsif ($state == STATE_DOCBLOCK) { | ||
749 | - if (/$doc_end/) | ||
750 | - { | ||
751 | - dump_doc_section($file, $section, xml_escape($contents)); | ||
752 | - $section = $section_default; | ||
753 | - $contents = ""; | ||
754 | - $function = ""; | ||
755 | - %parameterdescs = (); | ||
756 | - %parametertypes = (); | ||
757 | - @parameterlist = (); | ||
758 | - %sections = (); | ||
759 | - @sectionlist = (); | ||
760 | - $prototype = ""; | ||
761 | - $state = STATE_NORMAL; | ||
762 | - } | ||
763 | - elsif (/$doc_content/) | ||
764 | - { | ||
765 | - if ( $1 eq "" ) | ||
766 | - { | ||
767 | - $contents .= $blankline; | ||
768 | - } | ||
769 | - else | ||
770 | - { | ||
771 | - $contents .= $1 . "\n"; | ||
772 | - } | ||
773 | - } | ||
774 | + process_docblock($file, $_); | ||
775 | } | ||
776 | } | ||
777 | + | ||
778 | + # Make sure we got something interesting. | ||
779 | if ($initial_section_counter == $section_counter) { | ||
780 | if ($output_mode ne "none") { | ||
781 | print STDERR "${file}:1: warning: no structured comments found\n"; | ||
782 | -- | ||
783 | 2.7.4 | ||
784 | |||