Skip to content

Commit e7f7767

Browse files
committed
Record module scan elements per modulepath
Update extra match search mechanism to record elements defined by modulefiles per modulepath. First dict level is updated to split information per modulepath. This way when two modules with same name are available in several modulepaths, if only one matches search query, the others will not be included in result. Fixes #497
1 parent b1cc1bb commit e7f7767

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Modules 5.3.1 (not yet released)
2525
scripts to use `Hunspell`_ as spell checker instead of Aspell.
2626
* Fix unaligned :subcmd:`list` output when 100 or more modules are loaded.
2727
(fix issue #496)
28+
* Fix extra specifier search when an identical module name and version is
29+
available in several modulepaths. (fix issue #497)
2830

2931
.. _Hunspell: https://hunspell.github.io/
3032

tcl/modfind.tcl.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} {
28822882
# Phase #4: perform extra match search
28832883

28842884
if {$ems_required} {
2885-
filterExtraMatchSearch $mod found_list versmod_list
2885+
filterExtraMatchSearch $dir $mod found_list versmod_list
28862886
}
28872887

28882888
# ensure modEqStatic is defined as expected (could have been redefined

tcl/modscan.tcl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,16 @@ proc module-sc {command args} {
198198

199199
proc recordScanModuleElt {name args} {
200200
set mod [currentState modulename]
201+
set modpath [currentState modulepath]
201202
if {![info exists ::g_scanModuleElt]} {
202203
set ::g_scanModuleElt [dict create]
203204
}
204205
foreach elt $args {
205-
if {![dict exists $::g_scanModuleElt $elt]} {
206-
dict set ::g_scanModuleElt $elt {}
207-
}
208-
if {![dict exists $::g_scanModuleElt $elt $name]} {
209-
dict set ::g_scanModuleElt $elt $name [list $mod]
206+
if {![dict exists $::g_scanModuleElt $modpath $elt $name]} {
207+
dict set ::g_scanModuleElt $modpath $elt $name [list $mod]
210208
} else {
211209
##nagelfar ignore Suspicious variable name
212-
dict with ::g_scanModuleElt $elt {lappend $name $mod}
210+
dict with ::g_scanModuleElt $modpath $elt {lappend $name $mod}
213211
}
214212
reportDebug "Module $mod defines $elt:$name"
215213
}
@@ -248,29 +246,32 @@ proc doesModVariantMatch {mod pvrlist} {
248246
}
249247

250248
# collect list of modules matching all extra specifier criteria
251-
proc getModMatchingExtraSpec {pxtlist} {
249+
proc getModMatchingExtraSpec {modpath pxtlist} {
252250
set res [list]
253-
if {[info exists ::g_scanModuleElt]} {
251+
if {[info exists ::g_scanModuleElt] && [dict exists $::g_scanModuleElt\
252+
$modpath]} {
254253
foreach pxt $pxtlist {
255254
lassign $pxt elt name
256255
set one_crit_res [list]
257256
if {$elt in {require incompat load unload prereq conflict prereq-all\
258257
prereq-any depends-on always-load load-any try-load switch\
259258
switch-on switch-off}} {
260-
if {[dict exists $::g_scanModuleElt $elt]} {
261-
foreach {modspec values} [dict get $::g_scanModuleElt $elt] {
259+
if {[dict exists $::g_scanModuleElt $modpath $elt]} {
260+
foreach {modspec values} [dict get $::g_scanModuleElt $modpath\
261+
$elt] {
262262
# modEq proc has been initialized in getModules phase #2
263263
if {[modEq $modspec $name eqstart 1 5 1]} {
264264
# possible duplicate module entry in result list
265265
lappend one_crit_res {*}[dict get $::g_scanModuleElt\
266-
$elt $modspec]
266+
$modpath $elt $modspec]
267267
}
268268
}
269269
}
270270
} else {
271271
# get modules matching one simple extra specifier criterion
272-
if {[dict exists $::g_scanModuleElt $elt $name]} {
273-
set one_crit_res [dict get $::g_scanModuleElt $elt $name]
272+
if {[dict exists $::g_scanModuleElt $modpath $elt $name]} {
273+
set one_crit_res [dict get $::g_scanModuleElt $modpath\
274+
$elt $name]
274275
}
275276
}
276277
lappend all_crit_res $one_crit_res
@@ -299,7 +300,7 @@ proc isExtraMatchSearchRequired {mod} {
299300
}
300301

301302
# perform extra match search on currently being built module search result
302-
proc filterExtraMatchSearch {mod res_arrname versmod_arrname} {
303+
proc filterExtraMatchSearch {modpath mod res_arrname versmod_arrname} {
303304
# link to variables/arrays from upper context
304305
upvar $res_arrname found_list
305306
upvar $versmod_arrname versmod_list
@@ -329,7 +330,7 @@ proc filterExtraMatchSearch {mod res_arrname versmod_arrname} {
329330
if {![isModuleTagged $elt forbidden 0]} {
330331
##nagelfar ignore Suspicious variable name
331332
execute-modulefile [lindex $found_list($elt) 2] $elt $elt $elt\
332-
0 0
333+
0 0 $modpath
333334
}
334335
}
335336
}
@@ -358,7 +359,7 @@ proc filterExtraMatchSearch {mod res_arrname versmod_arrname} {
358359
# get list of modules matching extra specifiers to determine those to not
359360
# matching that need to be withdrawn from result
360361
if {$check_extra} {
361-
set extra_keep_list [getModMatchingExtraSpec $spec_xt_list]
362+
set extra_keep_list [getModMatchingExtraSpec $modpath $spec_xt_list]
362363
lassign [getDiffBetweenList $keep_list $extra_keep_list]\
363364
extra_unset_list
364365
set unset_list [list {*}$unset_list {*}$extra_unset_list]

0 commit comments

Comments
 (0)