Skip to main content

do_module_features

Function do_module_features 

Source
pub fn do_module_features(
    table: &mut modulestab,
    modname: &str,
    features: Option<&[String]>,
    flags: i32,
) -> i32
Expand description

Port of do_module_features(Module m, Feature_enables enablesarr, int flags) from Src/module.c:1998.

C body c:1998-2125 (128 lines):

if (features_module(m, &features) == 0) {
    int *enables = NULL;
    if (enables_module(m, &enables)) {
        if (!(flags & FEAT_IGNORE)) zwarn(...);
        return 1;
    }
    if ((flags & FEAT_CHECKAUTO) && m->autoloads) {
        /* validate autoloads against features list */
        /* on mismatch: zwarn + autofeatures(REMOVE|IGNORE) +
           expunge from enablesarr */
    }
    if (enablesarr) {
        /* walk enablesarr, flip enables bits per +/- prefix */
    } else {
        /* enable all features */
    }
    if (enables_module(m, &enables)) return 2;
} else if (enablesarr) {
    if (!(flags & FEAT_IGNORE)) zwarn("module does not support features");
    return 1;
}
return ret;

Prior Rust port confused module-name and enables-string into a single enablesarr: &str param — the module-lookup and zwarn diagnostic both used the feature-list string instead of the module’s name. Signature now separates them per C semantics: modname identifies the module, features is the list of features to enable (None = “enable all”). WARNING: param names don’t match C — Rust=(table, modname, features, flags) vs C=(m, enablesarr, flags)