diff options
Diffstat (limited to 'tools/man2help.tcl')
| -rw-r--r-- | tools/man2help.tcl | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/tools/man2help.tcl b/tools/man2help.tcl index e86e78b..018fa84 100644 --- a/tools/man2help.tcl +++ b/tools/man2help.tcl @@ -5,32 +5,37 @@ # entries. # # Copyright (c) 1996 by Sun Microsystems, Inc. -# -# RCS: @(#) $Id: man2help.tcl,v 1.4 1999/02/19 02:14:56 stanton Exp $ -# # # PASS 1 # +set man2tclprog [file join [file dirname [info script]] \ + man2tcl[file extension [info nameofexecutable]]] + proc generateContents {basename version files} { global curID topics set curID 0 foreach f $files { - regsub -all -- {-} [file tail $f] {} curFile puts "Pass 1 -- $f" flush stdout doFile $f } - set fd [open "$basename$version.cnt" w] + set fd [open [file join [file dirname [info script]] $basename$version.cnt] w] fconfigure $fd -translation crlf puts $fd ":Base $basename$version.hlp" foreach package [getPackages] { foreach section [getSections $package] { + if {![info exists lastSection]} { + set lastSection {} + } + if {[string compare $lastSection $section]} { puts $fd "1 $section" + } + set lastSection $section set lastTopic {} foreach topic [getTopics $package $section] { - if {[string compare $lastTopic $topic] != 0} { + if {[string compare $lastTopic $topic]} { set id $topics($package,$section,$topic) puts $fd "2 $topic=$id" set lastTopic $topic @@ -55,12 +60,11 @@ proc generateHelp {basename files} { lappend id_keywords($id) $key } } - - set file [open "$basename.rtf" w] + + set file [open [file join [file dirname [info script]] $basename.rtf] w] fconfigure $file -translation crlf - puts $file "\{\\rtf1\\ansi \\deff0\\deflang1033\{\\fonttbl\{\\f0\\froman\\fcharset0\\fprq2 Times New Roman\;\}\}" + puts $file "\{\\rtf1\\ansi \\deff0\\deflang1033\{\\fonttbl\{\\f0\\froman\\fcharset0\\fprq2 Times New Roman\;\}\{\\f1\\fmodern\\fcharset0\\fprq1 Courier New\;\}\}" foreach f $files { - regsub -all -- {-} [file tail $f] {} curFile puts "Pass 2 -- $f" flush stdout initGlobals @@ -80,8 +84,8 @@ proc generateHelp {basename files} { # file - Name of file to translate. proc doFile {file} { - if {[catch {eval [exec man2tcl [glob $file]]} msg] && - [catch {eval [exec ./man2tcl [glob $file]]} msg]} { + global man2tclprog + if {[catch {eval [exec $man2tclprog [glob $file]]} msg]} { global errorInfo puts stderr $msg puts "in" @@ -100,33 +104,38 @@ proc doFile {file} { proc doDir dir { puts "Generating man pages for $dir..." - foreach f [lsort [glob [file join $dir *.\[13n\]]]] { - do $f + foreach f [lsort [glob -directory $dir "*.\[13n\]"]] { + doFile $f } } # process command line arguments if {$argc < 3} { - puts stderr "usage: $argv0 projectName version manFiles..." + puts stderr "usage: $argv0 \[options\] projectName version manFiles..." exit 1 } -set baseName [lindex $argv 0] -set version [lindex $argv 1] +set arg 0 + +if {![string compare [lindex $argv $arg] "-bitmap"]} { + set bitmap [lindex $argv [incr arg]] + incr arg +} +set baseName [lindex $argv $arg] +set version [lindex $argv [incr arg]] set files {} -foreach i [lrange $argv 2 end] { +foreach i [lrange $argv [incr arg] end] { set i [file join $i] - if [file isdir $i] { - foreach f [lsort [glob [file join $i *.\[13n\]]]] { + if {[file isdir $i]} { + foreach f [lsort [glob -directory $i "*.\[13n\]"]] { lappend files $f } - } elseif [file exists $i] { + } elseif {[file exists $i]} { lappend files $i } } - -source [file join [file dir $argv0] index.tcl] +source [file join [file dirname [info script]] index.tcl] generateContents $baseName $version $files -source [file join [file dir $argv0] man2help2.tcl] +source [file join [file dirname [info script]] man2help2.tcl] generateHelp $baseName $files |
