?? protex
字號:
$verb = 1; $first_verb = 1; } else { for ($i = 3; $i <= $#Fld; $i++) { printf '%s ', $Fld[$i];}# end for}# end if ### print " "; $have_desc = 1; next LINE;}# end if}# end if# Handle optional keywords (these will appear as verbatim)# -------------------------------------------------------- if ($prologue) {KEY: foreach $key ( @keys ) { if ( /$key/ ) { if ($verb) { printf "\\end{verbatim}"; $verb = 0; } else { printf "\n\\bigskip";}# end if $k = sprintf('%s', $key); $ln = length($k); ###printf "\\subsubsection*{%s}\n", substr($k, 2, $ln - 1); ###printf "{\\Large \\em %s}\n", ucfirst lc substr($k, 2, $ln - 1); $_ = $key; if( /USES/ || /INPUT/ || /OUTPUT/ ) { printf "{\\em %s}\n", substr($k, 2, $ln - 1); } # italics else { printf "{\\sf %s}\n", substr($k, 2, $ln - 1); # san serif}# end if printf "\\begin{verbatim} "; $verb = 1; $first_verb = 1; if ( $key eq "!INTERFACE:" ) { $have_intf = 1; } if ( $key eq "!CALLING SEQUENCE:" ) { $have_intf = 1; } if ( $key eq "!REVISION HISTORY:" ) { $have_hist = 1; } next LINE;}# end if}# end foreach}# end if# End of prologue# --------------- if ($Fld[1] eq $eop_string) { if ($verb) { print "\\end{verbatim}"; $verb = 0;}# end if $prologue = 0;# &check_if_all_there(); # check if all required keyword are there. if ( $opt_l ) { $Fld[1] = $boc_string;} else { next LINE; }}# end if unless ( $opt_s ) {## Beginning of source code section# -------------------------------- if ($Fld[1] eq $boc_string) { print ' '; print '%/////////////////////////////////////////////////////////////'; $first = 0; $prologue = 0; $source = 1; ### printf "\\subsubsection*{CONTENTS:}\n\n", $Fld[3]; printf "{\\sf CONTENTS:}"; printf "\n \\begin{verbatim}\n"; $verb = 1; next LINE;}# end if# End of source code# ------------------ if ($Fld[1] eq $eoc_string) { &do_eoc(); $prologue = 0; next LINE;}# end if}# end unless # Prologue or Introduction, print regular line (except for !)# ----------------------------------------------------------- if ($prologue||$intro) { if ( $verb && $#Fld == 1 && ( $Fld[1] eq $comment_string ) ) { next LINE; # to eliminate excessive blanks }# end if if ( $Fld[2] eq "\\ev" ) { # special handling $_ = $comment_string . " \\end{verbatim}";}# end if s/^$comment_string/ /; # replace comment string with blank# $line = sprintf('%s', $_); # not necessary -- comment str is absent# $ln = length($line); # not necessary -- comment str is absent unless ( $first_verb ) { printf "\n "; } printf '%s', $_;# printf '%s', substr($line, 1, $ln - 1); # comment str is absent $first_verb = 0; next LINE;}# end if# Source code: print the full line# -------------------------------- if ($source) { print $_; next LINE;}# end if}# end inner loop for processing each line of the input file # ---------------------------------------------------------}# end main loop for each command-line argument # -------------------------------------------- print $_; if ( $source ) { &do_eoc(); } print '%...............................................................'; unless ( $opt_b ) { print "\\end{document}";}#end unless#---------------------------------------------------------------------- sub CheckOpts# Checks options against a given list. Outputs error message# for any invalid option.## Usage:# $rc = &CheckOpts ( options, valid_reg_options,# valid_sw_options,# quiet_mode )## character: options - options to be checked. (e.g. -df+x) The# list must begin with a positive or# negative sign. If no sign appears at the# beginning or by itself, then the argument# is not recognized as a list of options.# character: valid_reg_options - list of valid regular options.# (i.e. options that are associated only# eith negative sign.)# character: valid_sw_options - list of valid switch options.# (i.e. options that can be associated with# either a positive or negative sign.# logical: quiet mode (optional) If true then print no error# messages.# integer: rc - return code# = -1 if the arguement, options, is# not recognized as a list of options# = 0 if all options are valid.# > 0 for the number of invalid options.# { local($options, $valid_reg_options, $valid_sw_options, $quiet_mode ) = @_; if ( $options eq "+" || $options eq "-" ) {return -1} local(@Options) = split( / */, $options ); if ( $Options[ $[ ] ne "-" && $Options[ $[ ] ne "+" ) {return -1;} local($option, $option_sign, $valid_list, $pos); local($errs) = 0; foreach $option ( @Options ) { if ( $option eq "-" || $option eq "+" ) {$option_sign = $option;} else { if ( $option_sign eq "-" ) { $valid_list = $valid_reg_options . $valid_sw_options; } else { $valid_list = $valid_sw_options; } $pos = index ($valid_list,$option); if ( $pos < $[ && $quiet_mode ) { $errs++; print STDERR "Invalid option: $option_sign$option \n"; }# end if}# end if}# end foreach return $errs;}#end sub GetOpts sub GetOpts# Gets options. If an option is valid, then opt_[option] is# set to 0 or 1 as a side effect if the option is preceeded by# a positive or negative sign.## Usage:# $rc = &GetOpts ( options, valid_options )## character: options - options to be checked. (e.g. -df+x) The# list must begin with a positive or# negative sign. If no sign appears at the# beginning or by itself, then the argument# is not recognized as a list of options.# character: valid_options - list of valid options (e.g. dfhx)# integer: rc - return code# = -1 if the arguement, options, is# not recognized as a list of options.# = 0 otherwise# { local($options,$valid_options) = @_; if ( $options eq "+" || $options eq "-" ) {return -1} local(@Options) = split( / */, $options ); if ( $Options[ $[ ] ne "-" && $Options[ $[ ] ne "+" ) {return -1;} local($option, $option_sign); foreach $option ( @Options ) { if ( $option eq "-" || $option eq "+" ) { $option_sign = $option; } else { if ( index ($valid_options,$option) >= $[ ) { if ( $option_sign eq "-" ) {${"opt_$option"} = 1;} if ( $option_sign eq "+" ) {${"opt_$option"} = 0;};}# end if}# end if}# end foreach return 0;}#end sub GetOpts sub SetOpt# Sets option flags. For the last input option that is in a# list, the flag opt_[option] is set to 1 as a side effect.# For all other options in the list, opt_[option] is set to 0.## Usage:# $rc = &SetOpt ( options, valid_options )## character: options - options to be checked. (e.g. -df+x) The# list must begin with a positive or# negative sign. If no sign appears at the# beginning or by itself, then the argument# is not recognized as a list of options.# character: valid_options - list of valid options (e.g. def )# integer: rc - return code# = -1 if the arguement, options, is# not recognized as a list of options.# = 0 otherwise# Note: For the examples provided for the input arguments,# $opt_d = 0, $opt_e = 0, and $opt_f = 1, since the # input option, -f, was the last in the argument,# option.# { local($options,$valid_options) = @_; if ( $options eq "+" || $options eq "-" ) {return -1} local(@Options) = split( / */, $options ); local(@ValidOptions) = split( / */, $valid_options ); if ( $Options[ $[ ] ne "-" && $Options[ $[ ] ne "+" ) {return -1;} local($option, $option_sign); foreach $option ( @Options ) { if ( $option ne "-" && $option ne "+" ) { if ( index ($valid_options,$option) >= $[ ) { foreach $valid_option (@ValidOptions ) { ${"opt_$valid_option"} = 0;}# end foreach ${"opt_$option"} = 1;}# end if}# end if}# end foreach return 0;}#end sub SetOptsub print_help { print "Usage: protex [-hbACFS] [+-nlsxf] [src_file(s)]"; print " "; print " Options:"; print " -h Help mode: list command line options"; print " -b Bare mode, meaning no preamble, etc."; print " +-n New Page for each subsection (wastes paper)"; print " +-l Listing mode, default is prologues only"; print " +-s Shut-up mode, i.e., ignore any code from BOC to EOC"; print " +-x No LaTeX mode, i.e., put !DESCRIPTION: in verbatim mode"; print " +-f No source file info"; print " -A Ada code"; print " -C C++ code"; print " -F F90 code"; print " -S Shell script"; print " "; print " The options can appear in any order. The options, -h and -b,"; print " affect the input from all files listed on command-line input."; print " Each of the remaining options effects only the input from the"; print " files listed after the option and prior to any overriding"; print " option. The plus sign turns off the option."; }# end sub print_helpsub print_notice { print "% **** IMPORTANT NOTICE *****" ; print "% This LaTeX file has been automatically produced by ProTeX v. 1.1"; print "% Any changes made to this file will likely be lost next time"; print "% this file is regenerated from its source. Send questions "; print "% to Arlindo da Silva, dasilva\@gsfc.nasa.gov"; print " ";}# sub print_noticesub print_preamble { unless ( $opt_b ) { print "%------------------------ PREAMBLE --------------------------"; print "\\documentclass[11pt]{article}"; print "\\usepackage{amsmath}"; print "\\usepackage{epsfig}"; print "\\usepackage{hangcaption}"; print "\\textheight 9in"; print "\\topmargin 0pt"; print "\\headsep 1cm"; print "\\headheight 0pt"; print "\\textwidth 6in"; print "\\oddsidemargin 0in"; print "\\evensidemargin 0in"; print "\\marginparpush 0pt"; print "\\pagestyle{myheadings}"; print "\\markboth{}{}"; print "%-------------------------------------------------------------";}#end unless print "\\parskip 0pt"; print "\\parindent 0pt"; print "\\baselineskip 11pt";}# end sub print_preamblesub print_macros { print " "; print "%--------------------- SHORT-HAND MACROS ----------------------"; print "\\def\\bv{\\begin{verbatim}}"; print "\\def\\ev\{\\end\{verbatim}}"; print "\\def\\be{\\begin{equation}}"; print "\\def\\ee{\\end{equation}}"; print "\\def\\bea{\\begin{eqnarray}}"; print "\\def\\eea{\\end{eqnarray}}"; print "\\def\\bi{\\begin{itemize}}"; print "\\def\\ei{\\end{itemize}}"; print "\\def\\bn{\\begin{enumerate}}"; print "\\def\\en{\\end{enumerate}}"; print "\\def\\bd{\\begin{description}}"; print "\\def\\ed{\\end{description}}"; print "\\def\\({\\left (}"; print "\\def\\){\\right )}"; print "\\def\\[{\\left [}"; print "\\def\\]{\\right ]}"; print "\\def\\<{\\left \\langle}"; print "\\def\\>{\\right \\rangle}"; print "\\def\\cI{{\\cal I}}"; print "\\def\\diag{\\mathop{\\rm diag}}"; print "\\def\\tr{\\mathop{\\rm tr}}"; print "%-------------------------------------------------------------";}# end sub print_macrossub do_beg { unless ( $opt_b ) { if ( $begdoc == 0 ) { if ( $tpage ) { print "\\title{@title}"; print "\\author{{\\sc @author}\\\\ {\\em @affiliation}}"; print "\\date{@date}"; } print "\\begin{document}"; if ( $tpage ) { print "\\maketitle"; } print "\\tableofcontents"; print "\\newpage"; $begdoc = 1; } }}# end sub do_begsub do_eoc { print ' '; if ($verb) { print "\\end{verbatim}"; $verb = 0; } $source = 0;}# end sub do_eocsub set_missing { $have_name = 0; # have routine name? $have_desc = 0; # have description? $have_intf = 0; # have interface? $have_hist = 0; # have revision history? $name_is = "UNKNOWN";}# end sub set_missing sub check_if_all_there {$have_name || die "ProTeX: invalid prologue, missing !ROUTINE: or !IROUTINE: in <$name_is>";$have_desc || die "ProTeX: invalid prologue, missing !DESCRIPTION: in <$name_is>";$have_intf || die "ProTeX: invalid prologue, missing !INTERFACE: in <$name_is>";$have_hist || die "ProTeX: invalid prologue, missing !REVISION HISTORY: in <$name_is>";}# end sub check_if_all_there
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -