os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/man2html2.tcl
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/man2html2.tcl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,871 @@
1.4 +# man2html2.tcl --
1.5 +#
1.6 +# This file defines procedures that are used during the second pass of the
1.7 +# man page to html conversion process. It is sourced by man2html.tcl.
1.8 +#
1.9 +# Copyright (c) 1996 by Sun Microsystems, Inc.
1.10 +#
1.11 +# SCCS: @(#) man2html2.tcl 1.2 96/03/21 10:48:30
1.12 +#
1.13 +
1.14 +# Global variables used by these scripts:
1.15 +#
1.16 +# NAME_file - array indexed by NAME and containing file names used
1.17 +# for hyperlinks.
1.18 +#
1.19 +# textState - state variable defining action of 'text' proc.
1.20 +#
1.21 +# nestStk - stack oriented list containing currently active
1.22 +# HTML tags (UL, OL, DL). Local to 'nest' proc.
1.23 +#
1.24 +# inDT - set by 'TPmacro', cleared by 'newline'. Used to insert
1.25 +# the <DT> tag while in a dictionary list <DL>.
1.26 +#
1.27 +# curFont - Name of special font that is currently in
1.28 +# use. Null means the default paragraph font
1.29 +# is being used.
1.30 +#
1.31 +# file - Where to output the generated HTML.
1.32 +#
1.33 +# fontStart - Array to map font names to starting sequences.
1.34 +#
1.35 +# fontEnd - Array to map font names to ending sequences.
1.36 +#
1.37 +# noFillCount - Non-zero means don't fill the next $noFillCount
1.38 +# lines: force a line break at each newline. Zero
1.39 +# means filling is enabled, so don't output line
1.40 +# breaks for each newline.
1.41 +#
1.42 +# footer - info inserted at bottom of each page. Normally read
1.43 +# from the xref.tcl file
1.44 +
1.45 +# initGlobals --
1.46 +#
1.47 +# This procedure is invoked to set the initial values of all of the
1.48 +# global variables, before processing a man page.
1.49 +#
1.50 +# Arguments:
1.51 +# None.
1.52 +
1.53 +proc initGlobals {} {
1.54 + global file noFillCount textState
1.55 + global fontStart fontEnd curFont inPRE charCnt
1.56 +
1.57 + nest init
1.58 + set inPRE 0
1.59 + set textState 0
1.60 + set curFont ""
1.61 + set fontStart(Code) "<B>"
1.62 + set fontStart(Emphasis) "<I>"
1.63 + set fontEnd(Code) "</B>"
1.64 + set fontEnd(Emphasis) "</I>"
1.65 + set noFillCount 0
1.66 + set charCnt 0
1.67 + setTabs 0.5i
1.68 +}
1.69 +
1.70 +
1.71 +# beginFont --
1.72 +#
1.73 +# Arranges for future text to use a special font, rather than
1.74 +# the default paragraph font.
1.75 +#
1.76 +# Arguments:
1.77 +# font - Name of new font to use.
1.78 +
1.79 +proc beginFont font {
1.80 + global curFont file fontStart
1.81 +
1.82 + if {$curFont == $font} {
1.83 + return
1.84 + }
1.85 + endFont
1.86 + puts -nonewline $file $fontStart($font)
1.87 + set curFont $font
1.88 +}
1.89 +
1.90 +
1.91 +# endFont --
1.92 +#
1.93 +# Reverts to the default font for the paragraph type.
1.94 +#
1.95 +# Arguments:
1.96 +# None.
1.97 +
1.98 +proc endFont {} {
1.99 + global curFont file fontEnd
1.100 +
1.101 + if {$curFont != ""} {
1.102 + puts -nonewline $file $fontEnd($curFont)
1.103 + set curFont ""
1.104 + }
1.105 +}
1.106 +
1.107 +
1.108 +
1.109 +# text --
1.110 +#
1.111 +# This procedure adds text to the current paragraph. If this is
1.112 +# the first text in the paragraph then header information for the
1.113 +# paragraph is output before the text.
1.114 +#
1.115 +# Arguments:
1.116 +# string - Text to output in the paragraph.
1.117 +
1.118 +proc text string {
1.119 + global file textState inDT charCnt
1.120 +
1.121 + set pos [string first "\t" $string]
1.122 + if {$pos >= 0} {
1.123 + text [string range $string 0 [expr $pos-1]]
1.124 + tab
1.125 + text [string range $string [expr $pos+1] end]
1.126 + return
1.127 + }
1.128 + incr charCnt [string length $string]
1.129 + regsub -all {&} $string {\&} string
1.130 + regsub -all {<} $string {\<} string
1.131 + regsub -all {>} $string {\>} string
1.132 + regsub -all {"} $string {\"} string
1.133 + switch $textState {
1.134 + REF {
1.135 + if {$inDT == {}} {
1.136 + set string [insertRef $string]
1.137 + }
1.138 + }
1.139 + SEE {
1.140 + global NAME_file
1.141 + foreach i [split $string] {
1.142 + if ![regexp -nocase {^[a-z_]+} [string trim $i] i ] {
1.143 +# puts "Warning: $i in SEE ALSO not found"
1.144 + continue
1.145 + }
1.146 + if ![catch {set ref $NAME_file($i)} ] {
1.147 + regsub $i $string "<A HREF=\"$ref.html\">$i</A>" string
1.148 + }
1.149 + }
1.150 + }
1.151 + }
1.152 + puts -nonewline $file "$string"
1.153 +}
1.154 +
1.155 +
1.156 +
1.157 +# insertRef --
1.158 +#
1.159 +#
1.160 +# Arguments:
1.161 +# string - Text to output in the paragraph.
1.162 +
1.163 +proc insertRef string {
1.164 + global NAME_file self
1.165 + set path {}
1.166 + if ![catch {set ref $NAME_file([string trim $string])} ] {
1.167 + if {"$ref.html" != $self} {
1.168 + set string "<A HREF=\"${path}$ref.html\">$string</A>"
1.169 +# puts "insertRef: $self $ref.html ---$string--"
1.170 + }
1.171 + }
1.172 + return $string
1.173 +}
1.174 +
1.175 +
1.176 +
1.177 +# macro --
1.178 +#
1.179 +# This procedure is invoked to process macro invocations that start
1.180 +# with "." (instead of ').
1.181 +#
1.182 +# Arguments:
1.183 +# name - The name of the macro (without the ".").
1.184 +# args - Any additional arguments to the macro.
1.185 +
1.186 +proc macro {name args} {
1.187 + switch $name {
1.188 + AP {
1.189 + if {[llength $args] != 3} {
1.190 + puts stderr "Bad .AP macro: .$name [join $args " "]"
1.191 + }
1.192 + setTabs {1.25i 2.5i 3.75i}
1.193 + TPmacro {}
1.194 + font B
1.195 + text "[lindex $args 0] "
1.196 + font I
1.197 + text "[lindex $args 1]"
1.198 + font R
1.199 + text " ([lindex $args 2])"
1.200 + newline
1.201 + }
1.202 + AS {} ;# next page and previous page
1.203 + br {
1.204 + lineBreak
1.205 + }
1.206 + BS {}
1.207 + BE {}
1.208 + CE {
1.209 + global file noFillCount inPRE
1.210 + puts $file </PRE></BLOCKQUOTE>
1.211 + set inPRE 0
1.212 + }
1.213 + CS { ;# code section
1.214 + global file noFillCount inPRE
1.215 + puts -nonewline $file <BLOCKQUOTE><PRE>
1.216 + set inPRE 1
1.217 + }
1.218 + DE {
1.219 + global file noFillCount inPRE
1.220 + puts $file </PRE></BLOCKQUOTE>
1.221 + set inPRE 0
1.222 + set noFillCount 0
1.223 + }
1.224 + DS {
1.225 + global file noFillCount inPRE
1.226 + puts -nonewline $file <BLOCKQUOTE><PRE>
1.227 + set noFillCount 10000000
1.228 + set inPRE 1
1.229 + }
1.230 + fi {
1.231 + global noFillCount
1.232 + set noFillCount 0
1.233 + }
1.234 + IP {
1.235 + IPmacro $args
1.236 + }
1.237 + LP {
1.238 + nest decr
1.239 + nest incr
1.240 + newPara
1.241 + }
1.242 + ne {
1.243 + }
1.244 + nf {
1.245 + global noFillCount
1.246 + set noFillCount 1000000
1.247 + }
1.248 + OP {
1.249 + global inDT file inPRE
1.250 + if {[llength $args] != 3} {
1.251 + puts stderr "Bad .OP macro: .$name [join $args " "]"
1.252 + }
1.253 + nest para DL DT
1.254 + set inPRE 1
1.255 + puts -nonewline $file <PRE>
1.256 + setTabs 4c
1.257 + text "Command-Line Name:"
1.258 + tab
1.259 + font B
1.260 + set x [lindex $args 0]
1.261 + regsub -all {\\-} $x - x
1.262 + text $x
1.263 + newline
1.264 + font R
1.265 + text "Database Name:"
1.266 + tab
1.267 + font B
1.268 + text [lindex $args 1]
1.269 + newline
1.270 + font R
1.271 + text "Database Class:"
1.272 + tab
1.273 + font B
1.274 + text [lindex $args 2]
1.275 + font R
1.276 + puts -nonewline $file </PRE>
1.277 + set inDT "\n<DD>" ;# next newline writes inDT
1.278 + set inPRE 0
1.279 + newline
1.280 + }
1.281 + PP {
1.282 + nest decr
1.283 + nest incr
1.284 + newPara
1.285 + }
1.286 + RE {
1.287 + nest decr
1.288 + }
1.289 + RS {
1.290 + nest incr
1.291 + }
1.292 + SE {
1.293 + global noFillCount textState inPRE file
1.294 +
1.295 + font R
1.296 + puts -nonewline $file </PRE>
1.297 + set inPRE 0
1.298 + set noFillCount 0
1.299 + nest reset
1.300 + newPara
1.301 + text "See the "
1.302 + font B
1.303 + set temp $textState
1.304 + set textState REF
1.305 + text options
1.306 + set textState $temp
1.307 + font R
1.308 + text " manual entry for detailed descriptions of the above options."
1.309 + }
1.310 + SH {
1.311 + SHmacro $args
1.312 + }
1.313 + SO {
1.314 + global noFillCount inPRE file
1.315 +
1.316 + SHmacro "STANDARD OPTIONS"
1.317 + setTabs {4c 8c 12c}
1.318 + set noFillCount 1000000
1.319 + puts -nonewline $file <PRE>
1.320 + set inPRE 1
1.321 + font B
1.322 + }
1.323 + so {
1.324 + if {$args != "man.macros"} {
1.325 + puts stderr "Unknown macro: .$name [join $args " "]"
1.326 + }
1.327 + }
1.328 + sp { ;# needs work
1.329 + if {$args == ""} {
1.330 + set count 1
1.331 + } else {
1.332 + set count [lindex $args 0]
1.333 + }
1.334 + while {$count > 0} {
1.335 + lineBreak
1.336 + incr count -1
1.337 + }
1.338 + }
1.339 + ta {
1.340 + setTabs $args
1.341 + }
1.342 + TH {
1.343 + THmacro $args
1.344 + }
1.345 + TP {
1.346 + TPmacro $args
1.347 + }
1.348 + UL { ;# underline
1.349 + global file
1.350 + puts -nonewline $file "<B><U>"
1.351 + text [lindex $args 0]
1.352 + puts -nonewline $file "</U></B>"
1.353 + if {[llength $args] == 2} {
1.354 + text [lindex $args 1]
1.355 + }
1.356 + }
1.357 + VE {
1.358 +# global file
1.359 +# puts -nonewline $file "</FONT>"
1.360 + }
1.361 + VS {
1.362 +# global file
1.363 +# if {[llength $args] > 0} {
1.364 +# puts -nonewline $file "<BR>"
1.365 +# }
1.366 +# puts -nonewline $file "<FONT COLOR=\"GREEN\">"
1.367 + }
1.368 + default {
1.369 + puts stderr "Unknown macro: .$name [join $args " "]"
1.370 + }
1.371 + }
1.372 +
1.373 +# global nestStk; puts "$name [format "%-20s" $args] $nestStk"
1.374 +# flush stdout; flush stderr
1.375 +}
1.376 +
1.377 +
1.378 +# font --
1.379 +#
1.380 +# This procedure is invoked to handle font changes in the text
1.381 +# being output.
1.382 +#
1.383 +# Arguments:
1.384 +# type - Type of font: R, I, B, or S.
1.385 +
1.386 +proc font type {
1.387 + global textState
1.388 + switch $type {
1.389 + P -
1.390 + R {
1.391 + endFont
1.392 + if {$textState == "REF"} {
1.393 + set textState INSERT
1.394 + }
1.395 + }
1.396 + B {
1.397 + beginFont Code
1.398 + if {$textState == "INSERT"} {
1.399 + set textState REF
1.400 + }
1.401 + }
1.402 + I {
1.403 + beginFont Emphasis
1.404 + }
1.405 + S {
1.406 + }
1.407 + default {
1.408 + puts stderr "Unknown font: $type"
1.409 + }
1.410 + }
1.411 +}
1.412 +
1.413 +
1.414 +
1.415 +# formattedText --
1.416 +#
1.417 +# Insert a text string that may also have \fB-style font changes
1.418 +# and a few other backslash sequences in it.
1.419 +#
1.420 +# Arguments:
1.421 +# text - Text to insert.
1.422 +
1.423 +proc formattedText text {
1.424 +# puts "formattedText: $text"
1.425 + while {$text != ""} {
1.426 + set index [string first \\ $text]
1.427 + if {$index < 0} {
1.428 + text $text
1.429 + return
1.430 + }
1.431 + text [string range $text 0 [expr $index-1]]
1.432 + set c [string index $text [expr $index+1]]
1.433 + switch -- $c {
1.434 + f {
1.435 + font [string index $text [expr $index+2]]
1.436 + set text [string range $text [expr $index+3] end]
1.437 + }
1.438 + e {
1.439 + text \\
1.440 + set text [string range $text [expr $index+2] end]
1.441 + }
1.442 + - {
1.443 + dash
1.444 + set text [string range $text [expr $index+2] end]
1.445 + }
1.446 + | {
1.447 + set text [string range $text [expr $index+2] end]
1.448 + }
1.449 + default {
1.450 + puts stderr "Unknown sequence: \\$c"
1.451 + set text [string range $text [expr $index+2] end]
1.452 + }
1.453 + }
1.454 + }
1.455 +}
1.456 +
1.457 +
1.458 +
1.459 +# dash --
1.460 +#
1.461 +# This procedure is invoked to handle dash characters ("\-" in
1.462 +# troff). It outputs a special dash character.
1.463 +#
1.464 +# Arguments:
1.465 +# None.
1.466 +
1.467 +proc dash {} {
1.468 + global textState charCnt
1.469 + if {$textState == "NAME"} {
1.470 + set textState 0
1.471 + }
1.472 + incr charCnt
1.473 + text "-"
1.474 +}
1.475 +
1.476 +
1.477 +# tab --
1.478 +#
1.479 +# This procedure is invoked to handle tabs in the troff input.
1.480 +# Right now it does nothing.
1.481 +#
1.482 +# Arguments:
1.483 +# None.
1.484 +
1.485 +proc tab {} {
1.486 + global inPRE charCnt tabString
1.487 +# ? charCnt
1.488 + if {$inPRE == 1} {
1.489 + set pos [expr $charCnt % [string length $tabString] ]
1.490 + set spaces [string first "1" [string range $tabString $pos end] ]
1.491 + text [format "%*s" [incr spaces] " "]
1.492 + } else {
1.493 +# puts "tab: found tab outside of <PRE> block"
1.494 + }
1.495 +}
1.496 +
1.497 +
1.498 +# setTabs --
1.499 +#
1.500 +# This procedure handles the ".ta" macro, which sets tab stops.
1.501 +#
1.502 +# Arguments:
1.503 +# tabList - List of tab stops, each consisting of a number
1.504 +# followed by "i" (inch) or "c" (cm).
1.505 +
1.506 +proc setTabs {tabList} {
1.507 + global file breakPending tabString
1.508 +
1.509 +# puts "setTabs: --$tabList--"
1.510 + set last 0
1.511 + set tabString {}
1.512 + set charsPerInch 14.
1.513 + set numTabs [llength $tabList]
1.514 + foreach arg $tabList {
1.515 + if {[scan $arg "%f%s" distance units] != 2} {
1.516 + puts stderr "bad distance \"$arg\""
1.517 + return 0
1.518 + }
1.519 + switch -- $units {
1.520 + c {
1.521 + set distance [expr $distance * $charsPerInch / 2.54 ]
1.522 + }
1.523 + i {
1.524 + set distance [expr $distance * $charsPerInch]
1.525 + }
1.526 + default {
1.527 + puts stderr "bad units in distance \"$arg\""
1.528 + continue
1.529 + }
1.530 + }
1.531 +# ? distance
1.532 + lappend tabString [format "%*s1" [expr round($distance-$last-1)] " "]
1.533 + set last $distance
1.534 + }
1.535 + set tabString [join $tabString {}]
1.536 +# puts "setTabs: --$tabString--"
1.537 +}
1.538 +
1.539 +
1.540 +
1.541 +# lineBreak --
1.542 +#
1.543 +# Generates a line break in the HTML output.
1.544 +#
1.545 +# Arguments:
1.546 +# None.
1.547 +
1.548 +proc lineBreak {} {
1.549 + global file inPRE
1.550 + puts $file "<BR>"
1.551 +}
1.552 +
1.553 +
1.554 +
1.555 +# newline --
1.556 +#
1.557 +# This procedure is invoked to handle newlines in the troff input.
1.558 +# It outputs either a space character or a newline character, depending
1.559 +# on fill mode.
1.560 +#
1.561 +# Arguments:
1.562 +# None.
1.563 +
1.564 +proc newline {} {
1.565 + global noFillCount file inDT inPRE charCnt
1.566 +
1.567 + if {$inDT != {} } {
1.568 + puts $file "\n$inDT"
1.569 + set inDT {}
1.570 + } elseif {$noFillCount == 0 || $inPRE == 1} {
1.571 + puts $file {}
1.572 + } else {
1.573 + lineBreak
1.574 + incr noFillCount -1
1.575 + }
1.576 + set charCnt 0
1.577 +}
1.578 +
1.579 +
1.580 +
1.581 +# char --
1.582 +#
1.583 +# This procedure is called to handle a special character.
1.584 +#
1.585 +# Arguments:
1.586 +# name - Special character named in troff \x or \(xx construct.
1.587 +
1.588 +proc char name {
1.589 + global file charCnt
1.590 +
1.591 + incr charCnt
1.592 +# puts "char: $name"
1.593 + switch -exact $name {
1.594 + \\0 { ;# \0
1.595 + puts -nonewline $file " "
1.596 + }
1.597 + \\\\ { ;# \
1.598 + puts -nonewline $file "\\"
1.599 + }
1.600 + \\(+- { ;# +/-
1.601 + puts -nonewline $file "±"
1.602 + }
1.603 + \\% {} ;# \%
1.604 + \\| { ;# \|
1.605 + }
1.606 + default {
1.607 + puts stderr "Unknown character: $name"
1.608 + }
1.609 + }
1.610 +}
1.611 +
1.612 +
1.613 +# macro2 --
1.614 +#
1.615 +# This procedure handles macros that are invoked with a leading "'"
1.616 +# character instead of space. Right now it just generates an
1.617 +# error diagnostic.
1.618 +#
1.619 +# Arguments:
1.620 +# name - The name of the macro (without the ".").
1.621 +# args - Any additional arguments to the macro.
1.622 +
1.623 +proc macro2 {name args} {
1.624 + puts stderr "Unknown macro: '$name [join $args " "]"
1.625 +}
1.626 +
1.627 +
1.628 +
1.629 +# SHmacro --
1.630 +#
1.631 +# Subsection head; handles the .SH macro.
1.632 +#
1.633 +# Arguments:
1.634 +# name - Section name.
1.635 +
1.636 +proc SHmacro argList {
1.637 + global file noFillCount textState charCnt
1.638 +
1.639 + set args [join $argList " "]
1.640 + if {[llength $argList] < 1} {
1.641 + puts stderr "Bad .SH macro: .$name $args"
1.642 + }
1.643 +
1.644 + set noFillCount 0
1.645 + nest reset
1.646 +
1.647 + puts -nonewline $file "<H3>"
1.648 + text $args
1.649 + puts $file "</H3>"
1.650 +
1.651 +# ? args textState
1.652 +
1.653 + # control what the text proc does with text
1.654 +
1.655 + switch $args {
1.656 + NAME {set textState NAME}
1.657 + DESCRIPTION {set textState INSERT}
1.658 + INTRODUCTION {set textState INSERT}
1.659 + "WIDGET-SPECIFIC OPTIONS" {set textState INSERT}
1.660 + "SEE ALSO" {set textState SEE}
1.661 + KEYWORDS {set textState 0}
1.662 + }
1.663 + set charCnt 0
1.664 +}
1.665 +
1.666 +
1.667 +
1.668 +# IPmacro --
1.669 +#
1.670 +# This procedure is invoked to handle ".IP" macros, which may take any
1.671 +# of the following forms:
1.672 +#
1.673 +# .IP [1] Translate to a "1Step" paragraph.
1.674 +# .IP [x] (x > 1) Translate to a "Step" paragraph.
1.675 +# .IP Translate to a "Bullet" paragraph.
1.676 +# .IP text count Translate to a FirstBody paragraph with special
1.677 +# indent and tab stop based on "count", and tab after
1.678 +# "text".
1.679 +#
1.680 +# Arguments:
1.681 +# argList - List of arguments to the .IP macro.
1.682 +#
1.683 +# HTML limitations: 'count' in '.IP text count' is ignored.
1.684 +
1.685 +proc IPmacro argList {
1.686 + global file
1.687 +
1.688 + setTabs 0.5i
1.689 + set length [llength $argList]
1.690 + if {$length == 0} {
1.691 + nest para UL LI
1.692 + return
1.693 + }
1.694 + if {$length == 1} {
1.695 + nest para OL LI
1.696 + return
1.697 + }
1.698 + if {$length > 1} {
1.699 + nest para DL DT
1.700 + formattedText [lindex $argList 0]
1.701 + puts $file "\n<DD>"
1.702 + return
1.703 + }
1.704 + puts stderr "Bad .IP macro: .IP [join $argList " "]"
1.705 +}
1.706 +
1.707 +
1.708 +# TPmacro --
1.709 +#
1.710 +# This procedure is invoked to handle ".TP" macros, which may take any
1.711 +# of the following forms:
1.712 +#
1.713 +# .TP x Translate to an indented paragraph with the
1.714 +# specified indent (in 100 twip units).
1.715 +# .TP Translate to an indented paragraph with
1.716 +# default indent.
1.717 +#
1.718 +# Arguments:
1.719 +# argList - List of arguments to the .IP macro.
1.720 +#
1.721 +# HTML limitations: 'x' in '.TP x' is ignored.
1.722 +
1.723 +
1.724 +proc TPmacro {argList} {
1.725 + global inDT
1.726 + nest para DL DT
1.727 + set inDT "\n<DD>" ;# next newline writes inDT
1.728 + setTabs 0.5i
1.729 +}
1.730 +
1.731 +
1.732 +
1.733 +# THmacro --
1.734 +#
1.735 +# This procedure handles the .TH macro. It generates the non-scrolling
1.736 +# header section for a given man page, and enters information into the
1.737 +# table of contents. The .TH macro has the following form:
1.738 +#
1.739 +# .TH name section date footer header
1.740 +#
1.741 +# Arguments:
1.742 +# argList - List of arguments to the .TH macro.
1.743 +
1.744 +proc THmacro {argList} {
1.745 + global file
1.746 +
1.747 + if {[llength $argList] != 5} {
1.748 + set args [join $argList " "]
1.749 + puts stderr "Bad .TH macro: .$name $args"
1.750 + }
1.751 + set name [lindex $argList 0] ;# Tcl_UpVar
1.752 + set page [lindex $argList 1] ;# 3
1.753 + set vers [lindex $argList 2] ;# 7.4
1.754 + set lib [lindex $argList 3] ;# Tcl
1.755 + set pname [lindex $argList 4] ;# {Tcl Library Procedures}
1.756 +
1.757 + puts -nonewline $file "<HTML><HEAD><TITLE>"
1.758 + text "$lib - $name ($page)"
1.759 + puts $file "</TITLE></HEAD><BODY>\n"
1.760 +
1.761 + puts -nonewline $file "<H1><CENTER>"
1.762 + text $pname
1.763 + puts $file "</CENTER></H1>\n"
1.764 +}
1.765 +
1.766 +
1.767 +
1.768 +# newPara --
1.769 +#
1.770 +# This procedure sets the left and hanging indents for a line.
1.771 +# Indents are specified in units of inches or centimeters, and are
1.772 +# relative to the current nesting level and left margin.
1.773 +#
1.774 +# Arguments:
1.775 +# None
1.776 +
1.777 +proc newPara {} {
1.778 + global file nestStk
1.779 +
1.780 + if {[lindex $nestStk end] != "NEW" } {
1.781 + nest decr
1.782 + }
1.783 + puts -nonewline $file "<P>"
1.784 +}
1.785 +
1.786 +
1.787 +
1.788 +# nest --
1.789 +#
1.790 +# This procedure takes care of inserting the tags associated with the
1.791 +# IP, TP, RS, RE, LP and PP macros. Only 'nest para' takes arguments.
1.792 +#
1.793 +# Arguments:
1.794 +# op - operation: para, incr, decr, reset, init
1.795 +# listStart - begin list tag: OL, UL, DL.
1.796 +# listItem - item tag: LI, LI, DT.
1.797 +
1.798 +proc nest {op {listStart "NEW"} {listItem {} } } {
1.799 + global file nestStk inDT charCnt
1.800 +# puts "nest: $op $listStart $listItem"
1.801 + switch $op {
1.802 + para {
1.803 + set top [lindex $nestStk end]
1.804 + if {$top == "NEW" } {
1.805 + set nestStk [lreplace $nestStk end end $listStart]
1.806 + puts $file "<$listStart>"
1.807 + } elseif {$top != $listStart} {
1.808 + puts stderr "nest para: bad stack"
1.809 + exit 1
1.810 + }
1.811 + puts $file "\n<$listItem>"
1.812 + set charCnt 0
1.813 + }
1.814 + incr {
1.815 + lappend nestStk NEW
1.816 + }
1.817 + decr {
1.818 + if {[llength $nestStk] == 0} {
1.819 + puts stderr "nest error: nest length is zero"
1.820 + set nestStk NEW
1.821 + }
1.822 + set tag [lindex $nestStk end]
1.823 + if {$tag != "NEW"} {
1.824 + puts $file "</$tag>"
1.825 + }
1.826 + set nestStk [lreplace $nestStk end end]
1.827 + }
1.828 + reset {
1.829 + while {[llength $nestStk] > 0} {
1.830 + nest decr
1.831 + }
1.832 + set nestStk NEW
1.833 + }
1.834 + init {
1.835 + set nestStk NEW
1.836 + set inDT {}
1.837 + }
1.838 + }
1.839 + set charCnt 0
1.840 +}
1.841 +
1.842 +
1.843 +
1.844 +# do --
1.845 +#
1.846 +# This is the toplevel procedure that translates a man page
1.847 +# to Frame. It runs the man2tcl program to turn the man page
1.848 +# into a script, then it evals that script.
1.849 +#
1.850 +# Arguments:
1.851 +# fileName - Name of the file to translate.
1.852 +
1.853 +proc do fileName {
1.854 + global file self html_dir package footer
1.855 + set self "[file tail $fileName].html"
1.856 + set file [open "$html_dir/$package/$self" w]
1.857 + puts " Pass 2 -- $fileName"
1.858 + flush stdout
1.859 + initGlobals
1.860 + if [catch {eval [exec man2tcl [glob $fileName]]} msg] {
1.861 + global errorInfo
1.862 + puts stderr $msg
1.863 + puts "in"
1.864 + puts stderr $errorInfo
1.865 + exit 1
1.866 + }
1.867 + nest reset
1.868 + puts $file $footer
1.869 + puts $file "</BODY></HTML>"
1.870 + close $file
1.871 +}
1.872 +
1.873 +
1.874 +