summaryrefslogtreecommitdiffstats
path: root/library/init.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-02-03 12:27:37 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-02-03 12:27:37 (GMT)
commitb2a59d29b61de1e370bc0746f58bdf917c9170e2 (patch)
tree2cdfb937a678c6faaf7a6ca7ed5030b33ead4f2a /library/init.tcl
parentd917353c7e3cca82100ad439880e3c2e4c33d8c7 (diff)
parent7de961e9fab66ecc4e42f1ae1aa9442832728bc5 (diff)
downloadtcl-b2a59d29b61de1e370bc0746f58bdf917c9170e2.zip
tcl-b2a59d29b61de1e370bc0746f58bdf917c9170e2.tar.gz
tcl-b2a59d29b61de1e370bc0746f58bdf917c9170e2.tar.bz2
TIP #459 remaining part of implementation. Makes "package require Tk" give the right (... at least ... the expected ...) answer.
Diffstat (limited to 'library/init.tcl')
-rw-r--r--library/init.tcl21
1 files changed, 20 insertions, 1 deletions
diff --git a/library/init.tcl b/library/init.tcl
index 5a9e87c..49a523c 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -45,6 +45,7 @@ if {![info exists auto_path]} {
set auto_path ""
}
}
+
namespace eval tcl {
variable Dir
foreach Dir [list $::tcl_library [file dirname $::tcl_library]] {
@@ -112,6 +113,8 @@ namespace eval tcl {
}
}
+namespace eval tcl::Pkg {}
+
# Windows specific end of initialization
if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} {
@@ -457,6 +460,22 @@ proc auto_load {cmd {namespace {}}} {
return 0
}
+# ::tcl::Pkg::source --
+# This procedure provides an alternative "source" command, which doesn't
+# register the file for the "package files" command. Safe interpreters
+# don't have to do anything special.
+#
+# Arguments:
+# filename
+
+proc ::tcl::Pkg::source {filename} {
+ if {[interp issafe]} {
+ uplevel 1 [list ::source $filename]
+ } else {
+ uplevel 1 [list ::source -nopkg $filename]
+ }
+}
+
# auto_load_index --
# Loads the contents of tclIndex files on the auto_path directory
# list. This is usually invoked within auto_load to load the index
@@ -499,7 +518,7 @@ proc auto_load_index {} {
}
set name [lindex $line 0]
set auto_index($name) \
- "source [file join $dir [lindex $line 1]]"
+ "::tcl::Pkg::source [file join $dir [lindex $line 1]]"
}
} else {
error "[file join $dir tclIndex] isn't a proper Tcl index file"