Right now, if one uses "--rst" instead of "-rst", it just ignore the argument and produces a man page. Change the logic to accept both "-cmd" and "--cmd". Also, if "cmd" doesn't exist, print the usage information and exit.
Showing the changes to scripts/kernel-doc (1 of 1 file). Show all
Unified · Split
| @@ -391,47 +391,51 @@ my $undescribed = "-- undescribed --"; · 390 unmodified lines | ||
| 391 | 391 | |
| 392 | 392 | reset_state(); |
| 393 | 393 | |
| 394 | −while ($ARGV[0] =~ m/^-(.*)/) { | |
| 395 | − my $cmd = shift @ARGV; | |
| 396 | − if ($cmd eq "-man") { | |
| 394 | +while ($ARGV[0] =~ m/^--?(.*)/) { | |
| 395 | + my $cmd = $1; | |
| 396 | + shift @ARGV; | |
| 397 | + if ($cmd eq "man") { | |
| 397 | 398 | $output_mode = "man"; |
| 398 | 399 | @highlights = @highlights_man; |
| 399 | 400 | $blankline = $blankline_man; |
| 400 | − } elsif ($cmd eq "-rst") { | |
| 401 | + } elsif ($cmd eq "rst") { | |
| 401 | 402 | $output_mode = "rst"; |
| 402 | 403 | @highlights = @highlights_rst; |
| 403 | 404 | $blankline = $blankline_rst; |
| 404 | − } elsif ($cmd eq "-none") { | |
| 405 | + } elsif ($cmd eq "none") { | |
| 405 | 406 | $output_mode = "none"; |
| 406 | − } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document | |
| 407 | + } elsif ($cmd eq "module") { # not needed for XML, inherits from calling document | |
| 407 | 408 | $modulename = shift @ARGV; |
| 408 | − } elsif ($cmd eq "-function") { # to only output specific functions | |
| 409 | + } elsif ($cmd eq "function") { # to only output specific functions | |
| 409 | 410 | $output_selection = OUTPUT_INCLUDE; |
| 410 | 411 | $function = shift @ARGV; |
| 411 | 412 | $function_table{$function} = 1; |
| 412 | − } elsif ($cmd eq "-nofunction") { # output all except specific functions | |
| 413 | + } elsif ($cmd eq "nofunction") { # output all except specific functions | |
| 413 | 414 | $output_selection = OUTPUT_EXCLUDE; |
| 414 | 415 | $function = shift @ARGV; |
| 415 | 416 | $function_table{$function} = 1; |
| 416 | − } elsif ($cmd eq "-export") { # only exported symbols | |
| 417 | + } elsif ($cmd eq "export") { # only exported symbols | |
| 417 | 418 | $output_selection = OUTPUT_EXPORTED; |
| 418 | 419 | %function_table = (); |
| 419 | − } elsif ($cmd eq "-internal") { # only non-exported symbols | |
| 420 | + } elsif ($cmd eq "internal") { # only non-exported symbols | |
| 420 | 421 | $output_selection = OUTPUT_INTERNAL; |
| 421 | 422 | %function_table = (); |
| 422 | − } elsif ($cmd eq "-export-file") { | |
| 423 | + } elsif ($cmd eq "export-file") { | |
| 423 | 424 | my $file = shift @ARGV; |
| 424 | 425 | push(@export_file_list, $file); |
| 425 | − } elsif ($cmd eq "-v") { | |
| 426 | + } elsif ($cmd eq "v") { | |
| 426 | 427 | $verbose = 1; |
| 427 | − } elsif (($cmd eq "-h") || ($cmd eq "--help")) { | |
| 428 | + } elsif (($cmd eq "h") || ($cmd eq "help")) { | |
| 428 | 429 | usage(); |
| 429 | − } elsif ($cmd eq '-no-doc-sections') { | |
| 430 | + } elsif ($cmd eq 'no-doc-sections') { | |
| 430 | 431 | $no_doc_sections = 1; |
| 431 | − } elsif ($cmd eq '-enable-lineno') { | |
| 432 | + } elsif ($cmd eq 'enable-lineno') { | |
| 432 | 433 | $enable_lineno = 1; |
| 433 | − } elsif ($cmd eq '-show-not-found') { | |
| 434 | + } elsif ($cmd eq 'show-not-found') { | |
| 434 | 435 | $show_not_found = 1; |
| 436 | + } else { | |
| 437 | + # Unknown argument | |
| 438 | + usage(); | |
| 435 | 439 | } |
| 436 | 440 | } |
| 437 | 441 | |