os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/index.tcl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/index.tcl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,202 @@
     1.4 +# index.tcl --
     1.5 +#
     1.6 +# This file defines procedures that are used during the first pass of
     1.7 +# the man page conversion.  It is used to extract information used to
     1.8 +# generate a table of contents and a keyword list.
     1.9 +#
    1.10 +# Copyright (c) 1996 by Sun Microsystems, Inc.
    1.11 +#
    1.12 +# See the file "license.terms" for information on usage and redistribution
    1.13 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.14 +# 
    1.15 +# RCS: @(#) $Id: index.tcl,v 1.3.40.1 2003/06/04 23:41:15 mistachkin Exp $
    1.16 +# 
    1.17 +
    1.18 +# Global variables used by these scripts:
    1.19 +#
    1.20 +# state -	state variable that controls action of text proc.
    1.21 +#				
    1.22 +# topics -	array indexed by (package,section,topic) with value
    1.23 +# 		of topic ID.
    1.24 +#
    1.25 +# keywords -	array indexed by keyword string with value of topic ID.
    1.26 +#
    1.27 +# curID - 	current topic ID, starts at 0 and is incremented for
    1.28 +# 		each new topic file.
    1.29 +#
    1.30 +# curPkg -	current package name (e.g. Tcl).
    1.31 +#
    1.32 +# curSect -	current section title (e.g. "Tcl Built-In Commands").
    1.33 +#
    1.34 +
    1.35 +# getPackages --
    1.36 +#
    1.37 +# Generate a sorted list of package names from the topics array.
    1.38 +#
    1.39 +# Arguments:
    1.40 +# none.
    1.41 +
    1.42 +proc getPackages {} {
    1.43 +    global topics
    1.44 +    foreach i [array names topics] {
    1.45 +	regsub {^(.*),.*,.*$} $i {\1} i
    1.46 +	set temp($i) {}
    1.47 +    }
    1.48 +    lsort [array names temp]
    1.49 +}
    1.50 +
    1.51 +# getSections --
    1.52 +#
    1.53 +# Generate a sorted list of section titles in the specified package
    1.54 +# from the topics array.
    1.55 +#
    1.56 +# Arguments:
    1.57 +# pkg -			Name of package to search.
    1.58 +
    1.59 +proc getSections {pkg} {
    1.60 +    global topics
    1.61 +    regsub -all {[][*?\\]} $pkg {\\&} pkg
    1.62 +    foreach i [array names topics "${pkg},*"] {
    1.63 +	regsub {^.*,(.*),.*$} $i {\1} i
    1.64 +	set temp($i) {}
    1.65 +    }
    1.66 +    lsort [array names temp]
    1.67 +}
    1.68 +
    1.69 +# getTopics --
    1.70 +#
    1.71 +# Generate a sorted list of topics in the specified section of the
    1.72 +# specified package from the topics array.
    1.73 +#
    1.74 +# Arguments:
    1.75 +# pkg -			Name of package to search.
    1.76 +# sect -		Name of section to search.
    1.77 +
    1.78 +proc getTopics {pkg sect} {
    1.79 +    global topics
    1.80 +    regsub -all {[][*?\\]} $pkg {\\&} pkg
    1.81 +    regsub -all {[][*?\\]} $sect {\\&} sect
    1.82 +    foreach i [array names topics "${pkg},${sect},*"] {
    1.83 +	regsub {^.*,.*,(.*)$} $i {\1} i
    1.84 +	set temp($i) {}
    1.85 +    }
    1.86 +    lsort [array names temp]
    1.87 +}
    1.88 +
    1.89 +# text --
    1.90 +#
    1.91 +# This procedure adds entries to the hypertext arrays topics and keywords.
    1.92 +#
    1.93 +# Arguments:
    1.94 +# string -		Text to index.
    1.95 +
    1.96 +
    1.97 +proc text string {
    1.98 +    global state curID curPkg curSect topics keywords
    1.99 +
   1.100 +    switch $state {
   1.101 +	NAME {
   1.102 +	    foreach i [split $string ","] {
   1.103 +		set topic [string trim $i]
   1.104 +		set index "$curPkg,$curSect,$topic"
   1.105 +		if {[info exists topics($index)]
   1.106 +		    && [string compare $topics($index) $curID] != 0} {
   1.107 +		    puts stderr "duplicate topic $topic in $curPkg"
   1.108 +		}
   1.109 +		set topics($index) $curID
   1.110 +		lappend keywords($topic) $curID
   1.111 +	    }
   1.112 +	}
   1.113 +	KEY {
   1.114 +	    foreach i [split $string ","] {
   1.115 +		lappend keywords([string trim $i]) $curID
   1.116 +	    }
   1.117 +	}
   1.118 +	DT -
   1.119 +	OFF -
   1.120 +	DASH {}
   1.121 +	default {
   1.122 +	    puts stderr "text: unknown state: $state"
   1.123 +	}
   1.124 +    }
   1.125 +}
   1.126 +
   1.127 +
   1.128 +# macro --
   1.129 +#
   1.130 +# This procedure is invoked to process macro invocations that start
   1.131 +# with "." (instead of ').
   1.132 +#
   1.133 +# Arguments:
   1.134 +# name -	The name of the macro (without the ".").
   1.135 +# args -	Any additional arguments to the macro.
   1.136 +
   1.137 +proc macro {name args} {
   1.138 +    switch $name {
   1.139 +	SH {
   1.140 +	    global state
   1.141 +
   1.142 +	    switch $args {
   1.143 +		NAME {
   1.144 +		    if {$state == "INIT" } {
   1.145 +			set state NAME
   1.146 +		    }
   1.147 +		}
   1.148 +		DESCRIPTION {set state DT}
   1.149 +		INTRODUCTION {set state DT}
   1.150 +		KEYWORDS {set state KEY}
   1.151 +		default {set state OFF}
   1.152 +	    }
   1.153 +	    
   1.154 +	}
   1.155 +	TH {
   1.156 +	    global state curID curPkg curSect topics keywords
   1.157 +	    set state INIT
   1.158 +	    if {[llength $args] != 5} {
   1.159 +		set args [join $args " "]
   1.160 +		puts stderr "Bad .TH macro: .$name $args"
   1.161 +	    }
   1.162 +	    incr curID
   1.163 +	    set topic	[lindex $args 0]	;# Tcl_UpVar
   1.164 +	    set curPkg	[lindex $args 3]	;# Tcl
   1.165 +	    set curSect	[lindex $args 4]	;# {Tcl Library Procedures}
   1.166 +	    regsub -all {\\ } $curSect { } curSect
   1.167 +	    set index "$curPkg,$curSect,$topic"
   1.168 +	    set topics($index) $curID
   1.169 +	    lappend keywords($topic) $curID
   1.170 +	}
   1.171 +    }
   1.172 +}
   1.173 +
   1.174 +
   1.175 +# dash --
   1.176 +#
   1.177 +# This procedure is invoked to handle dash characters ("\-" in
   1.178 +# troff).  It only function in pass1 is to terminate the NAME state.
   1.179 +#
   1.180 +# Arguments:
   1.181 +# None.
   1.182 +
   1.183 +proc dash {} {
   1.184 +    global state
   1.185 +    if {$state == "NAME"} {
   1.186 +	set state DASH
   1.187 +    }
   1.188 +}
   1.189 +
   1.190 +
   1.191 +
   1.192 +# initGlobals, tab, font, char, macro2 --
   1.193 +#
   1.194 +# These procedures do nothing during the first pass. 
   1.195 +#
   1.196 +# Arguments:
   1.197 +# None.
   1.198 +
   1.199 +proc initGlobals {} {}
   1.200 +proc newline {} {}
   1.201 +proc tab {} {}
   1.202 +proc font type {}
   1.203 +proc char name {}
   1.204 +proc macro2 {name args} {}
   1.205 +