os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/index.tcl
First public contribution.
3 # This file defines procedures that are used during the first pass of
4 # the man page conversion. It is used to extract information used to
5 # generate a table of contents and a keyword list.
7 # Copyright (c) 1996 by Sun Microsystems, Inc.
9 # See the file "license.terms" for information on usage and redistribution
10 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 # RCS: @(#) $Id: index.tcl,v 1.3.40.1 2003/06/04 23:41:15 mistachkin Exp $
15 # Global variables used by these scripts:
17 # state - state variable that controls action of text proc.
19 # topics - array indexed by (package,section,topic) with value
22 # keywords - array indexed by keyword string with value of topic ID.
24 # curID - current topic ID, starts at 0 and is incremented for
25 # each new topic file.
27 # curPkg - current package name (e.g. Tcl).
29 # curSect - current section title (e.g. "Tcl Built-In Commands").
34 # Generate a sorted list of package names from the topics array.
41 foreach i [array names topics] {
42 regsub {^(.*),.*,.*$} $i {\1} i
45 lsort [array names temp]
50 # Generate a sorted list of section titles in the specified package
51 # from the topics array.
54 # pkg - Name of package to search.
56 proc getSections {pkg} {
58 regsub -all {[][*?\\]} $pkg {\\&} pkg
59 foreach i [array names topics "${pkg},*"] {
60 regsub {^.*,(.*),.*$} $i {\1} i
63 lsort [array names temp]
68 # Generate a sorted list of topics in the specified section of the
69 # specified package from the topics array.
72 # pkg - Name of package to search.
73 # sect - Name of section to search.
75 proc getTopics {pkg sect} {
77 regsub -all {[][*?\\]} $pkg {\\&} pkg
78 regsub -all {[][*?\\]} $sect {\\&} sect
79 foreach i [array names topics "${pkg},${sect},*"] {
80 regsub {^.*,.*,(.*)$} $i {\1} i
83 lsort [array names temp]
88 # This procedure adds entries to the hypertext arrays topics and keywords.
91 # string - Text to index.
95 global state curID curPkg curSect topics keywords
99 foreach i [split $string ","] {
100 set topic [string trim $i]
101 set index "$curPkg,$curSect,$topic"
102 if {[info exists topics($index)]
103 && [string compare $topics($index) $curID] != 0} {
104 puts stderr "duplicate topic $topic in $curPkg"
106 set topics($index) $curID
107 lappend keywords($topic) $curID
111 foreach i [split $string ","] {
112 lappend keywords([string trim $i]) $curID
119 puts stderr "text: unknown state: $state"
127 # This procedure is invoked to process macro invocations that start
128 # with "." (instead of ').
131 # name - The name of the macro (without the ".").
132 # args - Any additional arguments to the macro.
134 proc macro {name args} {
141 if {$state == "INIT" } {
145 DESCRIPTION {set state DT}
146 INTRODUCTION {set state DT}
147 KEYWORDS {set state KEY}
148 default {set state OFF}
153 global state curID curPkg curSect topics keywords
155 if {[llength $args] != 5} {
156 set args [join $args " "]
157 puts stderr "Bad .TH macro: .$name $args"
160 set topic [lindex $args 0] ;# Tcl_UpVar
161 set curPkg [lindex $args 3] ;# Tcl
162 set curSect [lindex $args 4] ;# {Tcl Library Procedures}
163 regsub -all {\\ } $curSect { } curSect
164 set index "$curPkg,$curSect,$topic"
165 set topics($index) $curID
166 lappend keywords($topic) $curID
174 # This procedure is invoked to handle dash characters ("\-" in
175 # troff). It only function in pass1 is to terminate the NAME state.
182 if {$state == "NAME"} {
189 # initGlobals, tab, font, char, macro2 --
191 # These procedures do nothing during the first pass.
196 proc initGlobals {} {}
201 proc macro2 {name args} {}