"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tcl/modfind.tcl.in" between
modules-5.1.1.tar.bz2 and modules-5.2.0.tar.bz2

About: The Environment Modules package provides for the dynamic modification of a user’s environment via modulefiles.

modfind.tcl.in  (modules-5.1.1.tar.bz2):modfind.tcl.in  (modules-5.2.0.tar.bz2)
skipping to change at line 34 skipping to change at line 34
# every local variable is prefixed by '0' to ensure they will not be # every local variable is prefixed by '0' to ensure they will not be
# overwritten through variable reference resolution process # overwritten through variable reference resolution process
proc resolvStringWithEnv {0str} { proc resolvStringWithEnv {0str} {
# fetch variable references in string # fetch variable references in string
set 0match_list [regexp -all -inline {\$[{]?([A-Za-z_][A-Za-z0-9_]*)[}]?}\ set 0match_list [regexp -all -inline {\$[{]?([A-Za-z_][A-Za-z0-9_]*)[}]?}\
${0str}] ${0str}]
if {[llength ${0match_list}] > 0} { if {[llength ${0match_list}] > 0} {
# put in local scope every environment variable referred in string # put in local scope every environment variable referred in string
for {set 0i 1} {${0i} < [llength ${0match_list}]} {incr 0i 2} { for {set 0i 1} {${0i} < [llength ${0match_list}]} {incr 0i 2} {
set 0varname [lindex ${0match_list} ${0i}] set 0varname [lindex ${0match_list} ${0i}]
##nagelfar vartype 0varname varName
if {![info exists ${0varname}]} { if {![info exists ${0varname}]} {
set ${0varname} [get-env ${0varname}] set ${0varname} [get-env ${0varname}]
} }
} }
# resolve variable reference with values (now in local scope) # resolve variable reference with values (now in local scope)
set 0res [subst -nobackslashes -nocommands ${0str}] set 0res [subst -nobackslashes -nocommands ${0str}]
} else { } else {
set 0res ${0str} set 0res ${0str}
} }
skipping to change at line 419 skipping to change at line 420
set parentmod . set parentmod .
} }
} }
} }
# recorded computed name list for later use # recorded computed name list for later use
set ::g_loadedAltAndSimplifiedName($mod) $namelist set ::g_loadedAltAndSimplifiedName($mod) $namelist
} }
return $namelist return $namelist
} }
# return list of loaded modules by parsing LOADEDMODULES env variable # return value list of a loaded module property by parsing corresponding
proc getLoadedModuleList {{filter_empty 1}} { # environment variable
set modlist [list] proc getLoadedModulePropertyList {prop {filter_empty 1}} {
foreach mod [split [get-env LOADEDMODULES] [getState path_separator]] { switch -- $prop {
# ignore empty element name {
if {$mod ne {} || !$filter_empty} { set envvar LOADEDMODULES
lappend modlist $mod set subsplit 0
}
file {
set envvar _LMFILES_
set subsplit 0
}
modulepath {
set envvar MODULEPATH
set subsplit 0
}
default {
set envvar __MODULES_LM[string toupper $prop]
set subsplit [expr {$prop ni {init refresh}}]
if {$prop in {altname conflict}} {
set nosubsubsplit 1
}
}
}
switch -- $prop {
conflict - prereq - init {
set unserialize_map {< :}
}
sourcesh {
set unserialize_submap [list <EnvModEscPS> [getState path_separator]\
<EnvModEscS1> [getState sub1_separator]\
<EnvModEscS2> [getState sub2_separator]]
} }
} }
return $modlist
}
# return list of loaded module files by parsing _LMFILES_ env variable set res_list [list]
proc getLoadedModuleFileList {} { foreach elt [split [get-env $envvar] [getState path_separator]] {
set modfilelist [list] if {$subsplit} {
foreach modfile [split [get-env _LMFILES_] [getState path_separator]] { set sub1sep [getState sub1_separator]
# ignore empty element set sub2sep [getState sub2_separator]
if {$modfile ne {}} { # unserialize content of environment variable if map translation set
lappend modfilelist $modfile if {[info exists unserialize_map]} {
} set elt [string map $unserialize_map $elt]
} }
return $modfilelist set subelt_list [split $elt $sub1sep]
} # ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $subelt_list] > 1 || !$filter_empty} {
# return list of declared source-sh by loaded module by parsing set subres_list {}
# __MODULES_LMSOURCESH foreach subelt $subelt_list {
proc getLoadedModuleSourceShList {} { # keep first arg as string and other args as lists (unless if
set modsrcshlist [list] # subelt should not be split)
set pathsep [getState path_separator] if {[llength $subres_list] > 0 && ![info exists\
set sub1sep [getState sub1_separator] nosubsubsplit]} {
set sub2sep [getState sub2_separator] set subelt [split $subelt $sub2sep]
set unsermap [list <EnvModEscPS> $pathsep <EnvModEscS1> $sub1sep\ # skip empty value element
<EnvModEscS2> $sub2sep] if {[llength $subelt] == 0 && $filter_empty} {
continue
}
}
if {[info exists unserialize_submap]} {
set subelt [string map $unserialize_submap $subelt]
}
lappend subres_list $subelt
}
foreach modsrcshser [split [get-env __MODULES_LMSOURCESH] $pathsep] { lappend res_list $subres_list
set srcshlist [split $modsrcshser $sub1sep] }
# ignore empty element (1 is meaningless as first elt is loaded mod) } else {
if {[llength $srcshlist] > 1} { # ignore empty element
set modsrcsh {} if {$elt ne {} || !$filter_empty} {
# keep first arg as string and other args as lists # unserialize content of env variable if map translation set
foreach srcsh $srcshlist { if {[info exists unserialize_map]} {
# unescape delimiter chars used in content set elt [string map $unserialize_map $elt]
if {[llength $modsrcsh] == 0} {
lappend modsrcsh [string map $unsermap $srcsh]
} else {
lappend modsrcsh [string map $unsermap [split $srcsh $sub2sep]]
} }
lappend res_list $elt
} }
lappend modsrcshlist $modsrcsh
} }
} }
return $modsrcshlist return $res_list
} }
# return list of loaded module declared conflict by parsing # return list of module paths by parsing MODULEPATH env variable
# __MODULES_LMCONFLICT # behavior param enables to exit in error when no MODULEPATH env variable
proc getLoadedModuleConflictList {} { # is set. by default an empty list is returned if no MODULEPATH set
set modconlist [list] # resolv_var param tells if environment variable references in path elements
# get sub level separator that serialize second level of info in env var # should be resolved or passed as-is in result list
set sub1sep [getState sub1_separator] # set_abs param applies an absolute path name conversion to path elements
foreach modconser [split [get-env __MODULES_LMCONFLICT] [getState\ # if enabled
path_separator]] { proc getModulePathList {{behavior returnempty} {resolv_var 1} {set_abs 1}} {
# recover range specifier ':' from its serialized form '<' if {![info exists ::env(MODULEPATH)] && $behavior eq {exiterronundef}} {
set conlist [split [string map {< :} $modconser] $sub1sep] reportErrorAndExit {No module path defined}
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $conlist] > 1} {
lappend modconlist $conlist
}
} }
return $modconlist
}
# return list of loaded module declared prereq by parsing __MODULES_LMPREREQ set modpath_list [list]
proc getLoadedModulePrereqList {} { foreach modpath [getLoadedModulePropertyList modulepath] {
set modprelist [list] if {$resolv_var} {
set sub1sep [getState sub1_separator] set modpath [resolvStringWithEnv $modpath]
# get sub sub level separator that serialize third level of info in env var
set sub2sep [getState sub2_separator]
foreach modpreser [split [get-env __MODULES_LMPREREQ] [getState\
path_separator]] {
# recover range specifier ':' from its serialized form '<'
set prelist [split [string map {< :} $modpreser] $sub1sep]
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $prelist] > 1} {
set modpre {}
# keep first arg as string and other args as lists
foreach pre $prelist {
if {[llength $modpre] == 0} {
lappend modpre $pre
} else {
lappend modpre [split $pre $sub2sep]
}
}
lappend modprelist $modpre
} }
} if {$set_abs} {
return $modprelist set modpath [getAbsolutePath $modpath]
}
# return list of loaded module declared altnames by parsing
# __MODULES_LMALTNAME
proc getLoadedModuleAltnameList {} {
set modaltlist [list]
set sub1sep [getState sub1_separator]
foreach modaltser [split [get-env __MODULES_LMALTNAME] [getState\
path_separator]] {
set altlist [split $modaltser $sub1sep]
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $altlist] > 1} {
lappend modaltlist $altlist
} }
appendNoDupToList modpath_list $modpath
} }
return $modaltlist return $modpath_list
} }
# return list of loaded module declared variant by parsing __MODULES_LMVARIANT # return list of the configured and existing global RC files
proc getLoadedModuleVariantList {} { proc getGlobalRcFileList {} {
set modvrspeclist [list] set rclist {}
set sub1sep [getState sub1_separator]
# get sub sub level separator that serialize third level of info in env var
set sub2sep [getState sub2_separator]
foreach modvrspecser [split [get-env __MODULES_LMVARIANT] [getState\
path_separator]] {
set vrspeclist [split $modvrspecser $sub1sep]
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $vrspeclist] > 1} {
set modvrspec {}
# keep first arg as string and other args as lists
foreach vrspec $vrspeclist {
if {[llength $modvrspec] == 0} {
lappend modvrspec $vrspec
# ignore empty variant spec
} elseif {[llength [set vrspecli [split $vrspec $sub2sep]]] > 0} {
lappend modvrspec $vrspecli
}
}
lappend modvrspeclist $modvrspec if {[set rcfile [getConf rcfile]] ne {}} {
# if MODULERCFILE is a dir, look at a modulerc file in it
if {[file isdirectory $rcfile] && [file isfile $rcfile/modulerc]} {
lappend rclist $rcfile/modulerc
} elseif {[file isfile $rcfile]} {
lappend rclist $rcfile
} }
} }
return $modvrspeclist if {[file isfile {@etcdir@/rc}]} {
} lappend rclist {@etcdir@/rc}
# return list of loaded module declared tags by parsing __MODULES_LMTAG
proc getLoadedModuleTagList {} {
set modtaglist [list]
set sub1sep [getState sub1_separator]
foreach modtagser [split [get-env __MODULES_LMTAG] [getState\
path_separator]] {
set taglist [split $modtagser $sub1sep]
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $taglist] > 1} {
lappend modtaglist $taglist
}
} }
return $modtaglist if {[info exists ::env(HOME)] && [file isfile $::env(HOME)/.modulerc]} {
} lappend rclist $::env(HOME)/.modulerc
# return list of loaded module extra tags by parsing __MODULES_LMEXTRATAG
proc getLoadedModuleExtraTagList {} {
set modtaglist [list]
set sub1sep [getState sub1_separator]
foreach modtagser [split [get-env __MODULES_LMEXTRATAG] [getState\
path_separator]] {
set taglist [split $modtagser $sub1sep]
# ignore empty element (1 is meaningless as first elt is loaded mod)
if {[llength $taglist] > 1} {
lappend modtaglist $taglist
}
} }
return $modtaglist
}
# return list of module paths by parsing MODULEPATH env variable set readable_rclist {}
# behavior param enables to exit in error when no MODULEPATH env variable foreach rc $rclist {
# is set. by default an empty list is returned if no MODULEPATH set if {[file readable $rc]} {
# resolv_var param tells if environment variable references in path elements lappend readable_rclist $rc
# should be resolved or passed as-is in result list
# set_abs param applies an absolute path name conversion to path elements
# if enabled
proc getModulePathList {{behavior returnempty} {resolv_var 1} {set_abs 1}} {
if {[info exists ::env(MODULEPATH)]} {
set modpathlist [list]
foreach modpath [split $::env(MODULEPATH) [getState path_separator]] {
# ignore empty element
if {$modpath ne {}} {
if {$resolv_var} {
set modpath [resolvStringWithEnv $modpath]
}
if {$set_abs} {
set modpath [getAbsolutePath $modpath]
}
appendNoDupToList modpathlist $modpath
}
} }
return $modpathlist
} elseif {$behavior eq {exiterronundef}} {
reportErrorAndExit {No module path defined}
} else {
return {}
} }
return $readable_rclist
} }
proc getModuleTag {mod tag {cmp eqstart} {return_rule 0}} { proc getModuleTag {mod tag {cmp eqstart} {return_rule 0}} {
set modroot [getModuleRootFromVersSpec $mod] set modroot [getModuleRootFromVersSpec $mod]
# look if mod matches one of the module specs applying to mod root # look if mod matches one of the module specs applying to mod root
if {[info exists ::g_moduleTagRoot($modroot)]} { if {[info exists ::g_moduleTagRoot($modroot)]} {
set idx [lsearch -exact $::g_moduleTagRoot($modroot) $tag] set idx [lsearch -exact $::g_moduleTagRoot($modroot) $tag]
if {$idx == -1} { if {$idx == -1} {
return {} return {}
} else { } else {
skipping to change at line 658 skipping to change at line 590
# retrieve tag information from collected tags or raw info # retrieve tag information from collected tags or raw info
if {$collected} { if {$collected} {
return [expr {$tag in [getTagList $mod]}] return [expr {$tag in [getTagList $mod]}]
} else { } else {
return [expr {[llength [getModuleTag $mod $tag]] != 0}] return [expr {[llength [getModuleTag $mod $tag]] != 0}]
} }
} }
proc getTaggedLoadedModuleList {tag} { proc getTaggedLoadedModuleList {tag} {
set modlist [list] set modlist [list]
foreach mod [getLoadedModuleList] { foreach mod [getLoadedModulePropertyList name] {
if {[isModuleTagged $mod $tag 1]} { if {[isModuleTagged $mod $tag 1]} {
lappend modlist $mod lappend modlist $mod
} }
} }
return $modlist return $modlist
} }
proc getModuleTagProp {mod tag prop} { proc getModuleTagProp {mod tag prop} {
set ret {} set ret {}
array set tags [getModuleTag $mod $tag] array set tags [getModuleTag $mod $tag]
skipping to change at line 960 skipping to change at line 892
# test if mod is declared hidden or has one element in its name starting with # test if mod is declared hidden or has one element in its name starting with
# dot character. mod is considered hidden depending on their hiding level, # dot character. mod is considered hidden depending on their hiding level,
# current search query and hiding threshold. when retdetails option is # current search query and hiding threshold. when retdetails option is
# enabled, mod hiding level and query match hind are also returned # enabled, mod hiding level and query match hind are also returned
proc isModuleHidden {mod {modspec {}} {retdetails 0}} { proc isModuleHidden {mod {modspec {}} {retdetails 0}} {
set defhidlvl [set hidlvl [getModuleHidingLevel $mod]] set defhidlvl [set hidlvl [getModuleHidingLevel $mod]]
if {$hidlvl >= [getState hiding_threshold]} { if {$hidlvl >= [getState hiding_threshold]} {
# soft hidden mods are considered matched if their root name matches # soft hidden mods are considered matched if their root name matches
# search query, other kind of hidden mods must fully matches query # search query, other kind of hidden mods must fully matches query
set hidmatch [expr {$hidlvl == 0 ? [expr {[modStartNb $mod $modspec]\ set hidmatch [expr {$hidlvl == 0 ? [modStartNb $mod $modspec] > 0 :\
> 0}] : [modEq $modspec $mod eqspec]}] [modEq $modspec $mod eqspec]}]
} else { } else {
set hidlvl -1 set hidlvl -1
set hidmatch 0 set hidmatch 0
} }
if {$hidlvl < 1 && [set isdot [isModuleDotHidden $mod]] && [getState\ if {$hidlvl < 1 && [set isdot [isModuleDotHidden $mod]] && [getState\
hiding_threshold] < 1} { hiding_threshold] < 1} {
set hidlvl 1 set hidlvl 1
# dot hidden are considered matched if remaining string part after # dot hidden are considered matched if remaining string part after
# search query is not dot hidden # search query is not dot hidden
set hidmatch [expr {[set i [modStartNb $mod $modspec]] > 0 &&\ set hidmatch [expr {[set i [modStartNb $mod $modspec]] > 0 &&\
skipping to change at line 1063 skipping to change at line 995
# get list of modules corresponding to searched query # get list of modules corresponding to searched query
array unset mod_list array unset mod_list
array set mod_list [getModules $dir $mod 0 [list rc_defs_included\ array set mod_list [getModules $dir $mod 0 [list rc_defs_included\
resolve]] resolve]]
set prevmod {} set prevmod {}
set mod_res {} set mod_res {}
# loop to resolve correct modulefile in case specified mod is a # loop to resolve correct modulefile in case specified mod is a
# directory that should be analyzed to get default mod in it # directory that should be analyzed to get default mod in it
while {$prevmod ne $mod} { while {$prevmod ne $mod} {
##nagelfar ignore Found constant
set mod [getEqArrayKey mod_list $mod] set mod [getEqArrayKey mod_list $mod]
set prevmod $mod set prevmod $mod
if {[info exists mod_list($mod)]} { if {[info exists mod_list($mod)]} {
switch -- [lindex $mod_list($mod) 0] { switch -- [lindex $mod_list($mod) 0] {
alias - version { alias - version {
set newmod [resolveModuleVersionOrAlias $mod $icase] set newmod [resolveModuleVersionOrAlias $mod $icase]
if {[info exists mod_list($newmod)]} { if {[info exists mod_list($newmod)]} {
set mod $newmod set mod $newmod
} else { } else {
# add specified variants to current resolution # add specified variants to current resolution
skipping to change at line 1211 skipping to change at line 1144
if {$idx eq {all}} { if {$idx eq {all}} {
return $modlist return $modlist
} else { } else {
return [lindex $modlist $idx] return [lindex $modlist $idx]
} }
} else { } else {
return {} return {}
} }
} }
proc setLoadedModule {mod modfile uasked {modvr {}}} { proc isModuleRefreshQualified {mod} {
return $::g_loadedModulesRefresh($mod)
}
proc setLoadedModule {mod modfile uasked modvr refresh} {
set ::g_loadedModules($mod) $modfile set ::g_loadedModules($mod) $modfile
# a loaded modfile may correspond to multiple loaded virtual modules # a loaded modfile may correspond to multiple loaded virtual modules
lappend ::g_loadedModuleFiles($modfile) $mod lappend ::g_loadedModuleFiles($modfile) $mod
# record if mod has been asked by user and relative loaded/auto-loaded tag # record if mod has been asked by user and relative loaded/auto-loaded tag
set loadedtag [expr {$uasked ? {loaded} : {auto-loaded}}] set loadedtag [expr {$uasked ? {loaded} : {auto-loaded}}]
setModuleTag $mod $loadedtag setModuleTag $mod $loadedtag
# also record tag for module designation including variants if specified # also record tag for module designation including variants if specified
if {$modvr ne {} && $mod ne $modvr} { if {$modvr ne {} && $mod ne $modvr} {
setModuleTag $modvr $loadedtag setModuleTag $modvr $loadedtag
} }
# is module qualified for refresh evaluation
set ::g_loadedModulesRefresh($mod) $refresh
# build dependency chain # build dependency chain
setModuleDependency $mod setModuleDependency $mod
} }
proc unsetLoadedModule {mod modfile} { proc unsetLoadedModule {mod modfile} {
unset ::g_loadedModules($mod) unset ::g_loadedModules($mod)
# a loaded modfile may correspond to multiple loaded virtual modules # a loaded modfile may correspond to multiple loaded virtual modules
if {[llength $::g_loadedModuleFiles($modfile)] == 1} { if {[llength $::g_loadedModuleFiles($modfile)] == 1} {
unset ::g_loadedModuleFiles($modfile) unset ::g_loadedModuleFiles($modfile)
} else { } else {
set ::g_loadedModuleFiles($modfile) [replaceFromList\ set ::g_loadedModuleFiles($modfile) [replaceFromList\
$::g_loadedModuleFiles($modfile) $mod] $::g_loadedModuleFiles($modfile) $mod]
} }
unset ::g_loadedModulesRefresh($mod)
# update dependencies # update dependencies
unsetModuleDependency $mod unsetModuleDependency $mod
} }
# return the currently loaded module whose name is the closest to the # return the currently loaded module whose name is the closest to the
# name passed as argument. if no loaded module match at least one part # name passed as argument. if no loaded module match at least one part
# of the passed name, an empty string is returned. # of the passed name, an empty string is returned.
proc getLoadedWithClosestName {name} { proc getLoadedWithClosestName {name} {
set ret {} set ret {}
set retmax 1 set retmax 1
skipping to change at line 1275 skipping to change at line 1218
} else { } else {
set nametosplit $name set nametosplit $name
} }
if {[info exists nametosplit]} { if {[info exists nametosplit]} {
cacheCurrentModules cacheCurrentModules
set icase [isIcase] set icase [isIcase]
defineModStartNbProc $icase defineModStartNbProc $icase
defineModEqProc $icase [getConf extended_default] defineModEqProc $icase [getConf extended_default]
# compare name to each currently loaded module name # compare name to each currently loaded module name
foreach mod [getLoadedModuleList] { ##nagelfar ignore Found constant
foreach mod [getLoadedModulePropertyList name] {
# if module loaded as fullpath but test name not, try to get loaded # if module loaded as fullpath but test name not, try to get loaded
# mod short name (with currently used modulepaths) to compare it # mod short name (with currently used modulepaths) to compare it
if {[isModuleFullPath $mod] && [set modname\ if {[isModuleFullPath $mod] && [set modname\
[findModuleNameFromModulefile $mod]] ne {}} { [findModuleNameFromModulefile $mod]] ne {}} {
# no alt name to retrieve if module has been loaded full path # no alt name to retrieve if module has been loaded full path
set matchmodlist [list $modname] set matchmodlist [list $modname]
} else { } else {
# add alternative names of mod to the matching list # add alternative names of mod to the matching list
set matchmodlist [list $mod {*}[getLoadedAltname $mod]] set matchmodlist [list $mod {*}[getLoadedAltname $mod]]
} }
skipping to change at line 1320 skipping to change at line 1264
set retmax 0 set retmax 0
# get default behavior from unload_match_order config # get default behavior from unload_match_order config
if {$behavior eq {}} { if {$behavior eq {}} {
set behavior [getConf unload_match_order] set behavior [getConf unload_match_order]
} }
# use loading-specific procedures instead of loaded-specific ones # use loading-specific procedures instead of loaded-specific ones
if {$loading} { if {$loading} {
set isModulefileLoaded isModulefileLoading set isModulefileLoaded isModulefileLoading
set getModuleFromLoadedModulefile getModuleFromLoadingModulefile set getModuleFromLoadedModulefile getModuleFromLoadingModulefile
set getLoadedModuleList getLoadingModuleList set getLoadedModuleList [list getLoadingModuleList]
} else { } else {
##nagelfar ignore #3 Found constant
set isModulefileLoaded isModulefileLoaded set isModulefileLoaded isModulefileLoaded
set getModuleFromLoadedModulefile getModuleFromLoadedModulefile set getModuleFromLoadedModulefile getModuleFromLoadedModulefile
set getLoadedModuleList getLoadedModuleList set getLoadedModuleList [list getLoadedModulePropertyList name]
} }
# fetch currently loaded/loading module name is no list provided # fetch currently loaded/loading module name is no list provided
if {[llength $lmlist] == 0} { if {[llength $lmlist] == 0} {
set lmlist [$getLoadedModuleList] set lmlist [{*}$getLoadedModuleList]
} }
# if module is passed as full modulefile path name, look at lmfile names # if module is passed as full modulefile path name, look at lmfile names
# to return the eventual exact match # to return the eventual exact match
if {[isModuleFullPath $name]} { if {[isModuleFullPath $name]} {
set mod [getAbsolutePath $name] set mod [getAbsolutePath $name]
# if module is loaded with its full path name loadedmodules entry is # if module is loaded with its full path name loadedmodules entry is
# equivalent to _lmfiles_ corresponding entry so only check _lmfiles_ # equivalent to _lmfiles_ corresponding entry so only check _lmfiles_
if {[$isModulefileLoaded $mod]} { if {[$isModulefileLoaded $mod]} {
# a loaded modfile may correspond to multiple loaded virtual modules # a loaded modfile may correspond to multiple loaded virtual modules
skipping to change at line 1508 skipping to change at line 1453
foreach modcon [array names ::g_loadedModuleConflict] { foreach modcon [array names ::g_loadedModuleConflict] {
# look if some loaded or loading modules correspond to conflict defined # look if some loaded or loading modules correspond to conflict defined
# by mod # by mod
if {$modcon eq $mod || ($isfullpath && $modcon eq $smod)} { if {$modcon eq $mod || ($isfullpath && $modcon eq $smod)} {
foreach withmod $::g_loadedModuleConflict($modcon) { foreach withmod $::g_loadedModuleConflict($modcon) {
# skip own reflexive conflict (look at mod main and alternative # skip own reflexive conflict (look at mod main and alternative
# names) and those already known # names) and those already known
if {![modEq $withmod $mod eqstart 1 2 1] && (!$isfullpath ||\ if {![modEq $withmod $mod eqstart 1 2 1] && (!$isfullpath ||\
![modEq $withmod $smod eqstart 1 2 1]) && ([set lmmodlist\ ![modEq $withmod $smod eqstart 1 2 1]) && ([set lmmodlist\
[getLoadedMatchingName $withmod returnall]] ne {} || [set\ [getLoadedMatchingName $withmod returnall]] ne {} || [set\
lmmodlist [getLoadedMatchingName $withmod returnall 1]] ne {})} { lmmodlist [getLoadedMatchingName $withmod returnall 1]] ne\
{})} {
# multiple loaded module may match conflict declared name # multiple loaded module may match conflict declared name
foreach lmmod $lmmodlist { foreach lmmod $lmmodlist {
appendNoDupToList modconlist $lmmod appendNoDupToList modconlist $lmmod
} }
appendNoDupToList moddecconlist $withmod appendNoDupToList moddecconlist $withmod
set does 1 set does 1
} }
} }
# other loaded module declared conflicts (skipping those already known) # other loaded module declared conflicts (skipping those already known)
} elseif {$modcon ni $modconlist} { } elseif {$modcon ni $modconlist} {
skipping to change at line 1532 skipping to change at line 1478
[modEq $withmod $smod eqstart 1 2 1])} { [modEq $withmod $smod eqstart 1 2 1])} {
lappend modconlist $modcon lappend modconlist $modcon
lappend moddecconlist $modcon lappend moddecconlist $modcon
set does 1 set does 1
break break
} }
} }
} }
} }
reportDebug "'$mod' conflicts with '$modconlist' (declared as '$moddecconlist reportDebug "'$mod' conflicts with '$modconlist' (declared as\
')" '$moddecconlist')"
return [list $does $modconlist $moddecconlist] return [list $does $modconlist $moddecconlist]
} }
proc setLoadedPrereq {mod args} { proc setLoadedPrereq {mod args} {
appendNoDupToList ::g_loadedModulePrereq($mod) {*}$args appendNoDupToList ::g_loadedModulePrereq($mod) {*}$args
} }
proc unsetLoadedPrereq {mod} { proc unsetLoadedPrereq {mod} {
if {[info exists ::g_loadedModulePrereq($mod)]} { if {[info exists ::g_loadedModulePrereq($mod)]} {
unset ::g_loadedModulePrereq($mod) unset ::g_loadedModulePrereq($mod)
skipping to change at line 1669 skipping to change at line 1616
} else { } else {
set ret $::g_loadedModuleVariant($mod) set ret $::g_loadedModuleVariant($mod)
} }
} }
return $ret return $ret
} }
proc getLoadedModuleWithVariantList {} { proc getLoadedModuleWithVariantList {} {
set modvrlist [list] set modvrlist [list]
foreach mod [getLoadedModuleList] { foreach mod [getLoadedModulePropertyList name] {
set modvr [list $mod] set modvr [list $mod]
set vrlist [getVariantList $mod 5] set vrlist [getVariantList $mod 5]
if {[llength $vrlist] > 0} { if {[llength $vrlist] > 0} {
lappend modvr {*}$vrlist lappend modvr {*}$vrlist
} }
lappend modvrlist $modvr lappend modvrlist $modvr
} }
return $modvrlist return $modvrlist
} }
proc getLoadedModuleWithVariantSaveTagArrayList {} { proc getLoadedModuleWithVariantSaveTagArrayList {} {
array set tag_arr {} array set tag_arr {}
foreach mod [getLoadedModuleList] { foreach mod [getLoadedModulePropertyList name] {
set modvr [list $mod] set modvr [list $mod]
set vrlist [getVariantList $mod 1] set vrlist [getVariantList $mod 1]
if {[llength $vrlist] > 0} { if {[llength $vrlist] > 0} {
lappend modvr {*}$vrlist lappend modvr {*}$vrlist
} }
# create entry in array only if tags set # create entry in array only if tags set
set tag_list [getSaveTagList $mod] set tag_list [getSaveTagList $mod]
if {[llength $tag_list] > 0} { if {[llength $tag_list] > 0} {
set tag_arr($modvr) $tag_list set tag_arr($modvr) $tag_list
} }
} }
return [array get tag_arr] return [array get tag_arr]
} }
# get current loaded state to record it as the virtual init collection
proc getLoadedInit {} {
set ret [formatCollectionContent [getModulePathList returnempty 0]\
[getLoadedModuleWithVariantList]\
[getLoadedModuleWithVariantSaveTagArrayList] {}]
# remove ending newline in collection output
set ret [string trimright $ret \n]
# get init state as a string that can be registered in an env var translate
# tag list separator ':' into '<' and line split '\n' into ':'
set ret [string map {: < \n :} $ret]
return $ret
}
# register conflict violation state between loaded modules # register conflict violation state between loaded modules
proc setModuleConflictViolation {mod modconlist} { proc setModuleConflictViolation {mod modconlist} {
reportDebug "set conflict violation state for '$mod'" reportDebug "set conflict violation state for '$mod'"
set ::g_conflictViolation($mod) $modconlist set ::g_conflictViolation($mod) $modconlist
# also update violation state for loaded mod conflicting with mod # also update violation state for loaded mod conflicting with mod
foreach lmmod $modconlist { foreach lmmod $modconlist {
if {[appendNoDupToList ::g_conflictViolation($lmmod) $mod]} { if {[appendNoDupToList ::g_conflictViolation($lmmod) $mod]} {
reportDebug "set/update conflict violation state for '$lmmod'" reportDebug "set/update conflict violation state for '$lmmod'"
} }
} }
skipping to change at line 1730 skipping to change at line 1693
set ::g_conflictViolation($lmmod) $convio set ::g_conflictViolation($lmmod) $convio
} }
} }
reportDebug "unset conflict violation state for '$mod'" reportDebug "unset conflict violation state for '$mod'"
unset ::g_conflictViolation($mod) unset ::g_conflictViolation($mod)
} }
} }
# build dependency chain between loaded modules based on registered prereqs # build dependency chain between loaded modules based on registered prereqs
proc setModuleDependency {mod} { proc setModuleDependency {mod} {
set modlist [getLoadedModuleList] set modlist [getLoadedModulePropertyList name]
defineModEqProc [isIcase] [getConf extended_default] 1 defineModEqProc [isIcase] [getConf extended_default] 1
# only look at modules loaded prior current one to find requirements, # only look at modules loaded prior current one to find requirements,
# modules loaded afterward are unmet dependencies as dependents have # modules loaded afterward are unmet dependencies as dependents have
# not been reloaded after them # not been reloaded after them
set modidx [lsearch -exact $modlist $mod] set modidx [lsearch -exact $modlist $mod]
set modnpolist [lrange $modlist [expr {$modidx + 1}] end] set modnpolist [lrange $modlist [expr {$modidx + 1}] end]
set modlist [lrange $modlist 0 $modidx] set modlist [lrange $modlist 0 $modidx]
# reverse list to get closest match if returning lastly loaded module # reverse list to get closest match if returning lastly loaded module
if {[getConf unload_match_order] eq {returnlast}} { if {[getConf unload_match_order] eq {returnlast}} {
set modlist [lreverse $modlist] set modlist [lreverse $modlist]
skipping to change at line 2001 skipping to change at line 1964
# are requirements loaded after their dependent included or not # are requirements loaded after their dependent included or not
if {$nporeq} { if {$nporeq} {
set reqVioVar ::g_prereqNPOViolation set reqVioVar ::g_prereqNPOViolation
set reqListVar ::g_moduleNPODepend set reqListVar ::g_moduleNPODepend
} else { } else {
set reqVioVar ::g_prereqViolation set reqVioVar ::g_prereqViolation
set reqListVar ::g_moduleDepend set reqListVar ::g_moduleDepend
} }
# check if any loaded module violates its prereq or conflict constraints # check if any loaded module violates its prereq or conflict constraints
##nagelfar vartype reqVioVar varName
if {$mod eq {}} { if {$mod eq {}} {
if {[array size ::g_conflictViolation] > 0 || [array size\ if {[array size ::g_conflictViolation] > 0 || [array size\
$reqVioVar] > 0} { $reqVioVar] > 0} {
set ret 0 set ret 0
} }
} else { } else {
set fulllist [list $mod] set fulllist [list $mod]
for {set i 0} {$i < [llength $fulllist]} {incr i 1} { for {set i 0} {$i < [llength $fulllist]} {incr i 1} {
set depmod [lindex $fulllist $i] set depmod [lindex $fulllist $i]
# check if depmod violates its prereq or conflict constraints # check if depmod violates its prereq or conflict constraints
##nagelfar ignore +2 Suspicious variable name
if {[info exists ::g_conflictViolation($depmod)] || [info exists\ if {[info exists ::g_conflictViolation($depmod)] || [info exists\
${reqVioVar}($depmod)]} { ${reqVioVar}($depmod)]} {
# found violation among the requirement chain of mod so the # found violation among the requirement chain of mod so the
# constraint of mod are not satisfied # constraint of mod are not satisfied
set ret 0 set ret 0
break break
} }
# add requirements of depmod to the module to check list # add requirements of depmod to the module to check list
##nagelfar ignore Suspicious variable name
foreach lmmodlist [set ${reqListVar}($depmod)] { foreach lmmodlist [set ${reqListVar}($depmod)] {
appendNoDupToList fulllist {*}$lmmodlist appendNoDupToList fulllist {*}$lmmodlist
} }
} }
} }
return $ret return $ret
} }
proc cacheCurrentModules {{exitonerr 1}} { proc cacheCurrentModules {{exitonerr 1}} {
# parse loaded modules information only once, global arrays are updated # parse loaded modules information only once, global arrays are updated
# afterwards when module commands update loaded modules state # afterwards when module commands update loaded modules state
if {![isStateDefined lm_info_cached]} { if {![isStateDefined lm_info_cached]} {
setState lm_info_cached 1 setState lm_info_cached 1
# mark specific as well as generic modules as loaded # mark specific as well as generic modules as loaded
set i 0 set i 0
set modfilelist [getLoadedModuleFileList] set modfilelist [getLoadedModulePropertyList file]
set modlist [getLoadedModuleList] set modlist [getLoadedModulePropertyList name]
set refreshlist [getLoadedModulePropertyList refresh]
if {[llength $modlist] == [llength $modfilelist]} { if {[llength $modlist] == [llength $modfilelist]} {
# cache declared variant of loaded modules # cache declared variant of loaded modules
foreach modvrspec [getLoadedModuleVariantList] { foreach modvrspec [getLoadedModulePropertyList variant] {
setLoadedVariant {*}$modvrspec setLoadedVariant {*}$modvrspec
# prepare modvr designation of loaded mod needed in next steps # prepare modvr designation of loaded mod needed in next steps
set mod [lindex $modvrspec 0] set mod [lindex $modvrspec 0]
set vrlist [getVariantList $mod 6] set vrlist [getVariantList $mod 6]
set modvr [list $mod {*}$vrlist] set modvr [list $mod {*}$vrlist]
set modvrarr($mod) $modvr set modvrarr($mod) $modvr
} }
# cache declared tags of loaded modules # cache declared tags of loaded modules
foreach modtag [getLoadedModuleTagList] { foreach modtag [getLoadedModulePropertyList tag] {
setModuleTag {*}$modtag setModuleTag {*}$modtag
# also record tag over full mod and vr designation # also record tag over full mod and vr designation
set mod [lindex $modtag 0] set mod [lindex $modtag 0]
if {[info exists modvrarr($mod)]} { if {[info exists modvrarr($mod)]} {
setModuleTag $modvrarr($mod) {*}[lrange $modtag 1 end] setModuleTag $modvrarr($mod) {*}[lrange $modtag 1 end]
} }
} }
foreach modtag [getLoadedModuleExtraTagList] { foreach modtag [getLoadedModulePropertyList extratag] {
setModuleExtraTag {*}$modtag setModuleExtraTag {*}$modtag
# also record tag over full mod and vr designation # also record tag over full mod and vr designation
set mod [lindex $modtag 0] set mod [lindex $modtag 0]
if {[info exists modvrarr($mod)]} { if {[info exists modvrarr($mod)]} {
setModuleExtraTag $modvrarr($mod) {*}[lrange $modtag 1 end] setModuleExtraTag $modvrarr($mod) {*}[lrange $modtag 1 end]
} }
} }
# cache declared alternative names of loaded modules # cache declared alternative names of loaded modules
foreach modalt [getLoadedModuleAltnameList] { foreach modalt [getLoadedModulePropertyList altname] {
setLoadedAltname {*}$modalt setLoadedAltname {*}$modalt
} }
# cache declared source-sh of loaded modules # cache declared source-sh of loaded modules
foreach modsrcsh [getLoadedModuleSourceShList] { foreach modsrcsh [getLoadedModulePropertyList sourcesh] {
setLoadedSourceSh {*}$modsrcsh setLoadedSourceSh {*}$modsrcsh
} }
# cache declared conflict of loaded modules # cache declared conflict of loaded modules
foreach modcon [getLoadedModuleConflictList] { foreach modcon [getLoadedModulePropertyList conflict] {
# parse module version specification to record translation # parse module version specification to record translation
foreach modconelt [lrange $modcon 1 end] { foreach modconelt [lrange $modcon 1 end] {
parseModuleSpecification 0 {*}$modconelt parseModuleSpecification 0 {*}$modconelt
} }
setLoadedConflict {*}$modcon setLoadedConflict {*}$modcon
} }
# cache declared prereq of loaded modules, prior to setLoadedModule # cache declared prereq of loaded modules, prior to setLoadedModule
# which triggers dependency chain build # which triggers dependency chain build
foreach modpre [getLoadedModulePrereqList] { foreach modpre [getLoadedModulePropertyList prereq] {
# parse module version specification to record translation # parse module version specification to record translation
foreach modpreeltlist [lrange $modpre 1 end] { foreach modpreeltlist [lrange $modpre 1 end] {
foreach modpreelt $modpreeltlist { foreach modpreelt $modpreeltlist {
parseModuleSpecification 0 {*}$modpreelt parseModuleSpecification 0 {*}$modpreelt
} }
} }
setLoadedPrereq {*}$modpre setLoadedPrereq {*}$modpre
} }
foreach mod $modlist { foreach mod $modlist {
# get all tags also recorded on mod and vr designation # get all tags also recorded on mod and vr designation
if {[info exists modvrarr($mod)]} { if {[info exists modvrarr($mod)]} {
set modvr $modvrarr($mod) set modvr $modvrarr($mod)
} else { } else {
set modvr {} set modvr {}
} }
setLoadedModule $mod [lindex $modfilelist $i] [expr\ setLoadedModule $mod [lindex $modfilelist $i] [expr\
{![isModuleTagged $mod auto-loaded 1]}] $modvr {![isModuleTagged $mod auto-loaded 1]}] $modvr [expr {$mod in\
$refreshlist}]
incr i incr i
} }
reportDebug "$i loaded" reportDebug "$i loaded"
} else { } else {
set errproc [expr {$exitonerr ? {reportErrorAndExit} :\ set errproc [expr {$exitonerr ? {reportErrorAndExit} :\
{reportError}}] {reportError}}]
$errproc "Loaded environment state is\ $errproc "Loaded environment state is\
inconsistent\nLOADEDMODULES=$modlist\n_LMFILES_=$modfilelist" inconsistent\nLOADEDMODULES=$modlist\n_LMFILES_=$modfilelist"
} }
skipping to change at line 2539 skipping to change at line 2507
# character to match anything starting with mod # character to match anything starting with mod
if {$wild && !$hasmoddir && [string index $findmod end] ne {*}} { if {$wild && !$hasmoddir && [string index $findmod end] ne {*}} {
append findmod * append findmod *
} }
} }
# add alias/version definitions from global or user rc to result # add alias/version definitions from global or user rc to result
set add_rc_defs [expr {{rc_defs_included} in $search}] set add_rc_defs [expr {{rc_defs_included} in $search}]
# if no indepth mode search, pass the depth level of the search query # if no indepth mode search, pass the depth level of the search query
set depthlvl [expr {$indepth ? 0 : [expr {$querydepth + 1}]}] set depthlvl [expr {$indepth ? 0 : $querydepth + 1}]
array set found_list [findModules $dir $findmod $depthlvl $fetch_mtime] array set found_list [findModules $dir $findmod $depthlvl $fetch_mtime]
} }
# Phase #1: consolidate every kind of entries (directory, modulefile, # Phase #1: consolidate every kind of entries (directory, modulefile,
# symbolic version, alias and virtual module) in found_list # symbolic version, alias and virtual module) in found_list
array set err_list {} array set err_list {}
array set versmod_list {} array set versmod_list {}
skipping to change at line 2592 skipping to change at line 2560
lappend versmod_list($versmod) $vers lappend versmod_list($versmod) $vers
} }
} }
# add aliases found when parsing .version or .modulerc files in this # add aliases found when parsing .version or .modulerc files in this
# directory (skip aliases not registered from this directory except if # directory (skip aliases not registered from this directory except if
# global or user rc definitions should be included) # global or user rc definitions should be included)
foreach alias [array names g_moduleAlias] { foreach alias [array names g_moduleAlias] {
if {($dir ne {} && [string first $dir/ $g_sourceAlias($alias)] == 0)\ if {($dir ne {} && [string first $dir/ $g_sourceAlias($alias)] == 0)\
|| ($add_rc_defs && [info exists g_rcAlias($alias)])} { || ($add_rc_defs && [info exists g_rcAlias($alias)])} {
##nagelfar ignore Found constant
set found_list($alias) [list alias $g_moduleAlias($alias)] set found_list($alias) [list alias $g_moduleAlias($alias)]
} }
} }
# add virtual mods found when parsing .version or .modulerc files in this # add virtual mods found when parsing .version or .modulerc files in this
# directory (skip virtual mods not registered from this directory except if # directory (skip virtual mods not registered from this directory except if
# global or user rc definitions should be included) # global or user rc definitions should be included)
foreach virt [array names g_moduleVirtual] { foreach virt [array names g_moduleVirtual] {
if {($dir ne {} && [string first $dir/ $g_sourceVirtual($virt)] == 0)\ if {($dir ne {} && [string first $dir/ $g_sourceVirtual($virt)] == 0)\
|| ($add_rc_defs && [info exists g_rcVirtual($virt)])} { || ($add_rc_defs && [info exists g_rcVirtual($virt)])} {
 End of changes. 53 change blocks. 
202 lines changed or deleted 170 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)