From 3bca85b23b94d896c7b0f59544aac9dce3d3feca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Feb 2024 14:16:57 +0000 Subject: Proposed fix for [86b3c15f0c]: ::unknown has infinite recursion in a corner case --- library/init.tcl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/init.tcl b/library/init.tcl index 9412e00..188cb3d 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -371,7 +371,10 @@ proc unknown args { return -options $::tcl::UnknownOptions $::tcl::UnknownResult } - set ret [catch {set candidates [info commands $name*]} msg] + set ret [catch [list uplevel 1 [list info commands $name*]] msg] + if {$ret == 0} { + set candidates $msg + } if {$name eq "::"} { set name "" } -- cgit v0.12 From 60de91cf50c7ff95be3579c1ac2025f8f8481f27 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Feb 2024 14:42:59 +0000 Subject: Slightly simpler --- library/init.tcl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/library/init.tcl b/library/init.tcl index 188cb3d..d2d1fa9 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -371,17 +371,14 @@ proc unknown args { return -options $::tcl::UnknownOptions $::tcl::UnknownResult } - set ret [catch [list uplevel 1 [list info commands $name*]] msg] - if {$ret == 0} { - set candidates $msg - } + set ret [catch [list uplevel 1 [list info commands $name*]] candidates] if {$name eq "::"} { set name "" } if {$ret != 0} { dict append opts -errorinfo \ "\n (expanding command prefix \"$name\" in unknown)" - return -options $opts $msg + return -options $opts $candidates } # Filter out bogus matches when $name contained # a glob-special char [Bug 946952] -- cgit v0.12 From f1ee146307be073327189e999d030d5d557dadf7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 6 Feb 2024 14:49:29 +0000 Subject: \032 -> \x1A, since hex reads better than octal --- library/auto.tcl | 14 +++++++------- library/init.tcl | 2 +- library/safe.tcl | 2 +- tools/genStubs.tcl | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/auto.tcl b/library/auto.tcl index f998b45..f293a38 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -140,13 +140,13 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { # source everything when in a safe interpreter because we have a # source command, but no file exists command - if {[interp issafe] || [file exists $file]} { - if {![catch {uplevel #0 [list source $file]} msg opts]} { - return - } + if {[interp issafe] || [file exists $file]} { + if {![catch {uplevel #0 [list source $file]} msg opts]} { + return + } append errors "$file: $msg\n" append errors [dict get $opts -errorinfo]\n - } + } } unset -nocomplain the_library set msg "Can't find a usable $initScript in the following directories: \n" @@ -240,7 +240,7 @@ proc auto_mkindex_old {dir args} { set f "" set error [catch { set f [open $file] - fconfigure $f -eofchar "\032 {}" + fconfigure $f -eofchar "\x1A {}" while {[gets $f line] >= 0} { if {[regexp {^proc[ ]+([^ ]*)} $line match procName]} { set procName [lindex [auto_qualify $procName "::"] 0] @@ -351,7 +351,7 @@ proc auto_mkindex_parser::mkindex {file} { set scriptFile $file set fid [open $file] - fconfigure $fid -eofchar "\032 {}" + fconfigure $fid -eofchar "\x1A {}" set contents [read $fid] close $fid diff --git a/library/init.tcl b/library/init.tcl index d2d1fa9..3200955 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -494,7 +494,7 @@ proc auto_load_index {} { continue } else { set error [catch { - fconfigure $f -eofchar "\032 {}" + fconfigure $f -eofchar "\x1A {}" set id [gets $f] if {$id eq "# Tcl autoload index file, version 2.0"} { eval [read $f] diff --git a/library/safe.tcl b/library/safe.tcl index 1eafec0..8c79abd 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -982,7 +982,7 @@ proc ::safe::AliasSource {child args} { set replacementMsg "script error" set code [catch { set f [open $realfile] - fconfigure $f -eofchar "\032 {}" + fconfigure $f -eofchar "\x1A {}" if {$encoding ne ""} { fconfigure $f -encoding $encoding } diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index 4f4acbb..28138e2 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -257,7 +257,7 @@ proc genStubs::rewriteFile {file text} { return } set in [open ${file} r] - fconfigure $in -eofchar "\032 {}" -encoding utf-8 + fconfigure $in -eofchar "\x1A {}" -encoding utf-8 set out [open ${file}.new w] fconfigure $out -translation lf -encoding utf-8 -- cgit v0.12