[media] docs-rst: parse-headers.pl: make debug a command line option
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 31 Aug 2016 09:41:40 +0000 (06:41 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 9 Sep 2016 12:20:06 +0000 (09:20 -0300)
Add a parser for the --debug option, in order to allow
seeing what the parser is doing.

Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Documentation/sphinx/parse-headers.pl

index 74089b0da7984720b3b9ff87a2d83dac5e2d9177..531c710fc73f9a3446c51f48948cb25dd2f9e6d1 100755 (executable)
@@ -2,12 +2,18 @@
 use strict;
 use Text::Tabs;
 
-# Uncomment if debug is needed
-#use Data::Dumper;
-
-# change to 1 to generate some debug prints
 my $debug = 0;
 
+while ($ARGV[0] =~ m/^-(.*)/) {
+       my $cmd = shift @ARGV;
+       if ($cmd eq "--debug") {
+               require Data::Dumper;
+               $debug = 1;
+               next;
+       }
+       die "argument $cmd unknown";
+}
+
 if (scalar @ARGV < 2 || scalar @ARGV > 3) {
        die "Usage:\n\t$0 <file in> <file out> [<exceptions file>]\n";
 }