os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/man2html2.tcl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 # man2html2.tcl --
     2 #
     3 # This file defines procedures that are used during the second pass of the
     4 # man page to html conversion process. It is sourced by man2html.tcl.
     5 #
     6 # Copyright (c) 1996 by Sun Microsystems, Inc.
     7 #
     8 # SCCS: @(#) man2html2.tcl 1.2 96/03/21 10:48:30
     9 #
    10 
    11 # Global variables used by these scripts:
    12 #
    13 # NAME_file -	array indexed by NAME and containing file names used
    14 #		for hyperlinks.
    15 #
    16 # textState -	state variable defining action of 'text' proc.
    17 #
    18 # nestStk -	stack oriented list containing currently active
    19 #		HTML tags (UL, OL, DL). Local to 'nest' proc.
    20 #
    21 # inDT -	set by 'TPmacro', cleared by 'newline'. Used to insert
    22 #		the <DT> tag while in a dictionary list <DL>.
    23 #
    24 # curFont -	Name of special font that is currently in
    25 #		use.  Null means the default paragraph font
    26 #		is being used.
    27 #
    28 # file -	Where to output the generated HTML.
    29 #
    30 # fontStart -	Array to map font names to starting sequences.
    31 #
    32 # fontEnd -	Array to map font names to ending sequences.
    33 #
    34 # noFillCount -	Non-zero means don't fill the next $noFillCount
    35 #		lines: force a line break at each newline.  Zero
    36 #		means filling is enabled, so don't output line
    37 #		breaks for each newline.
    38 #
    39 # footer -	info inserted at bottom of each page. Normally read
    40 #		from the xref.tcl file
    41 	
    42 # initGlobals --
    43 #
    44 # This procedure is invoked to set the initial values of all of the
    45 # global variables, before processing a man page.
    46 #
    47 # Arguments:
    48 # None.
    49 
    50 proc initGlobals {} {
    51     global file noFillCount textState
    52     global fontStart fontEnd curFont inPRE charCnt
    53 
    54     nest init
    55     set inPRE 0
    56     set textState 0
    57     set curFont ""
    58     set fontStart(Code) "<B>"
    59     set fontStart(Emphasis) "<I>"
    60     set fontEnd(Code) "</B>"
    61     set fontEnd(Emphasis) "</I>"
    62     set noFillCount 0
    63     set charCnt 0
    64     setTabs 0.5i
    65 }
    66 
    67 
    68 # beginFont --
    69 #
    70 # Arranges for future text to use a special font, rather than
    71 # the default paragraph font.
    72 #
    73 # Arguments:
    74 # font -		Name of new font to use.
    75 
    76 proc beginFont font {
    77     global curFont file fontStart
    78 
    79     if {$curFont == $font} {
    80 	return
    81     }
    82     endFont
    83     puts -nonewline $file $fontStart($font)
    84     set curFont $font
    85 }
    86 
    87 
    88 # endFont --
    89 #
    90 # Reverts to the default font for the paragraph type.
    91 #
    92 # Arguments:
    93 # None.
    94 
    95 proc endFont {} {
    96     global curFont file fontEnd
    97 
    98     if {$curFont != ""} {
    99     puts -nonewline $file $fontEnd($curFont)
   100     set curFont ""
   101     }
   102 }
   103 
   104 
   105 
   106 # text --
   107 #
   108 # This procedure adds text to the current paragraph.  If this is
   109 # the first text in the paragraph then header information for the
   110 # paragraph is output before the text.
   111 #
   112 # Arguments:
   113 # string -		Text to output in the paragraph.
   114 
   115 proc text string {
   116     global file textState inDT charCnt
   117 
   118     set pos [string first "\t" $string]
   119     if {$pos >= 0} {
   120     	text [string range $string 0 [expr $pos-1]]
   121     	tab
   122     	text [string range $string [expr $pos+1] end]
   123 	return    	
   124     }
   125     incr charCnt [string length $string]
   126     regsub -all {&} $string {\&amp;}  string
   127     regsub -all {<} $string {\&lt;}  string
   128     regsub -all {>} $string {\&gt;}  string
   129     regsub -all {"} $string {\&quot;}  string
   130     switch $textState {
   131 	REF { 
   132 	    if {$inDT == {}} {
   133 		set string [insertRef $string]
   134 	    }
   135 	}
   136 	SEE { 
   137 	    global NAME_file
   138 	    foreach i [split $string] {
   139 		if ![regexp -nocase {^[a-z_]+} [string trim $i] i ] {
   140 # 		    puts "Warning: $i in SEE ALSO not found"
   141 		    continue
   142 		}
   143 		if ![catch {set ref $NAME_file($i)} ] {
   144 		    regsub $i $string "<A HREF=\"$ref.html\">$i</A>" string
   145 		}
   146 	    }
   147 	}
   148     }
   149     puts -nonewline $file "$string"
   150 }
   151 
   152 
   153 
   154 # insertRef --
   155 #
   156 #
   157 # Arguments:
   158 # string -		Text to output in the paragraph.
   159 
   160 proc insertRef string {
   161     global NAME_file self
   162     set path {}
   163     if ![catch {set ref $NAME_file([string trim $string])} ] {
   164 	if {"$ref.html" != $self} {
   165 	    set string "<A HREF=\"${path}$ref.html\">$string</A>"
   166 #	    puts "insertRef: $self $ref.html ---$string--"
   167 	}
   168     }
   169     return $string
   170 }
   171 
   172 
   173 
   174 # macro --
   175 #
   176 # This procedure is invoked to process macro invocations that start
   177 # with "." (instead of ').
   178 #
   179 # Arguments:
   180 # name -		The name of the macro (without the ".").
   181 # args -		Any additional arguments to the macro.
   182 
   183 proc macro {name args} {
   184     switch $name {
   185 	AP {
   186 	    if {[llength $args] != 3} {
   187 		puts stderr "Bad .AP macro: .$name [join $args " "]"
   188 	    }
   189 	    setTabs {1.25i 2.5i 3.75i}
   190 	    TPmacro {}
   191 	    font B
   192 	    text "[lindex $args 0]  "
   193 	    font I
   194 	    text "[lindex $args 1]"
   195 	    font R
   196 	    text " ([lindex $args 2])"
   197 	    newline
   198 	}
   199 	AS {}				;# next page and previous page
   200 	br {
   201 	    lineBreak	
   202 	}
   203 	BS {}
   204 	BE {}
   205 	CE {
   206 	    global file noFillCount inPRE
   207 	    puts $file </PRE></BLOCKQUOTE>
   208 	    set inPRE 0
   209 	}
   210 	CS {				;# code section
   211 	    global file noFillCount inPRE
   212 	    puts -nonewline $file <BLOCKQUOTE><PRE>
   213 	    set inPRE 1
   214 	}
   215 	DE {
   216 	    global file noFillCount inPRE
   217 	    puts $file </PRE></BLOCKQUOTE>
   218 	    set inPRE 0
   219 	    set noFillCount 0
   220 	}
   221 	DS {
   222 	    global file noFillCount inPRE
   223 	    puts -nonewline $file <BLOCKQUOTE><PRE>
   224 	    set noFillCount 10000000
   225 	    set inPRE 1
   226 	}
   227 	fi {
   228 	    global noFillCount
   229 	    set noFillCount 0
   230 	}
   231 	IP {
   232 	    IPmacro $args
   233 	}
   234 	LP {
   235 	    nest decr
   236 	    nest incr
   237 	    newPara
   238 	}
   239 	ne {
   240 	}
   241 	nf {
   242 	    global noFillCount
   243 	    set noFillCount 1000000
   244 	}
   245 	OP {
   246 	    global inDT file inPRE 
   247 	    if {[llength $args] != 3} {
   248 		puts stderr "Bad .OP macro: .$name [join $args " "]"
   249 	    }
   250 	    nest para DL DT
   251 	    set inPRE 1
   252 	    puts -nonewline $file <PRE>				
   253 	    setTabs 4c
   254 	    text "Command-Line Name:"
   255 	    tab
   256 	    font B
   257 	    set x [lindex $args 0]
   258 	    regsub -all {\\-} $x - x
   259 	    text $x
   260 	    newline
   261 	    font R
   262 	    text "Database Name:"
   263 	    tab
   264 	    font B
   265 	    text [lindex $args 1]
   266 	    newline
   267 	    font R
   268 	    text "Database Class:"
   269 	    tab
   270 	    font B
   271 	    text [lindex $args 2]
   272 	    font R
   273 	    puts -nonewline $file </PRE>				
   274 	    set inDT "\n<DD>"			;# next newline writes inDT 
   275 	    set inPRE 0
   276 	    newline
   277 	}
   278 	PP {
   279 	    nest decr
   280 	    nest incr
   281 	    newPara
   282 	}
   283 	RE {
   284 	    nest decr    
   285 	}
   286 	RS {
   287 	    nest incr
   288 	}
   289 	SE {
   290 	    global noFillCount textState inPRE file
   291 
   292 	    font R
   293 	    puts -nonewline $file </PRE>
   294 	    set inPRE 0
   295 	    set noFillCount 0
   296 	    nest reset
   297 	    newPara
   298 	    text "See the "
   299 	    font B
   300 	    set temp $textState
   301 	    set textState REF
   302 	    text options
   303 	    set textState $temp
   304 	    font R
   305 	    text " manual entry for detailed descriptions of the above options."
   306 	}
   307 	SH {
   308 	    SHmacro $args
   309 	}
   310 	SO {
   311 	    global noFillCount inPRE file
   312 
   313 	    SHmacro "STANDARD OPTIONS"
   314 	    setTabs {4c 8c 12c}
   315 	    set noFillCount 1000000
   316 	    puts -nonewline $file <PRE>
   317 	    set inPRE 1
   318 	    font B
   319 	}
   320 	so {
   321 	    if {$args != "man.macros"} {
   322 		puts stderr "Unknown macro: .$name [join $args " "]"
   323 	    }
   324 	}
   325 	sp {					;# needs work
   326 	    if {$args == ""} {
   327 		set count 1
   328 	    } else {
   329 		set count [lindex $args 0]
   330 	    }
   331 	    while {$count > 0} {
   332 		lineBreak
   333 		incr count -1
   334 	    }
   335 	}
   336 	ta {
   337 	    setTabs $args
   338 	}
   339 	TH {
   340 	    THmacro $args
   341 	}
   342 	TP {
   343 	    TPmacro $args
   344 	}
   345 	UL {					;# underline
   346 	    global file
   347 	    puts -nonewline $file "<B><U>"
   348 	    text [lindex $args 0]
   349 	    puts -nonewline $file "</U></B>"
   350 	    if {[llength $args] == 2} {
   351 		text [lindex $args 1]
   352 	    }
   353 	}
   354 	VE {
   355 #	    global file
   356 #	    puts -nonewline $file "</FONT>"
   357 	}
   358 	VS {
   359 #	    global file
   360 #	    if {[llength $args] > 0} {
   361 #		puts -nonewline $file "<BR>"
   362 #	    }
   363 #	    puts -nonewline $file "<FONT COLOR=\"GREEN\">"
   364 	}
   365 	default {
   366 	    puts stderr "Unknown macro: .$name [join $args " "]"
   367 	}
   368     }
   369 
   370 #	global nestStk; puts "$name [format "%-20s" $args] $nestStk"
   371 #	flush stdout; flush stderr
   372 }
   373 
   374 
   375 # font --
   376 #
   377 # This procedure is invoked to handle font changes in the text
   378 # being output.
   379 #
   380 # Arguments:
   381 # type -		Type of font: R, I, B, or S.
   382 
   383 proc font type {
   384     global textState
   385     switch $type {
   386 	P -
   387 	R {
   388 	    endFont
   389 	    if {$textState == "REF"} {
   390 		set textState INSERT
   391 	    }
   392 	}
   393 	B {
   394 	    beginFont Code
   395 	    if {$textState == "INSERT"} {
   396 		set textState REF
   397 	    }
   398 	}
   399 	I {
   400 	    beginFont Emphasis
   401 	}
   402 	S {
   403 	}
   404 	default {
   405 	    puts stderr "Unknown font: $type"
   406 	}
   407     }
   408 }
   409 
   410 
   411 
   412 # formattedText --
   413 #
   414 # Insert a text string that may also have \fB-style font changes
   415 # and a few other backslash sequences in it.
   416 #
   417 # Arguments:
   418 # text -		Text to insert.
   419 
   420 proc formattedText text {
   421 #	puts "formattedText: $text"
   422     while {$text != ""} {
   423 	set index [string first \\ $text]
   424 	if {$index < 0} {
   425 	    text $text
   426 	    return
   427 	}
   428 	text [string range $text 0 [expr $index-1]]
   429 	set c [string index $text [expr $index+1]]
   430 	switch -- $c {
   431 	    f {
   432 		font [string index $text [expr $index+2]]
   433 		set text [string range $text [expr $index+3] end]
   434 	    }
   435 	    e {
   436 		text \\
   437 		set text [string range $text [expr $index+2] end]
   438 	    }
   439 	    - {
   440 		dash
   441 		set text [string range $text [expr $index+2] end]
   442 	    }
   443 	    | {
   444 		set text [string range $text [expr $index+2] end]
   445 	    }
   446 	    default {
   447 		puts stderr "Unknown sequence: \\$c"
   448 		set text [string range $text [expr $index+2] end]
   449 	    }
   450 	}
   451     }
   452 }
   453 
   454 
   455 
   456 # dash --
   457 #
   458 # This procedure is invoked to handle dash characters ("\-" in
   459 # troff).  It outputs a special dash character.
   460 #
   461 # Arguments:
   462 # None.
   463 
   464 proc dash {} {
   465     global textState charCnt
   466     if {$textState == "NAME"} {
   467     	set textState 0
   468     }
   469     incr charCnt
   470     text "-"
   471 }
   472 
   473 
   474 # tab --
   475 #
   476 # This procedure is invoked to handle tabs in the troff input.
   477 # Right now it does nothing.
   478 #
   479 # Arguments:
   480 # None.
   481 
   482 proc tab {} {
   483     global inPRE charCnt tabString
   484 #	? charCnt
   485     if {$inPRE == 1} {
   486 	set pos [expr $charCnt % [string length $tabString] ]
   487 	set spaces [string first "1" [string range $tabString $pos end] ]
   488 	text [format "%*s" [incr spaces] " "]
   489     } else {
   490 #	puts "tab: found tab outside of <PRE> block"
   491     }
   492 }
   493 
   494 
   495 # setTabs --
   496 #
   497 # This procedure handles the ".ta" macro, which sets tab stops.
   498 #
   499 # Arguments:
   500 # tabList -	List of tab stops, each consisting of a number
   501 #			followed by "i" (inch) or "c" (cm).
   502 
   503 proc setTabs {tabList} {
   504     global file breakPending tabString
   505 
   506 #	puts "setTabs: --$tabList--"
   507     set last 0
   508     set tabString {}
   509     set charsPerInch 14.
   510     set numTabs [llength $tabList]
   511     foreach arg $tabList {
   512 	if {[scan $arg "%f%s" distance units] != 2} {
   513 	    puts stderr "bad distance \"$arg\""
   514 	    return 0
   515     	}
   516 	switch -- $units {
   517 	    c	{
   518 		set distance [expr $distance * $charsPerInch / 2.54 ]
   519 	    }
   520 	    i	{
   521 		set distance [expr $distance * $charsPerInch]
   522 	    }
   523 	    default {
   524 		puts stderr "bad units in distance \"$arg\""
   525 		continue
   526 	    }
   527     	}
   528 #		? distance
   529     	lappend tabString [format "%*s1" [expr round($distance-$last-1)] " "]
   530     	set last $distance
   531     }
   532     set tabString [join $tabString {}]
   533 #	puts "setTabs: --$tabString--"
   534 }
   535 
   536 
   537 
   538 # lineBreak --
   539 #
   540 # Generates a line break in the HTML output.
   541 #
   542 # Arguments:
   543 # None.
   544 
   545 proc lineBreak {} {
   546     global file inPRE
   547     puts $file "<BR>"
   548 }
   549 
   550 
   551 
   552 # newline --
   553 #
   554 # This procedure is invoked to handle newlines in the troff input.
   555 # It outputs either a space character or a newline character, depending
   556 # on fill mode.
   557 #
   558 # Arguments:
   559 # None.
   560 
   561 proc newline {} {
   562     global noFillCount file inDT inPRE charCnt
   563 
   564     if {$inDT != {} } {
   565     	puts $file "\n$inDT"
   566     	set inDT {}
   567     } elseif {$noFillCount == 0 || $inPRE == 1} {
   568 	puts $file {}
   569     } else {
   570 	lineBreak
   571 	incr noFillCount -1
   572     }
   573     set charCnt 0
   574 }
   575 
   576 
   577 
   578 # char --
   579 #
   580 # This procedure is called to handle a special character.
   581 #
   582 # Arguments:
   583 # name -		Special character named in troff \x or \(xx construct.
   584 
   585 proc char name {
   586     global file charCnt
   587 
   588     incr charCnt
   589 #	puts "char: $name"
   590     switch -exact $name {
   591 	\\0 {					;#  \0
   592 	    puts -nonewline $file " "
   593 	}
   594 	\\\\ {					;#  \
   595 	    puts -nonewline $file "\\"
   596 	}
   597 	\\(+- { 				;#  +/-
   598 	    puts -nonewline $file "&#177;"
   599 	}
   600 	\\% {}					;#  \%
   601 	\\| {					;#  \|
   602 	}
   603 	default {
   604 	    puts stderr "Unknown character: $name"
   605 	}
   606     }
   607 }
   608 
   609 
   610 # macro2 --
   611 #
   612 # This procedure handles macros that are invoked with a leading "'"
   613 # character instead of space.  Right now it just generates an
   614 # error diagnostic.
   615 #
   616 # Arguments:
   617 # name -		The name of the macro (without the ".").
   618 # args -		Any additional arguments to the macro.
   619 
   620 proc macro2 {name args} {
   621     puts stderr "Unknown macro: '$name [join $args " "]"
   622 }
   623 
   624 
   625 
   626 # SHmacro --
   627 #
   628 # Subsection head; handles the .SH macro.
   629 #
   630 # Arguments:
   631 # name -		Section name.
   632 
   633 proc SHmacro argList {
   634     global file noFillCount textState charCnt
   635 
   636     set args [join $argList " "]
   637     if {[llength $argList] < 1} {
   638 	puts stderr "Bad .SH macro: .$name $args"
   639     }
   640 
   641     set noFillCount 0
   642     nest reset
   643 
   644     puts -nonewline $file "<H3>"
   645     text $args
   646     puts $file "</H3>"
   647 
   648 #	? args textState
   649 
   650     # control what the text proc does with text
   651     
   652     switch $args {
   653 	NAME {set textState NAME}
   654 	DESCRIPTION {set textState INSERT}
   655 	INTRODUCTION {set textState INSERT}
   656 	"WIDGET-SPECIFIC OPTIONS" {set textState INSERT}
   657 	"SEE ALSO" {set textState SEE}
   658 	KEYWORDS {set textState 0}
   659     }
   660     set charCnt 0
   661 }
   662 
   663 
   664 
   665 # IPmacro --
   666 #
   667 # This procedure is invoked to handle ".IP" macros, which may take any
   668 # of the following forms:
   669 #
   670 # .IP [1]			Translate to a "1Step" paragraph.
   671 # .IP [x] (x > 1)	Translate to a "Step" paragraph.
   672 # .IP				Translate to a "Bullet" paragraph.
   673 # .IP text count	Translate to a FirstBody paragraph with special
   674 #					indent and tab stop based on "count", and tab after
   675 #					"text".
   676 #
   677 # Arguments:
   678 # argList -		List of arguments to the .IP macro.
   679 #
   680 # HTML limitations: 'count' in '.IP text count' is ignored.
   681 
   682 proc IPmacro argList {
   683     global file
   684 
   685     setTabs 0.5i
   686     set length [llength $argList]
   687     if {$length == 0} {
   688     	nest para UL LI
   689 	return
   690     }
   691     if {$length == 1} {
   692     	nest para OL LI
   693 	    return
   694 	}
   695     if {$length > 1} {
   696     	nest para DL DT
   697 	    formattedText [lindex $argList 0]
   698 	    puts $file "\n<DD>"
   699 	    return
   700     }
   701     puts stderr "Bad .IP macro: .IP [join $argList " "]"
   702 }
   703 
   704 
   705 # TPmacro --
   706 #
   707 # This procedure is invoked to handle ".TP" macros, which may take any
   708 # of the following forms:
   709 #
   710 # .TP x		Translate to an indented paragraph with the
   711 # 			specified indent (in 100 twip units).
   712 # .TP		Translate to an indented paragraph with
   713 # 			default indent.
   714 #
   715 # Arguments:
   716 # argList -		List of arguments to the .IP macro.
   717 #
   718 # HTML limitations: 'x' in '.TP x' is ignored.
   719 
   720 
   721 proc TPmacro {argList} {
   722     global inDT
   723     nest para DL DT
   724     set inDT "\n<DD>"			;# next newline writes inDT 
   725     setTabs 0.5i
   726 }
   727 
   728 
   729 
   730 # THmacro --
   731 #
   732 # This procedure handles the .TH macro.  It generates the non-scrolling
   733 # header section for a given man page, and enters information into the
   734 # table of contents.  The .TH macro has the following form:
   735 #
   736 # .TH name section date footer header
   737 #
   738 # Arguments:
   739 # argList -		List of arguments to the .TH macro.
   740 
   741 proc THmacro {argList} {
   742     global file
   743 
   744     if {[llength $argList] != 5} {
   745 	set args [join $argList " "]
   746 	puts stderr "Bad .TH macro: .$name $args"
   747     }
   748     set name  [lindex $argList 0]		;# Tcl_UpVar
   749     set page  [lindex $argList 1]		;# 3
   750     set vers  [lindex $argList 2]		;# 7.4
   751     set lib   [lindex $argList 3]		;# Tcl
   752     set pname [lindex $argList 4]		;# {Tcl Library Procedures}
   753 
   754     puts -nonewline $file "<HTML><HEAD><TITLE>"
   755     text "$lib - $name ($page)"
   756     puts $file "</TITLE></HEAD><BODY>\n"
   757     
   758     puts -nonewline $file "<H1><CENTER>"
   759     text $pname
   760     puts $file "</CENTER></H1>\n"
   761 }
   762 
   763 
   764 
   765 # newPara --
   766 #
   767 # This procedure sets the left and hanging indents for a line.
   768 # Indents are specified in units of inches or centimeters, and are
   769 # relative to the current nesting level and left margin.
   770 #
   771 # Arguments:
   772 # None
   773 
   774 proc newPara {} {
   775     global file nestStk
   776 	
   777     if {[lindex $nestStk end] != "NEW" } {
   778 	nest decr    
   779     }
   780     puts -nonewline $file "<P>"
   781 }
   782 
   783 
   784 
   785 # nest --
   786 #
   787 # This procedure takes care of inserting the tags associated with the
   788 # IP, TP, RS, RE, LP and PP macros. Only 'nest para' takes arguments.
   789 #
   790 # Arguments:
   791 # op -				operation: para, incr, decr, reset, init
   792 # listStart -		begin list tag: OL, UL, DL.
   793 # listItem -		item tag:       LI, LI, DT.
   794 
   795 proc nest {op {listStart "NEW"} {listItem {} } } {
   796     global file nestStk inDT charCnt
   797 #	puts "nest: $op $listStart $listItem"
   798     switch $op {
   799 	para {
   800 	    set top [lindex $nestStk end]
   801 	    if {$top == "NEW" } {
   802 		set nestStk [lreplace $nestStk end end $listStart]
   803 		puts $file "<$listStart>"
   804 	    } elseif {$top != $listStart} {
   805 		puts stderr "nest para: bad stack"
   806 		exit 1
   807 	    }
   808 	    puts $file "\n<$listItem>"
   809 	    set charCnt 0
   810 	}
   811 	incr {
   812 	   lappend nestStk NEW
   813 	}
   814 	decr {
   815 	    if {[llength $nestStk] == 0} {
   816 		puts stderr "nest error: nest length is zero"
   817 		set nestStk NEW
   818 	    }
   819 	    set tag [lindex $nestStk end]
   820 	    if {$tag != "NEW"} {
   821 		puts $file "</$tag>"
   822 	    }
   823 	    set nestStk [lreplace $nestStk end end]
   824 	}
   825 	reset {
   826 	    while {[llength $nestStk] > 0} {
   827 		nest decr
   828 	    }
   829 	    set nestStk NEW
   830 	}
   831 	init {
   832 	    set nestStk NEW
   833 	    set inDT {}
   834 	}
   835     }
   836     set charCnt 0
   837 }
   838 
   839 
   840 
   841 # do --
   842 #
   843 # This is the toplevel procedure that translates a man page
   844 # to Frame.  It runs the man2tcl program to turn the man page
   845 # into a script, then it evals that script.
   846 #
   847 # Arguments:
   848 # fileName -		Name of the file to translate.
   849 
   850 proc do fileName {
   851     global file self html_dir package footer
   852     set self "[file tail $fileName].html"
   853     set file [open "$html_dir/$package/$self" w]
   854     puts "  Pass 2 -- $fileName"
   855     flush stdout
   856     initGlobals
   857     if [catch {eval [exec man2tcl [glob $fileName]]} msg] {
   858 	global errorInfo
   859 	puts stderr $msg
   860 	puts "in"
   861 	puts stderr $errorInfo
   862 	exit 1
   863     }
   864     nest reset
   865     puts $file $footer
   866     puts $file "</BODY></HTML>"
   867     close $file
   868 }
   869 
   870 
   871