@@ -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
371418proc 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