Skip to content

Commit 1f60b0a

Browse files
committed
Split extra match search modulefile scan from filtering
Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent a6617d6 commit 1f60b0a

File tree

3 files changed

+49
-35
lines changed

3 files changed

+49
-35
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ tcl/syntaxdb.tcl: modulecmd.tcl $(NAGELFAR)
11121112
set ::syntax(appendNoDupToList) {n x*};\
11131113
set ::syntax(lprepend) {n x*};\
11141114
set ::syntax(execute-modulefile) {x x n x x x? x? x?};\
1115+
set ::syntax(scanExtraMatchSearch) {x x n};\
11151116
set ::syntax(filterExtraMatchSearch) {x x n n};\
11161117
set ::syntax(findModulesFromDirsAndFiles) {x x x x n n? n? n? n?};\
11171118
set ::syntax(getArrayKey) {n x x};\

tcl/modfind.tcl.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,6 +3301,7 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} {
33013301
# Phase #4: perform extra match search
33023302

33033303
if {$ems_required} {
3304+
scanExtraMatchSearch $dir $mod found_list
33043305
filterExtraMatchSearch $dir $mod found_list versmod_list
33053306
}
33063307

tcl/modscan.tcl

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,53 @@ proc isExtraMatchSearchRequired {mod} {
367367
{avail paths whatis spider}))}]
368368
}
369369

370+
# scan modulefiles from currently being built module search result if extra
371+
# match search is needed
372+
proc scanExtraMatchSearch {modpath mod res_arrname} {
373+
upvar $res_arrname found_list
374+
375+
# get extra match query properties
376+
set spec_vr_list [getVariantListFromVersSpec $mod]
377+
set check_variant [llength $spec_vr_list]
378+
lassign [getSplitExtraListFromVersSpec $mod] spec_tag_list spec_xt_list
379+
set check_extra [llength $spec_xt_list]
380+
381+
# no scan evaluation if extra match search not needed
382+
if {!$check_variant && !$check_extra && ![isEltInReport variant 0] &&\
383+
![isEltInReport provided-alias 0]} {
384+
return
385+
}
386+
387+
# disable error reporting to avoid modulefile errors (not coping with
388+
# scan evaluation for instance) to pollute result
389+
set alreadyinhibit [getState inhibit_errreport]
390+
if {!$alreadyinhibit} {
391+
inhibitErrorReport
392+
}
393+
# evaluate all modules found in scan mode to gather content information
394+
lappendState mode scan
395+
396+
foreach elt [array names found_list] {
397+
switch -- [lindex $found_list($elt) 0] {
398+
modulefile - virtual {
399+
# skip evaluation of fully forbidden modulefile
400+
if {![isModuleTagged $elt forbidden 0 [lindex $found_list($elt)\
401+
2]]} {
402+
##nagelfar ignore Suspicious variable name
403+
execute-modulefile [lindex $found_list($elt) 2] $elt $elt $elt\
404+
0 0 0 $modpath
405+
}
406+
}
407+
}
408+
}
409+
410+
lpopState mode
411+
# re-enable error report only is it was disabled from this procedure
412+
if {!$alreadyinhibit} {
413+
setState inhibit_errreport 0
414+
}
415+
}
416+
370417
# perform extra match search on currently being built module search result
371418
proc filterExtraMatchSearch {modpath mod res_arrname versmod_arrname} {
372419
# link to variables/arrays from upper context
@@ -379,21 +426,8 @@ proc filterExtraMatchSearch {modpath mod res_arrname versmod_arrname} {
379426
lassign [getSplitExtraListFromVersSpec $mod] spec_tag_list spec_xt_list
380427
set check_extra [llength $spec_xt_list]
381428
set check_tag [llength $spec_tag_list]
382-
set scan_eval [expr {$check_variant || $check_extra || [isEltInReport\
383-
variant 0] || [isEltInReport provided-alias 0]}]
384429
set filter_res [expr {$check_variant || $check_extra || $check_tag}]
385430

386-
if {$scan_eval} {
387-
# disable error reporting to avoid modulefile errors (not coping with
388-
# scan evaluation for instance) to pollute result
389-
set alreadyinhibit [getState inhibit_errreport]
390-
if {!$alreadyinhibit} {
391-
inhibitErrorReport
392-
}
393-
# evaluate all modules found in scan mode to gather content information
394-
lappendState mode scan
395-
}
396-
397431
if {$check_tag} {
398432
# load tags from loaded mods prior collecting tags found during rc eval
399433
cacheCurrentModules 0
@@ -405,20 +439,6 @@ proc filterExtraMatchSearch {modpath mod res_arrname versmod_arrname} {
405439
if {$check_tag} {
406440
collectModuleTags $elt
407441
}
408-
# skip scan evaluation if only checking tags
409-
if {$scan_eval} {
410-
switch -- [lindex $found_list($elt) 0] {
411-
modulefile - virtual {
412-
# skip evaluation of fully forbidden modulefile
413-
if {![isModuleTagged $elt forbidden 0 [lindex\
414-
$found_list($elt) 2]]} {
415-
##nagelfar ignore Suspicious variable name
416-
execute-modulefile [lindex $found_list($elt) 2] $elt $elt\
417-
$elt 0 0 0 $modpath
418-
}
419-
}
420-
}
421-
}
422442

423443
# unset elements that do not match extra query
424444
if {$filter_res} {
@@ -444,14 +464,6 @@ proc filterExtraMatchSearch {modpath mod res_arrname versmod_arrname} {
444464
}
445465
}
446466

447-
if {$scan_eval} {
448-
lpopState mode
449-
# re-enable error report only is it was disabled from this procedure
450-
if {!$alreadyinhibit} {
451-
setState inhibit_errreport 0
452-
}
453-
}
454-
455467
if {$check_tag} {
456468
# indicate tags have been collected for this modulepath
457469
lappendState tags_collected_in $modpath

0 commit comments

Comments
 (0)