]>
git.zerfleddert.de Git - micropolis/blob - res/buildidx.tcl
ca85f8ce37b2425494765b001855fa179483020e
4 # Code to build Tcl package library. Defines the proc `buildpackageindex'.
6 #------------------------------------------------------------------------------
7 # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
9 # Permission to use, copy, modify, and distribute this software and its
10 # documentation for any purpose and without fee is hereby granted, provided
11 # that the above copyright notice appear in all copies. Karl Lehenbauer and
12 # Mark Diekhans make no representations about the suitability of this
13 # software for any purpose. It is provided "as is" without express or
15 #------------------------------------------------------------------------------
16 # $Id: buildidx.tcl,v 2.0 1992/10/16 04:51:38 markd Rel $
17 #------------------------------------------------------------------------------
20 proc TCHSH
:PutLibLine
{outfp
package where endwhere autoprocs
} {
21 puts $outfp [concat $package $where [expr {$endwhere - $where - 1}] \
25 proc TCLSH
:CreateLibIndex
{libName
} {
27 if {[file extension
$libName] != ".tlb"} {
28 error "Package library `$libName' does not have the extension `.tlb'"}
29 set idxName
"[file root $libName].tndx"
31 unlink
-nocomplain $idxName
32 set libFH
[open $libName r
]
33 set idxFH
[open $idxName w
]
35 set contectHdl
[scancontext create
]
37 scanmatch
$contectHdl "^#@package: " {
38 set size
[llength $matchInfo(line
)]
40 error [format "invalid package header \"%s\"" $matchInfo(line
)]
43 TCHSH
:PutLibLine
$idxFH $pkgDefName $pkgDefWhere \
44 $matchInfo(offset
) $pkgDefProcs
46 set pkgDefName
[lindex $matchInfo(line
) 1]
47 set pkgDefWhere
[tell $matchInfo(handle
)]
48 set pkgDefProcs
[lrange $matchInfo(line
) 2 end
]
52 scanmatch
$contectHdl "^#@packend" {
54 error "#@packend without #@package in $libName
56 TCHSH:PutLibLine $idxFH $pkgDefName $pkgDefWhere $matchInfo(offset) \
63 scanfile $contectHdl $libFH
65 global errorInfo errorCode
68 error $msg $errorInfo $errorCode
70 if {![info exists pkgDefName]} {
71 error "No
#@package definitions found in $libName"
74 TCHSH
:PutLibLine
$idxFH $pkgDefName $pkgDefWhere [tell $libFH] \
80 scancontext delete
$contectHdl
82 # Set mode and ownership of the index to be the same as the library.
84 file stat
$libName statInfo
85 chmod
$statInfo(mode
) $idxName
86 chown
[list $statInfo(uid
) $statInfo(gid
)] $idxName
90 proc buildpackageindex
{libfile
} {
92 set status
[catch {TCLSH
:CreateLibIndex
$libfile} errmsg
]
94 global errorInfo errorCode
95 error "building package index for `$libfile' failed: $errmsg" \