[PATCH 6/9] fcvextract.pl: Support 'style=' option and pass through other options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 4c276d2dc2b2d056354c3d21d6b9a0f857c36631 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@xxxxxxxxx>
Date: Wed, 29 Aug 2018 21:16:42 +0900
Subject: [PATCH 6/9] fcvextract.pl: Support 'style=' option and pass through other options

"style=N" option will generate a "VerbatimN" environment.
"style=U" option will generate a "VerbatimU" environment.
Default is the "VerbatimL" environment.
Other options to a \begin{snippet} meta command are passed through
as options to "VerbatimL/N/U" environment.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 utilities/fcvextract.pl | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/utilities/fcvextract.pl b/utilities/fcvextract.pl
index cb6869b..ce549d3 100755
--- a/utilities/fcvextract.pl
+++ b/utilities/fcvextract.pl
@@ -112,6 +112,8 @@ my $dir_name;
 my $file_name;
 my $func_name;
 my $label;
+my $env_name = "VerbatimL" ;
+my $other_opts;
 
 $src_file = $ARGV[0];
 $extract_labelbase = $ARGV[1];
@@ -158,25 +160,52 @@ while($line = <>) {
 	print "% Generated by utilities/fcvextract.pl.\n" ;
 	if ($line =~ /labelbase=([^,]+)/) {
 	    print "\\begin\{linelabel}\[$1\]\n" ;
+	    $_ = $line ;
+	    s/labelbase=[^,\]]+,?// ;
+	    $line = $_ ;
 	}
-	print "\\begin\{VerbatimL\}" ;
+	if ($line =~ /style=N[,\]]/) {
+	    $env_name = "VerbatimN" ;
+	    $_ = $line ;
+	    s/style=N,?// ;
+	    $line = $_ ;
+	} elsif ($line =~ /style=U[,\]]/) {
+	    $env_name = "VerbatimU" ;
+	    $_ = $line ;
+	    s/style=U,?// ;
+	    $line = $_ ;
+	}
+	print "\\begin\{$env_name\}" ;
+
 	if ($line =~ /commandchars=([^,]+).*\]/) {
 	    $esc_char = $1 ;
-	    print "\[commandchars=" . $esc_char . "\]\n" ;
+	    print "\[commandchars=" . $esc_char ;
 	    $esc_bsl = substr $esc_char, 1, 1;
 	    $esc_open = substr $esc_char, 3, 1;
 	    $esc_close = substr $esc_char, 5, 1;
+	    $_ = $line ;
+	    s/commandchars=.{6},?// ;
+	    $line = $_ ;
 	} else {
 	    $esc_bsl = "\\" ;
 	    $esc_open = "\{" ;
 	    $esc_close = "\}" ;
-	    print "\n" ;
+	}
+	if ($line =~ /\[(.*)\]$/) {
+	    $_ = $1 ;
+	    s/,$// ;
+	    $other_opts = $_ ;
+	}
+	if ($other_opts ne '') {
+	    print ",$other_opts\]\n";
+	} else {
+	    print "\]\n";
 	}
 	$extracting = 2;
     }
 }
 if ($extracting == 2) {
-    print "\\end\{VerbatimL\}\n\\end\{linelabel\}\n" ;
+    print "\\end\{$env_name\}\n\\end\{linelabel\}\n" ;
     exit 0;
 } else {
     exit 1;
-- 
2.7.4





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux