|
Packit Service |
c5cf8c |
#! /usr/bin/env perl
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# This script extracts the text blocks from a source file and creates a
|
|
Packit Service |
c5cf8c |
# simple text block out of them.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Initially, we will use this to create LaTeX blocks so that the ADI reference
|
|
Packit Service |
c5cf8c |
# manual can contain the comments from the example source files adi3.c and
|
|
Packit Service |
c5cf8c |
# adi3.h.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
use warnings;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
$debug = 0;
|
|
Packit Service |
c5cf8c |
while (<>) {
|
|
Packit Service |
c5cf8c |
if (/\/\*T([^ ]*)[ ]*\n/) {
|
|
Packit Service |
c5cf8c |
$filename = $1;
|
|
Packit Service |
c5cf8c |
print "Filename = |$filename|\n" if $debug;
|
|
Packit Service |
c5cf8c |
$filename =~ s/\s*//;
|
|
Packit Service |
c5cf8c |
if ($filename ne "") {
|
|
Packit Service |
c5cf8c |
open( OUTFILE, ">$filename" ) || die "Could not open $filename\n";
|
|
Packit Service |
c5cf8c |
$OUTFILE = OUTFILE;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$OUTFILE = STDOUT;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# Process until we find the matching T*/
|
|
Packit Service |
c5cf8c |
$_=<>;
|
|
Packit Service |
c5cf8c |
if (/Section[ ]*[0-9:]*[ ]*(.*)/) {
|
|
Packit Service |
c5cf8c |
print $OUTFILE "\\section{$1}\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
s/^ \*//;
|
|
Packit Service |
c5cf8c |
if (/[A-Za-z]:[ ]*$/) {
|
|
Packit Service |
c5cf8c |
s/[ ]*(.*):/\\subsection{$1}/g;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
s/^.vb/\\begin{verbatim}/g;
|
|
Packit Service |
c5cf8c |
s/^.ve/\\end{verbatim}/g;
|
|
Packit Service |
c5cf8c |
s/\'([^\']*)\'/]\texttt{$1}/g;
|
|
Packit Service |
c5cf8c |
s/\\:/:/g;
|
|
Packit Service |
c5cf8c |
print $OUTFILE $_;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
while (<>) {
|
|
Packit Service |
c5cf8c |
if (/T\*\//) { last ; }
|
|
Packit Service |
c5cf8c |
s/^ \*//;
|
|
Packit Service |
c5cf8c |
if (/[A-Za-z]:[ ]*$/) {
|
|
Packit Service |
c5cf8c |
s/[ ]*(.*):/\\subsection{$1}/g;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
s/^.vb/\\begin{verbatim}/g;
|
|
Packit Service |
c5cf8c |
s/^.ve/\\end{verbatim}/g;
|
|
Packit Service |
c5cf8c |
s/\'([^\']*)\'/\\texttt{$1}/g;
|
|
Packit Service |
c5cf8c |
s/\`([^\`]*)\`/\\emph{$1}/g;
|
|
Packit Service |
c5cf8c |
s/\\:/:/g;
|
|
Packit Service |
c5cf8c |
print $OUTFILE $_;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if ($filename ne "") { close(OUTFILE); }
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|