Skip to content

Commit f4ce1ac

Browse files
committed
Unset extra tags on cmdModuleTag
Add unset_extra argument to the cmdModuleTag procedure to remove, when enabled, the extra tags currently set on designated modules that are not part of the transmitted tag list. Update every cmdModuleTag calls to take into account this new unset_extra argument.
1 parent 92c9174 commit f4ce1ac

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

tcl/main.tcl.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ proc module {command args} {
530530
}
531531
# update tags on already loaded modules
532532
if {[info exists loadedmodlist]} {
533-
cmdModuleTag $tag_list {*}$loadedmodlist
533+
cmdModuleTag 0 $tag_list {*}$loadedmodlist
534534
}
535535
}
536536
}

tcl/mfinterp.tcl.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ proc prereq {args} {
17731773
}
17741774
} elseif {![getConf auto_handling]} {
17751775
# apply missing tag to first loaded module found
1776-
cmdModuleTag $tag_list $loadedmod
1776+
cmdModuleTag 0 $tag_list $loadedmod
17771777
}
17781778

17791779
return {}

tcl/modeval.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ proc loadRequirementModuleList {tag_list args} {
661661
releaseHeldReport {*}$holdidlist
662662
} else {
663663
# apply missing tag to first loaded module found
664-
cmdModuleTag $tag_list $loadedmod
664+
cmdModuleTag 0 $tag_list $loadedmod
665665
}
666666
}
667667

tcl/modfind.tcl.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,28 @@ proc setModuleExtraTag {mod args} {
707707
appendNoDupToList ::g_extraTagHash($mod) {*}$args
708708
}
709709

710+
proc unsetModuleTag {mod args} {
711+
if {[info exists ::g_tagHash($mod)]} {
712+
lassign [getDiffBetweenList $::g_tagHash($mod) $args] diff_list
713+
if {[llength $diff_list] > 0} {
714+
set ::g_tagHash($mod) $diff_list
715+
} else {
716+
unset ::g_tagHash($mod)
717+
}
718+
}
719+
}
720+
721+
proc unsetModuleExtraTag {mod args} {
722+
if {[info exists ::g_extraTagHash($mod)]} {
723+
lassign [getDiffBetweenList $::g_extraTagHash($mod) $args] diff_list
724+
if {[llength $diff_list] > 0} {
725+
set ::g_extraTagHash($mod) $diff_list
726+
} else {
727+
unset ::g_extraTagHash($mod)
728+
}
729+
}
730+
}
731+
710732
proc getTagList {mod {sort 1}} {
711733
if {[info exists ::g_tagHash($mod)]} {
712734
if {$sort} {

tcl/subcmd.tcl.in

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ proc cmdModuleLoad {context uasked tag_list args} {
912912
}
913913

914914
# apply missing tag to loaded module
915-
cmdModuleTag $tag_list $modname
915+
cmdModuleTag 0 $tag_list $modname
916916

917917
# exit treatment but no need to restore settings
918918
set loadok 1
@@ -2352,8 +2352,8 @@ proc cmdModuleHelp {args} {
23522352
}
23532353
}
23542354

2355-
proc cmdModuleTag {tag_list args} {
2356-
reportDebug "tagging $args (tag_list=$tag_list)"
2355+
proc cmdModuleTag {unset_extra tag_list args} {
2356+
reportDebug "tagging $args (unset_extra=$unset_extra, tag_list=$tag_list)"
23572357

23582358
set ret 0
23592359
foreach mod $args {
@@ -2367,9 +2367,13 @@ proc cmdModuleTag {tag_list args} {
23672367
continue
23682368
}
23692369

2370-
# record tags not already set
2370+
# record tags not already set and if asked unset extra tags not set
2371+
# anymore
23712372
lassign [getDiffBetweenList $tag_list [getTagList $modname]] diff_list
2372-
if {[llength $diff_list] > 0} {
2373+
lassign [getDiffBetweenList [getExtraTagList $modname] $tag_list] \
2374+
unset_list
2375+
if {[llength $diff_list] > 0 || ($unset_extra && [llength $unset_list]\
2376+
> 0)} {
23732377
lappendState mode unload
23742378
# first unset tags declared for this module on LM env var
23752379
if {[set modtag [getExportTagList $modname 1]] ne {}} {
@@ -2380,6 +2384,16 @@ proc cmdModuleTag {tag_list args} {
23802384
}
23812385
lpopState mode
23822386

2387+
# remove extra tags currently set not part of tag list if asked
2388+
if {$unset_extra && [llength $unset_list] > 0} {
2389+
unsetModuleTag $modname {*}$unset_list
2390+
unsetModuleExtraTag $modname {*}$unset_list
2391+
if {$modnamevr ne {} && $modname ne $modnamevr} {
2392+
unsetModuleTag $modnamevr {*}$unset_list
2393+
unsetModuleExtraTag $modnamevr {*}$unset_list
2394+
}
2395+
}
2396+
23832397
# record new tags as extra tag excluding tags relative to the way
23842398
# module is loaded (auto, keep)
23852399
lassign [getDiffBetweenList $diff_list [list auto-loaded\

0 commit comments

Comments
 (0)