From 71740887a1b116bd5a298e4fcc67cf486fa56149 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 24 Jun 2005 15:06:21 +0000 Subject: * library/auto.tcl: Make file safe to re-[source] without destroying registered auto_mkindex_parser hooks. --- ChangeLog | 5 +++++ library/auto.tcl | 47 +++++++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3630d3..7b57f16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-06-24 Don Porter + + * library/auto.tcl: Make file safe to re-[source] without + destroying registered auto_mkindex_parser hooks. + 2005-06-23 Kevin Kenny * win/tclWinChan.c: More rewriting of __asm__ blocks that diff --git a/library/auto.tcl b/library/auto.tcl index f512552..a5ee494 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -3,7 +3,7 @@ # utility procs formerly in init.tcl dealing with auto execution # of commands and can be auto loaded themselves. # -# RCS: @(#) $Id: auto.tcl,v 1.24 2005/05/10 18:34:53 kennykb Exp $ +# RCS: @(#) $Id: auto.tcl,v 1.25 2005/06/24 15:06:23 dgp Exp $ # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994-1998 Sun Microsystems, Inc. @@ -293,7 +293,10 @@ namespace eval auto_mkindex_parser { variable scriptFile "" ;# name of file being processed variable contextStack "" ;# stack of namespace scopes variable imports "" ;# keeps track of all imported cmds - variable initCommands "" ;# list of commands that create aliases + variable initCommands ;# list of commands that create aliases + if {![info exists initCommands]} { + set initCommands [list] + } proc init {} { variable parser @@ -515,24 +518,6 @@ proc auto_mkindex_parser::fullname {name} { return [string map [list \0 \$] $name] } -# Register all of the procedures for the auto_mkindex parser that -# will build the "tclIndex" file. - -# AUTO MKINDEX: proc name arglist body -# Adds an entry to the auto index list for the given procedure name. - -auto_mkindex_parser::command proc {name args} { - variable index - variable scriptFile - # Do some fancy reformatting on the "source" call to handle platform - # differences with respect to pathnames. Use format just so that the - # command is a little easier to read (otherwise it'd be full of - # backslashed dollar signs, etc. - append index [list set auto_index([fullname $name])] \ - [format { [list source [file join $dir %s]]} \ - [file split $scriptFile]] "\n" -} - # Conditionally add support for Tcl byte code files. There are some # tricky details here. First, we need to get the tbcload library # initialized in the current interpreter. We cannot load tbcload into the @@ -566,6 +551,28 @@ auto_mkindex_parser::hook { } } +if {[llength $::auto_mkindex_parser::initCommands]} { + return +} + +# Register all of the procedures for the auto_mkindex parser that +# will build the "tclIndex" file. + +# AUTO MKINDEX: proc name arglist body +# Adds an entry to the auto index list for the given procedure name. + +auto_mkindex_parser::command proc {name args} { + variable index + variable scriptFile + # Do some fancy reformatting on the "source" call to handle platform + # differences with respect to pathnames. Use format just so that the + # command is a little easier to read (otherwise it'd be full of + # backslashed dollar signs, etc. + append index [list set auto_index([fullname $name])] \ + [format { [list source [file join $dir %s]]} \ + [file split $scriptFile]] "\n" +} + # AUTO MKINDEX: namespace eval name command ?arg arg...? # Adds the namespace name onto the context stack and evaluates the # associated body of commands. -- cgit v0.12