+ # func_cache_lookup_module module
+ #
+ # looks up a module, like 'func_lookup_file modules/$module', and stores all
+ # of its relevant data in a cache in the memory of the processing shell. If
+ # already cached, it does not look it up again, thus saving file access time.
+ # Parameters:
+ # - module non-empty string
+ # Output if $have_associative:
+ # - modcache_cached[$module] set to yes
+ # - modcache_description[$module] ==
+ # - modcache_status[$module] \ set to the field's value, minus the
+ # - ... / final newline,
+ # - modcache_maintainer[$module] == or unset if the field's value is empty
+ # Output if ! $have_associative:
+ # - cachevar a shell variable name
+ # - ${cachevar}_cached set to $module
+ # - ${cachevar}_description ==
+ # - ${cachevar}_status \ set to the field's value, minus the
+ # - ... / final newline,
+ # - ${cachevar}_maintainer == or unset if the field's value is empty
+ # - ${cachevar}_description_set ==
+ # - ${cachevar}_status_set \ set to non-empty if the field's value
+ # - ... / is non-empty,
+ # - ${cachevar}_maintainer_set == or unset if the field's value is empty
+ func_cache_lookup_module ()
+ {
+ if $have_associative; then
+ cached=${modcache_cached[$1]}
+ else
+ func_cache_var "$1"
+ eval "cached=\"\$${cachevar}_cached\""
+ fi
+ if test -z "$cached"; then
+ # Not found in cache. Look it up on the file system.
+ func_lookup_file "modules/$1"
+ if $have_associative; then
+ modcache_cached[$1]=yes
+ else
+ eval "${cachevar}_cached=\"\$1\""
+ fi
+ if ! $have_associative; then
+ # sed_convert_to_cache_statements depends on the module.
+ modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
+ func_init_sed_convert_to_cache_statements
+ fi
+ cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
+ eval "$cache_statements"
+ else
+ if ! $have_associative; then
+ if test "$1" != "$cached"; then
+ func_fatal_error "cache variable collision between $1 and $cached"
+ fi
+ fi
+ fi
+ }