remove empty lines after kernel annotation
[linux-gpio-pinout] / gpio.pl
diff --git a/gpio.pl b/gpio.pl
index 55be687..aa7ebb6 100755 (executable)
--- a/gpio.pl
+++ b/gpio.pl
@@ -16,6 +16,7 @@ my $opt_zebra = 0;
 my $opt_lines = 0;
 my $opt_read = '';
 my $opt_pins = '';
+my $opt_color = 0;
 GetOptions(
        'svg!' => \$opt_svg,
        'alt!' => \$opt_alt,
@@ -28,6 +29,7 @@ GetOptions(
        'lines!' => \$opt_lines,
        'read=s' => \$opt_read,
        'pins=s' => \$opt_pins,
+       'color' => \$opt_color,
 );
 
 # svg font hints
@@ -76,9 +78,7 @@ while(<DATA>) {
 
 die "add pin definition for # $model" unless $pins;
 
-shift(@lines) while ( ! $lines[0] );   # remove empty at beginning
-pop(@lines) while ( ! $lines[-1] );    # remove empty at end
-
+#warn "# lines ",dump( \@lines );
 warn "# pins ",dump($pins);
 
 my $serial_tty;
@@ -127,6 +127,10 @@ warn "# pin_function = ",dump($pin_function);
 
 my @max_len = ( 0,0,0,0 );
 my @line_parts;
+
+shift(@lines) while ( ! $lines[0] );   # remove empty at beginning
+pop(@lines) while ( ! $lines[-1] );    # remove empty at end
+
 foreach my $line (@lines) {
        if ( $line =~ m/^#/ ) {
                push @line_parts, [ $line ] unless $opt_svg && $line =~ m/^###+/; # SVG doesn't display 3rd level comments
@@ -208,6 +212,9 @@ swap_cols 'txt' if $opt_invert;
 
 sub svg_style {
        my ($name,$x,$y,$col) = @_;
+
+       return '' unless $opt_color;
+
        $y -= $font_b; # shift box overlay to right vertical position based on font baseline
 
        sub rect {