diff options
author | welch <welch> | 1999-03-31 19:54:15 (GMT) |
---|---|---|
committer | welch <welch> | 1999-03-31 19:54:15 (GMT) |
commit | 4b19bd088d5b7499f08fd3186f42b55b1a197988 (patch) | |
tree | d26fef1396c1e3e3cca61272a278bf531f746cf2 /library | |
parent | 77f09670fcf1468714cd4ab7e10e01447061d496 (diff) | |
download | tcl-4b19bd088d5b7499f08fd3186f42b55b1a197988.zip tcl-4b19bd088d5b7499f08fd3186f42b55b1a197988.tar.gz tcl-4b19bd088d5b7499f08fd3186f42b55b1a197988.tar.bz2 |
Fixing quoting bugs in auto_mkindex slavehook: BUGID 1657
Diffstat (limited to 'library')
-rw-r--r-- | library/auto.tcl | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/library/auto.tcl b/library/auto.tcl index d1e9373..8768c0e 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.1.2.7 1999/02/11 03:15:40 stanton Exp $ +# RCS: @(#) $Id: auto.tcl,v 1.1.2.8 1999/03/31 19:54:15 welch Exp $ # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994-1998 Sun Microsystems, Inc. @@ -13,6 +13,7 @@ # # auto_reset -- +# # Destroy all cached information for auto-loading and auto-execution, # so that the information gets recomputed the next time it's needed. # Also delete any procedures that are listed in the auto-load index @@ -36,11 +37,12 @@ proc auto_reset {} { catch {unset auto_oldpath} } - -# tcl_findLibrary +# tcl_findLibrary -- +# # This is a utility for extensions that searches for a library directory # using a canonical searching algorithm. A side effect is to source # the initialization script and set a global library variable. +# # Arguments: # basename Prefix of the directory name, (e.g., "tk") # version Version number of the package, (e.g., "8.0") @@ -268,10 +270,9 @@ namespace eval auto_mkindex_parser { $parser invokehidden namespace delete :: $parser invokehidden proc unknown {args} {} - # # We'll need access to the "namespace" command within the # interp. Put it back, but move it out of the way. - # + $parser expose namespace $parser invokehidden rename namespace _%@namespace $parser expose eval @@ -292,13 +293,14 @@ namespace eval auto_mkindex_parser { } # auto_mkindex_parser::mkindex -- +# # Used by the "auto_mkindex" command to create a "tclIndex" file for # the given Tcl source file. Executes the commands in the file, and # handles things like the "proc" command by adding an entry for the # index file. Returns a string that represents the index file. # # Arguments: -# file - Name of Tcl source file to be indexed. +# file Name of Tcl source file to be indexed. proc auto_mkindex_parser::mkindex {file} { variable parser @@ -333,6 +335,7 @@ proc auto_mkindex_parser::mkindex {file} { } # auto_mkindex_parser::hook command +# # Registers a Tcl command to evaluate when initializing the # slave interpreter used by the mkindex parser. # The command is evaluated in the master interpreter, and can @@ -345,6 +348,7 @@ proc auto_mkindex_parser::hook {cmd} { } # auto_mkindex_parser::slavehook command +# # Registers a Tcl command to evaluate when initializing the # slave interpreter used by the mkindex parser. # The command is evaluated in the slave interpreter. @@ -352,10 +356,14 @@ proc auto_mkindex_parser::hook {cmd} { proc auto_mkindex_parser::slavehook {cmd} { variable initCommands - lappend initCommands [list \$parser eval $cmd] + # The $parser variable is defined to be the name of the + # slave interpreter when this command is used later. + + lappend initCommands "\$parser eval [list $cmd]" } # auto_mkindex_parser::command -- +# # Registers a new command with the "auto_mkindex_parser" interpreter # that parses Tcl files. These commands are fake versions of things # like the "proc" command. When you execute them, they simply write @@ -367,17 +375,23 @@ proc auto_mkindex_parser::slavehook {cmd} { # could be added to a "tclIndex" file for auto-loading. # # Arguments: -# name - Name of command recognized in Tcl files. -# arglist - Argument list for command. -# body - Implementation of command to handle indexing. +# name Name of command recognized in Tcl files. +# arglist Argument list for command. +# body Implementation of command to handle indexing. proc auto_mkindex_parser::command {name arglist body} { hook [list auto_mkindex_parser::commandInit $name $arglist $body] } # auto_mkindex_parser::commandInit -- +# # This does the actual work set up by auto_mkindex_parser::command # This is called when the interpreter used by the parser is created. +# +# Arguments: +# name Name of command recognized in Tcl files. +# arglist Argument list for command. +# body Implementation of command to handle indexing. proc auto_mkindex_parser::commandInit {name arglist body} { variable parser @@ -393,17 +407,28 @@ proc auto_mkindex_parser::commandInit {name arglist body} { } proc $fakeName $arglist $body - # # YUK! Tcl won't let us alias fully qualified command names, # so we can't handle names like "::itcl::class". Instead, # we have to build procs with the fully qualified names, and # have the procs point to the aliases. - # + if {[regexp {::} $name]} { set exportCmd [list _%@namespace export [namespace tail $name]] $parser eval [list _%@namespace eval $ns $exportCmd] + + # The following proc definition does not work if you + # want to tolerate space or something else diabolical + # in the procedure name, (i.e., space in $alias) + # The following does not work: + # "_%@eval {$alias} \$args" + # because $alias gets concat'ed to $args. + # The following does not work because $cmd is somehow undefined + # "set cmd {$alias} \; _%@eval {\$cmd} \$args" + # A gold star to someone that can make test + # autoMkindex-3.3 work properly + set alias [namespace tail $fakeName] - $parser invokehidden proc $name {args} [list _%@eval $alias \$args] + $parser invokehidden proc $name {args} "_%@eval {$alias} \$args" $parser alias $alias $fakeName } else { $parser alias $name $fakeName |