summaryrefslogtreecommitdiffstats
path: root/library/auto.tcl
diff options
context:
space:
mode:
authorericm <ericm>2000-02-01 01:14:00 (GMT)
committerericm <ericm>2000-02-01 01:14:00 (GMT)
commitacb2f260bec04797bce0d16b709b530c511fe87f (patch)
tree112da6d0b67c743bbc7eec435cfb6c42345bd653 /library/auto.tcl
parentbfc121a8bd79c18c8d1b7760be65a4db3ad18bfd (diff)
downloadtcl-acb2f260bec04797bce0d16b709b530c511fe87f.zip
tcl-acb2f260bec04797bce0d16b709b530c511fe87f.tar.gz
tcl-acb2f260bec04797bce0d16b709b530c511fe87f.tar.bz2
* tests/package.test:
* library/tclIndex: * library/package.tcl: Added ::package namespace and ::package::create function. * library/init.tcl: Fixed problem with auto_load and determining if commands were loaded. * library/auto.tcl: "Fixed" issues with $ in files to be auto indexed. * doc/Package.n: New man page for package::create function. * doc/pkgMkIndex.n: Added additional information. * doc/library.n: Added additional qualification regarding auto_mkindex.
Diffstat (limited to 'library/auto.tcl')
-rw-r--r--library/auto.tcl24
1 files changed, 14 insertions, 10 deletions
diff --git a/library/auto.tcl b/library/auto.tcl
index 07b3116..9575f7b 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.5 2000/01/28 16:38:34 ericm Exp $
+# RCS: @(#) $Id: auto.tcl,v 1.6 2000/02/01 01:14:01 ericm Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
@@ -318,13 +318,13 @@ proc auto_mkindex_parser::mkindex {file} {
# There is one problem with sourcing files into the safe
# interpreter: references like "$x" will fail since code is not
# really being executed and variables do not really exist.
- # Be careful to escape all naked "$" before evaluating.
- regsub -expanded -all {
- ([^\\](?:(?:\\\\)*)) # match any even number of backslashes ...
- \$ # ... followed by an unescaped dollar sign ...
- ([^\$]) # ... followed by anything but another dollar sign
- } $contents {\1\\$\2} contents; # add one backslash for the dollar sign
-
+ # To avoid this, we replace all $ with \0 (literally, the null char)
+ # later, when getting proc names we will have to reverse this replacement,
+ # in case there were any $ in the proc name. This will cause a problem
+ # if somebody actually tries to have a \0 in their proc name. Too bad
+ # for them.
+ regsub -all {\$} $contents "\0" contents
+
set index ""
set contextStack ""
set imports ""
@@ -466,10 +466,14 @@ proc auto_mkindex_parser::fullname {name} {
}
if {[string equal [namespace qualifiers $name] ""]} {
- return [namespace tail $name]
+ set name [namespace tail $name]
} elseif {![string match ::* $name]} {
- return "::$name"
+ set name "::$name"
}
+
+ # Earlier, mkindex replaced all $'s with \0. Now, we have to reverse
+ # that replacement.
+ regsub -all "\0" $name "\$" name
return $name
}